Author: cbredesen
Date: 2009-06-12 10:33:00 -0400 (Fri, 12 Jun 2009)
New Revision: 16771
Added:
core/branches/INFINISPAN/cache-infinispan/pom.xml
core/branches/INFINISPAN/cache-infinispan/src/
core/branches/INFINISPAN/cache-infinispan/src/main/
core/branches/INFINISPAN/cache-infinispan/src/main/java/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseGeneralDataRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseTransactionalDataRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java
core/branches/INFINISPAN/cache-infinispan/src/main/resources/
core/branches/INFINISPAN/cache-infinispan/src/test/
core/branches/INFINISPAN/cache-infinispan/src/test/java/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/InfinispanTest.java
core/branches/INFINISPAN/cache-infinispan/src/test/resources/
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
Modified:
core/branches/INFINISPAN/cache-infinispan/
Log:
Initial import
Property changes on: core/branches/INFINISPAN/cache-infinispan
___________________________________________________________________
Name: svn:ignore
+ target
.classpath
Added: core/branches/INFINISPAN/cache-infinispan/pom.xml
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/pom.xml (rev 0)
+++ core/branches/INFINISPAN/cache-infinispan/pom.xml 2009-06-12 14:33:00 UTC (rev 16771)
@@ -0,0 +1,149 @@
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-parent</artifactId>
+ <version>3.3.2-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-infinispan</artifactId>
+ <packaging>jar</packaging>
+
+ <name>Hibernate Infinispan Integration</name>
+ <description>Integration of Hibernate with Infinispan</description>
+
+ <dependencies>
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-core</artifactId>
+ <version>${version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.infinispan</groupId>
+ <artifactId>infinispan-core</artifactId>
+ <version>4.0.0.ALPHA3</version>
+ </dependency>
+
+ <!-- test dependencies -->
+ <dependency>
+ <groupId>${groupId}</groupId>
+ <artifactId>hibernate-testing</artifactId>
+ <version>${version}</version>
+ <!-- <scope>test</scope> TODO fix this -->
+ </dependency>
+ <dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.2</version>
+ <scope>test</scope>
+ </dependency>
+ <!-- this is optional on core :( and needed for testing -->
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ <version>3.4.GA</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <excludes>
+ <!-- Skip a long-running test of a prototype class -->
+
<exclude>**/ClusteredConcurrentTimestampRegionTestCase.java</exclude>
+ </excludes>
+ <systemProperties>
+ <property>
+
<name>hibernate.test.validatefailureexpected</name>
+ <value>true</value>
+ </property>
+ <property>
+ <name>jgroups.bind_addr</name>
+ <value>${jgroups.bind_addr}</value>
+ </property>
+ <!-- There are problems with multicast and IPv6 on some
+ OS/JDK combos, so we tell Java to use IPv4. If you
+ have problems with multicast when running the tests
+ you can try setting this to 'false', although
typically
+ that won't be helpful.
+ -->
+ <property>
+ <name>java.net.preferIPv4Stack</name>
+ <value>true</value>
+ </property>
+ <!-- Tell JGroups to only wait a short time for PING
+ responses before determining coordinator. Speeds cluster
+ formation during integration tests. (This is too
+ low a value for a real system; only use for tests.)
+ -->
+ <property>
+ <name>jgroups.ping.timeout</name>
+ <value>500</value>
+ </property>
+ <!-- Tell JGroups to only require one PING response
+ before determining coordinator. Speeds cluster
+ formation during integration tests. (This is too
+ low a value for a real system; only use for tests.)
+ -->
+ <property>
+ <name>jgroups.ping.num_initial_members</name>
+ <value>1</value>
+ </property>
+ <!-- Disable the JGroups message bundling feature
+ to speed tests and avoid FLUSH issue -->
+ <property>
+ <name>jgroups.udp.enable_bundling</name>
+ <value>false</value>
+ </property>
+ </systemProperties>
+ <skipExec>${skipUnitTests}</skipExec>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <properties>
+ <skipUnitTests>true</skipUnitTests>
+ <!--
+ Following is the default jgroups mcast address. If you find the testsuite
runs very slowly, there
+ may be problems with multicast on the interface JGroups uses by default on
your machine. You can
+ try to resolve setting 'jgroups.bind_addr' as a system-property to
the jvm launching maven and
+ setting the value to an interface where you know multicast works
+ -->
+ <jgroups.bind_addr>127.0.0.1</jgroups.bind_addr>
+ </properties>
+
+ <profiles>
+ <profile>
+ <id>test</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <properties>
+ <skipUnitTests>false</skipUnitTests>
+ </properties>
+ </profile>
+ </profiles>
+</project>
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseGeneralDataRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseGeneralDataRegion.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseGeneralDataRegion.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,34 @@
+package org.hibernate.cache.infinispan;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.GeneralDataRegion;
+import org.infinispan.Cache;
+
+/**
+ * Support for Infinispan {@link GeneralDataRegion} implementors.
+ *
+ * @author Chris Bredesen
+ */
+public abstract class BaseGeneralDataRegion extends BaseRegion implements
GeneralDataRegion {
+
+ public BaseGeneralDataRegion( Cache<Object, Object> cache, String name ) {
+ super( cache, name );
+ }
+
+ public void evict( Object key ) throws CacheException {
+ getCache().evict( key );
+ }
+
+ public void evictAll() throws CacheException {
+ getCache().clear();
+ }
+
+ public Object get( Object key ) throws CacheException {
+ return getCache().get( key );
+ }
+
+ public void put( Object key, Object value ) throws CacheException {
+ getCache().put( key, value );
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseRegion.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,74 @@
+package org.hibernate.cache.infinispan;
+
+import java.util.Collections;
+import java.util.Map;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.Region;
+import org.infinispan.Cache;
+
+/**
+ * Support for Infinispan {@link Region}s. Handles the management of a Cache
+ * instance as well as basic peripheral operations.
+ *
+ * @author Chris Bredesen
+ */
+abstract class BaseRegion implements Region {
+ private final Cache<Object, Object> cache;
+ private final String name;
+
+ public BaseRegion( Cache<Object, Object> cache, String name ) {
+ this.cache = cache;
+ this.name = name;
+ }
+
+ public Cache<Object, Object> getCache() {
+ return cache;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public long getElementCountInMemory() {
+ return cache.size();
+ }
+
+ /**
+ * Not supported.
+ *
+ * @return -1
+ */
+ public long getElementCountOnDisk() {
+ return -1;
+ }
+
+ /**
+ * Not supported.
+ *
+ * @return -1
+ */
+ public long getSizeInMemory() {
+ return -1;
+ }
+
+ public int getTimeout() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public long nextTimestamp() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ @SuppressWarnings("unchecked")
+ public Map toMap() {
+ return Collections.EMPTY_MAP;
+ }
+
+ public void destroy() throws CacheException {
+ // TODO see if we need to do this even in spite of RF.shutdown()
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseTransactionalDataRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseTransactionalDataRegion.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/BaseTransactionalDataRegion.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,28 @@
+package org.hibernate.cache.infinispan;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.TransactionalDataRegion;
+import org.infinispan.Cache;
+
+/**
+ * Support for Inifinispan {@link TransactionalDataRegion} implementors.
+ *
+ * @author Chris Bredesen
+ */
+public abstract class BaseTransactionalDataRegion extends BaseRegion implements
TransactionalDataRegion {
+ private final CacheDataDescription metadata;
+
+ public BaseTransactionalDataRegion( Cache<Object, Object> cache, String name,
CacheDataDescription metadata ) {
+ super( cache, name );
+ this.metadata = metadata;
+ }
+
+ public CacheDataDescription getCacheDataDescription() {
+ return metadata;
+ }
+
+ public boolean isTransactionAware() {
+ return true;
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/InfinispanRegionFactory.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,116 @@
+package org.hibernate.cache.infinispan;
+
+import java.util.Properties;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.RegionFactory;
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cache.infinispan.collection.InfinispanCollectionRegion;
+import org.hibernate.cache.infinispan.entity.InfinispanEntityRegion;
+import org.hibernate.cache.infinispan.query.InfinispanQueryResultsRegion;
+import org.hibernate.cache.infinispan.timestamp.InfinispanTimestampsRegion;
+import org.hibernate.cfg.Settings;
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A {@link RegionFactory} for <a
+ *
href="http://www.jboss.org/infinispan">Infinispan</a>-... cache
regions.
+ *
+ * @author Chris Bredesen
+ */
+public class InfinispanRegionFactory implements RegionFactory {
+ private static final Logger log =
LoggerFactory.getLogger(InfinispanRegionFactory.class);
+
+ final CacheManager cacheManager = new DefaultCacheManager( false );
+
+ /**
+ * Create a new instance using the default configuration.
+ */
+ public InfinispanRegionFactory() {
+ }
+
+ /**
+ * Create a new instance using conifguration properties in
+ * <code>props</code>.
+ *
+ * @param props Environmental properties; currently unused.
+ */
+ public InfinispanRegionFactory( Properties props ) {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public CollectionRegion buildCollectionRegion( String regionName, Properties
properties,
+ CacheDataDescription metadata ) throws CacheException {
+ log.debug( "Building collection cache region [" + regionName + "]"
);
+ return new InfinispanCollectionRegion( cacheManager.getCache( regionName ),
regionName,
+ metadata );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public EntityRegion buildEntityRegion( String regionName, Properties properties,
+ CacheDataDescription metadata ) throws CacheException {
+ log.debug( "Building entity cache region [" + regionName + "]" );
+ return new InfinispanEntityRegion( cacheManager.getCache( regionName ), regionName,
+ metadata );
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public QueryResultsRegion buildQueryResultsRegion( String regionName, Properties
properties )
+ throws CacheException {
+ log.debug( "Building query results cache region [" + regionName +
"]" );
+ return new InfinispanQueryResultsRegion( cacheManager.getCache(regionName),
regionName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public TimestampsRegion buildTimestampsRegion( String regionName, Properties properties
)
+ throws CacheException {
+ log.debug( "Building timestamps cache region [" + regionName + "]"
);
+ return new InfinispanTimestampsRegion( cacheManager.getCache( regionName ), regionName
);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isMinimalPutsEnabledByDefault() {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long nextTimestamp() {
+ return 0;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void start( Settings settings, Properties properties ) throws CacheException {
+ log.debug( "Starting Infinispan CacheManager" );
+ this.cacheManager.start();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void stop() {
+ log.debug( "Stopping Infinispan CacheManager" );
+ this.cacheManager.stop();
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/InfinispanCollectionRegion.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,28 @@
+package org.hibernate.cache.infinispan.collection;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.access.AccessType;
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.infinispan.BaseTransactionalDataRegion;
+import org.infinispan.Cache;
+
+public class InfinispanCollectionRegion extends BaseTransactionalDataRegion implements
CollectionRegion {
+
+ public InfinispanCollectionRegion( Cache<Object, Object> cache, String name,
CacheDataDescription metadata ) {
+ super( cache, name, metadata );
+ }
+
+ public CollectionRegionAccessStrategy buildAccessStrategy( AccessType accessType )
+ throws CacheException {
+ if (AccessType.READ_ONLY.equals( accessType )) {
+ return new ReadOnlyAccess(this);
+ } else if (AccessType.TRANSACTIONAL.equals( accessType )) {
+ return new TransactionalAccess(this);
+ }
+
+ throw new CacheException("unsupported access type [" +
accessType.getName() + "]");
+ }
+
+}
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/ReadOnlyAccess.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,79 @@
+package org.hibernate.cache.infinispan.collection;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.Region;
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+
+public class ReadOnlyAccess implements CollectionRegionAccessStrategy {
+ private final Region region;
+
+ public ReadOnlyAccess( Region region ) {
+ this.region = region;
+ }
+
+ public void evict( Object key ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void evictAll() throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object get( Object key, long txTimestamp ) throws CacheException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public CollectionRegion getRegion() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SoftLock lockItem( Object key, Object version ) throws CacheException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean putFromLoad( Object key, Object value, long txTimestamp, Object version
)
+ throws CacheException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean putFromLoad( Object key, Object value, long txTimestamp, Object version,
+ boolean minimalPutOverride ) throws CacheException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void remove( Object key ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeAll() throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unlockItem( Object key, SoftLock lock ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unlockRegion( SoftLock lock ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/collection/TransactionalAccess.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,78 @@
+package org.hibernate.cache.infinispan.collection;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.CollectionRegion;
+import org.hibernate.cache.Region;
+import org.hibernate.cache.access.CollectionRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+
+public class TransactionalAccess implements CollectionRegionAccessStrategy {
+ private final Region region;
+
+ public TransactionalAccess( Region region ) {
+ this.region = region;
+ }
+
+ public void evict( Object key ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void evictAll() throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Object get( Object key, long txTimestamp ) throws CacheException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public CollectionRegion getRegion() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SoftLock lockItem( Object key, Object version ) throws CacheException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean putFromLoad( Object key, Object value, long txTimestamp, Object version
)
+ throws CacheException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean putFromLoad( Object key, Object value, long txTimestamp, Object version,
+ boolean minimalPutOverride ) throws CacheException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void remove( Object key ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void removeAll() throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unlockItem( Object key, SoftLock lock ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void unlockRegion( SoftLock lock ) throws CacheException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/InfinispanEntityRegion.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,29 @@
+package org.hibernate.cache.infinispan.entity;
+
+import org.hibernate.cache.CacheDataDescription;
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.access.AccessType;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.infinispan.BaseTransactionalDataRegion;
+import org.infinispan.Cache;
+
+public class InfinispanEntityRegion extends BaseTransactionalDataRegion implements
EntityRegion {
+
+ public InfinispanEntityRegion( Cache<Object, Object> cache, String name,
CacheDataDescription metadata ) {
+ super( cache, name, metadata );
+ }
+
+ public EntityRegionAccessStrategy buildAccessStrategy( AccessType accessType )
+ throws CacheException {
+ if (AccessType.READ_ONLY.equals( accessType )) {
+ return new ReadOnlyAccess(this);
+ } else if (AccessType.TRANSACTIONAL.equals( accessType )) {
+ return new TransactionalAccess(this);
+ }
+
+ throw new CacheException("unsupported access type [" +
accessType.getName() + "]");
+
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/ReadOnlyAccess.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,48 @@
+package org.hibernate.cache.infinispan.entity;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.access.SoftLock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A specialization of {@link TransactionalAccess} that ensures we never update
+ * data. Infinispan access is always transactional.
+ *
+ * @author Chris Bredesen
+ */
+class ReadOnlyAccess extends TransactionalAccess {
+ private static final Logger log = LoggerFactory.getLogger( ReadOnlyAccess.class );
+
+ ReadOnlyAccess( InfinispanEntityRegion region ) {
+ super( region );
+ }
+
+ public SoftLock lockItem( Object key, Object version ) throws CacheException {
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only
item" );
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ throw new UnsupportedOperationException( "Illegal attempt to edit read only
item" );
+ }
+
+ public void unlockItem( Object key, SoftLock lock ) throws CacheException {
+ log.error( "Illegal attempt to edit read only item" );
+ }
+
+ public void unlockRegion( SoftLock lock ) throws CacheException {
+ log.error( "Illegal attempt to edit read only item" );
+ }
+
+ @Override
+ public boolean update(Object key, Object value, Object currentVersion, Object
previousVersion)
+ throws CacheException {
+ throw new UnsupportedOperationException("Illegal attempt to edit read only
item");
+ }
+
+ @Override
+ public boolean afterUpdate(Object key, Object value, Object currentVersion, Object
previousVersion, SoftLock lock)
+ throws CacheException {
+ throw new UnsupportedOperationException("Illegal attempt to edit read only
item");
+ }
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/entity/TransactionalAccess.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,94 @@
+package org.hibernate.cache.infinispan.entity;
+
+import org.hibernate.cache.CacheException;
+import org.hibernate.cache.EntityRegion;
+import org.hibernate.cache.access.EntityRegionAccessStrategy;
+import org.hibernate.cache.access.SoftLock;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Transactional entity region access for Infinispan.
+ *
+ * @author Chris Bredesen
+ */
+class TransactionalAccess implements EntityRegionAccessStrategy {
+ private static final Logger log = LoggerFactory.getLogger( TransactionalAccess.class );
+ private final InfinispanEntityRegion region;
+
+ TransactionalAccess( InfinispanEntityRegion region ) {
+ this.region = region;
+ }
+
+ public void evict( Object key ) throws CacheException {
+ region.getCache().evict( key );
+ }
+
+ public void evictAll() throws CacheException {
+ region.getCache().clear();
+ }
+
+ public Object get( Object key, long txTimestamp ) throws CacheException {
+ return region.getCache().get( key );
+ }
+
+ public EntityRegion getRegion() {
+ return this.region;
+ }
+
+ public boolean insert( Object key, Object value, Object version ) throws CacheException
{
+ region.getCache().put( key, value );
+ return true; // TODO this is suspect
+ }
+
+ public boolean putFromLoad( Object key, Object value, long txTimestamp, Object version
)
+ throws CacheException {
+ region.getCache().putForExternalRead( key, value );
+ return true;
+ }
+
+ public boolean putFromLoad( Object key, Object value, long txTimestamp, Object version,
+ boolean minimalPutOverride ) throws CacheException {
+ region.getCache().putForExternalRead( key, value );
+ return true;
+ }
+
+ public void remove( Object key ) throws CacheException {
+ region.getCache().remove( key );
+ }
+
+ public void removeAll() throws CacheException {
+ region.getCache().clear(); // TODO is this right?
+ }
+
+ public boolean update( Object key, Object value, Object currentVersion, Object
previousVersion )
+ throws CacheException {
+ region.getCache().put( key, value );
+ return true; // JBC2 provider does this...
+ }
+
+ // all remaining methods copied from the o.h.c.jbc2.entity.TransactionalAccess
+
+ public SoftLock lockItem(Object key, Object version) throws CacheException {
+ return null;
+ }
+
+ public SoftLock lockRegion() throws CacheException {
+ return null;
+ }
+
+ public void unlockItem(Object key, SoftLock lock) throws CacheException {
+ }
+
+ public void unlockRegion(SoftLock lock) throws CacheException {
+ }
+
+ public boolean afterInsert(Object key, Object value, Object version) throws
CacheException {
+ return false;
+ }
+
+ public boolean afterUpdate(Object key, Object value, Object currentVersion, Object
previousVersion, SoftLock lock)
+ throws CacheException {
+ return false;
+ }
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/query/InfinispanQueryResultsRegion.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,13 @@
+package org.hibernate.cache.infinispan.query;
+
+import org.hibernate.cache.QueryResultsRegion;
+import org.hibernate.cache.infinispan.BaseGeneralDataRegion;
+import org.infinispan.Cache;
+
+public class InfinispanQueryResultsRegion extends BaseGeneralDataRegion implements
QueryResultsRegion {
+
+ public InfinispanQueryResultsRegion( Cache<Object, Object> cache, String name ) {
+ super( cache, name );
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/main/java/org/hibernate/cache/infinispan/timestamp/InfinispanTimestampsRegion.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,13 @@
+package org.hibernate.cache.infinispan.timestamp;
+
+import org.hibernate.cache.TimestampsRegion;
+import org.hibernate.cache.infinispan.BaseGeneralDataRegion;
+import org.infinispan.Cache;
+
+public class InfinispanTimestampsRegion extends BaseGeneralDataRegion implements
TimestampsRegion {
+
+ public InfinispanTimestampsRegion( Cache<Object, Object> cache, String name ) {
+ super( cache, name );
+ }
+
+}
\ No newline at end of file
Added:
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/InfinispanTest.java
===================================================================
---
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/InfinispanTest.java
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/java/org/hibernate/cache/infinispan/InfinispanTest.java 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,37 @@
+package org.hibernate.cache.infinispan;
+
+import org.hibernate.test.cache.BaseRegionFactoryTestCase;
+
+public class InfinispanTest extends BaseRegionFactoryTestCase {
+
+ public InfinispanTest( String x ) {
+ super( x );
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Class getRegionFactory() {
+ return InfinispanRegionFactory.class;
+ }
+
+ @Override
+ protected String getConfigResourceKey() {
+ return null;
+ }
+
+ @Override
+ protected String getConfigResourceLocation() {
+ return null;
+ }
+
+ @Override
+ protected boolean useTransactionManager() {
+ return true;
+ }
+
+ @Override
+ public String getCacheConcurrencyStrategy() {
+ return "read-only";
+ }
+
+}
\ No newline at end of file
Added: core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,34 @@
+################################################################################
+# Hibernate, Relational Persistence for Idiomatic Java #
+# #
+# Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as #
+# indicated by the @author tags or express copyright attribution #
+# statements applied by the authors. All third-party contributions are #
+# distributed under license by Red Hat Middleware LLC. #
+# #
+# This copyrighted material is made available to anyone wishing to use, modify,#
+# copy, or redistribute it subject to the terms and conditions of the GNU #
+# Lesser General Public License, as published by the Free Software Foundation. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+# for more details. #
+# #
+# You should have received a copy of the GNU Lesser General Public License #
+# along with this distribution; if not, write to: #
+# Free Software Foundation, Inc. #
+# 51 Franklin Street, Fifth Floor #
+# Boston, MA 02110-1301 USA #
+################################################################################
+hibernate.dialect org.hibernate.dialect.HSQLDialect
+hibernate.connection.driver_class org.hsqldb.jdbcDriver
+hibernate.connection.url jdbc:hsqldb:mem:/test
+hibernate.connection.username sa
+hibernate.connection.password
+
+hibernate.connection.pool_size 5
+
+hibernate.format_sql true
+
+hibernate.max_fetch_depth 5
Property changes on:
core/branches/INFINISPAN/cache-infinispan/src/test/resources/hibernate.properties
___________________________________________________________________
Name: svn:executable
+ *
Added: core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
===================================================================
--- core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
(rev 0)
+++
core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties 2009-06-12
14:33:00 UTC (rev 16771)
@@ -0,0 +1,39 @@
+################################################################################
+# Hibernate, Relational Persistence for Idiomatic Java #
+# #
+# Copyright (c) 2007, Red Hat Middleware LLC or third-party contributors as #
+# indicated by the @author tags or express copyright attribution #
+# statements applied by the authors. All third-party contributions are #
+# distributed under license by Red Hat Middleware LLC. #
+# #
+# This copyrighted material is made available to anyone wishing to use, modify,#
+# copy, or redistribute it subject to the terms and conditions of the GNU #
+# Lesser General Public License, as published by the Free Software Foundation. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
+# for more details. #
+# #
+# You should have received a copy of the GNU Lesser General Public License #
+# along with this distribution; if not, write to: #
+# Free Software Foundation, Inc. #
+# 51 Franklin Street, Fifth Floor #
+# Boston, MA 02110-1301 USA #
+################################################################################
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p [%t] %c{1}:%L - %m%n
+
+
+log4j.rootLogger=info, stdout
+
+log4j.logger.org.hibernate.test=info
+log4j.logger.org.hibernate.cache=debug
+#log4j.logger.org.jgroups=info
+#log4j.logger.org.jboss.cache=trace
+#log4j.logger.org.jboss.cache.RegionManager=info
+#log4j.logger.org.jboss.cache.lock=info
+#log4j.logger.org.jboss.cache.interceptors.PessimisticLockInterceptor=info
+#log4j.logger.org.jboss.cache.interceptors.UnlockInterceptor=info
Property changes on:
core/branches/INFINISPAN/cache-infinispan/src/test/resources/log4j.properties
___________________________________________________________________
Name: svn:executable
+ *