Permalink
Browse files

ISPN-2639 Initial JSR 107 implementation

* Basic operations and validation supported.
  • Loading branch information...
vblagoje authored and maniksurtani committed Jan 18, 2013
1 parent 2512668 commit b0636a7c06df5e81c2cfd79ac2bcd02cd69e4ab8
Showing with 2,185 additions and 0 deletions.
  1. +98 −0 jsr107impl/pom.xml
  2. +88 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/ConfigurationAdapter.java
  3. +398 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCache.java
  4. +44 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCacheEntry.java
  5. +139 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCacheListenerAdapter.java
  6. +80 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCacheLoaderAdapter.java
  7. +247 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCacheManager.java
  8. +141 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCacheManagerFactory.java
  9. +104 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCacheWriterAdapter.java
  10. +54 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanCachingProvider.java
  11. +54 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/InfinispanStatusConverter.java
  12. +118 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/RICacheEntryEvent.java
  13. +64 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/RICacheEntryEventFilteringIterable.java
  14. +114 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/RICacheEntryEventFilteringIterator.java
  15. +141 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/RICacheEntryListenerRegistration.java
  16. +300 −0 jsr107impl/src/main/java/org/infinispan/jsr107/cache/RICacheStatistics.java
  17. +1 −0 jsr107impl/src/main/resources/META-INF/services/javax.cache.spi.CachingProvider
View
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- ~ JBoss, Home of Professional Open Source ~ Copyright 2012 Red Hat Inc.
+ and/or its affiliates and other ~ contributors as indicated by the @author
+ tags. All rights reserved. ~ See the copyright.txt in the distribution for
+ a full listing of ~ individual contributors. ~ ~ This is free software; you
+ can redistribute it and/or modify it ~ under the terms of the GNU Lesser
+ General Public License as ~ published by the Free Software Foundation; either
+ version 2.1 of ~ the License, or (at your option) any later version. ~ ~
+ This software 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 software; if not, write to the Free ~ Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ~ 02110-1301 USA,
+ or see the FSF site: http://www.fsf.org. -->
+<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.infinispan</groupId>
+ <artifactId>infinispan-parent</artifactId>
+ <version>5.2.0-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+
+ <artifactId>infinispan-jsr107</artifactId>
+ <packaging>bundle</packaging>
+ <name>Infinispan JSR107 implementation</name>
+ <description>JSR107 implementation using Infinispan</description>
+
+ <!-- This module declares components that either has lifecycle (@Start or
+ @Stop) or uses @Inject to retrieve dependencies -->
+ <properties>
+ <module.skipComponentMetaDataProcessing>false</module.skipComponentMetaDataProcessing>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>infinispan-core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.cache</groupId>
+ <artifactId>cache-api</artifactId>
+ <version>0.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.cache.implementation</groupId>
+ <artifactId>cache-ri-common</artifactId>
+ <version>0.6-SNAPSHOT</version>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>infinispan-core</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+
+ <repositories>
+ <repository>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ <id>sonatype-snapshot-repository</id>
+ <name>Sonatype snapshot to be removed once everything becomes stable</name>
+ <url>https://oss.sonatype.org/content/repositories/snapshots</url>
+ </repository>
+ </repositories>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ ${project.groupId}.jsr107.*;version=${project.version};-split-package:=error
+ </Export-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
@@ -0,0 +1,88 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
+ * as indicated by the @author tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * 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, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ */
+package org.infinispan.jsr107.cache;
+
+import org.infinispan.configuration.cache.CacheMode;
+import org.infinispan.configuration.cache.ConfigurationBuilder;
+import org.infinispan.transaction.TransactionMode;
+
+/**
+ * ConfigurationAdapter takes {@link javax.cache.Configuration} and creates equivalent instance of
+ * {@link org.infinispan.configuration.cache.Configuration}
+ *
+ * @author Vladimir Blagojevic
+ * @since 5.3
+ */
+public class ConfigurationAdapter<K, V> {
+
+ private javax.cache.Configuration<K, V> c;
+ private ClassLoader classLoader;
+
+ public ConfigurationAdapter(javax.cache.Configuration<K, V> configuration,
+ ClassLoader classLoader) {
+ this.c = configuration;
+ this.classLoader = classLoader;
+ }
+
+ public org.infinispan.configuration.cache.Configuration build() {
+ ConfigurationBuilder cb = new ConfigurationBuilder();
+ cb.storeAsBinary().enabled(c.isStoreByValue());
+ cb.classLoader(classLoader);
+ cb.clustering().cacheMode(CacheMode.DIST_SYNC);
+
+ switch (c.getTransactionMode()) {
+ case NONE:
+ cb.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
+ break;
+ case LOCAL:
+ cb.transaction().transactionMode(TransactionMode.TRANSACTIONAL);
+ break;
+ case XA:
+ //TODO
+ break;
+ default:
+ break;
+ }
+ switch (c.getTransactionIsolationLevel()) {
+ case NONE:
+ cb.locking().isolationLevel(org.infinispan.util.concurrent.IsolationLevel.NONE);
+ break;
+ case READ_UNCOMMITTED:
+ cb.locking().isolationLevel(
+ org.infinispan.util.concurrent.IsolationLevel.READ_UNCOMMITTED);
+ break;
+ case READ_COMMITTED:
+ cb.locking().isolationLevel(
+ org.infinispan.util.concurrent.IsolationLevel.READ_COMMITTED);
+ break;
+ case REPEATABLE_READ:
+ cb.locking().isolationLevel(
+ org.infinispan.util.concurrent.IsolationLevel.REPEATABLE_READ);
+ break;
+ case SERIALIZABLE:
+ cb.locking().isolationLevel(org.infinispan.util.concurrent.IsolationLevel.SERIALIZABLE);
+ break;
+ default:
+ break;
+ }
+ //TODO
+ //whatever else is needed
+ return cb.build();
+ }
+}
Oops, something went wrong.

0 comments on commit b0636a7

Please sign in to comment.