ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akuznet...@apache.org
Subject [11/50] [abbrv] incubator-ignite git commit: # ignite-113 : extra Ignite-prefixes were deleted
Date Sat, 31 Jan 2015 01:22:58 GMT
# ignite-113 : extra Ignite-prefixes were deleted


Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/31f2b6e7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/31f2b6e7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/31f2b6e7

Branch: refs/heads/ignite-32
Commit: 31f2b6e72df2281088263aa4d87baf10eae73bfb
Parents: 0c0fcf3
Author: Artem SHutak <ashutak@gridgain.com>
Authored: Thu Jan 29 12:50:10 2015 +0300
Committer: Artem SHutak <ashutak@gridgain.com>
Committed: Thu Jan 29 12:50:10 2015 +0300

----------------------------------------------------------------------
 .../apache/ignite/cache/store/CacheStore.java   |    2 +-
 .../ignite/spi/deployment/DeploymentSpi.java    |    2 +-
 .../apache/ignite/transactions/IgniteTx.java    |    2 +-
 .../hibernate/CacheHibernateBlobStore.java      |  593 ++++++++
 .../CacheHibernateBlobStoreEntry.hbm.xml        |   29 +
 .../hibernate/CacheHibernateBlobStoreEntry.java |   86 ++
 .../IgniteCacheHibernateBlobStore.java          |  593 --------
 .../IgniteCacheHibernateBlobStoreEntry.hbm.xml  |   29 -
 .../IgniteCacheHibernateBlobStoreEntry.java     |   86 --
 ...idHibernateL2CacheTransactionalSelfTest.java |    2 +-
 .../CacheHibernateBlobStoreSelfTest.java        |  108 ++
 .../IgniteCacheHibernateBlobStoreSelfTest.java  |  108 --
 .../cache/store/hibernate/hibernate.cfg.xml     |    2 +-
 .../testsuites/IgniteHibernateTestSuite.java    |    2 +-
 .../apache/ignite/cache/jta/CacheTmLookup.java  |   50 +
 .../ignite/cache/jta/IgniteCacheTmLookup.java   |   50 -
 .../cache/jta/jndi/CacheJndiTmLookup.java       |   74 +
 .../cache/jta/jndi/IgniteCacheJndiTmLookup.java |   74 -
 .../jta/reflect/CacheReflectionTmLookup.java    |  115 ++
 .../reflect/IgniteCacheReflectionTmLookup.java  |  115 --
 .../processors/cache/jta/CacheJtaManager.java   |    4 +-
 ...CacheJtaConfigurationValidationSelfTest.java |    2 +-
 .../processors/cache/GridCacheJtaSelfTest.java  |    2 +-
 .../GridTmLookupLifecycleAwareSelfTest.java     |    4 +-
 .../uri/GridUriDeploymentFileProcessor.java     |    2 +-
 .../deployment/uri/IgniteUriDeploymentSpi.java  | 1367 ------------------
 .../uri/IgniteUriDeploymentSpiMBean.java        |   53 -
 .../spi/deployment/uri/UriDeploymentSpi.java    | 1367 ++++++++++++++++++
 .../deployment/uri/UriDeploymentSpiMBean.java   |   53 +
 .../GridTaskUriDeploymentDeadlockSelfTest.java  |    2 +-
 .../ignite/p2p/GridP2PDisabledSelfTest.java     |    2 +-
 .../uri/GridUriDeploymentAbstractSelfTest.java  |    2 +-
 .../GridUriDeploymentClassLoaderSelfTest.java   |    2 +-
 ...riDeploymentClassloaderRegisterSelfTest.java |    4 +-
 .../uri/GridUriDeploymentConfigSelfTest.java    |   10 +-
 .../GridUriDeploymentFileProcessorSelfTest.java |    2 +-
 .../uri/GridUriDeploymentMd5CheckSelfTest.java  |    2 +-
 ...loymentMultiScannersErrorThrottlingTest.java |    2 +-
 .../GridUriDeploymentMultiScannersSelfTest.java |    2 +-
 .../uri/GridUriDeploymentSimpleSelfTest.java    |   10 +-
 .../file/GridFileDeploymentSelfTest.java        |    2 +-
 .../GridFileDeploymentUndeploySelfTest.java     |    8 +-
 .../uri/scanners/ftp/GridFtpDeploymentTest.java |    2 +-
 .../http/GridHttpDeploymentSelfTest.java        |    2 +-
 .../IgniteUriDeploymentTestSuite.java           |    2 +-
 45 files changed, 2516 insertions(+), 2516 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
index bf5ffdf..fe1d5a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
+++ b/modules/core/src/main/java/org/apache/ignite/cache/store/CacheStore.java
@@ -50,7 +50,7 @@ import static javax.cache.Cache.*;
  * <p>
  * Provided implementations may be used for test purposes:
  * <ul>
- *     <li>{@ignitelink org.apache.ignite.cache.store.hibernate.IgniteCacheHibernateBlobStore}</li>
+ *     <li>{@ignitelink org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore}</li>
  *     <li>{@link CacheJdbcBlobStore}</li>
  * </ul>
  * <p>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java b/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
index 27478e4..b1cee6e 100644
--- a/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
+++ b/modules/core/src/main/java/org/apache/ignite/spi/deployment/DeploymentSpi.java
@@ -48,7 +48,7 @@ import org.jetbrains.annotations.*;
  * Gridgain provides the following {@code GridDeploymentSpi} implementations:
  * <ul>
  * <li>{@link org.apache.ignite.spi.deployment.local.LocalDeploymentSpi}</li>
