Author: tv Date: Wed Aug 2 09:44:13 2017 New Revision: 1803791 URL: http://svn.apache.org/viewvc?rev=1803791&view=rev Log: Merge trunk changes into release branch for 2.2
Added: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java - copied unchanged from r1803785, commons/proper/jcs/trunk/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/ (props changed) commons/proper/jcs/branches/commons-jcs-2.2-RC/.travis.yml commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/pom.xml commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/servlet/JCSServletContextListener.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-dist/pom.xml commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CDIJCacheHelper.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CacheInvocationContextImpl.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/filecache/pom.xml commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/pom.xml commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/yajcache/pom.xml commons/proper/jcs/branches/commons-jcs-2.2-RC/pom.xml commons/proper/jcs/branches/commons-jcs-2.2-RC/src/changes/changes.xml Propchange: commons/proper/jcs/branches/commons-jcs-2.2-RC/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Wed Aug 2 09:44:13 2017 @@ -1,2 +1,2 @@ /commons/proper/jcs/branches/generics-interface:1232160-1344358 -/commons/proper/jcs/trunk:1776032-1781727 +/commons/proper/jcs/trunk:1776032-1803785 Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/.travis.yml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/.travis.yml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/.travis.yml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/.travis.yml Wed Aug 2 09:44:13 2017 @@ -18,6 +18,7 @@ sudo: false jdk: - openjdk7 + - oraclejdk7 - oraclejdk8 after_success: Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/pom.xml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/pom.xml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/pom.xml Wed Aug 2 09:44:13 2017 @@ -154,9 +154,6 @@ <exclude>**/UDPDiscoveryUnitTest.java</exclude> <!-- Causes hang in Continuum --> <exclude>**/UDPDiscoverySenderUnitTest.java</exclude> - <!-- The ones that fail may be different for you. --> - <!-- <exclude>**/JDBCDiskCacheRemovalUnitTest.java</exclude> --> - <!-- <exclude>**/JDBCDiskCacheUnitTest.java</exclude> --> </excludes> </configuration> </plugin> Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java Wed Aug 2 09:44:13 2017 @@ -130,6 +130,22 @@ public abstract class JCS } /** + * Shut down the cache manager and set the instance to null + */ + public static void shutdown() + { + synchronized ( JCS.class ) + { + if ( cacheMgr != null && cacheMgr.isInitialized()) + { + cacheMgr.shutDown(); + } + + cacheMgr = null; + } + } + + /** * Helper method which checks to make sure the cacheMgr class field is set, and if not requests * an instance from CacheManagerFactory. * Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java Wed Aug 2 09:44:13 2017 @@ -60,10 +60,38 @@ public abstract class AbstractRemoteCach * <p> * @param noWaits * @param rca + * @param cacheEventLogger + * @param elementSerializer + */ + public AbstractRemoteCacheNoWaitFacade( List<RemoteCacheNoWait<K,V>> noWaits, IRemoteCacheAttributes rca, + ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer ) + { + if ( log.isDebugEnabled() ) + { + log.debug( "CONSTRUCTING NO WAIT FACADE" ); + } + this.remoteCacheAttributes = rca; + setCacheEventLogger( cacheEventLogger ); + setElementSerializer( elementSerializer ); + this.noWaits = new ArrayList<RemoteCacheNoWait<K,V>>(noWaits); + for (RemoteCacheNoWait<K,V> nw : this.noWaits) + { + // FIXME: This cast is very brave. Remove this. + ((RemoteCache<K, V>)nw.getRemoteCache()).setFacade(this); + } + } + + /** + * Constructs with the given remote cache, and fires events to any listeners. + * <p> + * @param noWaits + * @param rca * @param cacheMgr * @param cacheEventLogger * @param elementSerializer + * @deprecated Unused parameter cacheMgr scheduled for removal */ + @Deprecated public AbstractRemoteCacheNoWaitFacade( List<ICache<K, V>> noWaits, RemoteCacheAttributes rca, ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer ) @@ -72,15 +100,16 @@ public abstract class AbstractRemoteCach { log.debug( "CONSTRUCTING NO WAIT FACADE" ); } + this.remoteCacheAttributes = rca; + setCacheEventLogger( cacheEventLogger ); + setElementSerializer( elementSerializer ); this.noWaits = new ArrayList<RemoteCacheNoWait<K,V>>(); for (ICache<K, V> nw : noWaits) { - RemoteCacheNoWait<K,V> rcnw = (RemoteCacheNoWait<K,V>) nw; + RemoteCacheNoWait<K,V> rcnw = (RemoteCacheNoWait<K,V>)nw; + ((RemoteCache<K, V>)rcnw.getRemoteCache()).setFacade(this); this.noWaits.add(rcnw); } - this.remoteCacheAttributes = rca; - setCacheEventLogger( cacheEventLogger ); - setElementSerializer( elementSerializer ); } /** Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java Wed Aug 2 09:44:13 2017 @@ -113,6 +113,16 @@ public class RemoteCache<K, V> } /** + * Get facade + * + * @return the facade + */ + protected AbstractRemoteCacheNoWaitFacade<K, V> getFacade() + { + return facade; + } + + /** * Handles exception by disabling the remote cache service before re-throwing the exception in * the form of an IOException. * <p> Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java Wed Aug 2 09:44:13 2017 @@ -32,7 +32,6 @@ import org.apache.commons.jcs.auxiliary. import org.apache.commons.jcs.auxiliary.AuxiliaryCacheAttributes; import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes; import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType; -import org.apache.commons.jcs.engine.behavior.ICache; import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager; import org.apache.commons.jcs.engine.behavior.IElementSerializer; import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger; @@ -75,7 +74,7 @@ public class RemoteCacheFactory { RemoteCacheAttributes rca = (RemoteCacheAttributes) iaca; - ArrayList<ICache<K, V>> noWaits = new ArrayList<ICache<K, V>>(); + ArrayList<RemoteCacheNoWait<K,V>> noWaits = new ArrayList<RemoteCacheNoWait<K,V>>(); switch (rca.getRemoteType()) { @@ -93,7 +92,7 @@ public class RemoteCacheFactory failovers.add( rca.getRemoteLocation() ); RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer ); - ICache<K, V> ic = rcm.getCache( rca ); + RemoteCacheNoWait<K,V> ic = rcm.getCache( rca ); noWaits.add( ic ); } @@ -120,7 +119,7 @@ public class RemoteCacheFactory // number it is at if ( ( !primaryDefined && fCnt == 1 ) || noWaits.size() <= 0 ) { - ICache<K, V> ic = rcm.getCache( rca ); + RemoteCacheNoWait<K,V> ic = rcm.getCache( rca ); noWaits.add( ic ); } } @@ -145,7 +144,7 @@ public class RemoteCacheFactory rca.setRemoteLocation(location); RemoteCacheManager rcm = getManager( rca, cacheMgr, cacheEventLogger, elementSerializer ); rca.setRemoteType( RemoteType.CLUSTER ); - ICache<K, V> ic = rcm.getCache( rca ); + RemoteCacheNoWait<K,V> ic = rcm.getCache( rca ); noWaits.add( ic ); } } @@ -153,7 +152,7 @@ public class RemoteCacheFactory } RemoteCacheNoWaitFacade<K, V> rcnwf = - new RemoteCacheNoWaitFacade<K, V>(noWaits, rca, cacheMgr, cacheEventLogger, elementSerializer, this ); + new RemoteCacheNoWaitFacade<K, V>(noWaits, rca, cacheEventLogger, elementSerializer, this ); return rcnwf; } Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java Wed Aug 2 09:44:13 2017 @@ -21,6 +21,7 @@ package org.apache.commons.jcs.auxiliary import java.util.List; +import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes; import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType; import org.apache.commons.jcs.engine.CacheStatus; import org.apache.commons.jcs.engine.behavior.ICache; @@ -52,11 +53,32 @@ public class RemoteCacheNoWaitFacade<K, * <p> * @param noWaits * @param rca + * @param cacheEventLogger + * @param elementSerializer + * @param cacheFactory + */ + public RemoteCacheNoWaitFacade( List<RemoteCacheNoWait<K,V>> noWaits, + IRemoteCacheAttributes rca, + ICacheEventLogger cacheEventLogger, + IElementSerializer elementSerializer, + RemoteCacheFactory cacheFactory) + { + super( noWaits, rca, cacheEventLogger, elementSerializer ); + this.cacheFactory = cacheFactory; + } + + /** + * Constructs with the given remote cache, and fires events to any listeners. + * <p> + * @param noWaits + * @param rca * @param cacheMgr * @param cacheEventLogger * @param elementSerializer * @param cacheFactory + * @deprecated Unused parameter cacheMgr scheduled for removal */ + @Deprecated public RemoteCacheNoWaitFacade( List<ICache<K, V>> noWaits, RemoteCacheAttributes rca, ICompositeCacheManager cacheMgr, @@ -66,12 +88,6 @@ public class RemoteCacheNoWaitFacade<K, { super( noWaits, rca, cacheMgr, cacheEventLogger, elementSerializer ); this.cacheFactory = cacheFactory; - - for (RemoteCacheNoWait<K,V> rcnw : this.noWaits) - { - ((RemoteCache<K, V>)rcnw.getRemoteCache()).setFacade(this); - this.noWaits.add(rcnw); - } } /** Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteUtils.java Wed Aug 2 09:44:13 2017 @@ -124,6 +124,15 @@ public class RemoteUtils if (null == is) // not found in class path { + // Try root of class path + if (propFile != null && !propFile.startsWith("/")) + { + is = RemoteUtils.class.getResourceAsStream("/" + propFile); + } + } + + if (null == is) // not found in class path + { if (new File(propFile).exists()) { // file found Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java Wed Aug 2 09:44:13 2017 @@ -29,12 +29,14 @@ import java.rmi.server.Unreferenced; import java.util.Collections; import java.util.Iterator; import java.util.Map; +import java.util.Properties; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.concurrent.locks.ReentrantLock; import org.apache.commons.jcs.access.exception.CacheException; +import org.apache.commons.jcs.auxiliary.remote.RemoteUtils; import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheListener; import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServer; import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes; @@ -71,6 +73,8 @@ public class RemoteCacheServer<K, V> extends UnicastRemoteObject implements IRemoteCacheServer<K, V>, Unreferenced { + public static final String DFEAULT_REMOTE_CONFIGURATION_FILE = "/remote.cache.ccf"; + /** For serialization. Don't change. */ private static final long serialVersionUID = -8072345435941473116L; @@ -121,11 +125,47 @@ public class RemoteCacheServer<K, V> /** * Constructor for the RemoteCacheServer object. This initializes the server with the values + * from the properties object. + * <p> + * @param rcsa + * @param config cache hub configuration + * @throws RemoteException + */ + protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa, Properties config ) + throws RemoteException + { + super( rcsa.getServicePort() ); + this.remoteCacheServerAttributes = rcsa; + init( config ); + } + + /** + * Constructor for the RemoteCacheServer object. This initializes the server with the values + * from the properties object. + * <p> + * @param rcsa + * @param config cache hub configuration + * @param customRMISocketFactory + * @throws RemoteException + */ + protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa, Properties config, RMISocketFactory customRMISocketFactory ) + throws RemoteException + { + super( rcsa.getServicePort(), customRMISocketFactory, customRMISocketFactory ); + this.remoteCacheServerAttributes = rcsa; + init( config ); + } + + /** + * Constructor for the RemoteCacheServer object. This initializes the server with the values * from the config file. * <p> * @param rcsa * @throws RemoteException + * + * @deprecated Use version with Properties object instead */ + @Deprecated protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa ) throws RemoteException { @@ -141,7 +181,10 @@ public class RemoteCacheServer<K, V> * @param rcsa * @param customRMISocketFactory * @throws RemoteException + * + * @deprecated Use version with Properties object instead */ + @Deprecated protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa, RMISocketFactory customRMISocketFactory ) throws RemoteException { @@ -155,8 +198,34 @@ public class RemoteCacheServer<K, V> * <p> * @param prop * @throws RemoteException if the configuration of the cache manager instance fails + * + * @deprecated Use version with Properties parameter instead */ - private void init( String prop ) throws RemoteException + @Deprecated + private void init( String propFile ) throws RemoteException + { + String propFileName = propFile == null ? DFEAULT_REMOTE_CONFIGURATION_FILE : propFile; + + Properties prop = null; + try + { + prop = RemoteUtils.loadProps(propFileName); + } + catch (IOException e) + { + throw new RemoteException(e.getMessage(), e); + } + + init(prop); + } + + /** + * Initialize the RMI Cache Server from a properties object. + * <p> + * @param prop the configuration properties + * @throws RemoteException if the configuration of the cache manager instance fails + */ + private void init( Properties prop ) throws RemoteException { try { @@ -181,23 +250,15 @@ public class RemoteCacheServer<K, V> /** * Subclass can override this method to create the specific cache manager. * <p> - * @param prop The name of the configuration file. - * @return The cache hub configured with this configuration file. + * @param prop the configuration object. + * @return The cache hub configured with this configuration. * * @throws CacheException if the configuration cannot be loaded */ - private CompositeCacheManager createCacheManager( String prop ) throws CacheException + private CompositeCacheManager createCacheManager( Properties prop ) throws CacheException { CompositeCacheManager hub = CompositeCacheManager.getUnconfiguredInstance(); - - if ( prop == null ) - { - hub.configure( "/remote.cache.ccf" ); - } - else - { - hub.configure( prop ); - } + hub.configure( prop ); return hub; } Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java Wed Aug 2 09:44:13 2017 @@ -94,32 +94,48 @@ public class RemoteCacheServerFactory * <p> * A remote cache is either a local cache or a cluster cache. * <p> - * @param host - * @param port - * @param propFile + * @param host the host name + * @param port the port number + * @param propFile the remote cache hub configuration file * @throws IOException + * + * @deprecated Use startup(String, int, Properties) instead */ + @Deprecated public static void startup( String host, int port, String propFile ) throws IOException { - if ( remoteCacheServer != null ) + if ( log.isInfoEnabled() ) { - throw new IllegalArgumentException( "Server already started." ); + log.info( "ConfigFileName = [" + propFile + "]" ); } + Properties props = RemoteUtils.loadProps( propFile ); + startup(host, port, props); + } - synchronized ( RemoteCacheServer.class ) + /** + * Starts up the remote cache server on this JVM, and binds it to the registry on the given host + * and port. + * <p> + * A remote cache is either a local cache or a cluster cache. + * <p> + * @param host the host name + * @param port the port number + * @param props the remote cache hub configuration + * @param propFile the remote cache hub configuration file + * @throws IOException + * + * @deprecated Use startup(String, int, Properties) instead + */ + @Deprecated + public static void startup( String host, int port, Properties props, String propFile ) + throws IOException + { + if ( log.isWarnEnabled() ) { - if ( remoteCacheServer != null ) - { - return; - } - if ( log.isInfoEnabled() ) - { - log.info( "ConfigFileName = [" + propFile + "]" ); - } - Properties props = RemoteUtils.loadProps( propFile ); - startup(host, port, props, propFile); + log.warn( "ConfigFileName = [" + propFile + "] ignored" ); } + startup(host, port, props); } /** @@ -133,7 +149,7 @@ public class RemoteCacheServerFactory * @param props * @throws IOException */ - public static void startup( String host, int port, Properties props, String propFile ) + public static void startup( String host, int port, Properties props) throws IOException { if ( remoteCacheServer != null ) @@ -153,7 +169,6 @@ public class RemoteCacheServerFactory } RemoteCacheServerAttributes rcsa = configureRemoteCacheServerAttributes(props); - rcsa.setConfigFileName( propFile ); // These should come from the file! rcsa.setRemoteLocation( host, port ); @@ -174,11 +189,11 @@ public class RemoteCacheServerFactory // CREATE SERVER if ( customRMISocketFactory != null ) { - remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>( rcsa, customRMISocketFactory ); + remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>( rcsa, props, customRMISocketFactory ); } else { - remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>( rcsa ); + remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>( rcsa, props ); } remoteCacheServer.setCacheEventLogger( cacheEventLogger ); @@ -446,21 +461,9 @@ public class RemoteCacheServerFactory // shutdown if ( args.length > 0 && args[0].toLowerCase().indexOf( "-shutdown" ) != -1 ) { - String remoteServiceName = prop.getProperty( REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_VAL ).trim(); - String registry = RemoteUtils.getNamingURL("", port, remoteServiceName); - - if ( log.isDebugEnabled() ) - { - log.debug( "looking up server " + registry ); - } - Object obj = Naming.lookup( registry ); - if ( log.isDebugEnabled() ) - { - log.debug( "server found" ); - } - ICacheServiceAdmin admin = (ICacheServiceAdmin) obj; try { + ICacheServiceAdmin admin = lookupCacheServiceAdmin(prop, port); admin.shutdown(); } catch ( Exception ex ) @@ -474,30 +477,21 @@ public class RemoteCacheServerFactory // STATS if ( args.length > 0 && args[0].toLowerCase().indexOf( "-stats" ) != -1 ) { - log.debug( "getting cache stats" ); try { - String sz = prop.getProperty( REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_VAL ).trim(); - String registry = RemoteUtils.getNamingURL("", port, sz); - log.debug( "looking up server " + registry ); - Object obj = Naming.lookup( registry ); - log.debug( "server found" ); - - log.debug( "obj = " + obj ); - ICacheServiceAdmin admin = (ICacheServiceAdmin) obj; + ICacheServiceAdmin admin = lookupCacheServiceAdmin(prop, port); try { // System.out.println( admin.getStats().toString() ); log.debug( admin.getStats() ); } - catch ( Exception es ) + catch ( IOException es ) { log.error( es ); } - } catch ( Exception ex ) { @@ -516,11 +510,38 @@ public class RemoteCacheServerFactory RemoteUtils.createRegistry( port ); } log.debug( "main> starting up RemoteCacheServer" ); - RemoteCacheServerFactory.startup( host, port, args.length > 0 ? args[0] : null ); + startup( host, port, prop); log.debug( "main> done" ); } /** + * Look up the remote cache service admin instance + * + * @param config the configuration properties + * @param port the local port + * @return the admin object instance + * + * @throws Exception if lookup fails + */ + private static ICacheServiceAdmin lookupCacheServiceAdmin(Properties config, int port) throws Exception + { + String remoteServiceName = config.getProperty( REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_VAL ).trim(); + String registry = RemoteUtils.getNamingURL("", port, remoteServiceName); + + if ( log.isDebugEnabled() ) + { + log.debug( "looking up server " + registry ); + } + Object obj = Naming.lookup( registry ); + if ( log.isDebugEnabled() ) + { + log.debug( "server found" ); + } + + return (ICacheServiceAdmin) obj; + } + + /** * @param serviceName the serviceName to set */ protected static void setServiceName( String serviceName ) Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheStartupServlet.java Wed Aug 2 09:44:13 2017 @@ -131,12 +131,10 @@ public class RemoteCacheStartupServlet { if (props == null) { - RemoteCacheServerFactory.startup(registryHost, registryPort, propsFileName); - } - else - { - RemoteCacheServerFactory.startup(registryHost, registryPort, props, propsFileName); + throw new ServletException("Could not load configuration from " + propsFileName); } + + RemoteCacheServerFactory.startup(registryHost, registryPort, props); if (log.isInfoEnabled()) { log.info("Remote JCS Server started with properties from " + propsFileName); @@ -144,7 +142,7 @@ public class RemoteCacheStartupServlet } catch (IOException e) { - log.error("Problem starting remote cache server.", e); + throw new ServletException("Problem starting remote cache server.", e); } } Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/behavior/IRemoteCacheServerAttributes.java Wed Aug 2 09:44:13 2017 @@ -66,7 +66,7 @@ public interface IRemoteCacheServerAttri /** * Gets the ConfigFileName attribute of the IRemoteCacheAttributes object. * <p> - * @return The clusterServers value + * @return The configuration file name */ String getConfigFileName(); @@ -74,7 +74,7 @@ public interface IRemoteCacheServerAttri * Sets the ConfigFileName attribute of the IRemoteCacheAttributes object. * <p> * @param s - * The new clusterServers value + * The new configuration file name */ void setConfigFileName( String s ); Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java Wed Aug 2 09:44:13 2017 @@ -111,6 +111,9 @@ public class CompositeCache<K, V> /** Count of misses where element was expired. */ private AtomicInteger missCountExpired; + /** Cache manager. */ + private CompositeCacheManager cacheManager = null; + /** * The cache hub can only have one memory cache. This could be made more flexible in the future, * but they are tied closely together. More than one doesn't make much sense. @@ -159,6 +162,16 @@ public class CompositeCache<K, V> } /** + * Injector for cache manager + * + * @param manager + */ + public void setCompositeCacheManager( CompositeCacheManager manager ) + { + this.cacheManager = manager; + } + + /** * @see org.apache.commons.jcs.engine.behavior.IRequireScheduler#setScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) */ @Override @@ -1286,19 +1299,26 @@ public class CompositeCache<K, V> */ public void dispose( boolean fromRemote ) { - if ( log.isInfoEnabled() ) + // If already disposed, return immediately + if ( alive.compareAndSet(true, false) == false ) { - log.info( "In DISPOSE, [" + this.cacheAttr.getCacheName() + "] fromRemote [" + fromRemote + "]" ); + return; } - // If already disposed, return immediately - if ( alive.compareAndSet(true, false) == false ) + if ( log.isInfoEnabled() ) { - return; + log.info( "In DISPOSE, [" + this.cacheAttr.getCacheName() + "] fromRemote [" + fromRemote + "]" ); } synchronized (this) { + // Remove us from the cache managers list + // This will call us back but exit immediately + if (cacheManager != null) + { + cacheManager.freeCache(getCacheName(), fromRemote); + } + // Try to stop shrinker thread if (future != null) { Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java Wed Aug 2 09:44:13 2017 @@ -207,6 +207,9 @@ public class CompositeCacheConfigurator ccm.getDefaultCacheAttributes(), regionPrefix ), ea ) : new CompositeCache<K, V>( cca, ea ); + // Inject cache manager + cache.setCompositeCacheManager(ccm); + // Inject scheduler service cache.setScheduledExecutorService(ccm.getScheduledExecutorService()); Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java Wed Aug 2 09:44:13 2017 @@ -527,7 +527,7 @@ public class CompositeCacheManager @Override public <K, V> CompositeCache<K, V> getCache( String cacheName ) { - return getCache( cacheName, this.defaultCacheAttr.clone() ); + return getCache( cacheName, getDefaultCacheAttributes() ); } /** @@ -540,7 +540,7 @@ public class CompositeCacheManager public <K, V> CompositeCache<K, V> getCache( String cacheName, ICompositeCacheAttributes cattr ) { cattr.setCacheName( cacheName ); - return getCache( cattr, this.defaultElementAttr ); + return getCache( cattr, getDefaultElementAttributes() ); } /** @@ -565,7 +565,7 @@ public class CompositeCacheManager */ public <K, V> CompositeCache<K, V> getCache( ICompositeCacheAttributes cattr ) { - return getCache( cattr, this.defaultElementAttr ); + return getCache( cattr, getDefaultElementAttributes() ); } /** Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/servlet/JCSServletContextListener.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/servlet/JCSServletContextListener.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/servlet/JCSServletContextListener.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/servlet/JCSServletContextListener.java Wed Aug 2 09:44:13 2017 @@ -19,14 +19,13 @@ package org.apache.commons.jcs.utils.ser * under the License. */ -import org.apache.commons.jcs.access.exception.CacheException; -import org.apache.commons.jcs.engine.control.CompositeCacheManager; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; +import org.apache.commons.jcs.JCS; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * If you add this to the context listeners section of your web.xml file, this will shutdown JCS * gracefully. @@ -56,32 +55,25 @@ public class JCSServletContextListener @Override public void contextInitialized( ServletContextEvent arg0 ) { - if ( log.isInfoEnabled() ) + if ( log.isDebugEnabled() ) { - log.info( "contextInitialized" ); + log.debug( "contextInitialized" ); } } /** - * This gets the singleton instance of the CompositeCacheManager and calls shutdown. + * Shutdown JCS. * <p> * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) */ @Override public void contextDestroyed( ServletContextEvent arg0 ) { - if ( log.isInfoEnabled() ) + if ( log.isDebugEnabled() ) { - log.info( "contextDestroyed, shutting down JCS." ); + log.debug( "contextDestroyed, shutting down JCS." ); } - try - { - CompositeCacheManager.getInstance().shutDown(); - } - catch (CacheException e) - { - log.error( "Could not retrieve cache manager instance", e ); - } + JCS.shutdown(); } } Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java Wed Aug 2 09:44:13 2017 @@ -65,8 +65,8 @@ public class IndexedDiskCacheOptimizatio Thread.sleep( 1000 ); long sizeBeforeRemove = disk.getDataFileSize(); - System.out.println( "file sizeBeforeRemove " + sizeBeforeRemove ); - System.out.println( "totalSize inserted " + DiskTestObjectUtil.totalSize( elements, numberToInsert ) ); + // System.out.println( "file sizeBeforeRemove " + sizeBeforeRemove ); + // System.out.println( "totalSize inserted " + DiskTestObjectUtil.totalSize( elements, numberToInsert ) ); // DO WORK for ( int i = 0; i < removeCount; i++ ) Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java Wed Aug 2 09:44:13 2017 @@ -1,5 +1,7 @@ package org.apache.commons.jcs.auxiliary.remote; +import java.util.Properties; + import org.apache.commons.jcs.JCS; import org.apache.commons.jcs.access.CacheAccess; import org.apache.commons.jcs.auxiliary.AuxiliaryCache; @@ -52,8 +54,9 @@ public class TestRemoteCache { System.out.println( "main> creating registry on the localhost" ); RemoteUtils.createRegistry( 1101 ); + Properties config = RemoteUtils.loadProps("/TestRemoteServer.ccf"); - RemoteCacheServerFactory.startup( "localhost", 1101, "/TestRemoteServer.ccf" ); + RemoteCacheServerFactory.startup( "localhost", 1101, config); } catch ( Exception e ) { Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerStartupUtil.java Wed Aug 2 09:44:13 2017 @@ -23,8 +23,8 @@ import java.io.IOException; import java.net.UnknownHostException; import java.util.Properties; +import org.apache.commons.jcs.auxiliary.remote.RemoteUtils; import org.apache.commons.jcs.utils.net.HostNameUtil; -import org.apache.commons.jcs.utils.props.PropertyLoader; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -53,7 +53,16 @@ public class RemoteCacheServerStartupUti // all three int registryPort = DEFAULT_REGISTRY_PORT; - Properties props = PropertyLoader.loadProperties( propsFileName ); + Properties props = null; + try + { + props = RemoteUtils.loadProps(propsFileName); + } + catch (IOException e) + { + log.error( "Problem loading configuration from " + propsFileName, e); + } + if ( props != null ) { String portS = props.getProperty( "registry.port", String.valueOf( DEFAULT_REGISTRY_PORT ) ); @@ -86,7 +95,7 @@ public class RemoteCacheServerStartupUti try { - RemoteCacheServerFactory.startup( registryHost, registryPort, "/" + propsFileName ); + RemoteCacheServerFactory.startup( registryHost, registryPort, props ); } catch ( IOException e ) { Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java Wed Aug 2 09:44:13 2017 @@ -22,17 +22,19 @@ package org.apache.commons.jcs.auxiliary import java.util.HashSet; import java.util.LinkedList; import java.util.List; - -import junit.framework.TestCase; +import java.util.Properties; import org.apache.commons.jcs.auxiliary.MockCacheEventLogger; import org.apache.commons.jcs.auxiliary.remote.MockRemoteCacheListener; +import org.apache.commons.jcs.auxiliary.remote.RemoteUtils; import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes; import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType; import org.apache.commons.jcs.engine.CacheElement; import org.apache.commons.jcs.engine.behavior.ICacheElement; import org.apache.commons.jcs.utils.timing.SleepUtil; +import junit.framework.TestCase; + /** * Since the server does not know that it is a server, it is easy to unit test. The factory does all * the rmi work. @@ -54,7 +56,8 @@ public class RemoteCacheServerUnitTest IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes(); rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" ); - this.server = new RemoteCacheServer<String, String>( rcsa ); + Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName()); + this.server = new RemoteCacheServer<String, String>( rcsa, config ); } @Override @@ -223,8 +226,9 @@ public class RemoteCacheServerUnitTest IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes(); rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" ); + Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName()); MockRemoteCacheListener<String, Long> mockListener = new MockRemoteCacheListener<String, Long>(); - RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>( rcsa ); + RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>( rcsa, config ); String cacheName = "testSimpleRegisterListenerAndPut"; server.addCacheListener( cacheName, mockListener ); @@ -268,7 +272,8 @@ public class RemoteCacheServerUnitTest IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes(); rcsa.setLocalClusterConsistency( true ); rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" ); - RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>( rcsa ); + Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName()); + RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>( rcsa, config ); // this is to get the listener id for inserts. MockRemoteCacheListener<String, Long> clusterListener = new MockRemoteCacheListener<String, Long>(); Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-dist/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-dist/pom.xml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-dist/pom.xml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-dist/pom.xml Wed Aug 2 09:44:13 2017 @@ -59,6 +59,14 @@ <skipDeploy>true</skipDeploy> </configuration> </plugin> + <plugin> + <!-- skip deployment of distribution files to maven repository --> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-deploy-plugin</artifactId> + <configuration> + <skip>true</skip> + </configuration> + </plugin> </plugins> </build> Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CDIJCacheHelper.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CDIJCacheHelper.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CDIJCacheHelper.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CDIJCacheHelper.java Wed Aug 2 09:44:13 2017 @@ -18,18 +18,8 @@ */ package org.apache.commons.jcs.jcache.cdi; -import java.lang.annotation.Annotation; -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.logging.Logger; import javax.annotation.PreDestroy; import javax.cache.annotation.CacheDefaults; -import javax.cache.annotation.CacheInvocationParameter; import javax.cache.annotation.CacheKey; import javax.cache.annotation.CacheKeyGenerator; import javax.cache.annotation.CacheResolverFactory; @@ -41,6 +31,15 @@ import javax.enterprise.inject.spi.Bean; import javax.enterprise.inject.spi.BeanManager; import javax.inject.Inject; import javax.interceptor.InvocationContext; +import java.lang.annotation.Annotation; +import java.lang.reflect.Method; +import java.lang.reflect.Proxy; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.logging.Logger; @ApplicationScoped public class CDIJCacheHelper @@ -104,8 +103,25 @@ public class CDIJCacheHelper public CacheDefaults findDefaults(final InvocationContext ic) { - Class<?> clazz = ic.getTarget().getClass(); + if (ic.getTarget() != null && Proxy.isProxyClass(ic.getTarget().getClass())) // target doesnt hold annotations + { + final Class<?> api = ic.getMethod().getDeclaringClass(); + for (final Class<?> type : ic.getTarget().getClass().getInterfaces()) + { + if (!api.isAssignableFrom(type)) + { + continue; + } + return extractDefaults(type); + } + } + return extractDefaults(ic.getTarget().getClass()); + } + + private CacheDefaults extractDefaults(final Class<?> type) + { CacheDefaults annotation = null; + Class<?> clazz = type; while (clazz != null && clazz != Object.class) { annotation = clazz.getAnnotation(CacheDefaults.class); Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CacheInvocationContextImpl.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CacheInvocationContextImpl.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CacheInvocationContextImpl.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/cdi/CacheInvocationContextImpl.java Wed Aug 2 09:44:13 2017 @@ -18,16 +18,18 @@ */ package org.apache.commons.jcs.jcache.cdi; -import java.lang.annotation.Annotation; -import java.util.HashSet; import javax.cache.annotation.CacheInvocationContext; import javax.cache.annotation.CacheInvocationParameter; import javax.interceptor.InvocationContext; +import java.lang.annotation.Annotation; +import java.util.HashSet; import static java.util.Arrays.asList; public class CacheInvocationContextImpl<A extends Annotation> extends CacheMethodDetailsImpl<A> implements CacheInvocationContext<A> { + private static final Object[] EMPTY_ARGS = new Object[0]; + private CacheInvocationParameter[] parameters = null; public CacheInvocationContextImpl(final InvocationContext delegate, final A cacheAnnotation, final String cacheName) @@ -63,7 +65,8 @@ public class CacheInvocationContextImpl< protected CacheInvocationParameter[] doGetAllParameters(final Integer[] indexes) { - final Object[] args = delegate.getParameters(); + final Object[] parameters = delegate.getParameters(); + final Object[] args = parameters == null ? EMPTY_ARGS : parameters; final Class<?>[] parameterTypes = getMethod().getParameterTypes(); final Annotation[][] parameterAnnotations = getMethod().getParameterAnnotations(); Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/proxy/ClassLoaderAwareCache.java Wed Aug 2 09:44:13 2017 @@ -34,7 +34,7 @@ import java.util.Map; import java.util.Set; // don't use a proxy, reflection is too slow here :( -public class ClassLoaderAwareCache<K extends Serializable, V extends Serializable> implements Cache<K, V> +public class ClassLoaderAwareCache<K, V> implements Cache<K, V> { private final ClassLoader loader; private final JCSCache<K, V> delegate; Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/filecache/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/filecache/pom.xml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/filecache/pom.xml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/filecache/pom.xml Wed Aug 2 09:44:13 2017 @@ -24,7 +24,7 @@ <parent> <groupId>org.apache.commons</groupId> <artifactId>commons-jcs-sandbox</artifactId> - <version>2.1-SNAPSHOT</version> + <version>2.2-SNAPSHOT</version> </parent> <artifactId>commons-jcs-filecache</artifactId> Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/pom.xml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/pom.xml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/pom.xml Wed Aug 2 09:44:13 2017 @@ -24,7 +24,7 @@ <parent> <groupId>org.apache.commons</groupId> <artifactId>commons-jcs</artifactId> - <version>2.1-SNAPSHOT</version> + <version>2.2-SNAPSHOT</version> </parent> <artifactId>commons-jcs-sandbox</artifactId> Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/yajcache/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/yajcache/pom.xml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/yajcache/pom.xml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/commons-jcs-sandbox/yajcache/pom.xml Wed Aug 2 09:44:13 2017 @@ -24,7 +24,7 @@ <parent> <groupId>org.apache.commons</groupId> <artifactId>commons-jcs-sandbox</artifactId> - <version>2.1-SNAPSHOT</version> + <version>2.2-SNAPSHOT</version> </parent> <artifactId>commons-jcs-yajcache</artifactId> Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/pom.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/pom.xml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/pom.xml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/pom.xml Wed Aug 2 09:44:13 2017 @@ -521,6 +521,7 @@ <commons.componentid>jcs</commons.componentid> <commons.release.version>2.1</commons.release.version> <commons.release.name>commons-jcs-dist-2.1</commons.release.name> + <commons.module.name>org.apache.commons.jcs</commons.module.name> <commons.release.desc>(Java 6.0+)</commons.release.desc> <!-- The RC version used in the staging repository URL. --> <commons.rc.version>RC1</commons.rc.version> Modified: commons/proper/jcs/branches/commons-jcs-2.2-RC/src/changes/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/jcs/branches/commons-jcs-2.2-RC/src/changes/changes.xml?rev=1803791&r1=1803790&r2=1803791&view=diff ============================================================================== --- commons/proper/jcs/branches/commons-jcs-2.2-RC/src/changes/changes.xml (original) +++ commons/proper/jcs/branches/commons-jcs-2.2-RC/src/changes/changes.xml Wed Aug 2 09:44:13 2017 @@ -20,6 +20,21 @@ </properties> <body> <release version="2.2" date="unreleased"> + <action issue="JCS-180" dev="rmannibucau" type="fix"> + CacheInvocationContextImpl NPE if method doesnt have any argument + </action> + <action issue="JCS-179" dev="tv" type="fix" due-to="Archer"> + RemoteCacheServerFactory not able to start server + </action> + <action issue="JCS-178" dev="tv" type="fix"> + Clients using RemoteCache are not working. Add a test. + </action> + <action dev="tv" type="add"> + Add a shutdown() method to JCS + </action> + <action issue="JCS-177" dev="tv" type="fix" due-to="Ryan Fong"> + Fix: CompositeCacheManager leaks memory if CacheAccess.dipose is called + </action> </release> <release version="2.1" date="2017-02-05"> <action dev="tv" type="fix">