# ignite-329 Changed example.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/7457968a Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/7457968a Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/7457968a Branch: refs/heads/ignite-gg-9828 Commit: 7457968a2aa93ca03243c59539d09990a555be69 Parents: 9cd9c1f Author: anovikov <anovi...@gridgain.com> Authored: Wed Mar 4 19:38:48 2015 +0700 Committer: anovikov <anovi...@gridgain.com> Committed: Wed Mar 4 19:38:48 2015 +0700 ---------------------------------------------------------------------- .../config/store/example-jdbc-pojo-store.xml | 48 +++-- .../datagrid/CacheJdbcPojoStoreExample.java | 167 ------------------ .../CacheJdbcPojoStoreLoadDataExample.java | 174 +++++++++++++++++++ .../store/CacheNodeWithStoreStartup.java | 29 ++++ .../datagrid/store/CacheStoreExample.java | 1 + .../store/CacheStoreLoadDataExample.java | 8 +- .../ignite/examples/datagrid/store/Person.java | 103 ----------- .../store/dummy/CacheDummyPersonStore.java | 2 +- .../hibernate/CacheHibernatePersonStore.java | 2 +- .../datagrid/store/hibernate/Person.hbm.xml | 2 +- .../datagrid/store/hibernate/hibernate.cfg.xml | 3 - .../store/jdbc/CacheJdbcPersonStore.java | 2 +- .../store/jdbc/CacheJdbcPojoPersonStore.java | 27 +++ .../examples/datagrid/store/model/Person.java | 70 ++++---- .../datagrid/store/model/PersonKey.java | 10 +- .../store/jdbc/CacheAbstractJdbcStore.java | 17 +- .../cache/store/jdbc/CacheJdbcPojoStore.java | 48 ++--- modules/schema-load/readme.txt | 105 +++++++++++ .../apache/ignite/visor/plugin/VisorPlugin.java | 10 +- 19 files changed, 451 insertions(+), 377 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/config/store/example-jdbc-pojo-store.xml ---------------------------------------------------------------------- diff --git a/examples/config/store/example-jdbc-pojo-store.xml b/examples/config/store/example-jdbc-pojo-store.xml index 608d9c1..22dea8f 100644 --- a/examples/config/store/example-jdbc-pojo-store.xml +++ b/examples/config/store/example-jdbc-pojo-store.xml @@ -31,20 +31,6 @@ xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - <bean id="jdbcPojoStore" class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore"> - <property name="dialect"> - <bean class="org.apache.ignite.cache.store.jdbc.dialect.H2Dialect"/> - </property> - - <property name="dataSource"> - <bean class="org.h2.jdbcx.JdbcConnectionPool" factory-method="create"> - <constructor-arg value="jdbc:h2:tcp://localhost/mem:ExampleDb"/> - <constructor-arg value="sa"/> - <constructor-arg value=""/> - </bean> - </property> - </bean> - <bean id="ignite.cfg" class="org.apache.ignite.configuration.IgniteConfiguration"> <!-- Set to true to enable distributed class loading for examples, default is false. --> <property name="peerClassLoadingEnabled" value="true"/> @@ -69,14 +55,27 @@ <property name="cacheStoreFactory"> <bean class="javax.cache.configuration.FactoryBuilder$SingletonFactory"> - <constructor-arg ref="jdbcPojoStore"/> + <constructor-arg> + <bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore"> + <property name="dialect"> + <bean class="org.apache.ignite.cache.store.jdbc.dialect.H2Dialect"/> + </property> + + <property name="dataSource"> + <bean class="org.h2.jdbcx.JdbcConnectionPool" factory-method="create"> + <constructor-arg value="jdbc:h2:tcp://localhost/mem:ExampleDb"/> + <constructor-arg value="sa"/> + <constructor-arg value=""/> + </bean> + </property> + </bean> + </constructor-arg> </bean> </property> <property name="typeMetadata"> <list> <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> <property name="databaseTable" value="ORGANIZATION"/> <property name="keyType" value="org.apache.ignite.examples.datagrid.store.model.OrganizationKey"/> <property name="valueType" value="org.apache.ignite.examples.datagrid.store.model.Organization"/> @@ -114,7 +113,6 @@ </property> </bean> <bean class="org.apache.ignite.cache.CacheTypeMetadata"> - <property name="databaseSchema" value="PUBLIC"/> <property name="databaseTable" value="PERSON"/> <property name="keyType" value="org.apache.ignite.examples.datagrid.store.model.PersonKey"/> <property name="valueType" value="org.apache.ignite.examples.datagrid.store.model.Person"/> @@ -124,7 +122,7 @@ <property name="databaseName" value="ID"/> <property name="databaseType" value="4"/> <property name="javaName" value="id"/> - <property name="javaType" value="int"/> + <property name="javaType" value="long"/> </bean> </list> </property> @@ -134,18 +132,18 @@ <property name="databaseName" value="ID"/> <property name="databaseType" value="4"/> <property name="javaName" value="id"/> - <property name="javaType" value="int"/> + <property name="javaType" value="long"/> </bean> <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="ORG_ID"/> - <property name="databaseType" value="4"/> - <property name="javaName" value="orgId"/> - <property name="javaType" value="java.lang.Integer"/> + <property name="databaseName" value="FIRST_NAME"/> + <property name="databaseType" value="12"/> + <property name="javaName" value="firstName"/> + <property name="javaType" value="java.lang.String"/> </bean> <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> - <property name="databaseName" value="NAME"/> + <property name="databaseName" value="LAST_NAME"/> <property name="databaseType" value="12"/> - <property name="javaName" value="name"/> + <property name="javaName" value="lastName"/> <property name="javaType" value="java.lang.String"/> </bean> </list> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheJdbcPojoStoreExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheJdbcPojoStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheJdbcPojoStoreExample.java deleted file mode 100644 index f76afc8..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/CacheJdbcPojoStoreExample.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.examples.datagrid; - -import org.apache.ignite.*; -import org.apache.ignite.examples.datagrid.store.model.*; -import org.apache.ignite.internal.util.typedef.internal.*; -import org.h2.tools.*; - -import java.sql.*; -import java.util.*; - -/** - * This examples demonstrates loading data into cache from underlying JDBC store. - */ -public class CacheJdbcPojoStoreExample { - /** DB connection URL. */ - private static final String CONN_URL = "jdbc:h2:mem:ExampleDb;DB_CLOSE_DELAY=-1"; - - /** Cache name. */ - private static final String CACHE_NAME = "partitioned"; - - /** Number of generated organizations. */ - private static final int ORGANIZATION_CNT = 5; - - /** Number of generated persons. */ - private static final int PERSON_CNT = 100; - - /** - * Executes example. - * - * @param args Command line arguments, none required. - * @throws Exception If example execution failed. - */ - public static void main(String[] args) throws Exception { - System.out.println("Populate database with sample data."); - - createDb(); - - // Start H2 database TCP server in order to access sample in-memory database from other processes. - // This is H2 specific only. - Server srv = Server.createTcpServer().start(); - - // Start node and load cache from database. - try (Ignite ignite = Ignition.start("examples/config/store/example-jdbc-pojo-store.xml")) { - IgniteCache<Object, Object> cache = ignite.jcache(CACHE_NAME); - - System.out.println("Load whole DB into cache."); - - cache.loadCache(null); - - System.out.println("Print loaded content."); - - System.out.println("Organizations:"); - for (int i = 0; i < ORGANIZATION_CNT; i++) { - OrganizationKey orgKey = new OrganizationKey(i); - - System.out.println(" " + cache.get(orgKey)); - } - - System.out.println("Persons:"); - for (int i = 0; i < PERSON_CNT; i++) { - PersonKey prnKey = new PersonKey(i); - - System.out.println(" " + cache.get(prnKey)); - } - - System.out.println("Clear cache for next demo."); - - cache.clear(); - - System.out.println("Cache size = " + cache.size()); - - System.out.println("Load cache by custom SQL."); - - // JDBC cache store accept pairs of "full key class name -> SQL statement" - cache.loadCache(null, - "org.apache.ignite.examples.datagrid.store.model.OrganizationKey", - "SELECT * FROM Organization WHERE id = 2", - "org.apache.ignite.examples.datagrid.store.model.PersonKey", - "SELECT * FROM Person WHERE id = 5"); - - System.out.println("Check custom SQL."); - System.out.println(" Organization: " + cache.get(new OrganizationKey(2))); - System.out.println(" Person: " + cache.get(new PersonKey(5))); - } - - // Stop H2 TCP server. H2 specific only. - srv.stop(); - - System.exit(0); - } - - /** - * Create example DB and populate it with sample data. - * - * @throws Exception If failed to create databse and populate it with sample data. - */ - private static void createDb() throws Exception { - Class.forName("org.h2.Driver"); - - Connection conn = DriverManager.getConnection(CONN_URL, "sa", ""); - - Statement stmt = conn.createStatement(); - - stmt.executeUpdate("CREATE TABLE IF NOT EXISTS Organization" + - "(id integer not null, name varchar(50), city varchar(50), PRIMARY KEY(id))"); - - stmt.executeUpdate("CREATE TABLE IF NOT EXISTS Person" + - "(id integer not null, org_id integer, name varchar(50), PRIMARY KEY(id))"); - - U.closeQuiet(stmt); - - conn.commit(); - - PreparedStatement orgStmt = conn.prepareStatement("INSERT INTO Organization(id, name, city) VALUES (?, ?, ?)"); - - for (int i = 0; i < ORGANIZATION_CNT; i++) { - orgStmt.setInt(1, i); - orgStmt.setString(2, "org-name-" + i); - orgStmt.setString(3, "city-" + i); - - orgStmt.addBatch(); - } - - orgStmt.executeBatch(); - - U.closeQuiet(orgStmt); - - conn.commit(); - - PreparedStatement prnStmt = conn.prepareStatement("INSERT INTO Person(id, org_id, name) VALUES (?, ?, ?)"); - - Random rnd = new Random(); - - for (int i = 0; i < PERSON_CNT; i++) { - prnStmt.setInt(1, i); - prnStmt.setInt(2, rnd.nextInt(ORGANIZATION_CNT)); - prnStmt.setString(3, "person-name-" + i); - - prnStmt.addBatch(); - } - - prnStmt.executeBatch(); - - U.closeQuiet(prnStmt); - - conn.commit(); - - U.closeQuiet(conn); - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheJdbcPojoStoreLoadDataExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheJdbcPojoStoreLoadDataExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheJdbcPojoStoreLoadDataExample.java new file mode 100644 index 0000000..ae51ede --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheJdbcPojoStoreLoadDataExample.java @@ -0,0 +1,174 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.datagrid.store; + +import org.apache.ignite.*; +import org.apache.ignite.examples.datagrid.store.model.*; +import org.apache.ignite.internal.util.typedef.internal.*; +import org.h2.tools.*; + +import java.sql.*; + +/** + * This examples demonstrates loading data into cache from underlying JDBC store. + * <p> + * Remote nodes should always be started with special configuration file: + * {@code 'ignite.{sh|bat} examples/config/store/example-jdbc-pojo-store.xml'}. + */ +public class CacheJdbcPojoStoreLoadDataExample { + /** DB connection URL. */ + private static final String CONN_URL = "jdbc:h2:mem:ExampleDb;DB_CLOSE_DELAY=-1"; + + /** Cache name. */ + private static final String CACHE_NAME = "partitioned"; + + /** Number of generated organizations. */ + private static final int ORGANIZATION_CNT = 5; + + /** Number of generated persons. */ + private static final int PERSON_CNT = 100; + + /** + * Executes example. + * + * @param args Command line arguments, none required. + * @throws Exception If example execution failed. + */ + public static void main(String[] args) throws Exception { + Server srv = null; + + // Start node and load cache from database. + try (Ignite ignite = Ignition.start("examples/config/store/example-jdbc-pojo-store.xml")) { + System.out.println(); + System.out.println(">>> Cache auto-loading data example started."); + + prepareDb(); + + // Start H2 database TCP server in order to access sample in-memory database from other processes. + srv = Server.createTcpServer().start(); + + IgniteCache<Object, Object> cache = ignite.jcache(CACHE_NAME); + + // Clean up caches on all nodes before run. + cache.clear(); + + System.out.println(); + System.out.println(">>> Load whole DB into cache."); + + cache.loadCache(null); + + System.out.println(); + System.out.println(">>> Print loaded content."); + + System.out.println("Organizations:"); + for (int i = 0; i < ORGANIZATION_CNT; i++) { + OrganizationKey orgKey = new OrganizationKey(i); + + System.out.println(" " + cache.get(orgKey)); + } + + System.out.println("Persons:"); + for (int i = 0; i < PERSON_CNT; i++) { + PersonKey prnKey = new PersonKey(i); + + System.out.println(" " + cache.get(prnKey)); + } + + System.out.println(">>> Clear cache for next demo."); + + cache.clear(); + + System.out.println(">>> Cache size = " + cache.size()); + + System.out.println(">>> Load cache by custom SQL."); + + // JDBC cache store accept pairs of "full key class name -> SQL statement" + cache.loadCache(null, + "org.apache.ignite.examples.datagrid.store.model.OrganizationKey", + "SELECT * FROM Organization WHERE id = 2", + "org.apache.ignite.examples.datagrid.store.model.PersonKey", + "SELECT * FROM Person WHERE id = 5"); + + System.out.println(">>> Check custom SQL."); + System.out.println(">>> Organization: " + cache.get(new OrganizationKey(2))); + System.out.println(">>> Person: " + cache.get(new PersonKey(5))); + } + finally { + // Stop H2 TCP server. + if (srv != null) + srv.stop(); + } + + System.exit(0); + } + + /** + * Create example DB and populate it with sample data. + * + * @throws Exception If failed to create database and populate it with sample data. + */ + private static void prepareDb() throws Exception { + Connection conn = DriverManager.getConnection(CONN_URL, "sa", ""); + + Statement stmt = conn.createStatement(); + + stmt.executeUpdate("CREATE TABLE IF NOT EXISTS Organization" + + "(id integer not null, name varchar(50), city varchar(50), PRIMARY KEY(id))"); + + stmt.executeUpdate("CREATE TABLE IF NOT EXISTS Person" + + "(id integer not null, first_name varchar(50), last_name varchar(50), PRIMARY KEY(id))"); + + U.closeQuiet(stmt); + + conn.commit(); + + PreparedStatement st = conn.prepareStatement("INSERT INTO Organization(id, name, city) VALUES (?, ?, ?)"); + + for (int i = 0; i < ORGANIZATION_CNT; i++) { + st.setInt(1, i); + st.setString(2, "name-" + i); + st.setString(3, "city-" + i); + + st.addBatch(); + } + + st.executeBatch(); + + U.closeQuiet(st); + + conn.commit(); + + st = conn.prepareStatement("INSERT INTO Person(id, first_name, last_name) VALUES (?, ?, ?)"); + + for (int i = 0; i < PERSON_CNT; i++) { + st.setInt(1, i); + st.setString(3, "firstName-" + i); + st.setString(3, "lastName-" + i); + + st.addBatch(); + } + + st.executeBatch(); + + U.closeQuiet(st); + + conn.commit(); + + U.closeQuiet(conn); + } +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java index 5245f98..1915c7f 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheNodeWithStoreStartup.java @@ -18,14 +18,18 @@ package org.apache.ignite.examples.datagrid.store; import org.apache.ignite.*; +import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; import org.apache.ignite.examples.datagrid.store.dummy.*; +import org.apache.ignite.examples.datagrid.store.model.*; +import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.spi.discovery.tcp.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.*; import org.apache.ignite.spi.discovery.tcp.ipfinder.vm.*; import javax.cache.configuration.*; +import java.sql.*; import java.util.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -76,6 +80,10 @@ public class CacheNodeWithStoreStartup { // store = new CacheJdbcPersonStore(); // store = new CacheHibernatePersonStore(); + // Uncomment two lines for try . + // store = new CacheJdbcPojoPersonStore(); + // cacheCfg.setTypeMetadata(typeMetadata()); + cacheCfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<>(store)); cacheCfg.setReadThrough(true); cacheCfg.setWriteThrough(true); @@ -85,4 +93,25 @@ public class CacheNodeWithStoreStartup { return cfg; } + + private static Collection<CacheTypeMetadata> typeMetadata() { + CacheTypeMetadata tm = new CacheTypeMetadata(); + + tm.setDatabaseTable("PERSON"); + + tm.setKeyType("org.apache.ignite.examples.datagrid.store.model.PersonKey"); + tm.setValueType("org.apache.ignite.examples.datagrid.store.model.Person"); + + CacheTypeFieldMetadata keyFld = new CacheTypeFieldMetadata("id", long.class, "ID", Types.BIGINT); + + tm.setKeyFields(F.asList(keyFld)); + + tm.setValueFields(F.asList(keyFld, + new CacheTypeFieldMetadata("firstName", String.class, "FIRST_NAME", Types.VARCHAR), + new CacheTypeFieldMetadata("lastName", String.class, "LAST_NAME", Types.VARCHAR) + )); + + return F.asList(tm); + + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java index c0d0561..ce1076d 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreExample.java @@ -19,6 +19,7 @@ package org.apache.ignite.examples.datagrid.store; import org.apache.ignite.*; import org.apache.ignite.configuration.*; +import org.apache.ignite.examples.datagrid.store.model.*; import org.apache.ignite.transactions.*; import java.util.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java index 7bc7133..e456579 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/CacheStoreLoadDataExample.java @@ -58,12 +58,10 @@ public class CacheStoreLoadDataExample { long start = System.currentTimeMillis(); // Start loading cache on all caching nodes. - ignite.compute(ignite.cluster().forCacheNodes(null)).broadcast(new IgniteCallable<Object>() { - @Override public Object call() throws Exception { + ignite.compute(ignite.cluster().forCacheNodes(null)).broadcast(new IgniteRunnable() { + @Override public void run() { // Load cache from persistent store. - cache.loadCache(null, 0, ENTRY_COUNT); - - return null; + cache.loadCache(null, ENTRY_COUNT); } }); http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/Person.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/Person.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/Person.java deleted file mode 100644 index 64f45ad..0000000 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/Person.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.ignite.examples.datagrid.store; - -import java.io.*; - -/** - * Person class. - */ -public class Person implements Serializable { - /** Person ID. */ - private long id; - - /** First name. */ - private String firstName; - - /** Last name. */ - private String lastName; - - /** - * - */ - public Person() { - // No-op. - } - - /** - * Constructs person record. - * - * @param id Person ID. - * @param firstName First name. - * @param lastName Last name. - */ - public Person(long id, String firstName, String lastName) { - this.id = id; - this.firstName = firstName; - this.lastName = lastName; - } - - /** - * @return Person ID. - */ - public long getId() { - return id; - } - - /** - * @param id Person ID. - */ - public void setId(long id) { - this.id = id; - } - - /** - * @return First name. - */ - public String getFirstName() { - return firstName; - } - - /** - * @param firstName First name. - */ - public void setFirstName(String firstName) { - this.firstName = firstName; - } - - /** - * @return Last name. - */ - public String getLastName() { - return lastName; - } - - /** - * @param lastName Last name. - */ - public void setLastName(String lastName) { - this.lastName = lastName; - } - - /** {@inheritDoc} */ - @Override public String toString() { - return "Person [id=" + id + - ", firstName=" + firstName + - ", lastName=" + lastName + ']'; - } -} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/dummy/CacheDummyPersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/dummy/CacheDummyPersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/dummy/CacheDummyPersonStore.java index 640cbfd..7b04528 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/dummy/CacheDummyPersonStore.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/dummy/CacheDummyPersonStore.java @@ -19,7 +19,7 @@ package org.apache.ignite.examples.datagrid.store.dummy; import org.apache.ignite.*; import org.apache.ignite.cache.store.*; -import org.apache.ignite.examples.datagrid.store.*; +import org.apache.ignite.examples.datagrid.store.model.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; import org.apache.ignite.transactions.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java index 9549598..05ce68d 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/CacheHibernatePersonStore.java @@ -18,7 +18,7 @@ package org.apache.ignite.examples.datagrid.store.hibernate; import org.apache.ignite.cache.store.*; -import org.apache.ignite.examples.datagrid.store.*; +import org.apache.ignite.examples.datagrid.store.model.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; import org.apache.ignite.transactions.Transaction; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml index 035ab98..7474d77 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/Person.hbm.xml @@ -23,7 +23,7 @@ "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping default-access="field"> - <class name="org.apache.ignite.examples.datagrid.store.Person" table="PERSONS"> + <class name="org.apache.ignite.examples.datagrid.store.model.Person" table="PERSONS"> <!-- ID. --> <id name="id"/> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml index 4502060..80a43e7 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/hibernate/hibernate.cfg.xml @@ -26,9 +26,6 @@ --> <hibernate-configuration> <session-factory> - <!-- Show SQL. --> - <property name="show_sql">true</property> - <!-- Database connection settings (private in-memory database). --> <property name="connection.url">jdbc:h2:mem:example;DB_CLOSE_DELAY=-1</property> http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java index 55ba1a7..2faa226 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPersonStore.java @@ -19,7 +19,7 @@ package org.apache.ignite.examples.datagrid.store.jdbc; import org.apache.ignite.*; import org.apache.ignite.cache.store.*; -import org.apache.ignite.examples.datagrid.store.*; +import org.apache.ignite.examples.datagrid.store.model.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; import org.jetbrains.annotations.*; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java new file mode 100644 index 0000000..535db10 --- /dev/null +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/jdbc/CacheJdbcPojoPersonStore.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.examples.datagrid.store.jdbc; + +import org.apache.ignite.cache.store.jdbc.*; + +/** + * TODO: Add class description. + */ +public class CacheJdbcPojoPersonStore<K, V> extends CacheJdbcPojoStore { + +} http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/Person.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/Person.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/Person.java index ad56534..417abf2 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/Person.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/Person.java @@ -29,13 +29,13 @@ public class Person implements Serializable { private static final long serialVersionUID = 0L; /** Value for id. */ - private int id; + private long id; - /** Value for orgId. */ - private Integer orgId; + /** Value for first name. */ + private String firstName; - /** Value for name. */ - private String name; + /** Value for last name. */ + private String lastName; /** * Empty constructor. @@ -48,13 +48,13 @@ public class Person implements Serializable { * Full constructor. */ public Person( - int id, - Integer orgId, - String name + long id, + String firstName, + String lastName ) { this.id = id; - this.orgId = orgId; - this.name = name; + this.firstName = firstName; + this.lastName = lastName; } /** @@ -62,7 +62,7 @@ public class Person implements Serializable { * * @return Value for id. */ - public int getId() { + public long getId() { return id; } @@ -71,44 +71,44 @@ public class Person implements Serializable { * * @param id New value for id. */ - public void setId(int id) { + public void setId(long id) { this.id = id; } /** - * Gets orgId. + * Gets first name. * - * @return Value for orgId. + * @return Value for first name. */ - public Integer getOrgId() { - return orgId; + public String getFirstName() { + return firstName; } /** - * Sets orgId. + * Sets first name. * - * @param orgId New value for orgId. + * @param firstName New value for first name. */ - public void setOrgId(Integer orgId) { - this.orgId = orgId; + public void setFirstName(String firstName) { + this.firstName = firstName; } /** - * Gets name. + * Gets last name. * - * @return Value for name. + * @return Value for last name. */ - public String getName() { - return name; + public String getLastName() { + return lastName; } /** - * Sets name. + * Sets last name. * - * @param name New value for name. + * @param lastName New value for last name. */ - public void setName(String name) { - this.name = name; + public void setLastName(String lastName) { + this.lastName = lastName; } /** {@inheritDoc} */ @@ -124,10 +124,10 @@ public class Person implements Serializable { if (id != that.id) return false; - if (orgId != null ? !orgId.equals(that.orgId) : that.orgId != null) + if (firstName != null ? !firstName.equals(that.firstName) : that.firstName != null) return false; - if (name != null ? !name.equals(that.name) : that.name != null) + if (lastName != null ? !lastName.equals(that.lastName) : that.lastName != null) return false; return true; @@ -135,11 +135,11 @@ public class Person implements Serializable { /** {@inheritDoc} */ @Override public int hashCode() { - int res = id; + int res = (int)(id ^ (id >>> 32)); - res = 31 * res + (orgId != null ? orgId.hashCode() : 0); + res = 31 * res + (firstName != null ? firstName.hashCode() : 0); - res = 31 * res + (name != null ? name.hashCode() : 0); + res = 31 * res + (lastName != null ? lastName.hashCode() : 0); return res; } @@ -147,8 +147,8 @@ public class Person implements Serializable { /** {@inheritDoc} */ @Override public String toString() { return "Person [id=" + id + - ", orgId=" + orgId + - ", name=" + name + + ", firstName=" + firstName + + ", lastName=" + lastName + "]"; } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/PersonKey.java ---------------------------------------------------------------------- diff --git a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/PersonKey.java b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/PersonKey.java index ec517d5..4850b0f 100644 --- a/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/PersonKey.java +++ b/examples/src/main/java/org/apache/ignite/examples/datagrid/store/model/PersonKey.java @@ -29,7 +29,7 @@ public class PersonKey implements Serializable { private static final long serialVersionUID = 0L; /** Value for id. */ - private int id; + private long id; /** * Empty constructor. @@ -42,7 +42,7 @@ public class PersonKey implements Serializable { * Full constructor. */ public PersonKey( - int id + long id ) { this.id = id; } @@ -52,7 +52,7 @@ public class PersonKey implements Serializable { * * @return Value for id. */ - public int getId() { + public long getId() { return id; } @@ -61,7 +61,7 @@ public class PersonKey implements Serializable { * * @param id New value for id. */ - public void setId(int id) { + public void setId(long id) { this.id = id; } @@ -83,7 +83,7 @@ public class PersonKey implements Serializable { /** {@inheritDoc} */ @Override public int hashCode() { - int res = id; + int res = (int)(id ^ (id >>> 32)); return res; } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java index 7c6f060..d652c0f 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheAbstractJdbcStore.java @@ -22,6 +22,7 @@ import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.cache.store.jdbc.dialect.*; import org.apache.ignite.configuration.*; +import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.tostring.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; @@ -135,8 +136,8 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>, * @param obj Cache object. * @return Field value from object. */ - @Nullable protected abstract Object extractField(String cacheName, String typeName, String fieldName, Object obj) - throws CacheException; + @Nullable protected abstract Object extractField(@Nullable String cacheName, String typeName, String fieldName, + Object obj) throws CacheException; /** * Construct object from query result. @@ -149,8 +150,9 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>, * @param rs ResultSet. * @return Constructed object. */ - protected abstract <R> R buildObject(String cacheName, String typeName, Collection<CacheTypeFieldMetadata> fields, - Map<String, Integer> loadColIdxs, ResultSet rs) throws CacheLoaderException; + protected abstract <R> R buildObject(@Nullable String cacheName, String typeName, + Collection<CacheTypeFieldMetadata> fields, Map<String, Integer> loadColIdxs, ResultSet rs) + throws CacheLoaderException; /** * Extract key type id from key object. @@ -477,8 +479,9 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>, if (entryMappings != null) return entryMappings; - Collection<CacheTypeMetadata> types = ignite().jcache(cacheName).getConfiguration(CacheConfiguration.class) - .getTypeMetadata(); + CacheConfiguration ccfg = ignite().jcache(cacheName).getConfiguration(CacheConfiguration.class); + + Collection<CacheTypeMetadata> types = ccfg.getTypeMetadata(); entryMappings = U.newHashMap(types.size()); @@ -1312,7 +1315,7 @@ public abstract class CacheAbstractJdbcStore<K, V> implements CacheStore<K, V>, * @param dialect JDBC dialect. * @param typeMeta Type metadata. */ - public EntryMapping(String cacheName, JdbcDialect dialect, CacheTypeMetadata typeMeta) { + public EntryMapping(@Nullable String cacheName, JdbcDialect dialect, CacheTypeMetadata typeMeta) { this.cacheName = cacheName; this.dialect = dialect; http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java index f2d6cae..68bc965 100644 --- a/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java +++ b/modules/core/src/main/java/org/apache/ignite/cache/store/jdbc/CacheJdbcPojoStore.java @@ -19,6 +19,7 @@ package org.apache.ignite.cache.store.jdbc; import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; +import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.jetbrains.annotations.*; @@ -42,13 +43,16 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object, Object> { protected final Class<?> cls; /** Constructor for POJO object. */ - private final Constructor ctor; + private Constructor ctor; + + /** Key have simple type. */ + private final boolean simpleKey; /** Cached setters for POJO object. */ - private final Map<String, Method> getters; + private Map<String, Method> getters; /** Cached getters for POJO object. */ - private final Map<String, Method> setters; + private Map<String, Method> setters; /** * POJO methods cache. @@ -60,6 +64,9 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object, Object> { try { cls = Class.forName(clsName); + if (simpleKey = cls.isAssignableFrom(Number.class) || cls.isInstance(String.class)) + return; + ctor = cls.getDeclaredConstructor(); if (!ctor.isAccessible()) @@ -112,21 +119,6 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object, Object> { return str == null ? null : str.isEmpty() ? "" : Character.toUpperCase(str.charAt(0)) + str.substring(1); } - - /** - * Construct new instance of pojo object. - * - * @return pojo object. - * @throws CacheLoaderException If construct new instance failed. - */ - protected Object newInstance() throws CacheLoaderException { - try { - return ctor.newInstance(); - } - catch (Exception e) { - throw new CacheLoaderException("Failed to create new instance for class: " + cls, e); - } - } } /** Methods cache. */ @@ -137,6 +129,8 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object, Object> { throws CacheException { Map<String, PojoMethodsCache> typeMethods = U.newHashMap(types.size() * 2); + // TODO Check for diff type of key + for (CacheTypeMetadata type : types) { String keyType = type.getKeyType(); typeMethods.put(keyType, new PojoMethodsCache(keyType, type.getKeyFields())); @@ -160,9 +154,15 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object, Object> { if (mc == null) throw new CacheLoaderException("Failed to find cache type metadata for type: " + typeName); - Object obj = mc.newInstance(); - try { + if (mc.simpleKey) { + CacheTypeFieldMetadata field = F.first(fields); + + return (R)getColumnValue(rs, loadColIdxs.get(field.getDatabaseName()), mc.cls); + } + + Object obj = mc.ctor.newInstance(); + for (CacheTypeFieldMetadata field : fields) { Method setter = mc.setters.get(field.getJavaName()); @@ -177,9 +177,12 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object, Object> { return (R)obj; } - catch (Exception e) { + catch (SQLException e) { throw new CacheLoaderException("Failed to read object of class: " + typeName, e); } + catch (Exception e) { + throw new CacheLoaderException("Failed to construct instance of class: " + typeName, e); + } } /** {@inheritDoc} */ @@ -191,6 +194,9 @@ public class CacheJdbcPojoStore extends CacheAbstractJdbcStore<Object, Object> { if (mc == null) throw new CacheException("Failed to find cache type metadata for type: " + typeName); + if (mc.simpleKey) + return obj; + Method getter = mc.getters.get(fieldName); if (getter == null) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/modules/schema-load/readme.txt ---------------------------------------------------------------------- diff --git a/modules/schema-load/readme.txt b/modules/schema-load/readme.txt new file mode 100644 index 0000000..f3969da --- /dev/null +++ b/modules/schema-load/readme.txt @@ -0,0 +1,105 @@ +Apache Ignite Schema-loading Module +------------------------------ + +Apache Ignite Schema-loading module provides a simple utility that automatically reads the database schema, +creates required type mapping description, and optionally generates the domain model in Java. + +For running utility use 'ignite-schema-load.{sh|bat}' script. For connection with RDBMS system from utility +you need to provide: connection url and jdbc driver. + + +Moving from disk-based architectures to in-memory architectures +------------------------------------------ + +Use Schema-loading utility for generation of type mapping and domain model in Java. + +For example you may use the following script for create sample type in your RDBMS system: + +CREATE TABLE Organization(id bigint not null, name varchar(50), city varchar(50), PRIMARY KEY(id)); +CREATE TABLE Person(id integer not null, firstName varchar(50), lastName varchar(50), PRIMARY KEY(id)); + +You need place domain model classes, jdbc driver (used for connect to you RDBMS system) in Ignite node classpath, +for example place in 'libs' folder. + +Append type mapping description generated by Schema-loading utility to your cache configuration and setup DataSource +to your RDBMS system for cache store. + +<bean class="org.apache.ignite.configuration.IgniteConfiguration"> + ... + <!-- Cache configuration. --> + <property name="cacheConfiguration"> + <list> + <bean class="org.apache.ignite.configuration.CacheConfiguration"> + ... + + <!-- Cache store. --> + <property name="cacheStoreFactory"> + <bean class="javax.cache.configuration.FactoryBuilder$SingletonFactory"> + <constructor-arg> + <bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcPojoStore"> + <property name="dataSource"> + <!-- Need specify connection pooling DataSource to your RDBMS system. --> + ... + </property> + </bean> + </constructor-arg> + </bean> + </property> + + <!-- Type mapping description. --> + <property name="typeMetadata"> + <list> + <bean class="org.apache.ignite.cache.CacheTypeMetadata"> + <property name="databaseTable" value="PERSON"/> + <property name="keyType" value="org.apache.ignite.examples.datagrid.store.model.PersonKey"/> + <property name="valueType" value="org.apache.ignite.examples.datagrid.store.model.Person"/> + <property name="keyFields"> + <list> + <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> + <property name="databaseName" value="ID"/> + <property name="databaseType"> + <util:constant static-field="java.sql.Types.BIGINT"/> + </property> + <property name="javaName" value="id"/> + <property name="javaType" value="long"/> + </bean> + </list> + </property> + <property name="valueFields"> + <list> + <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> + <property name="databaseName" value="ID"/> + <property name="databaseType"> + <util:constant static-field="java.sql.Types.BIGINT"/> + </property> + <property name="javaName" value="id"/> + <property name="javaType" value="long"/> + </bean> + <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> + <property name="databaseName" value="FIRST_NAME"/> + <property name="databaseType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + <property name="javaName" value="firstName"/> + <property name="javaType" value="java.lang.String"/> + </bean> + <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata"> + <property name="databaseName" value="LAST_NAME"/> + <property name="databaseType"> + <util:constant static-field="java.sql.Types.VARCHAR"/> + </property> + <property name="javaName" value="lastName"/> + <property name="javaType" value="java.lang.String"/> + </bean> + </list> + </property> + </bean> + </list> + </property> + ... + </bean> + </list> + </property> + ... +</bean> + http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/7457968a/modules/visor-plugins/src/main/java/org/apache/ignite/visor/plugin/VisorPlugin.java ---------------------------------------------------------------------- diff --git a/modules/visor-plugins/src/main/java/org/apache/ignite/visor/plugin/VisorPlugin.java b/modules/visor-plugins/src/main/java/org/apache/ignite/visor/plugin/VisorPlugin.java index 384053d..9c7bad4 100644 --- a/modules/visor-plugins/src/main/java/org/apache/ignite/visor/plugin/VisorPlugin.java +++ b/modules/visor-plugins/src/main/java/org/apache/ignite/visor/plugin/VisorPlugin.java @@ -23,8 +23,14 @@ import ro.fortsoft.pf4j.*; * Base class for Visor plugins. */ public abstract class VisorPlugin extends Plugin { - /** {@inheritDoc} */ - public VisorPlugin(PluginWrapper wrapper) { + /** + * Constructor to be used by plugin manager for plugin instantiation. + * Your plugins have to provide constructor with this exact signature to + * be successfully loaded by manager. + * + * @param wrapper A wrapper over plugin instance. + */ + protected VisorPlugin(PluginWrapper wrapper) { super(wrapper); }