- * <li>{@ignitelink org.apache.ignite.spi.deployment.uri.IgniteUriDeploymentSpi}</li>
+ * <li>{@ignitelink org.apache.ignite.spi.deployment.uri.UriDeploymentSpi}</li>
  * </ul>
  * <b>NOTE:</b> this SPI (i.e. methods in this interface) should never be used directly. SPIs provide
  * internal view on the subsystem and is used internally by GridGain kernal. In rare use cases when

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
index 9227ae9..af96a00 100644
--- a/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
+++ b/modules/core/src/main/java/org/apache/ignite/transactions/IgniteTx.java
@@ -28,7 +28,7 @@ import java.util.*;
 /**
  * Grid cache transaction. Cache transactions have a default 2PC (two-phase-commit) behavior and
  * can be plugged into ongoing {@code JTA} transaction by properly implementing
- * {@ignitelink org.apache.ignite.cache.jta.IgniteCacheTmLookup}
+ * {@ignitelink org.apache.ignite.cache.jta.CacheTmLookup}
  * interface. Cache transactions can also be started explicitly directly from {@link org.apache.ignite.cache.CacheProjection} API
  * via any of the {@code 'CacheProjection.txStart(..)'} methods.
  * <p>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
new file mode 100644
index 0000000..43a1737
--- /dev/null
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStore.java
@@ -0,0 +1,593 @@
+/*
+ * 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.cache.store.hibernate;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.store.*;
+import org.apache.ignite.resources.*;
+import org.apache.ignite.transactions.*;
+import org.apache.ignite.internal.util.typedef.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.internal.util.tostring.*;
+import org.hibernate.*;
+import org.hibernate.cfg.*;
+import org.jetbrains.annotations.*;
+
+import javax.cache.integration.*;
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.*;
+import java.util.concurrent.atomic.*;
+
+/**
+ * {@link CacheStore} implementation backed by Hibernate. This implementation
+ * stores objects in underlying database in {@code BLOB} format.
+ * <h2 class="header">Configuration</h2>
+ * Either {@link #setSessionFactory(SessionFactory)} or
+ * {@link #setHibernateConfigurationPath(String)} or
+ * {@link #setHibernateProperties(Properties)} should be set.
+ * <p>
+ * If session factory is provided it should contain
+ * {@link CacheHibernateBlobStoreEntry} persistent class (via provided
+ * mapping file {@code GridCacheHibernateStoreEntry.hbm.xml} or by
+ * adding {@link CacheHibernateBlobStoreEntry} to annotated classes
+ * of session factory.
+ * <p>
+ * Path to hibernate configuration may be either an URL or a file path or
+ * a classpath resource. This configuration file should include provided
+ * mapping {@code GridCacheHibernateStoreEntry.hbm.xml} or include annotated
+ * class {@link CacheHibernateBlobStoreEntry}.
+ * <p>
+ * If hibernate properties are provided, mapping
+ * {@code GridCacheHibernateStoreEntry.hbm.xml} is included automatically.
+ *
+ * <h2 class="header">Java Example</h2>
+ * In this example existing session factory is provided.
+ * <pre name="code" class="java">
+ *     ...
+ *     CacheHibernateBlobStore&lt;String, String&gt; store = new CacheHibernateBlobStore&lt;String, String&gt;();
+ *
+ *     store.setSessionFactory(sesFactory);
+ *     ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example (using Spring ORM)</h2>
+ * <pre name="code" class="xml">
+ *   ...
+ *   &lt;bean id=&quot;cache.hibernate.store&quot;
+ *       class=&quot;org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore&quot;&gt;
+ *       &lt;property name=&quot;sessionFactory&quot;&gt;
+ *           &lt;bean class=&quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot;&gt;
+ *               &lt;property name=&quot;hibernateProperties&quot;&gt;
+ *                   &lt;value&gt;
+ *                       connection.url=jdbc:h2:mem:
+ *                       show_sql=true
+ *                       hbm2ddl.auto=true
+ *                       hibernate.dialect=org.hibernate.dialect.H2Dialect
+ *                   &lt;/value&gt;
+ *               &lt;/property&gt;
+ *               &lt;property name=&quot;mappingResources&quot;&gt;
+ *                   &lt;list&gt;
+ *                       &lt;value&gt;
+ *                           org/gridgain/grid/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
+ *                       &lt;/value&gt;
+ *                   &lt;/list&gt;
+ *               &lt;/property&gt;
+ *           &lt;/bean&gt;
+ *       &lt;/property&gt;
+ *   &lt;/bean&gt;
+ *   ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example (using Spring ORM and persistent annotations)</h2>
+ * <pre name="code" class="xml">
+ *     ...
+ *     &lt;bean id=&quot;cache.hibernate.store1&quot;
+ *         class=&quot;org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore&quot;&gt;
+ *         &lt;property name=&quot;sessionFactory&quot;&gt;
+ *             &lt;bean class=&quot;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&quot;&gt;
+ *                 &lt;property name=&quot;hibernateProperties&quot;&gt;
+ *                     &lt;value&gt;
+ *                         connection.url=jdbc:h2:mem:
+ *                         show_sql=true
+ *                         hbm2ddl.auto=true
+ *                         hibernate.dialect=org.hibernate.dialect.H2Dialect
+ *                     &lt;/value&gt;
+ *                 &lt;/property&gt;
+ *                 &lt;property name=&quot;annotatedClasses&quot;&gt;
+ *                     &lt;list&gt;
+ *                         &lt;value&gt;
+ *                             org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry
+ *                         &lt;/value&gt;
+ *                     &lt;/list&gt;
+ *                 &lt;/property&gt;
+ *             &lt;/bean&gt;
+ *         &lt;/property&gt;
+ *     &lt;/bean&gt;
+ *     ...
+ * </pre>
+ *
+ * <h2 class="header">Spring Example</h2>
+ * <pre name="code" class="xml">
+ *     ...
+ *     &lt;bean id=&quot;cache.hibernate.store2&quot;
+ *         class=&quot;org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStore&quot;&gt;
+ *         &lt;property name=&quot;hibernateProperties&quot;&gt;
+ *             &lt;props&gt;
+ *                 &lt;prop key=&quot;connection.url&quot;&gt;jdbc:h2:mem:&lt;/prop&gt;
+ *                 &lt;prop key=&quot;hbm2ddl.auto&quot;&gt;update&lt;/prop&gt;
+ *                 &lt;prop key=&quot;show_sql&quot;&gt;true&lt;/prop&gt;
+ *             &lt;/props&gt;
+ *         &lt;/property&gt;
+ *     &lt;/bean&gt;
+ *     ...
+ * </pre>
+ * <p>
+ * <img src="http://www.gridgain.com/images/spring-small.png">
+ * <br>
+ * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
+ */
+public class CacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
+    /**
+     * Default connection URL
+     * (value is <tt>jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000</tt>).
+     */
+    public static final String DFLT_CONN_URL = "jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;" +
+        "DEFAULT_LOCK_TIMEOUT=5000";
+
+    /** Default show SQL property value (value is <tt>true</tt>). */
+    public static final String DFLT_SHOW_SQL = "true";
+
+    /** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is <tt>true</tt>). */
+    public static final String DFLT_HBM2DDL_AUTO = "update";
+
+    /** Session attribute name. */
+    private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
+
+    /** Name of Hibarname mapping resource. */
+    private static final String MAPPING_RESOURCE =
+            "org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml";
+
+    /** Init guard. */
+    @GridToStringExclude
+    private final AtomicBoolean initGuard = new AtomicBoolean();
+
+    /** Init latch. */
+    @GridToStringExclude
+    private final CountDownLatch initLatch = new CountDownLatch(1);
+
+    /** Hibernate properties. */
+    @GridToStringExclude
+    private Properties hibernateProps;
+
+    /** Session factory. */
+    @GridToStringExclude
+    private SessionFactory sesFactory;
+
+    /** Path to hibernate configuration file. */
+    private String hibernateCfgPath;
+
+    /** Log. */
+    @IgniteLoggerResource
+    private IgniteLogger log;
+
+    /** Ignite instance. */
+    @IgniteInstanceResource
+    private Ignite ignite;
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"unchecked", "RedundantTypeArguments"})
+    @Override public V load(K key) {
+        init();
+
+        IgniteTx tx = transaction();
+
+        if (log.isDebugEnabled())
+            log.debug("Store load [key=" + key + ", tx=" + tx + ']');
+
+        Session ses = session(tx);
+
+        try {
+            CacheHibernateBlobStoreEntry entry = (CacheHibernateBlobStoreEntry)
+                ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
+
+            if (entry == null)
+                return null;
+
+            return fromBytes(entry.getValue());
+        }
+        catch (IgniteCheckedException | HibernateException e) {
+            rollback(ses, tx);
+
+            throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
+        }
+        finally {
+            end(ses, tx);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void write(javax.cache.Cache.Entry<? extends K, ? extends V> entry) {
+        init();
+
+        IgniteTx tx = transaction();
+
+        K key = entry.getKey();
+        V val = entry.getValue();
+
+        if (log.isDebugEnabled())
+            log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
+
+        if (val == null) {
+            delete(key);
+
+            return;
+        }
+
+        Session ses = session(tx);
+
+        try {
+            CacheHibernateBlobStoreEntry entry0 = new CacheHibernateBlobStoreEntry(toBytes(key), toBytes(val));
+
+            ses.saveOrUpdate(entry0);
+        }
+        catch (IgniteCheckedException | HibernateException e) {
+            rollback(ses, tx);
+
+            throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
+        }
+        finally {
+            end(ses, tx);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings({"JpaQueryApiInspection", "JpaQlInspection"})
+    @Override public void delete(Object key) {
+        init();
+
+        IgniteTx tx = transaction();
+
+        if (log.isDebugEnabled())
+            log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
+
+        Session ses = session(tx);
+
+        try {
+            Object obj = ses.get(CacheHibernateBlobStoreEntry.class, toBytes(key));
+
+            if (obj != null)
+                ses.delete(obj);
+        }
+        catch (IgniteCheckedException | HibernateException e) {
+            rollback(ses, tx);
+
+            throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
+        }
+        finally {
+            end(ses, tx);
+        }
+    }
+
+    /**
+     * Rolls back hibernate session.
+     *
+     * @param ses Hibernate session.
+     * @param tx Cache ongoing transaction.
+     */
+    private void rollback(SharedSessionContract ses, IgniteTx tx) {
+        // Rollback only if there is no cache transaction,
+        // otherwise txEnd() will do all required work.
+        if (tx == null) {
+            Transaction hTx = ses.getTransaction();
+
+            if (hTx != null && hTx.isActive())
+                hTx.rollback();
+        }
+    }
+
+    /**
+     * Ends hibernate session.
+     *
+     * @param ses Hibernate session.
+     * @param tx Cache ongoing transaction.
+     */
+    private void end(Session ses, IgniteTx tx) {
+        // Commit only if there is no cache transaction,
+        // otherwise txEnd() will do all required work.
+        if (tx == null) {
+            Transaction hTx = ses.getTransaction();
+
+            if (hTx != null && hTx.isActive())
+                hTx.commit();
+
+            ses.close();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public void txEnd(boolean commit) {
+        init();
+
+        IgniteTx tx = transaction();
+
+        Map<String, Session> props = session().properties();
+
+        Session ses = props.remove(ATTR_SES);
+
+        if (ses != null) {
+            Transaction hTx = ses.getTransaction();
+
+            if (hTx != null) {
+                try {
+                    if (commit) {
+                        ses.flush();
+
+                        hTx.commit();
+                    }
+                    else
+                        hTx.rollback();
+
+                    if (log.isDebugEnabled())
+                        log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
+                }
+                catch (HibernateException e) {
+                    throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
+                        ", commit=" + commit + ']', e);
+                }
+                finally {
+                    ses.close();
+                }
+            }
+        }
+    }
+
+    /**
+     * Gets Hibernate session.
+     *
+     * @param tx Cache transaction.
+     * @return Session.
+     */
+    Session session(@Nullable IgniteTx tx) {
+        Session ses;
+
+        if (tx != null) {
+            Map<String, Session> props = session().properties();
+
+            ses = props.get(ATTR_SES);
+
+            if (ses == null) {
+                ses = sesFactory.openSession();
+
+                ses.beginTransaction();
+
+                // Store session in transaction metadata, so it can be accessed
+                // for other operations on the same transaction.
+                props.put(ATTR_SES, ses);
+
+                if (log.isDebugEnabled())
+                    log.debug("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
+            }
+        }
+        else {
+            ses = sesFactory.openSession();
+
+            ses.beginTransaction();
+        }
+
+        return ses;
+    }
+
+    /**
+     * Sets session factory.
+     *
+     * @param sesFactory Session factory.
+     */
+    public void setSessionFactory(SessionFactory sesFactory) {
+        this.sesFactory = sesFactory;
+    }
+
+    /**
+     * Sets hibernate configuration path.
+     * <p>
+     * This may be either URL or file path or classpath resource.
+     *
+     * @param hibernateCfgPath URL or file path or classpath resource
+     *      pointing to hibernate configuration XML file.
+     */
+    public void setHibernateConfigurationPath(String hibernateCfgPath) {
+        this.hibernateCfgPath = hibernateCfgPath;
+    }
+
+    /**
+     * Sets Hibernate properties.
+     *
+     * @param hibernateProps Hibernate properties.
+     */
+    public void setHibernateProperties(Properties hibernateProps) {
+        this.hibernateProps = hibernateProps;
+    }
+
+    /**
+     * Initializes store.
+     *
+     * @throws IgniteException If failed to initialize.
+     */
+    private void init() throws IgniteException {
+        if (initGuard.compareAndSet(false, true)) {
+            if (log.isDebugEnabled())
+                log.debug("Initializing cache store.");
+
+            try {
+                if (sesFactory != null)
+                    // Session factory has been provided - nothing to do.
+                    return;
+
+                if (!F.isEmpty(hibernateCfgPath)) {
+                    try {
+                        URL url = new URL(hibernateCfgPath);
+
+                        sesFactory = new Configuration().configure(url).buildSessionFactory();
+
+                        if (log.isDebugEnabled())
+                            log.debug("Configured session factory using URL: " + url);
+
+                        // Session factory has been successfully initialized.
+                        return;
+                    }
+                    catch (MalformedURLException e) {
+                        if (log.isDebugEnabled())
+                            log.debug("Caught malformed URL exception: " + e.getMessage());
+                    }
+
+                    // Provided path is not a valid URL. File?
+                    File cfgFile = new File(hibernateCfgPath);
+
+                    if (cfgFile.exists()) {
+                        sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
+
+                        if (log.isDebugEnabled())
+                            log.debug("Configured session factory using file: " + hibernateCfgPath);
+
+                        // Session factory has been successfully initialized.
+                        return;
+                    }
+
+                    // Provided path is not a file. Classpath resource?
+                    sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
+
+                    if (log.isDebugEnabled())
+                        log.debug("Configured session factory using classpath resource: " + hibernateCfgPath);
+                }
+                else {
+                    if (hibernateProps == null) {
+                        U.warn(log, "No Hibernate configuration has been provided for store (will use default).");
+
+                        hibernateProps = new Properties();
+
+                        hibernateProps.setProperty("hibernate.connection.url", DFLT_CONN_URL);
+                        hibernateProps.setProperty("hibernate.show_sql", DFLT_SHOW_SQL);
+                        hibernateProps.setProperty("hibernate.hbm2ddl.auto", DFLT_HBM2DDL_AUTO);
+                    }
+
+                    Configuration cfg = new Configuration();
+
+                    cfg.setProperties(hibernateProps);
+
+                    assert resourceAvailable(MAPPING_RESOURCE) : MAPPING_RESOURCE;
+
+                    cfg.addResource(MAPPING_RESOURCE);
+
+                    sesFactory = cfg.buildSessionFactory();
+
+                    if (log.isDebugEnabled())
+                        log.debug("Configured session factory using properties: " + hibernateProps);
+                }
+            }
+            catch (HibernateException e) {
+                throw new IgniteException("Failed to initialize store.", e);
+            }
+            finally {
+                initLatch.countDown();
+            }
+        }
+        else if (initLatch.getCount() > 0) {
+            try {
+                U.await(initLatch);
+            }
+            catch (IgniteInterruptedException e) {
+                throw new IgniteException(e);
+            }
+        }
+
+        if (sesFactory == null)
+            throw new IgniteException("Cache store was not properly initialized.");
+    }
+
+    /**
+     * Checks availability of a classpath resource.
+     *
+     * @param name Resource name.
+     * @return {@code true} if resource is available and ready for read, {@code false} otherwise.
+     */
+    private boolean resourceAvailable(String name) {
+        InputStream cfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
+
+        if (cfgStream == null) {
+            log.error("Classpath resource not found: " + name);
+
+            return false;
+        }
+
+        try {
+            // Read a single byte to force actual content access by JVM.
+            cfgStream.read();
+
+            return true;
+        }
+        catch (IOException e) {
+            log.error("Failed to read classpath resource: " + name, e);
+
+            return false;
+        }
+        finally {
+            U.close(cfgStream, log);
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override public String toString() {
+        return S.toString(CacheHibernateBlobStore.class, this);
+    }
+
+    /**
+     * Serialize object to byte array using marshaller.
+     *
+     * @param obj Object to convert to byte array.
+     * @return Byte array.
+     * @throws IgniteCheckedException If failed to convert.
+     */
+    protected byte[] toBytes(Object obj) throws IgniteCheckedException {
+        return ignite.configuration().getMarshaller().marshal(obj);
+    }
+
+    /**
+     * Deserialize object from byte array using marshaller.
+     *
+     * @param bytes Bytes to deserialize.
+     * @param <X> Result object type.
+     * @return Deserialized object.
+     * @throws IgniteCheckedException If failed.
+     */
+    protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
+        if (bytes == null || bytes.length == 0)
+            return null;
+
+        return ignite.configuration().getMarshaller().unmarshal(bytes, getClass().getClassLoader());
+    }
+
+    /**
+     * @return Current transaction.
+     */
+    @Nullable private IgniteTx transaction() {
+        CacheStoreSession ses = session();
+
+        return ses != null ? ses.transaction() : null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
new file mode 100644
index 0000000..b880a33
--- /dev/null
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml
@@ -0,0 +1,29 @@
+<?xml version="1.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.
+  -->
+
+<!DOCTYPE hibernate-mapping PUBLIC
+        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
+        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
+
+<hibernate-mapping package="org.gridgain.examples.datagrid.store" default-access="field">
+    <class name="org.apache.ignite.cache.store.hibernate.CacheHibernateBlobStoreEntry" table="ENTRIES">
+        <id name="key"/>
+
+        <property name="val"/>
+    </class>
+</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
new file mode 100644
index 0000000..981757b
--- /dev/null
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.java
@@ -0,0 +1,86 @@
+/*
+ * 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.cache.store.hibernate;
+
+import javax.persistence.*;
+
+/**
+ * Entry that is used by {@link CacheHibernateBlobStore} implementation.
+ * <p>
+ * Note that this is a reference implementation for tests only.
+ * When running on production systems use concrete key-value types to
+ * get better performance.
+ */
+@Entity
+@Table(name = "ENTRIES")
+public class CacheHibernateBlobStoreEntry {
+    /** Key (use concrete key type in production). */
+    @Id
+    @Column(length = 65535)
+    private byte[] key;
+
+    /** Value (use concrete value type in production). */
+    @Column(length = 65535)
+    private byte[] val;
+
+    /**
+     * Constructor.
+     */
+    CacheHibernateBlobStoreEntry() {
+        // No-op.
+    }
+
+    /**
+     * Constructor.
+     *
+     * @param key Key.
+     * @param val Value.
+     */
+    CacheHibernateBlobStoreEntry(byte[] key, byte[] val) {
+        this.key = key;
+        this.val = val;
+    }
+
+    /**
+     * @return Key.
+     */
+    public byte[] getKey() {
+        return key;
+    }
+
+    /**
+     * @param key Key.
+     */
+    public void setKey(byte[] key) {
+        this.key = key;
+    }
+
+    /**
+     * @return Value.
+     */
+    public byte[] getValue() {
+        return val;
+    }
+
+    /**
+     * @param val Value.
+     */
+    public void setValue(byte[] val) {
+        this.val = val;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStore.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStore.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStore.java
deleted file mode 100644
index 4a8f985..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStore.java
+++ /dev/null
@@ -1,593 +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.cache.store.hibernate;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.store.*;
-import org.apache.ignite.resources.*;
-import org.apache.ignite.transactions.*;
-import org.apache.ignite.internal.util.typedef.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.internal.util.tostring.*;
-import org.hibernate.*;
-import org.hibernate.cfg.*;
-import org.jetbrains.annotations.*;
-
-import javax.cache.integration.*;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.*;
-
-/**
- * {@link CacheStore} implementation backed by Hibernate. This implementation
- * stores objects in underlying database in {@code BLOB} format.
- * <h2 class="header">Configuration</h2>
- * Either {@link #setSessionFactory(SessionFactory)} or
- * {@link #setHibernateConfigurationPath(String)} or
- * {@link #setHibernateProperties(Properties)} should be set.
- * <p>
- * If session factory is provided it should contain
- * {@link IgniteCacheHibernateBlobStoreEntry} persistent class (via provided
- * mapping file {@code GridCacheHibernateStoreEntry.hbm.xml} or by
- * adding {@link IgniteCacheHibernateBlobStoreEntry} to annotated classes
- * of session factory.
- * <p>
- * Path to hibernate configuration may be either an URL or a file path or
- * a classpath resource. This configuration file should include provided
- * mapping {@code GridCacheHibernateStoreEntry.hbm.xml} or include annotated
- * class {@link IgniteCacheHibernateBlobStoreEntry}.
- * <p>
- * If hibernate properties are provided, mapping
- * {@code GridCacheHibernateStoreEntry.hbm.xml} is included automatically.
- *
- * <h2 class="header">Java Example</h2>
- * In this example existing session factory is provided.
- * <pre name="code" class="java">
- *     ...
- *     IgniteCacheHibernateBlobStore&lt;String, String&gt; store = new IgniteCacheHibernateBlobStore&lt;String, String&gt;();
- *
- *     store.setSessionFactory(sesFactory);
- *     ...
- * </pre>
- *
- * <h2 class="header">Spring Example (using Spring ORM)</h2>
- * <pre name="code" class="xml">
- *   ...
- *   &lt;bean id=&quot;cache.hibernate.store&quot;
- *       class=&quot;org.apache.ignite.cache.store.hibernate.IgniteCacheHibernateBlobStore&quot;&gt;
- *       &lt;property name=&quot;sessionFactory&quot;&gt;
- *           &lt;bean class=&quot;org.springframework.orm.hibernate3.LocalSessionFactoryBean&quot;&gt;
- *               &lt;property name=&quot;hibernateProperties&quot;&gt;
- *                   &lt;value&gt;
- *                       connection.url=jdbc:h2:mem:
- *                       show_sql=true
- *                       hbm2ddl.auto=true
- *                       hibernate.dialect=org.hibernate.dialect.H2Dialect
- *                   &lt;/value&gt;
- *               &lt;/property&gt;
- *               &lt;property name=&quot;mappingResources&quot;&gt;
- *                   &lt;list&gt;
- *                       &lt;value&gt;
- *                           org/gridgain/grid/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.hbm.xml
- *                       &lt;/value&gt;
- *                   &lt;/list&gt;
- *               &lt;/property&gt;
- *           &lt;/bean&gt;
- *       &lt;/property&gt;
- *   &lt;/bean&gt;
- *   ...
- * </pre>
- *
- * <h2 class="header">Spring Example (using Spring ORM and persistent annotations)</h2>
- * <pre name="code" class="xml">
- *     ...
- *     &lt;bean id=&quot;cache.hibernate.store1&quot;
- *         class=&quot;org.apache.ignite.cache.store.hibernate.IgniteCacheHibernateBlobStore&quot;&gt;
- *         &lt;property name=&quot;sessionFactory&quot;&gt;
- *             &lt;bean class=&quot;org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean&quot;&gt;
- *                 &lt;property name=&quot;hibernateProperties&quot;&gt;
- *                     &lt;value&gt;
- *                         connection.url=jdbc:h2:mem:
- *                         show_sql=true
- *                         hbm2ddl.auto=true
- *                         hibernate.dialect=org.hibernate.dialect.H2Dialect
- *                     &lt;/value&gt;
- *                 &lt;/property&gt;
- *                 &lt;property name=&quot;annotatedClasses&quot;&gt;
- *                     &lt;list&gt;
- *                         &lt;value&gt;
- *                             org.apache.ignite.cache.store.hibernate.IgniteCacheHibernateBlobStoreEntry
- *                         &lt;/value&gt;
- *                     &lt;/list&gt;
- *                 &lt;/property&gt;
- *             &lt;/bean&gt;
- *         &lt;/property&gt;
- *     &lt;/bean&gt;
- *     ...
- * </pre>
- *
- * <h2 class="header">Spring Example</h2>
- * <pre name="code" class="xml">
- *     ...
- *     &lt;bean id=&quot;cache.hibernate.store2&quot;
- *         class=&quot;org.apache.ignite.cache.store.hibernate.IgniteCacheHibernateBlobStore&quot;&gt;
- *         &lt;property name=&quot;hibernateProperties&quot;&gt;
- *             &lt;props&gt;
- *                 &lt;prop key=&quot;connection.url&quot;&gt;jdbc:h2:mem:&lt;/prop&gt;
- *                 &lt;prop key=&quot;hbm2ddl.auto&quot;&gt;update&lt;/prop&gt;
- *                 &lt;prop key=&quot;show_sql&quot;&gt;true&lt;/prop&gt;
- *             &lt;/props&gt;
- *         &lt;/property&gt;
- *     &lt;/bean&gt;
- *     ...
- * </pre>
- * <p>
- * <img src="http://www.gridgain.com/images/spring-small.png">
- * <br>
- * For information about Spring framework visit <a href="http://www.springframework.org/">www.springframework.org</a>
- */
-public class IgniteCacheHibernateBlobStore<K, V> extends CacheStoreAdapter<K, V> {
-    /**
-     * Default connection URL
-     * (value is <tt>jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;DEFAULT_LOCK_TIMEOUT=5000</tt>).
-     */
-    public static final String DFLT_CONN_URL = "jdbc:h2:mem:hibernateCacheStore;DB_CLOSE_DELAY=-1;" +
-        "DEFAULT_LOCK_TIMEOUT=5000";
-
-    /** Default show SQL property value (value is <tt>true</tt>). */
-    public static final String DFLT_SHOW_SQL = "true";
-
-    /** Default <tt>hibernate.hbm2ddl.auto</tt> property value (value is <tt>true</tt>). */
-    public static final String DFLT_HBM2DDL_AUTO = "update";
-
-    /** Session attribute name. */
-    private static final String ATTR_SES = "HIBERNATE_STORE_SESSION";
-
-    /** Name of Hibarname mapping resource. */
-    private static final String MAPPING_RESOURCE =
-            "org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.hbm.xml";
-
-    /** Init guard. */
-    @GridToStringExclude
-    private final AtomicBoolean initGuard = new AtomicBoolean();
-
-    /** Init latch. */
-    @GridToStringExclude
-    private final CountDownLatch initLatch = new CountDownLatch(1);
-
-    /** Hibernate properties. */
-    @GridToStringExclude
-    private Properties hibernateProps;
-
-    /** Session factory. */
-    @GridToStringExclude
-    private SessionFactory sesFactory;
-
-    /** Path to hibernate configuration file. */
-    private String hibernateCfgPath;
-
-    /** Log. */
-    @IgniteLoggerResource
-    private IgniteLogger log;
-
-    /** Ignite instance. */
-    @IgniteInstanceResource
-    private Ignite ignite;
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"unchecked", "RedundantTypeArguments"})
-    @Override public V load(K key) {
-        init();
-
-        IgniteTx tx = transaction();
-
-        if (log.isDebugEnabled())
-            log.debug("Store load [key=" + key + ", tx=" + tx + ']');
-
-        Session ses = session(tx);
-
-        try {
-            IgniteCacheHibernateBlobStoreEntry entry = (IgniteCacheHibernateBlobStoreEntry)
-                ses.get(IgniteCacheHibernateBlobStoreEntry.class, toBytes(key));
-
-            if (entry == null)
-                return null;
-
-            return fromBytes(entry.getValue());
-        }
-        catch (IgniteCheckedException | HibernateException e) {
-            rollback(ses, tx);
-
-            throw new CacheLoaderException("Failed to load value from cache store with key: " + key, e);
-        }
-        finally {
-            end(ses, tx);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void write(javax.cache.Cache.Entry<? extends K, ? extends V> entry) {
-        init();
-
-        IgniteTx tx = transaction();
-
-        K key = entry.getKey();
-        V val = entry.getValue();
-
-        if (log.isDebugEnabled())
-            log.debug("Store put [key=" + key + ", val=" + val + ", tx=" + tx + ']');
-
-        if (val == null) {
-            delete(key);
-
-            return;
-        }
-
-        Session ses = session(tx);
-
-        try {
-            IgniteCacheHibernateBlobStoreEntry entry0 = new IgniteCacheHibernateBlobStoreEntry(toBytes(key), toBytes(val));
-
-            ses.saveOrUpdate(entry0);
-        }
-        catch (IgniteCheckedException | HibernateException e) {
-            rollback(ses, tx);
-
-            throw new CacheWriterException("Failed to put value to cache store [key=" + key + ", val" + val + "]", e);
-        }
-        finally {
-            end(ses, tx);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings({"JpaQueryApiInspection", "JpaQlInspection"})
-    @Override public void delete(Object key) {
-        init();
-
-        IgniteTx tx = transaction();
-
-        if (log.isDebugEnabled())
-            log.debug("Store remove [key=" + key + ", tx=" + tx + ']');
-
-        Session ses = session(tx);
-
-        try {
-            Object obj = ses.get(IgniteCacheHibernateBlobStoreEntry.class, toBytes(key));
-
-            if (obj != null)
-                ses.delete(obj);
-        }
-        catch (IgniteCheckedException | HibernateException e) {
-            rollback(ses, tx);
-
-            throw new CacheWriterException("Failed to remove value from cache store with key: " + key, e);
-        }
-        finally {
-            end(ses, tx);
-        }
-    }
-
-    /**
-     * Rolls back hibernate session.
-     *
-     * @param ses Hibernate session.
-     * @param tx Cache ongoing transaction.
-     */
-    private void rollback(SharedSessionContract ses, IgniteTx tx) {
-        // Rollback only if there is no cache transaction,
-        // otherwise txEnd() will do all required work.
-        if (tx == null) {
-            Transaction hTx = ses.getTransaction();
-
-            if (hTx != null && hTx.isActive())
-                hTx.rollback();
-        }
-    }
-
-    /**
-     * Ends hibernate session.
-     *
-     * @param ses Hibernate session.
-     * @param tx Cache ongoing transaction.
-     */
-    private void end(Session ses, IgniteTx tx) {
-        // Commit only if there is no cache transaction,
-        // otherwise txEnd() will do all required work.
-        if (tx == null) {
-            Transaction hTx = ses.getTransaction();
-
-            if (hTx != null && hTx.isActive())
-                hTx.commit();
-
-            ses.close();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public void txEnd(boolean commit) {
-        init();
-
-        IgniteTx tx = transaction();
-
-        Map<String, Session> props = session().properties();
-
-        Session ses = props.remove(ATTR_SES);
-
-        if (ses != null) {
-            Transaction hTx = ses.getTransaction();
-
-            if (hTx != null) {
-                try {
-                    if (commit) {
-                        ses.flush();
-
-                        hTx.commit();
-                    }
-                    else
-                        hTx.rollback();
-
-                    if (log.isDebugEnabled())
-                        log.debug("Transaction ended [xid=" + tx.xid() + ", commit=" + commit + ']');
-                }
-                catch (HibernateException e) {
-                    throw new CacheWriterException("Failed to end transaction [xid=" + tx.xid() +
-                        ", commit=" + commit + ']', e);
-                }
-                finally {
-                    ses.close();
-                }
-            }
-        }
-    }
-
-    /**
-     * Gets Hibernate session.
-     *
-     * @param tx Cache transaction.
-     * @return Session.
-     */
-    Session session(@Nullable IgniteTx tx) {
-        Session ses;
-
-        if (tx != null) {
-            Map<String, Session> props = session().properties();
-
-            ses = props.get(ATTR_SES);
-
-            if (ses == null) {
-                ses = sesFactory.openSession();
-
-                ses.beginTransaction();
-
-                // Store session in transaction metadata, so it can be accessed
-                // for other operations on the same transaction.
-                props.put(ATTR_SES, ses);
-
-                if (log.isDebugEnabled())
-                    log.debug("Hibernate session open [ses=" + ses + ", tx=" + tx.xid() + "]");
-            }
-        }
-        else {
-            ses = sesFactory.openSession();
-
-            ses.beginTransaction();
-        }
-
-        return ses;
-    }
-
-    /**
-     * Sets session factory.
-     *
-     * @param sesFactory Session factory.
-     */
-    public void setSessionFactory(SessionFactory sesFactory) {
-        this.sesFactory = sesFactory;
-    }
-
-    /**
-     * Sets hibernate configuration path.
-     * <p>
-     * This may be either URL or file path or classpath resource.
-     *
-     * @param hibernateCfgPath URL or file path or classpath resource
-     *      pointing to hibernate configuration XML file.
-     */
-    public void setHibernateConfigurationPath(String hibernateCfgPath) {
-        this.hibernateCfgPath = hibernateCfgPath;
-    }
-
-    /**
-     * Sets Hibernate properties.
-     *
-     * @param hibernateProps Hibernate properties.
-     */
-    public void setHibernateProperties(Properties hibernateProps) {
-        this.hibernateProps = hibernateProps;
-    }
-
-    /**
-     * Initializes store.
-     *
-     * @throws IgniteException If failed to initialize.
-     */
-    private void init() throws IgniteException {
-        if (initGuard.compareAndSet(false, true)) {
-            if (log.isDebugEnabled())
-                log.debug("Initializing cache store.");
-
-            try {
-                if (sesFactory != null)
-                    // Session factory has been provided - nothing to do.
-                    return;
-
-                if (!F.isEmpty(hibernateCfgPath)) {
-                    try {
-                        URL url = new URL(hibernateCfgPath);
-
-                        sesFactory = new Configuration().configure(url).buildSessionFactory();
-
-                        if (log.isDebugEnabled())
-                            log.debug("Configured session factory using URL: " + url);
-
-                        // Session factory has been successfully initialized.
-                        return;
-                    }
-                    catch (MalformedURLException e) {
-                        if (log.isDebugEnabled())
-                            log.debug("Caught malformed URL exception: " + e.getMessage());
-                    }
-
-                    // Provided path is not a valid URL. File?
-                    File cfgFile = new File(hibernateCfgPath);
-
-                    if (cfgFile.exists()) {
-                        sesFactory = new Configuration().configure(cfgFile).buildSessionFactory();
-
-                        if (log.isDebugEnabled())
-                            log.debug("Configured session factory using file: " + hibernateCfgPath);
-
-                        // Session factory has been successfully initialized.
-                        return;
-                    }
-
-                    // Provided path is not a file. Classpath resource?
-                    sesFactory = new Configuration().configure(hibernateCfgPath).buildSessionFactory();
-
-                    if (log.isDebugEnabled())
-                        log.debug("Configured session factory using classpath resource: " + hibernateCfgPath);
-                }
-                else {
-                    if (hibernateProps == null) {
-                        U.warn(log, "No Hibernate configuration has been provided for store (will use default).");
-
-                        hibernateProps = new Properties();
-
-                        hibernateProps.setProperty("hibernate.connection.url", DFLT_CONN_URL);
-                        hibernateProps.setProperty("hibernate.show_sql", DFLT_SHOW_SQL);
-                        hibernateProps.setProperty("hibernate.hbm2ddl.auto", DFLT_HBM2DDL_AUTO);
-                    }
-
-                    Configuration cfg = new Configuration();
-
-                    cfg.setProperties(hibernateProps);
-
-                    assert resourceAvailable(MAPPING_RESOURCE) : MAPPING_RESOURCE;
-
-                    cfg.addResource(MAPPING_RESOURCE);
-
-                    sesFactory = cfg.buildSessionFactory();
-
-                    if (log.isDebugEnabled())
-                        log.debug("Configured session factory using properties: " + hibernateProps);
-                }
-            }
-            catch (HibernateException e) {
-                throw new IgniteException("Failed to initialize store.", e);
-            }
-            finally {
-                initLatch.countDown();
-            }
-        }
-        else if (initLatch.getCount() > 0) {
-            try {
-                U.await(initLatch);
-            }
-            catch (IgniteInterruptedException e) {
-                throw new IgniteException(e);
-            }
-        }
-
-        if (sesFactory == null)
-            throw new IgniteException("Cache store was not properly initialized.");
-    }
-
-    /**
-     * Checks availability of a classpath resource.
-     *
-     * @param name Resource name.
-     * @return {@code true} if resource is available and ready for read, {@code false} otherwise.
-     */
-    private boolean resourceAvailable(String name) {
-        InputStream cfgStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(name);
-
-        if (cfgStream == null) {
-            log.error("Classpath resource not found: " + name);
-
-            return false;
-        }
-
-        try {
-            // Read a single byte to force actual content access by JVM.
-            cfgStream.read();
-
-            return true;
-        }
-        catch (IOException e) {
-            log.error("Failed to read classpath resource: " + name, e);
-
-            return false;
-        }
-        finally {
-            U.close(cfgStream, log);
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override public String toString() {
-        return S.toString(IgniteCacheHibernateBlobStore.class, this);
-    }
-
-    /**
-     * Serialize object to byte array using marshaller.
-     *
-     * @param obj Object to convert to byte array.
-     * @return Byte array.
-     * @throws IgniteCheckedException If failed to convert.
-     */
-    protected byte[] toBytes(Object obj) throws IgniteCheckedException {
-        return ignite.configuration().getMarshaller().marshal(obj);
-    }
-
-    /**
-     * Deserialize object from byte array using marshaller.
-     *
-     * @param bytes Bytes to deserialize.
-     * @param <X> Result object type.
-     * @return Deserialized object.
-     * @throws IgniteCheckedException If failed.
-     */
-    protected <X> X fromBytes(byte[] bytes) throws IgniteCheckedException {
-        if (bytes == null || bytes.length == 0)
-            return null;
-
-        return ignite.configuration().getMarshaller().unmarshal(bytes, getClass().getClassLoader());
-    }
-
-    /**
-     * @return Current transaction.
-     */
-    @Nullable private IgniteTx transaction() {
-        CacheStoreSession ses = session();
-
-        return ses != null ? ses.transaction() : null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.hbm.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.hbm.xml b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.hbm.xml
deleted file mode 100644
index 8c247e0..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.hbm.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.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.
-  -->
-
-<!DOCTYPE hibernate-mapping PUBLIC
-        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
-        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">
-
-<hibernate-mapping package="org.gridgain.examples.datagrid.store" default-access="field">
-    <class name="org.apache.ignite.cache.store.hibernate.IgniteCacheHibernateBlobStoreEntry" table="ENTRIES">
-        <id name="key"/>
-
-        <property name="val"/>
-    </class>
-</hibernate-mapping>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.java
deleted file mode 100644
index 7f563c1..0000000
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreEntry.java
+++ /dev/null
@@ -1,86 +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.cache.store.hibernate;
-
-import javax.persistence.*;
-
-/**
- * Entry that is used by {@link IgniteCacheHibernateBlobStore} implementation.
- * <p>
- * Note that this is a reference implementation for tests only.
- * When running on production systems use concrete key-value types to
- * get better performance.
- */
-@Entity
-@Table(name = "ENTRIES")
-public class IgniteCacheHibernateBlobStoreEntry {
-    /** Key (use concrete key type in production). */
-    @Id
-    @Column(length = 65535)
-    private byte[] key;
-
-    /** Value (use concrete value type in production). */
-    @Column(length = 65535)
-    private byte[] val;
-
-    /**
-     * Constructor.
-     */
-    IgniteCacheHibernateBlobStoreEntry() {
-        // No-op.
-    }
-
-    /**
-     * Constructor.
-     *
-     * @param key Key.
-     * @param val Value.
-     */
-    IgniteCacheHibernateBlobStoreEntry(byte[] key, byte[] val) {
-        this.key = key;
-        this.val = val;
-    }
-
-    /**
-     * @return Key.
-     */
-    public byte[] getKey() {
-        return key;
-    }
-
-    /**
-     * @param key Key.
-     */
-    public void setKey(byte[] key) {
-        this.key = key;
-    }
-
-    /**
-     * @return Value.
-     */
-    public byte[] getValue() {
-        return val;
-    }
-
-    /**
-     * @param val Value.
-     */
-    public void setValue(byte[] val) {
-        this.val = val;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/GridHibernateL2CacheTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/GridHibernateL2CacheTransactionalSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/GridHibernateL2CacheTransactionalSelfTest.java
index c149315..81ab9e2 100644
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/GridHibernateL2CacheTransactionalSelfTest.java
+++ b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/GridHibernateL2CacheTransactionalSelfTest.java
@@ -62,7 +62,7 @@ public class GridHibernateL2CacheTransactionalSelfTest extends GridHibernateL2Ca
     /**
      */
     @SuppressWarnings("PublicInnerClass")
-    public static class TestTmLookup implements IgniteCacheTmLookup {
+    public static class TestTmLookup implements CacheTmLookup {
         /** {@inheritDoc} */
         @Override public TransactionManager getTm() throws IgniteCheckedException {
             return jotm.getTransactionManager();

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
new file mode 100644
index 0000000..65a4f77
--- /dev/null
+++ b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreSelfTest.java
@@ -0,0 +1,108 @@
+/*
+ * 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.cache.store.hibernate;
+
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.testframework.junits.cache.*;
+import org.hibernate.*;
+
+import java.io.*;
+import java.net.*;
+
+/**
+ * Cache store test.
+ */
+public class CacheHibernateBlobStoreSelfTest extends
+    GridAbstractCacheStoreSelfTest<CacheHibernateBlobStore<Object, Object>> {
+    /**
+     * @throws Exception If failed.
+     */
+    public CacheHibernateBlobStoreSelfTest() throws Exception {
+        // No-op.
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTest() throws Exception {
+        super.afterTest();
+
+        Session s = store.session(null);
+
+        if (s == null)
+            return;
+
+        try {
+            s.createQuery("delete from " + CacheHibernateBlobStoreEntry.class.getSimpleName())
+                    .setFlushMode(FlushMode.ALWAYS).executeUpdate();
+
+            Transaction hTx = s.getTransaction();
+
+            if (hTx != null && hTx.isActive())
+                hTx.commit();
+        }
+        finally {
+            s.close();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheHibernateBlobStore<Object, Object> store() {
+        return new CacheHibernateBlobStore<>();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConfigurationByUrl() throws Exception {
+        URL url = U.resolveGridGainUrl(
+            "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+        assert url != null;
+
+        store.setHibernateConfigurationPath(url.toString());
+
+        // Store will be implicitly initialized.
+        store.load("key");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConfigurationByFile() throws Exception {
+        URL url = U.resolveGridGainUrl(
+            "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+        assert url != null;
+
+        File file = new File(url.toURI());
+
+        store.setHibernateConfigurationPath(file.getAbsolutePath());
+
+        // Store will be implicitly initialized.
+        store.load("key");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testConfigurationByResource() throws Exception {
+        store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
+
+        // Store will be implicitly initialized.
+        store.load("key");
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreSelfTest.java
deleted file mode 100644
index 9c9da7a..0000000
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/IgniteCacheHibernateBlobStoreSelfTest.java
+++ /dev/null
@@ -1,108 +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.cache.store.hibernate;
-
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.testframework.junits.cache.*;
-import org.hibernate.*;
-
-import java.io.*;
-import java.net.*;
-
-/**
- * Cache store test.
- */
-public class IgniteCacheHibernateBlobStoreSelfTest extends
-    GridAbstractCacheStoreSelfTest<IgniteCacheHibernateBlobStore<Object, Object>> {
-    /**
-     * @throws Exception If failed.
-     */
-    public IgniteCacheHibernateBlobStoreSelfTest() throws Exception {
-        // No-op.
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTest() throws Exception {
-        super.afterTest();
-
-        Session s = store.session(null);
-
-        if (s == null)
-            return;
-
-        try {
-            s.createQuery("delete from " + IgniteCacheHibernateBlobStoreEntry.class.getSimpleName())
-                    .setFlushMode(FlushMode.ALWAYS).executeUpdate();
-
-            Transaction hTx = s.getTransaction();
-
-            if (hTx != null && hTx.isActive())
-                hTx.commit();
-        }
-        finally {
-            s.close();
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteCacheHibernateBlobStore<Object, Object> store() {
-        return new IgniteCacheHibernateBlobStore<>();
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testConfigurationByUrl() throws Exception {
-        URL url = U.resolveGridGainUrl(
-            "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
-        assert url != null;
-
-        store.setHibernateConfigurationPath(url.toString());
-
-        // Store will be implicitly initialized.
-        store.load("key");
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testConfigurationByFile() throws Exception {
-        URL url = U.resolveGridGainUrl(
-            "modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
-        assert url != null;
-
-        File file = new File(url.toURI());
-
-        store.setHibernateConfigurationPath(file.getAbsolutePath());
-
-        // Store will be implicitly initialized.
-        store.load("key");
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    public void testConfigurationByResource() throws Exception {
-        store.setHibernateConfigurationPath("/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml");
-
-        // Store will be implicitly initialized.
-        store.load("key");
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
index d2166e2..650c7e7 100644
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
+++ b/modules/hibernate/src/test/java/org/apache/ignite/cache/store/hibernate/hibernate.cfg.xml
@@ -35,6 +35,6 @@
         <property name="hibernate.dialect">org.hibernate.dialect.H2Dialect</property>
 
         <!-- Mappings. -->
-        <mapping resource="org/apache/ignite/cache/store/hibernate/GridCacheHibernateBlobStoreEntry.hbm.xml"/>
+        <mapping resource="org/apache/ignite/cache/store/hibernate/CacheHibernateBlobStoreEntry.hbm.xml"/>
     </session-factory>
 </hibernate-configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java b/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
index c472779..38785c4 100644
--- a/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
+++ b/modules/hibernate/src/test/java/org/apache/ignite/testsuites/IgniteHibernateTestSuite.java
@@ -37,7 +37,7 @@ public class IgniteHibernateTestSuite extends TestSuite {
 //        suite.addTestSuite(GridHibernateL2CacheTransactionalSelfTest.class);
         suite.addTestSuite(GridHibernateL2CacheConfigurationSelfTest.class);
 
-        suite.addTestSuite(IgniteCacheHibernateBlobStoreSelfTest.class);
+        suite.addTestSuite(CacheHibernateBlobStoreSelfTest.class);
 
         return suite;
     }

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/jta/src/main/java/org/apache/ignite/cache/jta/CacheTmLookup.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/CacheTmLookup.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/CacheTmLookup.java
new file mode 100644
index 0000000..e3460bf
--- /dev/null
+++ b/modules/jta/src/main/java/org/apache/ignite/cache/jta/CacheTmLookup.java
@@ -0,0 +1,50 @@
+/*
+ * 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.cache.jta;
+
+import org.apache.ignite.*;
+import org.jetbrains.annotations.*;
+
+import javax.transaction.*;
+
+/**
+ * Allows grid to use different transactional systems. Implement this interface
+ * to look up native transaction manager within your environment. Transaction
+ * manager lookup is configured via {@link org.apache.ignite.cache.CacheConfiguration#getTransactionManagerLookupClassName()}
+ * method.
+ * <p>
+ * The following implementations are provided out of the box:
+ * <ul>
+ * <li>
+ *  {@link org.apache.ignite.cache.jta.jndi.CacheJndiTmLookup} utilizes a configured JNDI name to look up a transaction manager.
+ * </li>
+ * <li>
+ *  {@link org.apache.ignite.cache.jta.reflect.CacheReflectionTmLookup} uses reflection to call a method on a given class
+ *  to get to transaction manager.
+ * </li>
+ * </ul>
+ */
+public interface CacheTmLookup {
+    /**
+     * Gets Transaction Manager (TM).
+     *
+     * @return TM or {@code null} if TM cannot be looked up.
+     * @throws IgniteCheckedException In case of error.
+     */
+    @Nullable public TransactionManager getTm() throws IgniteCheckedException;
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/jta/src/main/java/org/apache/ignite/cache/jta/IgniteCacheTmLookup.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/IgniteCacheTmLookup.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/IgniteCacheTmLookup.java
deleted file mode 100644
index b44117a..0000000
--- a/modules/jta/src/main/java/org/apache/ignite/cache/jta/IgniteCacheTmLookup.java
+++ /dev/null
@@ -1,50 +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.cache.jta;
-
-import org.apache.ignite.*;
-import org.jetbrains.annotations.*;
-
-import javax.transaction.*;
-
-/**
- * Allows grid to use different transactional systems. Implement this interface
- * to look up native transaction manager within your environment. Transaction
- * manager lookup is configured via {@link org.apache.ignite.cache.CacheConfiguration#getTransactionManagerLookupClassName()}
- * method.
- * <p>
- * The following implementations are provided out of the box:
- * <ul>
- * <li>
- *  {@link org.apache.ignite.cache.jta.jndi.IgniteCacheJndiTmLookup} utilizes a configured JNDI name to look up a transaction manager.
- * </li>
- * <li>
- *  {@link org.apache.ignite.cache.jta.reflect.IgniteCacheReflectionTmLookup} uses reflection to call a method on a given class
- *  to get to transaction manager.
- * </li>
- * </ul>
- */
-public interface IgniteCacheTmLookup {
-    /**
-     * Gets Transaction Manager (TM).
-     *
-     * @return TM or {@code null} if TM cannot be looked up.
-     * @throws IgniteCheckedException In case of error.
-     */
-    @Nullable public TransactionManager getTm() throws IgniteCheckedException;
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmLookup.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmLookup.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmLookup.java
new file mode 100644
index 0000000..2b20949
--- /dev/null
+++ b/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmLookup.java
@@ -0,0 +1,74 @@
+/*
+ * 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.cache.jta.jndi;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.jta.*;
+import org.jetbrains.annotations.*;
+
+import javax.naming.*;
+import javax.transaction.*;
+import java.util.*;
+
+/**
+ * Implementation of {@link org.apache.ignite.cache.jta.CacheTmLookup} interface that is using list of JNDI names to find TM.
+ */
+public class CacheJndiTmLookup implements CacheTmLookup {
+    /** */
+    private List<String> jndiNames;
+
+    /**
+     * Gets a list of JNDI names.
+     *
+     * @return List of JNDI names that is used to find TM.
+     */
+    public List<String> getJndiNames() {
+        return jndiNames;
+    }
+
+    /**
+     * Sets a list of JNDI names used by this TM.
+     *
+     * @param jndiNames List of JNDI names that is used to find TM.
+     */
+    public void setJndiNames(List<String> jndiNames) {
+        this.jndiNames = jndiNames;
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public TransactionManager getTm() throws IgniteCheckedException {
+        assert jndiNames != null;
+        assert !jndiNames.isEmpty();
+
+        try {
+            InitialContext ctx = new InitialContext();
+
+            for (String s : jndiNames) {
+                Object obj = ctx.lookup(s);
+
+                if (obj != null && obj instanceof TransactionManager)
+                    return (TransactionManager) obj;
+            }
+        }
+        catch (NamingException e) {
+            throw new IgniteCheckedException("Unable to lookup TM by: " + jndiNames, e);
+        }
+
+        return null;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/IgniteCacheJndiTmLookup.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/IgniteCacheJndiTmLookup.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/IgniteCacheJndiTmLookup.java
deleted file mode 100644
index 6836e14..0000000
--- a/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/IgniteCacheJndiTmLookup.java
+++ /dev/null
@@ -1,74 +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.cache.jta.jndi;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.jta.*;
-import org.jetbrains.annotations.*;
-
-import javax.naming.*;
-import javax.transaction.*;
-import java.util.*;
-
-/**
- * Implementation of {@link org.apache.ignite.cache.jta.IgniteCacheTmLookup} interface that is using list of JNDI names to find TM.
- */
-public class IgniteCacheJndiTmLookup implements IgniteCacheTmLookup {
-    /** */
-    private List<String> jndiNames;
-
-    /**
-     * Gets a list of JNDI names.
-     *
-     * @return List of JNDI names that is used to find TM.
-     */
-    public List<String> getJndiNames() {
-        return jndiNames;
-    }
-
-    /**
-     * Sets a list of JNDI names used by this TM.
-     *
-     * @param jndiNames List of JNDI names that is used to find TM.
-     */
-    public void setJndiNames(List<String> jndiNames) {
-        this.jndiNames = jndiNames;
-    }
-
-    /** {@inheritDoc} */
-    @Nullable @Override public TransactionManager getTm() throws IgniteCheckedException {
-        assert jndiNames != null;
-        assert !jndiNames.isEmpty();
-
-        try {
-            InitialContext ctx = new InitialContext();
-
-            for (String s : jndiNames) {
-                Object obj = ctx.lookup(s);
-
-                if (obj != null && obj instanceof TransactionManager)
-                    return (TransactionManager) obj;
-            }
-        }
-        catch (NamingException e) {
-            throw new IgniteCheckedException("Unable to lookup TM by: " + jndiNames, e);
-        }
-
-        return null;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/CacheReflectionTmLookup.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/CacheReflectionTmLookup.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/CacheReflectionTmLookup.java
new file mode 100644
index 0000000..6549308
--- /dev/null
+++ b/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/CacheReflectionTmLookup.java
@@ -0,0 +1,115 @@
+/*
+ * 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.cache.jta.reflect;
+
+import org.apache.ignite.*;
+import org.apache.ignite.cache.jta.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+
+import javax.transaction.*;
+import java.lang.reflect.*;
+
+/**
+ * Implementation of {@link org.apache.ignite.cache.jta.CacheTmLookup} interface that attempts to obtain
+ * JTA manager by calling static method on the class.
+ */
+public class CacheReflectionTmLookup implements CacheTmLookup {
+    /** */
+    private String cls;
+
+    /** */
+    private String mtd;
+
+    /**
+     * Creates uninitialized reflection TM lookup.
+     */
+    public CacheReflectionTmLookup() { /* No-op. */ }
+
+    /**
+     * Creates generic TM lookup with given class and method name.
+     *
+     * @param cls Class name.
+     * @param mtd Method name on that the class.
+     */
+    public CacheReflectionTmLookup(String cls, String mtd) {
+        A.notNull(cls, "cls");
+        A.notNull(mtd, "mtd");
+
+        this.cls = cls;
+        this.mtd = mtd;
+    }
+
+    /**
+     * Gets class name to use.
+     *
+     * @return Class name to use.
+     */
+    public String getClassName() {
+        return cls;
+    }
+
+    /**
+     * Sets class name to use.
+     *
+     * @param cls Class name to use.
+     */
+    public void setClassName(String cls) {
+        A.notNull(cls, "cls");
+
+        this.cls = cls;
+    }
+
+    /**
+     * Gets method name.
+     *
+     * @return Method name to use.
+     */
+    public String getMethodName() {
+        return mtd;
+    }
+
+    /**
+     * Sets method name.
+     *
+     * @param mtd Method name to use.
+     */
+    public void setMethodName(String mtd) {
+        A.notNull(mtd, "mtd");
+
+        this.mtd = mtd;
+    }
+
+    /** {@inheritDoc} */
+    @Override public TransactionManager getTm() throws IgniteCheckedException {
+        assert cls != null;
+        assert mtd != null;
+
+        try {
+            return (TransactionManager)Class.forName(cls).getMethod(mtd).invoke(null);
+        }
+        catch (ClassNotFoundException e) {
+            throw new IgniteCheckedException("Failed to find class: " + cls, e);
+        }
+        catch (NoSuchMethodException e) {
+            throw new IgniteCheckedException("Failed to find method: " + mtd, e);
+        }
+        catch (InvocationTargetException | IllegalAccessException e) {
+            throw new IgniteCheckedException("Failed to invoke method: " + mtd, e);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/31f2b6e7/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/IgniteCacheReflectionTmLookup.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/IgniteCacheReflectionTmLookup.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/IgniteCacheReflectionTmLookup.java
deleted file mode 100644
index e1c9875..0000000
--- a/modules/jta/src/main/java/org/apache/ignite/cache/jta/reflect/IgniteCacheReflectionTmLookup.java
+++ /dev/null
@@ -1,115 +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.cache.jta.reflect;
-
-import org.apache.ignite.*;
-import org.apache.ignite.cache.jta.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-
-import javax.transaction.*;
-import java.lang.reflect.*;
-
-/**
- * Implementation of {@link org.apache.ignite.cache.jta.IgniteCacheTmLookup} interface that attempts to obtain
- * JTA manager by calling static method on the class.
- */
-public class IgniteCacheReflectionTmLookup implements IgniteCacheTmLookup {
-    /** */
-    private String cls;
-
-    /** */
-    private String mtd;
-
-    /**
-     * Creates uninitialized reflection TM lookup.
-     */
-    public IgniteCacheReflectionTmLookup() { /* No-op. */ }
-
-    /**
-     * Creates generic TM lookup with given class and method name.
-     *
-     * @param cls Class name.
-     * @param mtd Method name on that the class.
-     */
-    public IgniteCacheReflectionTmLookup(String cls, String mtd) {
-        A.notNull(cls, "cls");
-        A.notNull(mtd, "mtd");
-
-        this.cls = cls;
-        this.mtd = mtd;
-    }
-
-    /**
-     * Gets class name to use.
-     *
-     * @return Class name to use.
-     */
-    public String getClassName() {
-        return cls;
-    }
-
-    /**
-     * Sets class name to use.
-     *
-     * @param cls Class name to use.
-     */
-    public void setClassName(String cls) {
-        A.notNull(cls, "cls");
-
-        this.cls = cls;
-    }
-
-    /**
-     * Gets method name.
-     *
-     * @return Method name to use.
-     */
-    public String getMethodName() {
-        return mtd;
-    }
-
-    /**
-     * Sets method name.
-     *
-     * @param mtd Method name to use.
-     */
-    public void setMethodName(String mtd) {
-        A.notNull(mtd, "mtd");
-
-        this.mtd = mtd;
-    }
-
-    /** {@inheritDoc} */
-    @Override public TransactionManager getTm() throws IgniteCheckedException {
-        assert cls != null;
-        assert mtd != null;
-
-        try {
-            return (TransactionManager)Class.forName(cls).getMethod(mtd).invoke(null);
-        }
-        catch (ClassNotFoundException e) {
-            throw new IgniteCheckedException("Failed to find class: " + cls, e);
-        }
-        catch (NoSuchMethodException e) {
-            throw new IgniteCheckedException("Failed to find method: " + mtd, e);
-        }
-        catch (InvocationTargetException | IllegalAccessException e) {
-            throw new IgniteCheckedException("Failed to invoke method: " + mtd, e);
-        }
-    }
-}


Mime
View raw message