Build failed in Hudson: jboss-cache-searchable-trunk-jdk1.5 » JBoss Cache - Searchable Edition #22
by jboss-qa-internal@redhat.com
See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.5...
Changes:
[manik.surtani(a)jboss.com] Fixed release script again
[manik.surtani(a)jboss.com] Fixed script
[Navin Surtani] Commented out pojo classes ...
[manik.surtani(a)jboss.com]
[manik.surtani(a)jboss.com]
------------------------------------------
started
Building remotely on soavmg8-linux
$ /qa/tools/opt/jdk1.5.0_15/bin/java -Xmx512m -cp /home/hudson/hudson_workspace/maven-agent.jar:/qa/tools/opt/maven-2.0.9/boot/classworlds-1.1.jar hudson.maven.agent.Main /qa/tools/opt/maven-2.0.9 /qa/services/hudson/hudson_release/WEB-INF/slave.jar /home/hudson/hudson_workspace/maven-interceptor.jar 38097
channel started
Executing Maven: -B -N -B -f http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.5... -cpu -U clean site -P codeCoverage
[INFO] Scanning for projects...
WAGON_VERSION: 1.0-beta-2
[INFO] ------------------------------------------------------------------------
[INFO] Building JBoss Cache - Searchable Edition
[INFO] task-segment: [clean, site]
[INFO] ------------------------------------------------------------------------
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from Main Maven Repo
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.repository.codehaus.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from e-xml.sourceforge.net
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from repository.jboss.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from Main Maven Repo
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from snapshots.repository.codehaus.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from central
[HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-searchable-trunk-jdk1.5/./pom.xml to /home/hudson/hudson_workspace/jobs/jboss-cache-searchable-trunk-jdk1.5/modules/org.jboss.cache$jbosscache-searchable/builds/2009-01-05_00-01-59/archive/org.jboss.cache/jbosscache-searchable/1.0.0-SNAPSHOT/pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-eclipse-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Mon Jan 05 00:02:16 EST 2009
[INFO] Final Memory: 8M/15M
[INFO] ------------------------------------------------------------------------
Waiting for Hudson to finish collecting data
15 years, 9 months
Build failed in Hudson: jboss-cache-searchable-trunk-jdk1.6 » JBoss Cache - Searchable Edition #22
by jboss-qa-internal@redhat.com
See http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.6...
Changes:
[manik.surtani(a)jboss.com] Fixed release script again
[manik.surtani(a)jboss.com] Fixed script
[Navin Surtani] Commented out pojo classes ...
[manik.surtani(a)jboss.com]
[manik.surtani(a)jboss.com]
------------------------------------------
started
Building remotely on soavmg10-linux
$ java -Xmx512m -cp /home/hudson/hudson_workspace/maven-agent.jar:/qa/tools/opt/maven-2.0.9/boot/classworlds-1.1.jar hudson.maven.agent.Main /qa/tools/opt/maven-2.0.9 /qa/services/hudson/hudson_release/WEB-INF/slave.jar /home/hudson/hudson_workspace/maven-interceptor.jar 51659
channel started
Executing Maven: -B -N -B -f http://hudson.qa.jboss.com/hudson/job/jboss-cache-searchable-trunk-jdk1.6... -cpu -U clean site -P codeCoverage
[INFO] Scanning for projects...
WAGON_VERSION: 1.0-beta-2
[INFO] ------------------------------------------------------------------------
[INFO] Building JBoss Cache - Searchable Edition
[INFO] task-segment: [clean, site]
[INFO] ------------------------------------------------------------------------
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from Main Maven Repo
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.repository.codehaus.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from snapshots.jboss.org
[INFO] snapshot org.codehaus.mojo:emma-maven-plugin:1.0-SNAPSHOT: checking for updates from e-xml.sourceforge.net
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from repository.jboss.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from Main Maven Repo
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from snapshots.repository.codehaus.org
[INFO] artifact org.apache.maven.plugins:maven-eclipse-plugin: checking for updates from central
[HUDSON] Archiving /home/hudson/hudson_workspace/workspace/jboss-cache-searchable-trunk-jdk1.6/./pom.xml to /home/hudson/hudson_workspace/jobs/jboss-cache-searchable-trunk-jdk1.6/modules/org.jboss.cache$jbosscache-searchable/builds/2009-01-05_00-01-59/archive/org.jboss.cache/jbosscache-searchable/1.0.0-SNAPSHOT/pom.xml
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The plugin 'org.apache.maven.plugins:maven-eclipse-plugin' does not exist or no valid version could be found
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8 seconds
[INFO] Finished at: Mon Jan 05 00:02:16 EST 2009
[INFO] Final Memory: 14M/33M
[INFO] ------------------------------------------------------------------------
Waiting for Hudson to finish collecting data
15 years, 9 months
JBoss Cache SVN: r7622 - in core/branches/flat/src: test/java/org/horizon/notifications and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-31 05:39:31 -0500 (Sat, 31 Jan 2009)
New Revision: 7622
Added:
core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerListener.java
Modified:
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java
core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java
core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java
Log:
Started work on notifications
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java 2009-01-31 09:44:26 UTC (rev 7621)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java 2009-01-31 10:39:31 UTC (rev 7622)
@@ -1,6 +1,8 @@
package org.horizon.notifications.cachemanagerlistener;
import org.horizon.factories.annotations.NonVolatile;
+import org.horizon.factories.annotations.Start;
+import org.horizon.factories.annotations.Stop;
import org.horizon.factories.scopes.Scope;
import org.horizon.factories.scopes.Scopes;
import org.horizon.remoting.transport.Address;
@@ -41,4 +43,14 @@
public Set<Object> getListeners() {
return null; // TODO: Manik: Customise this generated block
}
+
+ @Start
+ public void start() {
+ // TODO: Manik: Customise this generated block
+ }
+
+ @Stop
+ public void stop() {
+
+ }
}
Modified: core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java 2009-01-31 09:44:26 UTC (rev 7621)
+++ core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java 2009-01-31 10:39:31 UTC (rev 7622)
@@ -1,6 +1,8 @@
package org.horizon.notifications;
import org.horizon.Cache;
+import org.horizon.logging.Log;
+import org.horizon.logging.LogFactory;
import org.horizon.manager.CacheManager;
import org.horizon.manager.DefaultCacheManager;
import org.horizon.notifications.cachelistener.annotation.CacheEntryCreated;
@@ -23,6 +25,7 @@
Cache<String, String> cache;
CacheManager cm;
CacheListener listener;
+ Log log = LogFactory.getLog(ConcurrentNotificationTest.class);
@BeforeMethod
public void setUp() {
@@ -88,7 +91,11 @@
for (Exception e : exceptions)
throw e;
- assert 4 * loops * workers.length == listener.counter.get();
+ // we cannot ascertain the exact number of invocations on the listener since some removes would mean that other
+ // gets would miss. And this would cause no notification to fire for that get. And we cannot be sure of the
+ // timing between removes and gets, so we just make sure *some* of these have got through, and no exceptions
+ // were thrown due to concurrent access.
+ assert loops * workers.length < listener.counter.get();
}
@Listener
Added: core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerListener.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerListener.java 2009-01-31 10:39:31 UTC (rev 7622)
@@ -0,0 +1,35 @@
+package org.horizon.notifications.cachemanagerlistener;
+
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachemanagerlistener.annotation.CacheStarted;
+import org.horizon.notifications.cachemanagerlistener.annotation.CacheStopped;
+import org.horizon.notifications.cachemanagerlistener.annotation.ViewChanged;
+import org.horizon.notifications.cachemanagerlistener.event.Event;
+
+@Listener
+public class CacheManagerListener {
+ Event event;
+ int invocationCount;
+
+ public void reset() {
+ event = null;
+ invocationCount = 0;
+ }
+
+ public Event getEvent() {
+ return event;
+ }
+
+ public int getInvocationCount() {
+ return invocationCount;
+ }
+
+ // handler
+ @CacheStarted
+ @CacheStopped
+ @ViewChanged
+ public void handle(Event e) {
+ event = e;
+ invocationCount++;
+ }
+}
Modified: core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java 2009-01-31 09:44:26 UTC (rev 7621)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java 2009-01-31 10:39:31 UTC (rev 7622)
@@ -1,8 +1,54 @@
package org.horizon.notifications.cachemanagerlistener;
+import org.easymock.EasyMock;
+import org.horizon.notifications.cachemanagerlistener.event.CacheStartedEvent;
+import org.horizon.notifications.cachemanagerlistener.event.CacheStoppedEvent;
+import org.horizon.notifications.cachemanagerlistener.event.Event;
+import org.horizon.notifications.cachemanagerlistener.event.ViewChangedEvent;
+import org.horizon.remoting.transport.Address;
+import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+import java.util.Collections;
+import java.util.List;
+
@Test(groups = "unit")
public class CacheManagerNotifierImplTest {
- // TODO implement me!
+ CacheManagerNotifierImpl n;
+ CacheManagerListener cl;
+
+ @BeforeMethod
+ public void setUp() {
+ n = new CacheManagerNotifierImpl();
+ cl = new CacheManagerListener();
+ n.start();
+ n.addListener(cl);
+ }
+
+ public void testNotifyViewChanged() {
+ Address a = EasyMock.createNiceMock(Address.class);
+ List<Address> addresses = Collections.emptyList();
+ n.notifyViewChange(addresses, a);
+
+ assert cl.invocationCount == 1;
+ assert ((ViewChangedEvent) cl.getEvent()).getLocalAddress() == a;
+ assert ((ViewChangedEvent) cl.getEvent()).getNewMemberList() == addresses;
+ assert cl.getEvent().getType() == Event.Type.VIEW_CHANGED;
+ }
+
+ public void testNotifyCacheStarted() {
+ n.notifyCacheStarted("cache");
+
+ assert cl.invocationCount == 1;
+ assert ((CacheStartedEvent) cl.getEvent()).getCacheName().equals("cache");
+ assert cl.getEvent().getType() == Event.Type.CACHE_STARTED;
+ }
+
+ public void testNotifyCacheStopped() {
+ n.notifyCacheStopped("cache");
+
+ assert cl.invocationCount == 1;
+ assert ((CacheStoppedEvent) cl.getEvent()).getCacheName().equals("cache");
+ assert cl.getEvent().getType() == Event.Type.CACHE_STOPPED;
+ }
}
15 years, 10 months
JBoss Cache SVN: r7621 - in core/branches/flat/src: main/java/org/horizon/interceptors and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-31 04:44:26 -0500 (Sat, 31 Jan 2009)
New Revision: 7621
Modified:
core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java
core/branches/flat/src/main/java/org/horizon/interceptors/CacheLoaderInterceptor.java
core/branches/flat/src/main/java/org/horizon/interceptors/NotificationInterceptor.java
core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java
core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java
core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java
Log:
Modified: core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -7,7 +7,7 @@
import org.horizon.factories.scopes.Scopes;
import org.horizon.marshall.Marshaller;
import org.horizon.marshall.VersionAwareMarshaller;
-import org.horizon.notifications.CacheManagerNotifier;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
import org.horizon.remoting.InboundInvocationHandler;
/**
Modified: core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -31,7 +31,7 @@
import org.horizon.loader.CacheLoaderManager;
import org.horizon.marshall.Marshaller;
import org.horizon.marshall.VersionAwareMarshaller;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import org.horizon.transaction.TransactionTable;
/**
Modified: core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -35,7 +35,7 @@
import org.horizon.lock.TimeoutException;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
/**
* // TODO: MANIK: Document this
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/CacheLoaderInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/CacheLoaderInterceptor.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/CacheLoaderInterceptor.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -37,7 +37,7 @@
import org.horizon.interceptors.base.JmxStatsCommandInterceptor;
import org.horizon.loader.CacheLoader;
import org.horizon.loader.CacheLoaderManager;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import org.horizon.transaction.TransactionTable;
import java.util.HashMap;
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/NotificationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/NotificationInterceptor.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/NotificationInterceptor.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -26,7 +26,7 @@
import org.horizon.commands.tx.RollbackCommand;
import org.horizon.context.InvocationContext;
import org.horizon.factories.annotations.Inject;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
/**
* The interceptor in charge of firing off notifications to cache listeners
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -39,7 +39,7 @@
import org.horizon.invocation.InvocationContextContainer;
import org.horizon.lock.LockManager;
import org.horizon.manager.CacheManager;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import org.horizon.remoting.ReplicationException;
import org.horizon.transaction.GlobalTransaction;
import org.horizon.transaction.TransactionTable;
Modified: core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/remoting/transport/Transport.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -7,7 +7,7 @@
import org.horizon.factories.scopes.Scopes;
import org.horizon.lifecycle.Lifecycle;
import org.horizon.marshall.Marshaller;
-import org.horizon.notifications.CacheManagerNotifier;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
import org.horizon.remoting.InboundInvocationHandler;
import org.horizon.remoting.ResponseFilter;
import org.horizon.remoting.ResponseMode;
Modified: core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -8,7 +8,7 @@
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
import org.horizon.marshall.Marshaller;
-import org.horizon.notifications.CacheManagerNotifier;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
import org.horizon.remoting.InboundInvocationHandler;
import org.horizon.remoting.ReplicationException;
import org.horizon.remoting.ResponseFilter;
@@ -297,7 +297,6 @@
// List<org.jgroups.Address> removed = toJGroupsAddressList(members);
// removed.removeAll(newMembers);
// spi.getInvocationContext().getOptionOverrides().setSkipCacheStatusCheck(true);
-// NodeSPI root = null; // spi.getRoot();
// if (root != null)
// {
//removeLocksForDeadMembers(root.getDelegationTarget(), removed);
Modified: core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java 2009-01-31 00:36:37 UTC (rev 7620)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java 2009-01-31 09:44:26 UTC (rev 7621)
@@ -6,7 +6,6 @@
import org.horizon.config.Configuration;
import org.horizon.config.GlobalConfiguration;
import org.horizon.manager.CacheManager;
-import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
import org.horizon.remoting.transport.Address;
import org.horizon.util.TestingUtil;
import org.testng.annotations.Test;
15 years, 10 months
JBoss Cache SVN: r7620 - core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-30 19:36:37 -0500 (Fri, 30 Jan 2009)
New Revision: 7620
Modified:
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java
Log:
Started work on notifications
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java 2009-01-31 00:34:44 UTC (rev 7619)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java 2009-01-31 00:36:37 UTC (rev 7620)
@@ -1,8 +1,5 @@
package org.horizon.notifications.cachemanagerlistener;
-import org.horizon.factories.annotations.NonVolatile;
-import org.horizon.factories.scopes.Scope;
-import org.horizon.factories.scopes.Scopes;
import org.horizon.notifications.Listenable;
import org.horizon.remoting.transport.Address;
@@ -14,8 +11,6 @@
* @author Manik Surtani
* @since 1.0
*/
-@NonVolatile
-(a)Scope(Scopes.GLOBAL)
public interface CacheManagerNotifier extends Listenable {
/**
* Notifies all registered listeners of a viewChange event. Note that viewChange notifications are ALWAYS sent
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java 2009-01-31 00:34:44 UTC (rev 7619)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java 2009-01-31 00:36:37 UTC (rev 7620)
@@ -1,5 +1,8 @@
package org.horizon.notifications.cachemanagerlistener;
+import org.horizon.factories.annotations.NonVolatile;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
import org.horizon.remoting.transport.Address;
import java.util.List;
@@ -11,6 +14,8 @@
* @author Manik Surtani
* @since 1.0
*/
+@NonVolatile
+(a)Scope(Scopes.GLOBAL)
public class CacheManagerNotifierImpl implements CacheManagerNotifier {
public void notifyViewChange(List<Address> members, Address myAddress) {
15 years, 10 months
JBoss Cache SVN: r7619 - in core/branches/flat/src: main/java/org/horizon/commands/read and 3 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-30 19:34:44 -0500 (Fri, 30 Jan 2009)
New Revision: 7619
Added:
core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java
core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java
Removed:
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java
core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java
Modified:
core/branches/flat/src/main/java/org/horizon/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/horizon/commands/read/GetKeyValueCommand.java
Log:
Started work on notifications
Modified: core/branches/flat/src/main/java/org/horizon/commands/CommandsFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/CommandsFactoryImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
+++ core/branches/flat/src/main/java/org/horizon/commands/CommandsFactoryImpl.java 2009-01-31 00:34:44 UTC (rev 7619)
@@ -37,7 +37,7 @@
import org.horizon.commands.write.ReplaceCommand;
import org.horizon.container.DataContainer;
import org.horizon.factories.annotations.Inject;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import org.horizon.remoting.transport.Address;
import org.horizon.transaction.GlobalTransaction;
Modified: core/branches/flat/src/main/java/org/horizon/commands/read/GetKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/read/GetKeyValueCommand.java 2009-01-31 00:32:22 UTC (rev 7618)
+++ core/branches/flat/src/main/java/org/horizon/commands/read/GetKeyValueCommand.java 2009-01-31 00:34:44 UTC (rev 7619)
@@ -26,7 +26,7 @@
import org.horizon.context.InvocationContext;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
/**
* // TODO: MANIK: Document this
Deleted: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java 2009-01-31 00:32:22 UTC (rev 7618)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java 2009-01-31 00:34:44 UTC (rev 7619)
@@ -1,211 +0,0 @@
-package org.horizon.notifications;
-
-import static org.easymock.EasyMock.*;
-import org.horizon.Cache;
-import org.horizon.config.Configuration;
-import org.horizon.context.InvocationContext;
-import org.horizon.lock.IsolationLevel;
-import org.horizon.manager.CacheManager;
-import org.horizon.manager.DefaultCacheManager;
-import org.horizon.notifications.cachelistener.CacheNotifier;
-import org.horizon.transaction.DummyTransactionManagerLookup;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import javax.transaction.Transaction;
-import javax.transaction.TransactionManager;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-@Test(groups = "functional", sequential = true)
-public class CacheListenerTest {
- private Cache<Object, Object> cache;
- private TransactionManager tm;
- private CacheNotifier mockNotifier;
- private CacheNotifier origNotifier;
-
- @BeforeMethod(alwaysRun = true)
- public void setUp() throws Exception {
- Configuration c = new Configuration();
- c.setCacheMode(Configuration.CacheMode.LOCAL);
- c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
- c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
-
- CacheManager cm = new DefaultCacheManager(c);
-
- cache = cm.getCache();
- tm = TestingUtil.getTransactionManager(cache);
- mockNotifier = createMock(CacheNotifier.class);
- origNotifier = TestingUtil.replaceComponent(cache, CacheNotifier.class, mockNotifier, true);
- }
-
- @AfterMethod(alwaysRun = true)
- public void tearDown() throws Exception {
- TestingUtil.replaceComponent(cache, CacheNotifier.class, origNotifier, true);
- TestingUtil.killCaches(cache);
- }
-
- private void initCacheData(Object key, Object value) {
- initCacheData(Collections.singletonMap(key, value));
- }
-
- private void initCacheData(Map data) {
- mockNotifier.notifyCacheEntryCreated(anyObject(), anyBoolean(), isA(InvocationContext.class));
- expectLastCall().anyTimes();
- mockNotifier.notifyCacheEntryModified(anyObject(), anyObject(), anyBoolean(), isA(InvocationContext.class));
- expectLastCall().anyTimes();
- replay(mockNotifier);
- cache.putAll(data);
- verify(mockNotifier);
-
- // now reset the mock
- reset(mockNotifier);
- }
-
- private void expectSingleEntryCreated(Object key, Object value) {
- mockNotifier.notifyCacheEntryCreated(eq(key), eq(true), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyCacheEntryCreated(eq(key), eq(false), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyCacheEntryModified(eq(key), isNull(), eq(true), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyCacheEntryModified(eq(key), eq(value), eq(false), isA(InvocationContext.class));
- expectLastCall().once();
- }
-
- private void expectTransactionBoundaries(boolean successful) {
- mockNotifier.notifyTransactionRegistered(isA(Transaction.class), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyTransactionCompleted(isA(Transaction.class), eq(successful), isA(InvocationContext.class));
- expectLastCall().once();
- }
-
-
- // simple tests first
-
- public void testCreation() throws Exception {
- expectSingleEntryCreated("key", "value");
- replay(mockNotifier);
- cache.put("key", "value");
- verify(mockNotifier);
- }
-
- public void testOnlyModification() throws Exception {
- initCacheData("key", "value");
-
- mockNotifier.notifyCacheEntryModified(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyCacheEntryModified(eq("key"), eq("value2"), eq(false), isA(InvocationContext.class));
- expectLastCall().once();
-
- replay(mockNotifier);
- cache.put("key", "value2");
- verify(mockNotifier);
- }
-
- public void testNonexistentRemove() throws Exception {
- cache.remove("doesNotExist");
- replay(mockNotifier);
- verify(mockNotifier);
- }
-
- public void testRemoveData() throws Exception {
- Map data = new HashMap();
- data.put("key", "value");
- data.put("key2", "value2");
- initCacheData(data);
-
- mockNotifier.notifyCacheEntryRemoved(eq("key2"), eq("value2"), eq(true), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyCacheEntryRemoved(eq("key2"), isNull(), eq(false), isA(InvocationContext.class));
- expectLastCall().once();
- replay(mockNotifier);
-
- cache.remove("key2");
-
- verify(mockNotifier);
- }
-
- public void testPutMap() throws Exception {
- Map<Object, Object> data = new HashMap<Object, Object>();
- data.put("key", "value");
- data.put("key2", "value2");
- expectSingleEntryCreated("key", "value");
- expectSingleEntryCreated("key2", "value2");
-
- replay(mockNotifier);
-
- cache.putAll(data);
- verify(mockNotifier);
- }
-
- // -- now the transactional ones
-
- public void testTxNonexistentRemove() throws Exception {
- expectTransactionBoundaries(true);
- replay(mockNotifier);
- tm.begin();
- cache.remove("doesNotExist");
- tm.commit();
- verify(mockNotifier);
- }
-
- public void testTxCreationCommit() throws Exception {
- expectTransactionBoundaries(true);
- expectSingleEntryCreated("key", "value");
- replay(mockNotifier);
- tm.begin();
- cache.put("key", "value");
- tm.commit();
- verify(mockNotifier);
- }
-
- public void testTxCreationRollback() throws Exception {
- expectTransactionBoundaries(false);
- expectSingleEntryCreated("key", "value");
- replay(mockNotifier);
- tm.begin();
- cache.put("key", "value");
- tm.rollback();
- verify(mockNotifier);
- }
-
- public void testTxOnlyModification() throws Exception {
- initCacheData("key", "value");
- expectTransactionBoundaries(true);
- mockNotifier.notifyCacheEntryModified(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyCacheEntryModified(eq("key"), eq("value2"), eq(false), isA(InvocationContext.class));
- expectLastCall().once();
-
- replay(mockNotifier);
-
- tm.begin();
- cache.put("key", "value2");
- tm.commit();
-
- verify(mockNotifier);
- }
-
- public void testTxRemoveData() throws Exception {
- Map data = new HashMap();
- data.put("key", "value");
- data.put("key2", "value2");
- initCacheData(data);
- expectTransactionBoundaries(true);
- mockNotifier.notifyCacheEntryRemoved(eq("key2"), eq("value2"), eq(true), isA(InvocationContext.class));
- expectLastCall().once();
- mockNotifier.notifyCacheEntryRemoved(eq("key2"), isNull(), eq(false), isA(InvocationContext.class));
- expectLastCall().once();
- replay(mockNotifier);
-
- tm.begin();
- cache.remove("key2");
- tm.commit();
-
- verify(mockNotifier);
- }
-}
Deleted: core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java 2009-01-31 00:32:22 UTC (rev 7618)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java 2009-01-31 00:34:44 UTC (rev 7619)
@@ -1,70 +0,0 @@
-package org.horizon.notifications;
-
-import static org.easymock.EasyMock.*;
-import org.horizon.BaseClusteredTest;
-import org.horizon.Cache;
-import org.horizon.config.Configuration;
-import org.horizon.config.GlobalConfiguration;
-import org.horizon.manager.CacheManager;
-import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
-import org.horizon.remoting.transport.Address;
-import org.horizon.util.TestingUtil;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
-@Test(groups = "unit", sequential = true, testName = "notifications.CacheManagerNotifierTest")
-public class CacheManagerNotifierTest extends BaseClusteredTest {
- public void testViewChange() {
- CacheManager cm1 = addClusterEnabledCacheManager();
- CacheManager cm2 = addClusterEnabledCacheManager();
- Configuration c = new Configuration();
- c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
- defineCacheOnAllManagers("cache", c);
-
- Cache c1 = cm1.getCache("cache");
-
- // this will mean only 1 cache in the cluster so far
- assert cm1.getMembers().size() == 1;
- Address myAddress = cm1.getAddress();
- assert cm1.getMembers().contains(myAddress);
-
- // now attach a mock notifier
- CacheManagerNotifier mockNotifier = createMock(CacheManagerNotifier.class);
- CacheManagerNotifier origNotifier = TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, mockNotifier, true);
- try {
- mockNotifier.notifyViewChange(isA(List.class), eq(myAddress));
- replay(mockNotifier);
- // start a second cache.
- Cache c2 = cm2.getCache("cache");
- TestingUtil.blockUntilViewsReceived(60000, cm1, cm2);
- verify(mockNotifier);
-
- } finally {
- TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, origNotifier, true);
- }
- }
-
- public void testCacheStartedAndStopped() {
- CacheManager cm1 = addCacheManager(GlobalConfiguration.getNonClusteredDefault());
- Cache defCache = cm1.getCache();
- CacheManagerNotifier mockNotifier = createMock(CacheManagerNotifier.class);
- CacheManagerNotifier origNotifier = TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, mockNotifier, true);
- try {
- cm1.defineCache("testCache", new Configuration());
- mockNotifier.notifyCacheStarted("testCache");
- replay(mockNotifier);
- // start a second cache.
- Cache testCache = cm1.getCache("testCache");
- verify(mockNotifier);
-
- reset(mockNotifier);
- mockNotifier.notifyCacheStopped("testCache");
- replay(mockNotifier);
- testCache.stop();
- verify(mockNotifier);
- } finally {
- TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, origNotifier, true);
- }
- }
-}
Copied: core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java (from rev 7618, core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java)
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierTest.java 2009-01-31 00:34:44 UTC (rev 7619)
@@ -0,0 +1,210 @@
+package org.horizon.notifications.cachelistener;
+
+import static org.easymock.EasyMock.*;
+import org.horizon.Cache;
+import org.horizon.config.Configuration;
+import org.horizon.context.InvocationContext;
+import org.horizon.lock.IsolationLevel;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.transaction.DummyTransactionManagerLookup;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+@Test(groups = "functional", sequential = true)
+public class CacheNotifierTest {
+ private Cache<Object, Object> cache;
+ private TransactionManager tm;
+ private CacheNotifier mockNotifier;
+ private CacheNotifier origNotifier;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception {
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.LOCAL);
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+
+ CacheManager cm = new DefaultCacheManager(c);
+
+ cache = cm.getCache();
+ tm = TestingUtil.getTransactionManager(cache);
+ mockNotifier = createMock(CacheNotifier.class);
+ origNotifier = TestingUtil.replaceComponent(cache, CacheNotifier.class, mockNotifier, true);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception {
+ TestingUtil.replaceComponent(cache, CacheNotifier.class, origNotifier, true);
+ TestingUtil.killCaches(cache);
+ }
+
+ private void initCacheData(Object key, Object value) {
+ initCacheData(Collections.singletonMap(key, value));
+ }
+
+ private void initCacheData(Map data) {
+ mockNotifier.notifyCacheEntryCreated(anyObject(), anyBoolean(), isA(InvocationContext.class));
+ expectLastCall().anyTimes();
+ mockNotifier.notifyCacheEntryModified(anyObject(), anyObject(), anyBoolean(), isA(InvocationContext.class));
+ expectLastCall().anyTimes();
+ replay(mockNotifier);
+ cache.putAll(data);
+ verify(mockNotifier);
+
+ // now reset the mock
+ reset(mockNotifier);
+ }
+
+ private void expectSingleEntryCreated(Object key, Object value) {
+ mockNotifier.notifyCacheEntryCreated(eq(key), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryCreated(eq(key), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq(key), isNull(), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq(key), eq(value), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ }
+
+ private void expectTransactionBoundaries(boolean successful) {
+ mockNotifier.notifyTransactionRegistered(isA(Transaction.class), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyTransactionCompleted(isA(Transaction.class), eq(successful), isA(InvocationContext.class));
+ expectLastCall().once();
+ }
+
+
+ // simple tests first
+
+ public void testCreation() throws Exception {
+ expectSingleEntryCreated("key", "value");
+ replay(mockNotifier);
+ cache.put("key", "value");
+ verify(mockNotifier);
+ }
+
+ public void testOnlyModification() throws Exception {
+ initCacheData("key", "value");
+
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value2"), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+
+ replay(mockNotifier);
+ cache.put("key", "value2");
+ verify(mockNotifier);
+ }
+
+ public void testNonexistentRemove() throws Exception {
+ cache.remove("doesNotExist");
+ replay(mockNotifier);
+ verify(mockNotifier);
+ }
+
+ public void testRemoveData() throws Exception {
+ Map data = new HashMap();
+ data.put("key", "value");
+ data.put("key2", "value2");
+ initCacheData(data);
+
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), eq("value2"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), isNull(), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ replay(mockNotifier);
+
+ cache.remove("key2");
+
+ verify(mockNotifier);
+ }
+
+ public void testPutMap() throws Exception {
+ Map<Object, Object> data = new HashMap<Object, Object>();
+ data.put("key", "value");
+ data.put("key2", "value2");
+ expectSingleEntryCreated("key", "value");
+ expectSingleEntryCreated("key2", "value2");
+
+ replay(mockNotifier);
+
+ cache.putAll(data);
+ verify(mockNotifier);
+ }
+
+ // -- now the transactional ones
+
+ public void testTxNonexistentRemove() throws Exception {
+ expectTransactionBoundaries(true);
+ replay(mockNotifier);
+ tm.begin();
+ cache.remove("doesNotExist");
+ tm.commit();
+ verify(mockNotifier);
+ }
+
+ public void testTxCreationCommit() throws Exception {
+ expectTransactionBoundaries(true);
+ expectSingleEntryCreated("key", "value");
+ replay(mockNotifier);
+ tm.begin();
+ cache.put("key", "value");
+ tm.commit();
+ verify(mockNotifier);
+ }
+
+ public void testTxCreationRollback() throws Exception {
+ expectTransactionBoundaries(false);
+ expectSingleEntryCreated("key", "value");
+ replay(mockNotifier);
+ tm.begin();
+ cache.put("key", "value");
+ tm.rollback();
+ verify(mockNotifier);
+ }
+
+ public void testTxOnlyModification() throws Exception {
+ initCacheData("key", "value");
+ expectTransactionBoundaries(true);
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value2"), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+
+ replay(mockNotifier);
+
+ tm.begin();
+ cache.put("key", "value2");
+ tm.commit();
+
+ verify(mockNotifier);
+ }
+
+ public void testTxRemoveData() throws Exception {
+ Map data = new HashMap();
+ data.put("key", "value");
+ data.put("key2", "value2");
+ initCacheData(data);
+ expectTransactionBoundaries(true);
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), eq("value2"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), isNull(), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ replay(mockNotifier);
+
+ tm.begin();
+ cache.remove("key2");
+ tm.commit();
+
+ verify(mockNotifier);
+ }
+}
Copied: core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java (from rev 7618, core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java)
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierTest.java 2009-01-31 00:34:44 UTC (rev 7619)
@@ -0,0 +1,70 @@
+package org.horizon.notifications.cachemanagerlistener;
+
+import static org.easymock.EasyMock.*;
+import org.horizon.BaseClusteredTest;
+import org.horizon.Cache;
+import org.horizon.config.Configuration;
+import org.horizon.config.GlobalConfiguration;
+import org.horizon.manager.CacheManager;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
+import org.horizon.remoting.transport.Address;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+@Test(groups = "unit", sequential = true, testName = "notifications.CacheManagerNotifierTest")
+public class CacheManagerNotifierTest extends BaseClusteredTest {
+ public void testViewChange() {
+ CacheManager cm1 = addClusterEnabledCacheManager();
+ CacheManager cm2 = addClusterEnabledCacheManager();
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ defineCacheOnAllManagers("cache", c);
+
+ Cache c1 = cm1.getCache("cache");
+
+ // this will mean only 1 cache in the cluster so far
+ assert cm1.getMembers().size() == 1;
+ Address myAddress = cm1.getAddress();
+ assert cm1.getMembers().contains(myAddress);
+
+ // now attach a mock notifier
+ CacheManagerNotifier mockNotifier = createMock(CacheManagerNotifier.class);
+ CacheManagerNotifier origNotifier = TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, mockNotifier, true);
+ try {
+ mockNotifier.notifyViewChange(isA(List.class), eq(myAddress));
+ replay(mockNotifier);
+ // start a second cache.
+ Cache c2 = cm2.getCache("cache");
+ TestingUtil.blockUntilViewsReceived(60000, cm1, cm2);
+ verify(mockNotifier);
+
+ } finally {
+ TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, origNotifier, true);
+ }
+ }
+
+ public void testCacheStartedAndStopped() {
+ CacheManager cm1 = addCacheManager(GlobalConfiguration.getNonClusteredDefault());
+ Cache defCache = cm1.getCache();
+ CacheManagerNotifier mockNotifier = createMock(CacheManagerNotifier.class);
+ CacheManagerNotifier origNotifier = TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, mockNotifier, true);
+ try {
+ cm1.defineCache("testCache", new Configuration());
+ mockNotifier.notifyCacheStarted("testCache");
+ replay(mockNotifier);
+ // start a second cache.
+ Cache testCache = cm1.getCache("testCache");
+ verify(mockNotifier);
+
+ reset(mockNotifier);
+ mockNotifier.notifyCacheStopped("testCache");
+ replay(mockNotifier);
+ testCache.stop();
+ verify(mockNotifier);
+ } finally {
+ TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, origNotifier, true);
+ }
+ }
+}
15 years, 10 months
JBoss Cache SVN: r7618 - in core/branches/flat/src: main/java/org/horizon/commands/write and 20 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-30 19:32:22 -0500 (Fri, 30 Jan 2009)
New Revision: 7618
Added:
core/branches/flat/src/main/java/org/horizon/notifications/IncorrectListenerException.java
core/branches/flat/src/main/java/org/horizon/notifications/Listener.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifier.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifierImpl.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryActivated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryCreated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryEvicted.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryInvalidated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryLoaded.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryModified.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryPassivated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryRemoved.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryVisited.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryActivatedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryCreatedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvictedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryLoadedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryModifiedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryPassivatedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryRemovedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryVisitedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/Event.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/EventImpl.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStarted.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStopped.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/ViewChanged.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStartedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStoppedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/Event.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/EventImpl.java
core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/ViewChangedEvent.java
core/branches/flat/src/test/java/org/horizon/notifications/
core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java
core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java
core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java
core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java
core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/
core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheListener.java
core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java
core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java
core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/
core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java
Removed:
core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifier.java
core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifierImpl.java
core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifier.java
core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java
core/branches/flat/src/main/java/org/horizon/notifications/EventLog.java
core/branches/flat/src/main/java/org/horizon/notifications/IncorrectCacheListenerException.java
core/branches/flat/src/main/java/org/horizon/notifications/annotation/
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryActivated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryCreated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryEvicted.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryInvalidated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryLoaded.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryModified.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryPassivated.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryRemoved.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryVisited.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheStarted.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheStopped.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/Listener.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/ViewChanged.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryActivatedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryCreatedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvictedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryLoadedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryModifiedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryPassivatedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryRemovedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryVisitedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheStartedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheStoppedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/Event.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/EventImpl.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/ViewChangedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/event/
core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java
Modified:
core/branches/flat/src/main/java/org/horizon/CacheDelegate.java
core/branches/flat/src/main/java/org/horizon/CacheSPI.java
core/branches/flat/src/main/java/org/horizon/commands/write/EvictCommand.java
core/branches/flat/src/main/java/org/horizon/commands/write/InvalidateCommand.java
core/branches/flat/src/main/java/org/horizon/commands/write/PutKeyValueCommand.java
core/branches/flat/src/main/java/org/horizon/commands/write/PutMapCommand.java
core/branches/flat/src/main/java/org/horizon/commands/write/RemoveCommand.java
core/branches/flat/src/main/java/org/horizon/context/EntryLookup.java
core/branches/flat/src/main/java/org/horizon/eviction/EvictionWatcher.java
core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/loader/SingletonStoreCacheLoader.java
core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
core/branches/flat/src/main/java/org/horizon/notifications/Listenable.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/TransactionCompleted.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/TransactionRegistered.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionCompletedEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionRegisteredEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionalEvent.java
core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java
core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
Log:
Started work on notifications
Modified: core/branches/flat/src/main/java/org/horizon/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/CacheDelegate.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/CacheDelegate.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -50,7 +50,7 @@
import org.horizon.logging.LogFactory;
import org.horizon.manager.CacheManager;
import org.horizon.marshall.Marshaller;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import org.horizon.remoting.RPCManager;
import org.horizon.statetransfer.StateTransferManager;
import org.horizon.transaction.GlobalTransaction;
Modified: core/branches/flat/src/main/java/org/horizon/CacheSPI.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/CacheSPI.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/CacheSPI.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -29,7 +29,7 @@
import org.horizon.loader.CacheLoaderManager;
import org.horizon.lock.LockManager;
import org.horizon.marshall.Marshaller;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import org.horizon.remoting.RPCManager;
import org.horizon.statetransfer.StateTransferManager;
import org.horizon.transaction.GlobalTransaction;
@@ -141,7 +141,7 @@
* From 2.1.0, Interceptor authors should obtain this by injection rather than this method. See the {@link
* org.horizon.factories.annotations.Inject} annotation.
*
- * @return the notifier attached with this instance of the cache. See {@link org.horizon.notifications.CacheNotifier},
+ * @return the notifier attached with this instance of the cache. See {@link org.horizon.notifications.cachelistener.CacheNotifier},
* a class that is responsible for emitting notifications to registered CacheListeners.
*/
CacheNotifier getNotifier();
Modified: core/branches/flat/src/main/java/org/horizon/commands/write/EvictCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/write/EvictCommand.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/commands/write/EvictCommand.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -23,7 +23,7 @@
import org.horizon.commands.Visitor;
import org.horizon.context.InvocationContext;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
/**
* @author Mircea.Markus(a)jboss.com
@@ -53,7 +53,7 @@
}
@Override
- public void notify(InvocationContext ctx, boolean isPre) {
+ public void notify(InvocationContext ctx, Object value, boolean isPre) {
notifier.notifyCacheEntryEvicted(key, isPre, ctx);
}
Modified: core/branches/flat/src/main/java/org/horizon/commands/write/InvalidateCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/write/InvalidateCommand.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/commands/write/InvalidateCommand.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -25,7 +25,7 @@
import org.horizon.context.InvocationContext;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import java.util.Arrays;
@@ -67,7 +67,7 @@
}
@Override
- protected void notify(InvocationContext ctx, boolean isPre) {
+ protected void notify(InvocationContext ctx, Object value, boolean isPre) {
notifier.notifyCacheEntryInvalidated(key, isPre, ctx);
}
Modified: core/branches/flat/src/main/java/org/horizon/commands/write/PutKeyValueCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/write/PutKeyValueCommand.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/commands/write/PutKeyValueCommand.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -27,7 +27,7 @@
import org.horizon.commands.read.AbstractDataCommand;
import org.horizon.container.MVCCEntry;
import org.horizon.context.InvocationContext;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
/**
* Implements functionality defined by {@link org.horizon.Cache#put(Object, Object)}
@@ -76,7 +76,7 @@
successful = false;
return e.getValue();
} else {
- notifier.notifyCacheEntryModified(key, true, ctx);
+ notifier.notifyCacheEntryModified(key, e.getValue(), true, ctx);
if (value instanceof Delta) {
// magic
@@ -89,7 +89,7 @@
} else {
o = e.setValue(value);
}
- notifier.notifyCacheEntryModified(key, false, ctx);
+ notifier.notifyCacheEntryModified(key, e.getValue(), false, ctx);
}
return o;
}
Modified: core/branches/flat/src/main/java/org/horizon/commands/write/PutMapCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/write/PutMapCommand.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/commands/write/PutMapCommand.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -24,7 +24,7 @@
import org.horizon.commands.Visitor;
import org.horizon.container.MVCCEntry;
import org.horizon.context.InvocationContext;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
import java.util.Map;
import java.util.Map.Entry;
@@ -59,9 +59,9 @@
for (Entry<Object, Object> e : map.entrySet()) {
Object key = e.getKey();
MVCCEntry me = ctx.lookupEntry(key);
- notifier.notifyCacheEntryModified(key, true, ctx);
- if (me != null) me.setValue(e.getValue());
- notifier.notifyCacheEntryModified(key, false, ctx);
+ notifier.notifyCacheEntryModified(key, me.getValue(), true, ctx);
+ me.setValue(e.getValue());
+ notifier.notifyCacheEntryModified(key, me.getValue(), false, ctx);
}
return null;
}
Modified: core/branches/flat/src/main/java/org/horizon/commands/write/RemoveCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/write/RemoveCommand.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/commands/write/RemoveCommand.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -25,7 +25,7 @@
import org.horizon.commands.read.AbstractDataCommand;
import org.horizon.container.MVCCEntry;
import org.horizon.context.InvocationContext;
-import org.horizon.notifications.CacheNotifier;
+import org.horizon.notifications.cachelistener.CacheNotifier;
/**
@@ -71,15 +71,15 @@
return false;
}
- notify(ctx, true);
+ notify(ctx, e.getValue(), true);
e.setDeleted(true);
e.setValid(false);
- notify(ctx, false);
+ notify(ctx, null, false);
return value == null ? e.getValue() : true;
}
- protected void notify(InvocationContext ctx, boolean isPre) {
- notifier.notifyCacheEntryRemoved(key, isPre, ctx);
+ protected void notify(InvocationContext ctx, Object value, boolean isPre) {
+ notifier.notifyCacheEntryRemoved(key, value, isPre, ctx);
}
public byte getCommandId() {
Modified: core/branches/flat/src/main/java/org/horizon/context/EntryLookup.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/context/EntryLookup.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/context/EntryLookup.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -26,7 +26,7 @@
import java.util.Map;
/**
- * // TODO: MANIK: Document this
+ * Interface that can look up MVCC wrapped entries.
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 1.0
Modified: core/branches/flat/src/main/java/org/horizon/eviction/EvictionWatcher.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/eviction/EvictionWatcher.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/eviction/EvictionWatcher.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,9 +1,9 @@
package org.horizon.eviction;
import org.horizon.Cache;
-import org.horizon.notifications.annotation.CacheEntryEvicted;
-import org.horizon.notifications.annotation.Listener;
-import org.horizon.notifications.event.CacheEntryEvictedEvent;
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryEvicted;
+import org.horizon.notifications.cachelistener.event.CacheEntryEvictedEvent;
import org.horizon.tree.Fqn;
import java.util.ArrayList;
Modified: core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -5,10 +5,12 @@
import org.horizon.ComponentStatus;
import org.horizon.config.Configuration;
import org.horizon.config.ConfigurationException;
+import org.horizon.factories.annotations.Inject;
import org.horizon.factories.scopes.ScopeDetector;
import org.horizon.factories.scopes.Scopes;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
import java.util.Map;
@@ -23,7 +25,13 @@
GlobalComponentRegistry globalComponents;
String cacheName;
Log log = LogFactory.getLog(ComponentRegistry.class);
+ CacheManagerNotifier cacheManagerNotifier;
+ @Inject
+ public void setCacheManagerNotifier(CacheManagerNotifier cacheManagerNotifier) {
+ this.cacheManagerNotifier = cacheManagerNotifier;
+ }
+
/**
* Creates an instance of the component registry. The configuration passed in is automatically registered.
*
@@ -102,11 +110,13 @@
}
super.start();
globalComponents.registerNamedComponentRegistry(this, cacheName);
+ cacheManagerNotifier.notifyCacheStarted(cacheName);
}
@Override
public void stop() {
if (state.stopAllowed()) globalComponents.unregisterNamedComponentRegistry(cacheName);
super.stop();
+ cacheManagerNotifier.notifyCacheStopped(cacheName);
}
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -107,4 +107,13 @@
public void unregisterNamedComponentRegistry(String name) {
componentLookup.remove(NAMED_REGISTRY_PREFIX + name);
}
+
+ public void rewireNamedRegistries() {
+ for (String name : componentLookup.keySet()) {
+ if (name.startsWith(NAMED_REGISTRY_PREFIX)) {
+ Component c = componentLookup.get(name);
+ ((ComponentRegistry) c.instance).rewire();
+ }
+ }
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/loader/SingletonStoreCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/SingletonStoreCacheLoader.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/loader/SingletonStoreCacheLoader.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -25,12 +25,12 @@
import org.horizon.config.CacheLoaderConfig.IndividualCacheLoaderConfig.SingletonStoreConfig;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
-import org.horizon.notifications.annotation.CacheStarted;
-import org.horizon.notifications.annotation.CacheStopped;
-import org.horizon.notifications.annotation.Listener;
-import org.horizon.notifications.annotation.ViewChanged;
-import org.horizon.notifications.event.Event;
-import org.horizon.notifications.event.ViewChangedEvent;
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachelistener.event.Event;
+import org.horizon.notifications.cachemanagerlistener.annotation.CacheStarted;
+import org.horizon.notifications.cachemanagerlistener.annotation.CacheStopped;
+import org.horizon.notifications.cachemanagerlistener.annotation.ViewChanged;
+import org.horizon.notifications.cachemanagerlistener.event.ViewChangedEvent;
import org.horizon.remoting.transport.Address;
import org.horizon.tree.Fqn;
Modified: core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -35,7 +35,7 @@
import org.horizon.factories.scopes.Scope;
import org.horizon.factories.scopes.Scopes;
import org.horizon.lifecycle.Lifecycle;
-import org.horizon.notifications.CacheManagerNotifier;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
import org.horizon.remoting.RPCManager;
import org.horizon.remoting.transport.Address;
@@ -93,7 +93,6 @@
private final ConcurrentMap<String, Configuration> configurationOverrides = new ConcurrentHashMap<String, Configuration>();
private GlobalComponentRegistry globalComponentRegistry;
-
/**
* Constructs and starts a default instance of the CacheManager, using configuration defaults.
*/
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifier.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifier.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifier.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,19 +0,0 @@
-package org.horizon.notifications;
-
-import org.horizon.remoting.transport.Address;
-
-import java.util.List;
-
-/**
- * Notifications for the cache manager
- *
- * @author Manik Surtani
- * @since 1.0
- */
-public interface CacheManagerNotifier extends Listenable {
- /**
- * Notifies all registered listeners of a viewChange event. Note that viewChange notifications are ALWAYS sent
- * immediately.
- */
- void notifyViewChange(List<Address> members, Address myAddress);
-}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifierImpl.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifierImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,36 +0,0 @@
-package org.horizon.notifications;
-
-import org.horizon.factories.annotations.NonVolatile;
-import org.horizon.factories.scopes.Scope;
-import org.horizon.factories.scopes.Scopes;
-import org.horizon.remoting.transport.Address;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Global, shared notifications. Typically on the CacheManager. See
- *
- * @author Manik Surtani
- * @since 1.0
- */
-@NonVolatile
-(a)Scope(Scopes.GLOBAL)
-public class CacheManagerNotifierImpl implements CacheManagerNotifier {
-
- public void notifyViewChange(List<Address> members, Address myAddress) {
- // TODO: Manik: Customise this generated block
- }
-
- public void addListener(Object listener) {
- // TODO: Manik: Customise this generated block
- }
-
- public void removeListener(Object listener) {
- // TODO: Manik: Customise this generated block
- }
-
- public Set<Object> getListeners() {
- return null; // TODO: Manik: Customise this generated block
- }
-}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifier.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifier.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifier.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,94 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications;
-
-import org.horizon.context.InvocationContext;
-
-import javax.transaction.Transaction;
-
-/**
- * Public interface with all allowed notifications.
- *
- * @author Mircea.Markus(a)jboss.com
- * @since 1.0
- */
-public interface CacheNotifier extends Listenable {
- /**
- * Notifies all registered listeners of a CacheEntryCreated event.
- */
- void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryModified event.
- */
- void notifyCacheEntryModified(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryRemoved event.
- */
- void notifyCacheEntryRemoved(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryVisited event.
- */
- void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryEvicted event.
- */
- void notifyCacheEntryEvicted(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryInvalidated event.
- */
- void notifyCacheEntryInvalidated(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryLoaded event.
- */
- void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryActivated event.
- */
- void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a CacheEntryPassivated event.
- */
- void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a transaction completion event.
- *
- * @param transaction the transaction that has just completed
- * @param successful if true, the transaction committed. If false, this is a rollback event
- */
- void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx);
-
- /**
- * Notifies all registered listeners of a transaction registration event.
- *
- * @param transaction the transaction that has just completed
- */
- void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx);
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,524 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications;
-
-import org.horizon.Cache;
-import org.horizon.CacheException;
-import org.horizon.CacheSPI;
-import org.horizon.config.Configuration;
-import org.horizon.context.InvocationContext;
-import org.horizon.factories.KnownComponentNames;
-import org.horizon.factories.annotations.ComponentName;
-import org.horizon.factories.annotations.Destroy;
-import org.horizon.factories.annotations.Inject;
-import org.horizon.factories.annotations.NonVolatile;
-import org.horizon.factories.annotations.Start;
-import org.horizon.factories.annotations.Stop;
-import org.horizon.factories.scopes.Scope;
-import org.horizon.factories.scopes.Scopes;
-import org.horizon.logging.Log;
-import org.horizon.logging.LogFactory;
-import org.horizon.notifications.annotation.*;
-import org.horizon.notifications.event.*;
-import static org.horizon.notifications.event.Event.Type.*;
-import org.horizon.util.ReflectionUtil;
-import org.horizon.util.concurrent.WithinThreadExecutor;
-
-import javax.transaction.Transaction;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicInteger;
-
-/**
- * Helper class that handles all notifications to registered listeners.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @since 1.0
- */
-@NonVolatile
-(a)Scope(Scopes.NAMED_CACHE)
-public class CacheNotifierImpl implements CacheNotifier {
- private static final Log log = LogFactory.getLog(CacheNotifierImpl.class);
-
- private static final Class[] allowedMethodAnnotations =
- {
- CacheStarted.class, CacheStopped.class, CacheEntryCreated.class, CacheEntryRemoved.class, CacheEntryVisited.class, CacheEntryModified.class,
- CacheEntryActivated.class, CacheEntryPassivated.class, CacheEntryLoaded.class, CacheEntryEvicted.class, TransactionRegistered.class, TransactionCompleted.class,
- CacheEntryInvalidated.class
- };
- private static final Class[] parameterTypes =
- {
- CacheStartedEvent.class, CacheStoppedEvent.class, CacheEntryCreatedEvent.class, CacheEntryRemovedEvent.class, CacheEntryVisitedEvent.class, CacheEntryModifiedEvent.class,
- CacheEntryActivatedEvent.class, CacheEntryPassivatedEvent.class, CacheEntryLoadedEvent.class, CacheEntryEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class,
- CacheEntryInvalidatedEvent.class
- };
-
- final Map<Class<? extends Annotation>, List<ListenerInvocation>> listenersMap = new HashMap<Class<? extends Annotation>, List<ListenerInvocation>>(16, 0.99f);
- final List<ListenerInvocation> cacheStartedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheStoppedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryCreatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryRemovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryVisitedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryModifiedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryActivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryPassivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryLoadedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryInvalidatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> cacheEntryEvictedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> transactionRegisteredListeners = new CopyOnWriteArrayList<ListenerInvocation>();
- final List<ListenerInvocation> transactionCompletedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
-
- private Cache cache;
- private Configuration config;
- // two separate executor services, one for sync and one for async listeners
- private ExecutorService syncProcessor;
- private ExecutorService asyncProcessor;
- private static final AtomicInteger asyncNotifierThreadNumber = new AtomicInteger(0);
-
- public CacheNotifierImpl() {
- listenersMap.put(CacheStarted.class, cacheStartedListeners);
- listenersMap.put(CacheStopped.class, cacheStoppedListeners);
- listenersMap.put(CacheEntryCreated.class, cacheEntryCreatedListeners);
- listenersMap.put(CacheEntryRemoved.class, cacheEntryRemovedListeners);
- listenersMap.put(CacheEntryVisited.class, cacheEntryVisitedListeners);
- listenersMap.put(CacheEntryModified.class, cacheEntryModifiedListeners);
- listenersMap.put(CacheEntryActivated.class, cacheEntryActivatedListeners);
- listenersMap.put(CacheEntryPassivated.class, cacheEntryPassivatedListeners);
- listenersMap.put(CacheEntryLoaded.class, cacheEntryLoadedListeners);
- listenersMap.put(CacheEntryEvicted.class, cacheEntryEvictedListeners);
- listenersMap.put(TransactionRegistered.class, transactionRegisteredListeners);
- listenersMap.put(TransactionCompleted.class, transactionCompletedListeners);
- listenersMap.put(CacheEntryInvalidated.class, cacheEntryInvalidatedListeners);
- }
-
- @Inject
- void injectDependencies(CacheSPI cache, Configuration config,
- @ComponentName(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR) ExecutorService executor) {
- this.cache = cache;
- this.config = config;
- this.asyncProcessor = executor;
- }
-
- @Stop
- void stop() {
- syncProcessor.shutdownNow();
- asyncProcessor.shutdownNow();
- }
-
- @Destroy
- void destroy() {
- removeAllCacheListeners();
- }
-
- @Start
- void start() {
- syncProcessor = new WithinThreadExecutor();
- }
-
- /**
- * Loops through all valid methods on the object passed in, and caches the relevant methods as {@link
- * CacheNotifierImpl.ListenerInvocation} for invocation by reflection.
- *
- * @param listener object to be considered as a listener.
- */
- @SuppressWarnings("unchecked")
- private void validateAndAddListenerInvocation(Object listener) {
- boolean sync = testListenerClassValidity(listener.getClass());
-
- boolean foundMethods = false;
- // now try all methods on the listener for anything that we like. Note that only PUBLIC methods are scanned.
- for (Method m : listener.getClass().getMethods()) {
- // loop through all valid method annotations
- for (int i = 0; i < allowedMethodAnnotations.length; i++) {
- if (m.isAnnotationPresent(allowedMethodAnnotations[i])) {
- testListenerMethodValidity(m, parameterTypes[i], allowedMethodAnnotations[i].getName());
- addListenerInvocation(allowedMethodAnnotations[i], new ListenerInvocation(listener, m, sync));
- foundMethods = true;
- }
- }
- }
-
- if (!foundMethods && log.isWarnEnabled())
- log.warn("Attempted to register listener of class " + listener.getClass() + ", but no valid, public methods annotated with method-level event annotations found! Ignoring listener.");
- }
-
- /**
- * Tests if a class is properly annotated as a CacheListener and returns whether callbacks on this class should be
- * invoked synchronously or asynchronously.
- *
- * @param listenerClass class to inspect
- * @return true if callbacks on this class should use the syncProcessor; false if it should use the asyncProcessor.
- */
- private static boolean testListenerClassValidity(Class<?> listenerClass) {
- Listener l = ReflectionUtil.getAnnotation(listenerClass, Listener.class);
- if (l == null)
- throw new IncorrectCacheListenerException("Cache listener class MUST be annotated with org.horizon.notifications.annotation.Listener");
- if (!Modifier.isPublic(listenerClass.getModifiers()))
- throw new IncorrectCacheListenerException("Cache listener class MUST be public!");
- return l.sync();
- }
-
- private static void testListenerMethodValidity(Method m, Class allowedParameter, String annotationName) {
- if (m.getParameterTypes().length != 1 || !m.getParameterTypes()[0].isAssignableFrom(allowedParameter))
- throw new IncorrectCacheListenerException("Methods annotated with " + annotationName + " must accept exactly one parameter, of assignable from type " + allowedParameter.getName());
- if (!m.getReturnType().equals(void.class))
- throw new IncorrectCacheListenerException("Methods annotated with " + annotationName + " should have a return type of void.");
- }
-
- private void addListenerInvocation(Class annotation, ListenerInvocation li) {
- List<ListenerInvocation> result = getListenerCollectionForAnnotation(annotation);
- result.add(li);
- }
-
- public void addListener(Object listener) {
- validateAndAddListenerInvocation(listener);
- }
-
- public void removeListener(Object listener) {
- for (Class annotation : allowedMethodAnnotations) removeListenerInvocation(annotation, listener);
- }
-
- private void removeListenerInvocation(Class annotation, Object listener) {
- if (listener == null) return;
- List<ListenerInvocation> l = getListenerCollectionForAnnotation(annotation);
- Set<Object> markedForRemoval = new HashSet<Object>();
- for (ListenerInvocation li : l) {
- if (listener.equals(li.target)) markedForRemoval.add(li);
- }
- l.removeAll(markedForRemoval);
- }
-
- /**
- * Removes all listeners from the notifier, including the evictionPolicyListener.
- */
- @Stop(priority = 99)
- public void removeAllCacheListeners() {
- cacheStartedListeners.clear();
- cacheStoppedListeners.clear();
- cacheEntryCreatedListeners.clear();
- cacheEntryRemovedListeners.clear();
- cacheEntryVisitedListeners.clear();
- cacheEntryModifiedListeners.clear();
- cacheEntryActivatedListeners.clear();
- cacheEntryPassivatedListeners.clear();
- cacheEntryLoadedListeners.clear();
- cacheEntryEvictedListeners.clear();
- transactionRegisteredListeners.clear();
- transactionCompletedListeners.clear();
- }
-
- public Set<Object> getListeners() {
- Set<Object> result = new HashSet<Object>();
- for (List<ListenerInvocation> list : listenersMap.values()) {
- for (ListenerInvocation li : list) result.add(li.target);
- }
- return Collections.unmodifiableSet(result);
- }
-
- public void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx) {
- if (!cacheEntryCreatedListeners.isEmpty()) {
- boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_CREATED);
- for (ListenerInvocation listener : cacheEntryCreatedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryModified(Object key, boolean pre, InvocationContext ctx) {
- if (!cacheEntryModifiedListeners.isEmpty()) {
- boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_MODIFIED);
- for (ListenerInvocation listener : cacheEntryModifiedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryRemoved(Object key, boolean pre, InvocationContext ctx) {
- if (!cacheEntryRemovedListeners.isEmpty()) {
- boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_REMOVED);
- for (ListenerInvocation listener : cacheEntryRemovedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx) {
- if (!cacheEntryVisitedListeners.isEmpty()) {
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_VISITED);
- for (ListenerInvocation listener : cacheEntryVisitedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryEvicted(final Object key, final boolean pre, InvocationContext ctx) {
- if (!cacheEntryEvictedListeners.isEmpty()) {
- final boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_EVICTED);
- for (ListenerInvocation listener : cacheEntryEvictedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryInvalidated(final Object key, final boolean pre, InvocationContext ctx) {
- if (!cacheEntryInvalidatedListeners.isEmpty()) {
- final boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_INVALIDATED);
- for (ListenerInvocation listener : cacheEntryInvalidatedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx) {
- if (!cacheEntryLoadedListeners.isEmpty()) {
- boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_LOADED);
- for (ListenerInvocation listener : cacheEntryLoadedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx) {
- if (!cacheEntryActivatedListeners.isEmpty()) {
- boolean originLocal = ctx.isOriginLocal();
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(originLocal);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_ACTIVATED);
- for (ListenerInvocation listener : cacheEntryActivatedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx) {
- if (!cacheEntryPassivatedListeners.isEmpty()) {
- Transaction tx = ctx.getTransaction();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setPre(pre);
- e.setKey(key);
- e.setTransaction(tx);
- e.setType(CACHE_ENTRY_PASSIVATED);
- for (ListenerInvocation listener : cacheEntryPassivatedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- /**
- * Notifies all registered listeners of a cacheStarted event.
- */
- @Start(priority = 99)
- public void notifyCacheStarted() {
- if (!cacheStartedListeners.isEmpty()) {
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setType(CACHE_STARTED);
- for (ListenerInvocation listener : cacheStartedListeners) listener.invoke(e);
- }
- }
-
- /**
- * Notifies all registered listeners of a cacheStopped event.
- */
- @Stop(priority = 98)
- public void notifyCacheStopped() {
- if (!cacheStoppedListeners.isEmpty()) {
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setType(CACHE_STOPPED);
- for (ListenerInvocation listener : cacheStoppedListeners) listener.invoke(e);
- }
- }
-
- public void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx) {
- if (!transactionCompletedListeners.isEmpty()) {
- boolean isOriginLocal = ctx.isOriginLocal();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(isOriginLocal);
- e.setTransaction(transaction);
- e.setSuccessful(successful);
- e.setType(TRANSACTION_COMPLETED);
- for (ListenerInvocation listener : transactionCompletedListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- public void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx) {
- if (!transactionRegisteredListeners.isEmpty()) {
- boolean isOriginLocal = ctx.isOriginLocal();
- InvocationContext backup = resetInvocationContext(ctx);
- EventImpl e = new EventImpl();
- e.setCache(cache);
- e.setOriginLocal(isOriginLocal);
- e.setTransaction(transaction);
- e.setType(TRANSACTION_REGISTERED);
- for (ListenerInvocation listener : transactionRegisteredListeners) listener.invoke(e);
- restoreInvocationContext(backup);
- }
- }
-
- private void restoreInvocationContext(InvocationContext backup) {
- InvocationContext currentIC = cache.getInvocationContext();
- backup.clearLookedUpEntries();
- backup.putLookedUpEntries(currentIC.getLookedUpEntries());
- cache.setInvocationContext(backup);
- }
-
- /**
- * Resets the current (passed-in) invocation, and returns a temp InvocationContext containing its state so it can be
- * restored later using {@link #restoreInvocationContext(InvocationContext)}
- *
- * @param ctx the current context to be reset
- * @return a clone of ctx, before it was reset
- */
- private InvocationContext resetInvocationContext(InvocationContext ctx) {
- // wipe current context.
- cache.setInvocationContext(null);
- // get a new Invocation Context
- InvocationContext newContext = cache.getInvocationContext();
- newContext.putLookedUpEntries(ctx.getLookedUpEntries());
- return ctx;
- }
-
- /**
- * Class that encapsulates a valid invocation for a given registered listener - containing a reference to the method
- * to be invoked as well as the target object.
- */
- class ListenerInvocation {
- private final Object target;
- private final Method method;
- private final boolean sync;
-
- public ListenerInvocation(Object target, Method method, boolean sync) {
- this.target = target;
- this.method = method;
- this.sync = sync;
- }
-
- public void invoke(final Event e) {
- Runnable r = new Runnable() {
-
- public void run() {
- try {
- method.invoke(target, e);
- }
- catch (InvocationTargetException exception) {
- Throwable cause = exception.getCause();
- if (cause != null)
- throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, cause);
- else
- throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, exception);
- }
- catch (IllegalAccessException exception) {
- log.warn("Unable to invoke method " + method + " on Object instance " + target + " - removing this target object from list of listeners!", exception);
- removeListener(target);
- }
- }
- };
-
- if (sync)
- syncProcessor.execute(r);
- else
- asyncProcessor.execute(r);
-
- }
-
- }
-
- private List<ListenerInvocation> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation) {
- List<ListenerInvocation> list = listenersMap.get(annotation);
- if (list == null) throw new CacheException("Unknown listener annotation: " + annotation);
- return list;
- }
-}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/EventLog.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/EventLog.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/notifications/EventLog.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,42 +0,0 @@
-package org.horizon.notifications;
-
-import org.horizon.notifications.annotation.*;
-import org.horizon.notifications.event.Event;
-import org.horizon.notifications.event.EventImpl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-
-@Listener
-public class EventLog {
- public final List<Event> events = new ArrayList<Event>();
-
- @CacheEntryCreated
- @CacheEntryRemoved
- @CacheEntryModified
- @CacheEntryVisited
- @TransactionCompleted
- @TransactionRegistered
- @CacheEntryEvicted
- @CacheEntryPassivated
- @CacheEntryActivated
- @CacheEntryInvalidated
- public void callback(Event e) {
- events.add(e);
- }
-
- public String toString() {
- return "EventLog{" +
- "events=" + events +
- '}';
- }
-
- /**
- * Done when we don't have a Transaction reference to compare with, e.g., when using implicit transactions in opt
- * locking.
- */
- public void scrubImplicitTransactions() {
- for (Event e : events) ((EventImpl) e).setTransaction(null);
- }
-}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/IncorrectCacheListenerException.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/IncorrectCacheListenerException.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/notifications/IncorrectCacheListenerException.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,40 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications;
-
-import org.horizon.CacheException;
-
-/**
- * Thrown when an incorrectly annotated class is added as a cache listener using the {@link
- * org.horizon.Cache#addCacheListener(Object)} API.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public class IncorrectCacheListenerException extends CacheException {
-
- private static final long serialVersionUID = 3847404572671886703L;
-
- public IncorrectCacheListenerException(String s) {
- super(s);
- }
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/IncorrectListenerException.java (from rev 7607, core/branches/flat/src/main/java/org/horizon/notifications/IncorrectCacheListenerException.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/IncorrectListenerException.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/IncorrectListenerException.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications;
+
+import org.horizon.CacheException;
+
+/**
+ * Thrown when an incorrectly annotated class is added as a cache listener using the {@link
+ * org.horizon.notifications.Listenable#addListener(Object)} API.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public class IncorrectListenerException extends CacheException {
+
+ private static final long serialVersionUID = 3847404572671886703L;
+
+ public IncorrectListenerException(String s) {
+ super(s);
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/IncorrectListenerException.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/branches/flat/src/main/java/org/horizon/notifications/Listenable.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/Listenable.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/notifications/Listenable.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -11,11 +11,10 @@
public interface Listenable {
/**
- * Adds a listener to the component. Typically, listeners would need to be annotated with {@link
- * org.horizon.notifications.annotation.Listener} and further to that, contain methods annotated appropriately,
- * otherwise the listener will not be registered.
+ * Adds a listener to the component. Typically, listeners would need to be annotated with {@link Listener} and
+ * further to that, contain methods annotated appropriately, otherwise the listener will not be registered.
* <p/>
- * See the {@link org.horizon.notifications.annotation.Listener} annotation for more information.
+ * See the {@link Listener} annotation for more information.
* <p/>
*
* @param listener must not be null.
Added: core/branches/flat/src/main/java/org/horizon/notifications/Listener.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/Listener.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/Listener.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,238 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Class-level annotation used to annotate an object as being a valid cache listener. Used with the {@link
+ * org.horizon.Cache#addListener(Object)} and related APIs. <p/> Note that even if a class is annotated with this
+ * annotation, it still needs method-level annotation (such as {@link org.horizon.notifications.cachemanagerlistener.annotation.CacheStarted})
+ * to actually receive notifications. <p/> Objects annotated with this annotation - listeners - can be attached to a
+ * running {@link org.horizon.Cache} so users can be notified of {@link org.horizon.Cache} events. <p/> <p/> There can
+ * be multiple methods that are annotated to receive the same event, and a method may receive multiple events by using a
+ * super type. </p> <p/> <h4>Delivery Semantics</h4> <p/> An event is delivered immediately after the respective
+ * operation, but before the underlying cache call returns. For this reason it is important to keep listener processing
+ * logic short-lived. If a long running task needs to be performed, it's recommended to use another thread. </p> <p/>
+ * <h4>Transactional Semantics</h4> <p/> Since the event is delivered during the actual cache call, the transactional
+ * outcome is not yet known. For this reason, <i>events are always delivered, even if the changes they represent are
+ * discarded by their containing transaction</i>. For applications that must only process events that represent changes
+ * in a completed transaction, {@link org.horizon.notifications.cachelistener.event.TransactionalEvent#getTransaction()}
+ * can be used, along with {@link org.horizon.notifications.cachelistener.event.TransactionCompletedEvent#isTransactionSuccessful()}
+ * to record events and later process them once the transaction has been successfully committed. Example 4 demonstrates
+ * this. </p> <p/> <h4>Threading Semantics</h4> <p/> A listener implementation must be capable of handling concurrent
+ * invocations. Local notifications reuse the calling thread; remote notifications reuse the network thread. </p> <p/>
+ * Since notifications reuse the calling or network thread, it is important to realise that if your listener
+ * implementation blocks or performs a long-running task, the original caller which triggered the cache event may block
+ * until the listener callback completes. It is therefore a good idea to use the listener to be notified of an event
+ * but to perform any long running tasks in a separate thread so as not to block the original caller. </p> <p/> In
+ * addition, any locks acquired for the operation being performed will still be held for the callback. This needs to be
+ * kept in mind as locks may be held longer than necessary or intended to and may cause deadlocking in certain
+ * situations. See above paragraph on long-running tasks that should be run in a separate thread. </p> <b>Note</b>:
+ * Since 3.0, a new parameter, <tt>sync</tt>, has been introduced on this annotation. This defaults to <tt>true</tt>
+ * which provides the above semantics. Alternatively, if you set <tt>sync</tt> to <tt>false</tt>, then invocations are
+ * made in a <i>separate</i> thread, which will not cause any blocking on the caller or network thread. The separate
+ * thread is taken from a pool, which can be configured using {@link org.horizon.config.GlobalConfiguration#setAsyncListenerExecutorProperties(java.util.Properties)}
+ * and {@link org.horizon.config.GlobalConfiguration#setAsyncListenerExecutorFactoryClass(String)}.
+ * <p/>
+ * <b>Summary of Notification Annotations</b> <table border="1" cellpadding="1" cellspacing="1" summary="Summary of
+ * notification annotations"> <tr> <th bgcolor="#CCCCFF" align="left">Annotation</th> <th bgcolor="#CCCCFF"
+ * align="left">Event</th> <th bgcolor="#CCCCFF" align="left">Description</th> </tr> <tr> <td valign="top">{@link
+ * org.horizon.notifications.cachemanagerlistener.annotation.CacheStarted}</td> <td valign="top">{@link
+ * org.horizon.notifications.cachemanagerlistener.event.CacheStartedEvent}</td> <td valign="top">A cache was
+ * started</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachemanagerlistener.annotation.CacheStopped}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachemanagerlistener.event.CacheStoppedEvent}</td> <td
+ * valign="top">A cache was stopped</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachelistener.annotation.CacheEntryModified}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachelistener.event.CacheEntryModifiedEvent}</td> <td
+ * valign="top">A cache entry was modified</td> </tr> <tr> <td valign="top">{@link
+ * org.horizon.notifications.cachelistener.annotation.CacheEntryCreated}</td> <td valign="top">{@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryCreatedEvent}</td> <td valign="top">A cache entry was
+ * created</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachelistener.event.CacheEntryRemovedEvent}</td> <td valign="top">A
+ * cache entry was removed</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachelistener.annotation.CacheEntryVisited}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachelistener.event.CacheEntryVisitedEvent}</td> <td valign="top">A
+ * cache entry was visited</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachelistener.annotation.CacheEntryLoaded}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachelistener.event.CacheEntryLoadedEvent}</td> <td valign="top">A
+ * cache entry was loaded</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachelistener.annotation.CacheEntryEvicted}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachelistener.event.CacheEntryEvictedEvent}</td> <td valign="top">A
+ * cache entry was evicted</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachelistener.annotation.CacheEntryActivated}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachelistener.event.CacheEntryActivatedEvent}</td> <td
+ * valign="top">A cache entry was activated</td> </tr> <tr> <td valign="top">{@link
+ * org.horizon.notifications.cachelistener.annotation.CacheEntryPassivated}</td> <td valign="top">{@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryPassivatedEvent}</td> <td valign="top">A cache entry was
+ * passivated</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachemanagerlistener.annotation.ViewChanged}</td>
+ * <td valign="top">{@link org.horizon.notifications.cachemanagerlistener.event.ViewChangedEvent}</td> <td
+ * valign="top">A view change event was detected</td> </tr> <tr> <td valign="top">{@link
+ * org.horizon.notifications.cachelistener.annotation.TransactionRegistered}</td> <td valign@="top">{@link
+ * org.horizon.notifications.cachelistener.event.TransactionRegisteredEvent}</td> <td valign="top">The cache has started
+ * to participate in a transaction</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.cachelistener.annotation.TransactionCompleted}</td>
+ * <td valign=@"top">{@link org.horizon.notifications.cachelistener.event.TransactionCompletedEvent}</td> <td
+ * valign="top">The cache has completed its participation in a transaction</td> </tr> <tr> <td valign="top">{@link
+ * org.horizon.notifications.cachelistener.annotation.CacheEntryInvalidated}</td> <td valign=@"top">{@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryInvalidatedEvent}</td> <td valign="top">A cache entry was
+ * invalidated by a remote cache. Only if cache mode is INVALIDATION_SYNC or INVALIDATION_ASYNC.</td> </tr>
+ * <p/>
+ * </table>
+ * <p/>
+ * <h4>Example 1 - Method receiving a single event</h4>
+ * <pre>
+ * @Listener
+ * public class SingleEventListener
+ * {
+ * @CacheStarted
+ * public void doSomething(Event event)
+ * {
+ * System.out.println("Cache started. Details = " + event);
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <h4>Example 2 - Method receiving multiple events</h4>
+ * <pre>
+ * @Listener
+ * public class MultipleEventListener
+ * {
+ * @CacheStarted
+ * @CacheStopped
+ * public void doSomething(Event event)
+ * {
+ * if (event.getType() == Event.Type.CACHE_STARTED)
+ * System.out.println("Cache started. Details = " + event);
+ * else if (event.getType() == Event.Type.CACHE_STOPPED)
+ * System.out.println("Cache stopped. Details = " + event);
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <h4>Example 3 - Multiple methods receiving the same event</h4>
+ * <pre>
+ * @Listener
+ * public class SingleEventListener
+ * {
+ * @CacheStarted
+ * public void handleStart(Event event)
+ * {
+ * System.out.println("Cache started");
+ * }
+ * <p/>
+ * @CacheStarted
+ * @CacheStopped
+ * @CacheBlocked
+ * @CacheUnblocked
+ * @ViewChanged
+ * public void logEvent(Event event)
+ * {
+ * logSystem.logEvent(event.getType());
+ * }
+ * }
+ * </pre>
+ * <p/>
+ * <p/>
+ * <b>Example 4 - Processing only events with a committed transaction.</b>
+ * <p/>
+ * <pre>
+ * @Listener
+ * public class TxGuaranteedListener
+ * {
+ * private class TxEventQueue
+ * {
+ * private ConcurrentMap<Transaction, Queue<Event>> map = new ConcurrentHashMap<Transaction,
+ * Queue<Event>>();
+ * <p/>
+ * public void offer(Event event)
+ * {
+ * Queue<Event> queue = getQueue(event.getContext().getTransaction());
+ * queue.offer(event);
+ * }
+ * <p/>
+ * private Queue<Event> getQueue(Transaction transaction)
+ * {
+ * Queue<Event> queue = map.get(transaction);
+ * if (queue == null)
+ * {
+ * queue = new ConcurrentLinkedQueue<Event>();
+ * map.putIfAbsent(transaction, queue);
+ * }
+ * <p/>
+ * return queue;
+ * }
+ * <p/>
+ * public Queue<Event> takeAll(Transaction transaction)
+ * {
+ * return map.remove(transaction);
+ * }
+ * }
+ * <p/>
+ * private TxEventQueue events = new TxEventQueue();
+ * <p/>
+ * @CacheEntryModified
+ * @CacheEntryCreated
+ * @CacheEntryRemoved
+ * public void handle(Event event)
+ * {
+ * events.offer(event);
+ * }
+ * <p/>
+ * @TransactionCompleted
+ * public void handleTx(TransactionCompletedEvent event)
+ * {
+ * Queue<Event> completed = events.takeAll(event.getTransaction());
+ * if (completed != null && event.isSuccessful())
+ * System.out.println("Comitted events = " + completed);
+ * }
+ * }
+ * </pre>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @author Jason T. Greene
+ * @see org.horizon.notifications.cachemanagerlistener.annotation.CacheStarted
+ * @see org.horizon.notifications.cachemanagerlistener.annotation.CacheStopped
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryModified
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryCreated
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryVisited
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryLoaded
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryEvicted
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryActivated
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryPassivated
+ * @see org.horizon.notifications.cachemanagerlistener.annotation.ViewChanged
+ * @see org.horizon.notifications.cachelistener.annotation.TransactionCompleted
+ * @see org.horizon.notifications.cachelistener.annotation.TransactionRegistered
+ * @see org.horizon.notifications.cachelistener.annotation.CacheEntryInvalidated
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.TYPE)
+public @interface Listener {
+ /**
+ * Specifies whether callbacks on any class annotated with this annotation happens synchronously (in the caller's
+ * thread) or asynchronously (using a separate thread). Defaults to <tt>true</tt>.
+ *
+ * @return true if the expectation is that callbacks are called using the caller's thread; false if they are to be
+ * made in a separate thread.
+ * @since 1.0
+ */
+ boolean sync() default true;
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/Listener.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifier.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifier.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifier.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifier.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,95 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener;
+
+import org.horizon.context.InvocationContext;
+import org.horizon.notifications.Listenable;
+
+import javax.transaction.Transaction;
+
+/**
+ * Public interface with all allowed notifications.
+ *
+ * @author Mircea.Markus(a)jboss.com
+ * @since 1.0
+ */
+public interface CacheNotifier extends Listenable {
+ /**
+ * Notifies all registered listeners of a CacheEntryCreated event.
+ */
+ void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryModified event.
+ */
+ void notifyCacheEntryModified(Object key, Object value, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryRemoved event.
+ */
+ void notifyCacheEntryRemoved(Object key, Object value, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryVisited event.
+ */
+ void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryEvicted event.
+ */
+ void notifyCacheEntryEvicted(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryInvalidated event.
+ */
+ void notifyCacheEntryInvalidated(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryLoaded event.
+ */
+ void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryActivated event.
+ */
+ void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a CacheEntryPassivated event.
+ */
+ void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a transaction completion event.
+ *
+ * @param transaction the transaction that has just completed
+ * @param successful if true, the transaction committed. If false, this is a rollback event
+ */
+ void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx);
+
+ /**
+ * Notifies all registered listeners of a transaction registration event.
+ *
+ * @param transaction the transaction that has just completed
+ */
+ void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx);
+}
\ No newline at end of file
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifier.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifierImpl.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/CacheNotifierImpl.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifierImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifierImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,489 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener;
+
+import org.horizon.Cache;
+import org.horizon.CacheException;
+import org.horizon.CacheSPI;
+import org.horizon.context.InvocationContext;
+import org.horizon.factories.KnownComponentNames;
+import org.horizon.factories.annotations.ComponentName;
+import org.horizon.factories.annotations.Destroy;
+import org.horizon.factories.annotations.Inject;
+import org.horizon.factories.annotations.NonVolatile;
+import org.horizon.factories.annotations.Start;
+import org.horizon.factories.annotations.Stop;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+import org.horizon.logging.Log;
+import org.horizon.logging.LogFactory;
+import org.horizon.notifications.IncorrectListenerException;
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachelistener.annotation.*;
+import org.horizon.notifications.cachelistener.event.*;
+import static org.horizon.notifications.cachelistener.event.Event.Type.*;
+import org.horizon.util.ReflectionUtil;
+import org.horizon.util.concurrent.WithinThreadExecutor;
+
+import javax.transaction.Transaction;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.ExecutorService;
+
+/**
+ * Helper class that handles all notifications to registered listeners.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
+ * @since 1.0
+ */
+@NonVolatile
+(a)Scope(Scopes.NAMED_CACHE)
+public class CacheNotifierImpl implements CacheNotifier {
+ private static final Log log = LogFactory.getLog(CacheNotifierImpl.class);
+
+ private static final Class[] allowedMethodAnnotations =
+ {
+ CacheEntryCreated.class, CacheEntryRemoved.class, CacheEntryVisited.class, CacheEntryModified.class,
+ CacheEntryActivated.class, CacheEntryPassivated.class, CacheEntryLoaded.class, CacheEntryEvicted.class, TransactionRegistered.class, TransactionCompleted.class,
+ CacheEntryInvalidated.class
+ };
+ private static final Class[] parameterTypes =
+ {
+ CacheEntryCreatedEvent.class, CacheEntryRemovedEvent.class, CacheEntryVisitedEvent.class, CacheEntryModifiedEvent.class,
+ CacheEntryActivatedEvent.class, CacheEntryPassivatedEvent.class, CacheEntryLoadedEvent.class, CacheEntryEvictedEvent.class, TransactionRegisteredEvent.class, TransactionCompletedEvent.class,
+ CacheEntryInvalidatedEvent.class
+ };
+
+ final Map<Class<? extends Annotation>, List<ListenerInvocation>> listenersMap = new HashMap<Class<? extends Annotation>, List<ListenerInvocation>>(16, 0.99f);
+ final List<ListenerInvocation> cacheEntryCreatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryRemovedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryVisitedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryModifiedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryActivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryPassivatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryLoadedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryInvalidatedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> cacheEntryEvictedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> transactionRegisteredListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+ final List<ListenerInvocation> transactionCompletedListeners = new CopyOnWriteArrayList<ListenerInvocation>();
+
+ private Cache cache;
+ // two separate executor services, one for sync and one for async listeners
+ private ExecutorService syncProcessor;
+ private ExecutorService asyncProcessor;
+
+ public CacheNotifierImpl() {
+ listenersMap.put(CacheEntryCreated.class, cacheEntryCreatedListeners);
+ listenersMap.put(CacheEntryRemoved.class, cacheEntryRemovedListeners);
+ listenersMap.put(CacheEntryVisited.class, cacheEntryVisitedListeners);
+ listenersMap.put(CacheEntryModified.class, cacheEntryModifiedListeners);
+ listenersMap.put(CacheEntryActivated.class, cacheEntryActivatedListeners);
+ listenersMap.put(CacheEntryPassivated.class, cacheEntryPassivatedListeners);
+ listenersMap.put(CacheEntryLoaded.class, cacheEntryLoadedListeners);
+ listenersMap.put(CacheEntryEvicted.class, cacheEntryEvictedListeners);
+ listenersMap.put(TransactionRegistered.class, transactionRegisteredListeners);
+ listenersMap.put(TransactionCompleted.class, transactionCompletedListeners);
+ listenersMap.put(CacheEntryInvalidated.class, cacheEntryInvalidatedListeners);
+ }
+
+ @Inject
+ void injectDependencies(CacheSPI cache,
+ @ComponentName(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR) ExecutorService executor) {
+ this.cache = cache;
+ this.asyncProcessor = executor;
+ }
+
+ @Stop
+ void stop() {
+ syncProcessor.shutdownNow();
+ asyncProcessor.shutdownNow();
+ }
+
+ @Destroy
+ void destroy() {
+ removeAllCacheListeners();
+ }
+
+ @Start
+ void start() {
+ syncProcessor = new WithinThreadExecutor();
+ }
+
+ /**
+ * Loops through all valid methods on the object passed in, and caches the relevant methods as {@link
+ * CacheNotifierImpl.ListenerInvocation} for invocation by reflection.
+ *
+ * @param listener object to be considered as a listener.
+ */
+ @SuppressWarnings("unchecked")
+ private void validateAndAddListenerInvocation(Object listener) {
+ boolean sync = testListenerClassValidity(listener.getClass());
+
+ boolean foundMethods = false;
+ // now try all methods on the listener for anything that we like. Note that only PUBLIC methods are scanned.
+ for (Method m : listener.getClass().getMethods()) {
+ // loop through all valid method annotations
+ for (int i = 0; i < allowedMethodAnnotations.length; i++) {
+ if (m.isAnnotationPresent(allowedMethodAnnotations[i])) {
+ testListenerMethodValidity(m, parameterTypes[i], allowedMethodAnnotations[i].getName());
+ addListenerInvocation(allowedMethodAnnotations[i], new ListenerInvocation(listener, m, sync));
+ foundMethods = true;
+ }
+ }
+ }
+
+ if (!foundMethods && log.isWarnEnabled())
+ log.warn("Attempted to register listener of class " + listener.getClass() + ", but no valid, public methods annotated with method-level event annotations found! Ignoring listener.");
+ }
+
+ /**
+ * Tests if a class is properly annotated as a CacheListener and returns whether callbacks on this class should be
+ * invoked synchronously or asynchronously.
+ *
+ * @param listenerClass class to inspect
+ * @return true if callbacks on this class should use the syncProcessor; false if it should use the asyncProcessor.
+ */
+ private static boolean testListenerClassValidity(Class<?> listenerClass) {
+ Listener l = ReflectionUtil.getAnnotation(listenerClass, Listener.class);
+ if (l == null)
+ throw new IncorrectListenerException("Cache listener class MUST be annotated with org.horizon.notifications.annotation.Listener");
+ if (!Modifier.isPublic(listenerClass.getModifiers()))
+ throw new IncorrectListenerException("Cache listener class MUST be public!");
+ return l.sync();
+ }
+
+ private static void testListenerMethodValidity(Method m, Class allowedParameter, String annotationName) {
+ if (m.getParameterTypes().length != 1 || !m.getParameterTypes()[0].isAssignableFrom(allowedParameter))
+ throw new IncorrectListenerException("Methods annotated with " + annotationName + " must accept exactly one parameter, of assignable from type " + allowedParameter.getName());
+ if (!m.getReturnType().equals(void.class))
+ throw new IncorrectListenerException("Methods annotated with " + annotationName + " should have a return type of void.");
+ }
+
+ private void addListenerInvocation(Class annotation, ListenerInvocation li) {
+ List<ListenerInvocation> result = getListenerCollectionForAnnotation(annotation);
+ result.add(li);
+ }
+
+ public void addListener(Object listener) {
+ validateAndAddListenerInvocation(listener);
+ }
+
+ public void removeListener(Object listener) {
+ for (Class annotation : allowedMethodAnnotations) removeListenerInvocation(annotation, listener);
+ }
+
+ private void removeListenerInvocation(Class annotation, Object listener) {
+ if (listener == null) return;
+ List<ListenerInvocation> l = getListenerCollectionForAnnotation(annotation);
+ Set<Object> markedForRemoval = new HashSet<Object>();
+ for (ListenerInvocation li : l) {
+ if (listener.equals(li.target)) markedForRemoval.add(li);
+ }
+ l.removeAll(markedForRemoval);
+ }
+
+ /**
+ * Removes all listeners from the notifier, including the evictionPolicyListener.
+ */
+ @Stop(priority = 99)
+ public void removeAllCacheListeners() {
+ cacheEntryCreatedListeners.clear();
+ cacheEntryRemovedListeners.clear();
+ cacheEntryVisitedListeners.clear();
+ cacheEntryModifiedListeners.clear();
+ cacheEntryActivatedListeners.clear();
+ cacheEntryPassivatedListeners.clear();
+ cacheEntryLoadedListeners.clear();
+ cacheEntryEvictedListeners.clear();
+ transactionRegisteredListeners.clear();
+ transactionCompletedListeners.clear();
+ }
+
+ public Set<Object> getListeners() {
+ Set<Object> result = new HashSet<Object>();
+ for (List<ListenerInvocation> list : listenersMap.values()) {
+ for (ListenerInvocation li : list) result.add(li.target);
+ }
+ return Collections.unmodifiableSet(result);
+ }
+
+ public void notifyCacheEntryCreated(Object key, boolean pre, InvocationContext ctx) {
+ if (!cacheEntryCreatedListeners.isEmpty()) {
+ boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_CREATED);
+ for (ListenerInvocation listener : cacheEntryCreatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryModified(Object key, Object value, boolean pre, InvocationContext ctx) {
+ if (!cacheEntryModifiedListeners.isEmpty()) {
+ boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setValue(value);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_MODIFIED);
+ for (ListenerInvocation listener : cacheEntryModifiedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryRemoved(Object key, Object value, boolean pre, InvocationContext ctx) {
+ if (!cacheEntryRemovedListeners.isEmpty()) {
+ boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setValue(value);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_REMOVED);
+ for (ListenerInvocation listener : cacheEntryRemovedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryVisited(Object key, boolean pre, InvocationContext ctx) {
+ if (!cacheEntryVisitedListeners.isEmpty()) {
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_VISITED);
+ for (ListenerInvocation listener : cacheEntryVisitedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryEvicted(final Object key, final boolean pre, InvocationContext ctx) {
+ if (!cacheEntryEvictedListeners.isEmpty()) {
+ final boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_EVICTED);
+ for (ListenerInvocation listener : cacheEntryEvictedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryInvalidated(final Object key, final boolean pre, InvocationContext ctx) {
+ if (!cacheEntryInvalidatedListeners.isEmpty()) {
+ final boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_INVALIDATED);
+ for (ListenerInvocation listener : cacheEntryInvalidatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryLoaded(Object key, boolean pre, InvocationContext ctx) {
+ if (!cacheEntryLoadedListeners.isEmpty()) {
+ boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_LOADED);
+ for (ListenerInvocation listener : cacheEntryLoadedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryActivated(Object key, boolean pre, InvocationContext ctx) {
+ if (!cacheEntryActivatedListeners.isEmpty()) {
+ boolean originLocal = ctx.isOriginLocal();
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(originLocal);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_ACTIVATED);
+ for (ListenerInvocation listener : cacheEntryActivatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyCacheEntryPassivated(Object key, boolean pre, InvocationContext ctx) {
+ if (!cacheEntryPassivatedListeners.isEmpty()) {
+ Transaction tx = ctx.getTransaction();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setPre(pre);
+ e.setKey(key);
+ e.setTransaction(tx);
+ e.setType(CACHE_ENTRY_PASSIVATED);
+ for (ListenerInvocation listener : cacheEntryPassivatedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyTransactionCompleted(Transaction transaction, boolean successful, InvocationContext ctx) {
+ if (!transactionCompletedListeners.isEmpty()) {
+ boolean isOriginLocal = ctx.isOriginLocal();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(isOriginLocal);
+ e.setTransaction(transaction);
+ e.setTransactionSuccessful(successful);
+ e.setType(TRANSACTION_COMPLETED);
+ for (ListenerInvocation listener : transactionCompletedListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ public void notifyTransactionRegistered(Transaction transaction, InvocationContext ctx) {
+ if (!transactionRegisteredListeners.isEmpty()) {
+ boolean isOriginLocal = ctx.isOriginLocal();
+ InvocationContext backup = resetInvocationContext(ctx);
+ EventImpl e = new EventImpl();
+ e.setCache(cache);
+ e.setOriginLocal(isOriginLocal);
+ e.setTransaction(transaction);
+ e.setType(TRANSACTION_REGISTERED);
+ for (ListenerInvocation listener : transactionRegisteredListeners) listener.invoke(e);
+ restoreInvocationContext(backup);
+ }
+ }
+
+ private void restoreInvocationContext(InvocationContext backup) {
+ InvocationContext currentIC = cache.getInvocationContext();
+ backup.clearLookedUpEntries();
+ backup.putLookedUpEntries(currentIC.getLookedUpEntries());
+ cache.setInvocationContext(backup);
+ }
+
+ /**
+ * Resets the current (passed-in) invocation, and returns a temp InvocationContext containing its state so it can be
+ * restored later using {@link #restoreInvocationContext(InvocationContext)}
+ *
+ * @param ctx the current context to be reset
+ * @return a clone of ctx, before it was reset
+ */
+ private InvocationContext resetInvocationContext(InvocationContext ctx) {
+ // wipe current context.
+ cache.setInvocationContext(null);
+ // get a new Invocation Context
+ InvocationContext newContext = cache.getInvocationContext();
+ newContext.putLookedUpEntries(ctx.getLookedUpEntries());
+ return ctx;
+ }
+
+ /**
+ * Class that encapsulates a valid invocation for a given registered listener - containing a reference to the method
+ * to be invoked as well as the target object.
+ */
+ class ListenerInvocation {
+ private final Object target;
+ private final Method method;
+ private final boolean sync;
+
+ public ListenerInvocation(Object target, Method method, boolean sync) {
+ this.target = target;
+ this.method = method;
+ this.sync = sync;
+ }
+
+ public void invoke(final Event e) {
+ Runnable r = new Runnable() {
+
+ public void run() {
+ try {
+ method.invoke(target, e);
+ }
+ catch (InvocationTargetException exception) {
+ Throwable cause = exception.getCause();
+ if (cause != null)
+ throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, cause);
+ else
+ throw new CacheException("Caught exception invoking method " + method + " on listener instance " + target, exception);
+ }
+ catch (IllegalAccessException exception) {
+ log.warn("Unable to invoke method " + method + " on Object instance " + target + " - removing this target object from list of listeners!", exception);
+ removeListener(target);
+ }
+ }
+ };
+
+ if (sync)
+ syncProcessor.execute(r);
+ else
+ asyncProcessor.execute(r);
+ }
+ }
+
+ private List<ListenerInvocation> getListenerCollectionForAnnotation(Class<? extends Annotation> annotation) {
+ List<ListenerInvocation> list = listenersMap.get(annotation);
+ if (list == null) throw new CacheException("Unknown listener annotation: " + annotation);
+ return list;
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/CacheNotifierImpl.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation (from rev 7607, core/branches/flat/src/main/java/org/horizon/notifications/annotation)
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryActivated.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryActivated.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryActivated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is activated.
- * <p/>
- * Methods annotated with this annotation should be public and take in a single parameter, a {@link
- * org.horizon.notifications.event.NodeActivatedEvent} otherwise an {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your cache listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @see org.horizon.notifications.annotation.NodePassivated
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryActivated {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryActivated.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryActivated.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryActivated.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryActivated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is activated.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryActivatedEvent} otherwise an {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @see CacheEntryPassivated
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryActivated {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryCreated.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryCreated.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryCreated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is created.
- * <p/>
- * Methods annotated with this annotation should be public and take in a single parameter, a {@link
- * org.horizon.notifications.event.NodeCreatedEvent} otherwise an {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your cache listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryCreated {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryCreated.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryCreated.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryCreated.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryCreated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is created.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryCreatedEvent} otherwise an {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryCreated {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryEvicted.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryEvicted.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryEvicted.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is evicted.
- * <p/>
- * Methods annotated with this annotation should be public and take in a single parameter, a {@link
- * org.horizon.notifications.event.NodeEvictedEvent} otherwise an {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your cache listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @see org.horizon.notifications.annotation.NodeLoaded
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryEvicted {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryEvicted.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryEvicted.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryEvicted.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryEvicted.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is evicted.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryEvictedEvent} otherwise an {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @see CacheEntryLoaded
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryEvicted {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryInvalidated.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryInvalidated.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryInvalidated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is invalidated.
- * <p/>
- * Methods annotated with this annotation should be public and take in a single parameter, a {@link
- * org.horizon.notifications.event.NodeInvalidatedEvent} otherwise an {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your cache listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryInvalidated {
-}
\ No newline at end of file
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryInvalidated.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryInvalidated.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryInvalidated.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryInvalidated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is invalidated.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryInvalidatedEvent} otherwise an {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryInvalidated {
+}
\ No newline at end of file
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryLoaded.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryLoaded.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryLoaded.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is loaded from a {@link
- * org.horizon.loader.CacheLoader}.
- * <p/>
- * Methods annotated with this annotation should be public and take in a single parameter, a {@link
- * org.horizon.notifications.event.NodeEvictedEvent} otherwise an {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your cache listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryLoaded {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryLoaded.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryLoaded.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryLoaded.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryLoaded.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is loaded from a {@link
+ * org.horizon.loader.CacheLoader}.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryLoadedEvent} otherwise an {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your cache listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryLoaded {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryModified.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryModified.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryModified.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node has been modified.
- * <p/>
- * Methods annotated with this annotation should be public and take in a single parameter, a {@link
- * org.horizon.notifications.event.NodeModifiedEvent} otherwise an {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your cache listener.
- * <p/>
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryModified {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryModified.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryModified.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryModified.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryModified.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry has been modified.
+ * <p/>
+ * Methods annotated with this annotation should be public and take in a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryModifiedEvent} otherwise an {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your cache listener.
+ * <p/>
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryModified {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryPassivated.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryPassivated.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryPassivated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is passivated.
- * <p/>
- * Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.NodePassivatedEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-// ensure this annotation is available at runtime.
-(a)Retention(RetentionPolicy.RUNTIME)
-// ensure that this annotation is applied to classes.
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryPassivated {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryPassivated.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryPassivated.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryPassivated.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryPassivated.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is passivated.
+ * <p/>
+ * Methods annotated with this annotation should accept a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryPassivatedEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryPassivated {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryRemoved.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryRemoved.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryRemoved.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is removed from the cache.
- * <p/>
- * Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.TransactionRegisteredEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-// ensure this annotation is available at runtime.
-(a)Retention(RetentionPolicy.RUNTIME)
-// ensure that this annotation is applied to classes.
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryRemoved {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryRemoved.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryRemoved.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryRemoved.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryRemoved.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is removed from the cache.
+ * <p/>
+ * Methods annotated with this annotation should accept a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryRemovedEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryRemoved {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryVisited.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryVisited.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryVisited.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a node is visited.
- * <p/>
- * Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.NodeVisitedEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-// ensure this annotation is available at runtime.
-(a)Retention(RetentionPolicy.RUNTIME)
-// ensure that this annotation is applied to classes.
-(a)Target(ElementType.METHOD)
-public @interface CacheEntryVisited {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryVisited.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheEntryVisited.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryVisited.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheEntryVisited.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache entry is visited.
+ * <p/>
+ * Methods annotated with this annotation should accept a single parameter, a {@link
+ * org.horizon.notifications.cachelistener.event.CacheEntryVisitedEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface CacheEntryVisited {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheStarted.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheStarted.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheStarted.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a cache is started.
- * <p/>
- * Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.CacheStartedEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheStarted {
-}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheStopped.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/CacheStopped.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/CacheStopped.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,43 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when a cache is stopped.
- * <p/>
- * Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.CacheStoppedEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.METHOD)
-public @interface CacheStopped {
-}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/Listener.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/Listener.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/Listener.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,239 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Class-level annotation used to annotate an object as being a valid cache listener. Used with the {@link
- * org.horizon.Cache_Legacy#addCacheListener(Object)} and related APIs. <p/> Note that even if a class is annotated with
- * this annotation, it still needs method-level annotation (such as {@link org.horizon.notifications.annotation.CacheStarted})
- * to actually receive notifications. <p/> Objects annotated with this annotation - listeners - can be attached to a
- * running {@link org.horizon.Cache_Legacy} so users can be notified of {@link org.horizon.Cache_Legacy} events. <p/>
- * <p/> There can be multiple methods that are annotated to receive the same event, and a method may receive multiple
- * events by using a super type. </p> <p/> <h4>Delivery Semantics</h4> <p/> An event is delivered immediately after the
- * respective operation, but before the underlying cache call returns. For this reason it is important to keep listener
- * processing logic short-lived. If a long running task needs to be performed, it's recommended to use another thread.
- * </p> <p/> <h4>Transactional Semantics</h4> <p/> Since the event is delivered during the actual cache call, the
- * transactional outcome is not yet known. For this reason, <i>events are always delivered, even if the changes they
- * represent are discarded by their containing transaction</i>. For applications that must only process events that
- * represent changes in a completed transaction, {@link org.horizon.notifications.event.TransactionalEvent#getTransaction()}
- * can be used, along with {@link org.horizon.notifications.event.TransactionCompletedEvent#isSuccessful()} to record
- * events and later process them once the transaction has been successfully committed. Example 4 demonstrates this. </p>
- * <p/> <h4>Threading Semantics</h4> <p/> A listener implementation must be capable of handling concurrent invocations.
- * Local notifications reuse the calling thread; remote notifications reuse the network thread. </p> <p/> Since
- * notifications reuse the calling or network thread, it is important to realise that if your listener implementation
- * blocks or performs a long-running task, the original caller which triggered the cache event may block until the
- * listener callback completes. It is therefore a good idea to use the listener to be notified of an event but to
- * perform any long running tasks in a separate thread so as not to block the original caller. </p> <p/> In addition,
- * any locks acquired for the operation being performed will still be held for the callback. This needs to be kept in
- * mind as locks may be held longer than necessary or intended to and may cause deadlocking in certain situations. See
- * above paragraph on long-running tasks that should be run in a separate thread. </p> <b>Note</b>: Since 3.0, a new
- * parameter, <tt>sync</tt>, has been introduced on this annotation. This defaults to <tt>true</tt> which provides the
- * above semantics. Alternatively, if you set <tt>sync</tt> to <tt>false</tt>, then invocations are made in a
- * <i>separate</i> thread, which will not cause any blocking on the caller or network thread. The separate thread is
- * taken from a pool, which can be configured using {@link org.horizon.config.Configuration#setListenerAsyncPoolSize(int)}.
- * <p/>
- * <b>Summary of Notification Annotations</b> <table border="1" cellpadding="1" cellspacing="1" summary="Summary of
- * notification annotations"> <tr> <th bgcolor="#CCCCFF" align="left">Annotation</th> <th bgcolor="#CCCCFF"
- * align="left">Event</th> <th bgcolor="#CCCCFF" align="left">Description</th> </tr> <tr> <td valign="top">{@link
- * CacheStarted}</td> <td valign="top">{@link org.horizon.notifications.event.CacheStartedEvent}</td> <td valign="top">A
- * cache was started</td> </tr> <tr> <td valign="top">{@link CacheStopped}</td> <td valign="top">{@link
- * org.horizon.notifications.event.CacheStoppedEvent}</td> <td valign="top">A cache was stopped</td> </tr> <tr> <td
- * valign="top">{@link CacheEntryModified}</td> <td valign="top">{@link org.horizon.notifications.event.NodeModifiedEvent}</td>
- * <td valign="top">A node was modified</td> </tr> <tr> <td valign="top">{@link NodeMoved}</td> <td valign="top">{@link
- * org.horizon.notifications.event.NodeMovedEvent}</td> <td valign="top">A node was moved</td> </tr> <tr> <td
- * valign="top">{@link CacheEntryCreated}</td> <td valign="top">{@link org.horizon.notifications.event.NodeCreatedEvent}</td>
- * <td valign="top">A node was created</td> </tr> <tr> <td valign="top">{@link CacheEntryRemoved}</td> <td
- * valign="top">{@link org.horizon.notifications.event.NodeRemovedEvent}</td> <td valign="top">A node was removed</td>
- * </tr> <tr> <td valign="top">{@link CacheEntryVisited}</td> <td valign="top">{@link
- * org.horizon.notifications.event.NodeVisitedEvent}</td> <td valign="top">A node was visited</td> </tr> <tr> <td
- * valign="top">{@link CacheEntryLoaded}</td> <td valign="top">{@link org.horizon.notifications.event.NodeLoadedEvent}</td>
- * <td valign="top">A node was loaded</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.annotation.NodeEvicted}</td>
- * <td valign="top">{@link org.horizon.notifications.event.NodeEvictedEvent}</td> <td valign="top">A node was
- * evicted</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.annotation.NodeActivated}</td> <td
- * valign="top">{@link org.horizon.notifications.event.NodeActivatedEvent}</td> <td valign="top">A node was
- * activated</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.annotation.NodePassivated}</td> <td
- * valign="top">{@link org.horizon.notifications.event.NodePassivatedEvent}</td> <td valign="top">A node was
- * passivated</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.annotation.ViewChanged}</td> <td
- * valign="top">{@link org.horizon.notifications.event.ViewChangedEvent}</td> <td valign="top">A view change event was
- * detected</td> </tr> <tr> <td valign="top">{@link org.horizon.notifications.annotation.CacheBlocked}</td> <td
- * valign="top">{@link org.horizon.notifications.event.CacheBlockedEvent}</td> <td valign="top">A cache block event was
- * detected</td> </tr> <tr> <td valign="top">{@link CacheUnblocked}</td> <td valign="top">{@link
- * org.horizon.notifications.event.CacheUnblockedEvent}</td> <td valign="top">A cache unblock event was detected</td>
- * </tr> <tr> <td valign="top">{@link TransactionRegistered}</td> <td valign@="top">{@link
- * org.horizon.notifications.event.TransactionRegisteredEvent}</td> <td valign="top">The cache has started to
- * participate in a transaction</td> </tr> <tr> <td valign="top">{@link TransactionCompleted}</td> <td
- * valign=@"top">{@link org.horizon.notifications.event.TransactionCompletedEvent}</td> <td valign="top">The cache has
- * completed its participation in a transaction</td> </tr> <tr> <td valign="top">{@link BuddyGroupChanged}</td> <td
- * valign=@"top">{@link org.horizon.notifications.event.BuddyGroupChangedEvent}</td> <td valign="top">Buddy replication
- * is enabled and one of the buddy groups that the instance is a member of has changed its membership.</td> </tr> <tr>
- * <td valign="top">{@link CacheEntryInvalidated}</td> <td valign=@"top">{@link org.horizon.notifications.event.NodeInvalidatedEvent}</td>
- * <td valign="top">A node was invalidated by a remote cache. Only if cache mode is INVALIDATION_SYNC or
- * INVALIDATION_ASYNC.</td> </tr>
- * <p/>
- * </table>
- * <p/>
- * <h4>Example 1 - Method receiving a single event</h4>
- * <pre>
- * @CacheListener
- * public class SingleEventListener
- * {
- * @CacheStarted
- * public void doSomething(Event event)
- * {
- * System.out.println("Cache started. Details = " + event);
- * }
- * }
- * </pre>
- * <p/>
- * <h4>Example 2 - Method receiving multiple events</h4>
- * <pre>
- * @CacheListener
- * public class MultipleEventListener
- * {
- * @CacheStarted
- * @CacheStopped
- * public void doSomething(Event event)
- * {
- * if (event.getType() == Event.Type.CACHE_STARTED)
- * System.out.println("Cache started. Details = " + event);
- * else if (event.getType() == Event.Type.CACHE_STOPPED)
- * System.out.println("Cache stopped. Details = " + event);
- * }
- * }
- * </pre>
- * <p/>
- * <h4>Example 3 - Multiple methods receiving the same event</h4>
- * <pre>
- * @CAcheListener
- * public class SingleEventListener
- * {
- * @CacheStarted
- * public void handleStart(Event event)
- * {
- * System.out.println("Cache started");
- * }
- * <p/>
- * @CacheStarted
- * @CacheStopped
- * @CacheBlocked
- * @CacheUnblocked
- * @ViewChanged
- * public void logEvent(Event event)
- * {
- * logSystem.logEvent(event.getType());
- * }
- * }
- * </pre>
- * <p/>
- * <p/>
- * <b>Example 4 - Processing only events with a committed transaction.</b>
- * <p/>
- * <pre>
- * @CacheListener
- * public class TxGuaranteedListener
- * {
- * private class TxEventQueue
- * {
- * private ConcurrentMap<Transaction, Queue<Event>> map = new ConcurrentHashMap<Transaction,
- * Queue<Event>>();
- * <p/>
- * public void offer(Event event)
- * {
- * Queue<Event> queue = getQueue(event.getContext().getTransaction());
- * queue.offer(event);
- * }
- * <p/>
- * private Queue<Event> getQueue(Transaction transaction)
- * {
- * Queue<Event> queue = map.get(transaction);
- * if (queue == null)
- * {
- * queue = new ConcurrentLinkedQueue<Event>();
- * map.putIfAbsent(transaction, queue);
- * }
- * <p/>
- * return queue;
- * }
- * <p/>
- * public Queue<Event> takeAll(Transaction transaction)
- * {
- * return map.remove(transaction);
- * }
- * }
- * <p/>
- * private TxEventQueue events = new TxEventQueue();
- * <p/>
- * @NodeModified
- * @NodeMoved
- * @NodeCreated
- * @NodeRemoved
- * public void handle(Event event)
- * {
- * events.offer(event);
- * }
- * <p/>
- * @TransactionCompleted
- * public void handleTx(TransactionCompletedEvent event)
- * {
- * Queue<Event> completed = events.takeAll(event.getTransaction());
- * if (completed != null && event.isSuccessful())
- * System.out.println("Comitted events = " + completed);
- * }
- * }
- * </pre>
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @author Jason T. Greene
- * @see CacheStarted
- * @see CacheStopped
- * @see CacheEntryModified
- * @see CacheEntryCreated
- * @see CacheEntryRemoved
- * @see CacheEntryVisited
- * @see CacheEntryLoaded
- * @see CacheEntryEvicted
- * @see CacheEntryActivated
- * @see CacheEntryPassivated
- * @see ViewChanged
- * @see TransactionCompleted
- * @see TransactionRegistered
- * @see CacheEntryInvalidated
- * @since 1.0
- */
-(a)Retention(RetentionPolicy.RUNTIME)
-(a)Target(ElementType.TYPE)
-public @interface Listener {
- /**
- * Specifies whether callbacks on any class annotated with this annotation happens synchronously (in the caller's
- * thread) or asynchronously (using a separate thread). Defaults to <tt>true</tt>.
- *
- * @return true if the expectation is that callbacks are called using the caller's thread; false if they are to be
- * made in a separate thread.
- * @since 1.0
- */
- boolean sync() default true;
-}
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/TransactionCompleted.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/TransactionCompleted.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/TransactionCompleted.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.horizon.notifications.annotation;
+package org.horizon.notifications.cachelistener.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -31,14 +31,14 @@
* transaction and the transaction completes, either with a commit or a rollback.
* <p/>
* Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.TransactionCompletedEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
+ * org.horizon.notifications.cachelistener.event.TransactionCompletedEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
* <p/>
* Note that methods marked with this annotation will only be fired <i>after the fact</i>, i.e., your method will never
- * be called with {@link org.horizon.notifications.event.Event#isPre()} being set to <tt>true</tt>.
+ * be called with {@link org.horizon.notifications.cachelistener.event.Event#isPre()} being set to <tt>true</tt>.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
+ * @see org.horizon.notifications.Listener
* @since 1.0
*/
// ensure this annotation is available at runtime.
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/TransactionRegistered.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/TransactionRegistered.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/TransactionRegistered.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.horizon.notifications.annotation;
+package org.horizon.notifications.cachelistener.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
@@ -32,14 +32,14 @@
* javax.transaction.TransactionManager}.
* <p/>
* Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.TransactionRegisteredEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
+ * org.horizon.notifications.cachelistener.event.TransactionRegisteredEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
* <p/>
* Note that methods marked with this annotation will only be fired <i>after the fact</i>, i.e., your method will never
- * be called with {@link org.horizon.notifications.event.Event#isPre()} being set to <tt>true</tt>.
+ * be called with {@link org.horizon.notifications.cachelistener.event.Event#isPre()} being set to <tt>true</tt>.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
+ * @see org.horizon.notifications.Listener
* @since 1.0
*/
// ensure this annotation is available at runtime.
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/ViewChanged.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/annotation/ViewChanged.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/annotation/ViewChanged.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * This annotation should be used on methods that need to be notified when the cache is used in a cluster and the
- * cluster topology changes (i.e., a member joins or leaves the cluster).
- * <p/>
- * Methods annotated with this annotation should accept a single parameter, a {@link
- * org.horizon.notifications.event.ViewChangedEvent} otherwise a {@link org.horizon.notifications.IncorrectCacheListenerException}
- * will be thrown when registering your listener.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @see Listener
- * @since 1.0
- */
-// ensure this annotation is available at runtime.
-(a)Retention(RetentionPolicy.RUNTIME)
-// ensure that this annotation is applied to classes.
-(a)Target(ElementType.METHOD)
-public @interface ViewChanged {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event (from rev 7607, core/branches/flat/src/main/java/org/horizon/notifications/event)
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryActivatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryActivatedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryActivatedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodeActivated}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryActivatedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryActivatedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryActivatedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryActivatedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryActivatedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryActivated}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryActivatedEvent extends CacheEntryEvent {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryCreatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryCreatedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryCreatedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodeCreated}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryCreatedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryCreatedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryCreatedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryCreatedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryCreatedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryCreated}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryCreatedEvent extends CacheEntryEvent {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,35 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * Transactional events that additionally expose an Fqn as such events pertain to a specific node.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryEvent extends TransactionalEvent {
- /**
- * @return the Fqn pointing to the node that is affected.
- */
- Object getKey();
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvent.java (from rev 7617, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * Transactional events that additionally expose a key as such events pertain to a specific cache entry.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryEvent extends TransactionalEvent {
+ /**
+ * @return the key to the affected cache entry.
+ */
+ Object getKey();
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvictedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvictedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvictedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodeEvicted}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryEvictedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvictedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvictedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvictedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryEvictedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryEvicted}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryEvictedEvent extends CacheEntryEvent {
+}
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryInvalidatedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryInvalidatedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.horizon.notifications.event;
+package org.horizon.notifications.cachelistener.event;
/**
* Notifies a listener of an invalidation event
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryLoadedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryLoadedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryLoadedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodeLoaded}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryLoadedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryLoadedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryLoadedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryLoadedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryLoadedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryLoaded}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryLoadedEvent extends CacheEntryEvent {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryModifiedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryModifiedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryModifiedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodeModified}
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryModifiedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryModifiedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryModifiedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryModifiedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryModifiedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryModified}
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryModifiedEvent extends CacheEntryEvent {
+ Object getValue();
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryPassivatedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryPassivatedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryPassivatedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodePassivated}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryPassivatedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryPassivatedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryPassivatedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryPassivatedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryPassivatedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryPassivated}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryPassivatedEvent extends CacheEntryEvent {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryRemovedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryRemovedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryRemovedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodeRemoved}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryRemovedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryRemovedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryRemovedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryRemovedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryRemovedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryRemovedEvent extends CacheEntryEvent {
+ Object getValue();
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryVisitedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryVisitedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryVisitedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.NodeVisited}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheEntryVisitedEvent extends CacheEntryEvent {
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryVisitedEvent.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryVisitedEvent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryVisitedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheEntryVisitedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,31 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.CacheEntryVisited}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheEntryVisitedEvent extends CacheEntryEvent {
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheStartedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheStartedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheStartedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.CacheStarted}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheStartedEvent extends Event {
-}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheStoppedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheStoppedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/CacheStoppedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.CacheStopped}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface CacheStoppedEvent extends Event {
-}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/Event.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/Event.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/Event.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,53 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-import org.horizon.Cache;
-
-/**
- * An interface that defines common characteristics of events
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface Event {
- static enum Type {
- CACHE_STARTED, CACHE_STOPPED, CACHE_ENTRY_ACTIVATED, CACHE_ENTRY_PASSIVATED, CACHE_ENTRY_VISITED,
- CACHE_ENTRY_LOADED, CACHE_ENTRY_EVICTED, CACHE_ENTRY_CREATED, CACHE_ENTRY_REMOVED, CACHE_ENTRY_MODIFIED,
- TRANSACTION_COMPLETED, TRANSACTION_REGISTERED, VIEW_CHANGED, BUDDY_GROUP_CHANGED, CACHE_ENTRY_INVALIDATED
- }
-
- /**
- * @return the type of event represented by this instance.
- */
- Type getType();
-
- /**
- * @return true if the notification is before the event has occured, false if after the event has occured.
- */
- boolean isPre();
-
- /**
- * @return a handle to the cache instance that generated this notification.
- */
- Cache getCache();
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/Event.java (from rev 7616, core/branches/flat/src/main/java/org/horizon/notifications/event/Event.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/Event.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/Event.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+import org.horizon.Cache;
+
+/**
+ * An interface that defines common characteristics of events
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface Event {
+ static enum Type {
+ CACHE_ENTRY_ACTIVATED, CACHE_ENTRY_PASSIVATED, CACHE_ENTRY_VISITED,
+ CACHE_ENTRY_LOADED, CACHE_ENTRY_EVICTED, CACHE_ENTRY_CREATED, CACHE_ENTRY_REMOVED, CACHE_ENTRY_MODIFIED,
+ TRANSACTION_COMPLETED, TRANSACTION_REGISTERED, CACHE_ENTRY_INVALIDATED
+ }
+
+ /**
+ * @return the type of event represented by this instance.
+ */
+ Type getType();
+
+ /**
+ * @return true if the notification is before the event has occured, false if after the event has occured.
+ */
+ boolean isPre();
+
+ /**
+ * @return a handle to the cache instance that generated this notification.
+ */
+ Cache getCache();
+}
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/EventImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/EventImpl.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/EventImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,193 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-import org.horizon.Cache;
-import org.horizon.remoting.transport.Address;
-import org.horizon.tree.Fqn;
-
-import javax.transaction.Transaction;
-import java.util.List;
-
-/**
- * Basic implementation of an event that covers all event types.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public class EventImpl implements CacheStartedEvent, CacheStoppedEvent,
- CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntryEvictedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent,
- CacheEntryPassivatedEvent, CacheEntryRemovedEvent, CacheEntryVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent,
- ViewChangedEvent, CacheEntryInvalidatedEvent {
- private boolean pre = false; // by default events are after the fact
- private Cache cache;
- private Object key;
- private Transaction transaction;
- private boolean originLocal = true; // by default events all originate locally
- private Fqn targetFqn;
- private boolean successful;
- private Type type;
- private List<Address> members;
- Address localAddress;
-
- public EventImpl(boolean pre, Cache cache, Object key, Transaction transaction, boolean originLocal, Fqn targetFqn, boolean successful, List<Address> members, Address localAddress, Type type) {
- this.pre = pre;
- this.cache = cache;
- this.key = key;
- this.transaction = transaction;
- this.originLocal = originLocal;
- this.targetFqn = targetFqn;
- this.successful = successful;
- this.type = type;
- this.members = members;
- this.localAddress = localAddress;
- }
-
- public EventImpl() {
- }
-
- public Type getType() {
- return type;
- }
-
- public boolean isPre() {
- return pre;
- }
-
- public Cache getCache() {
- return cache;
- }
-
- public Object getKey() {
- return key;
- }
-
- public Transaction getTransaction() {
- return transaction;
- }
-
- public boolean isOriginLocal() {
- return originLocal;
- }
-
- public Fqn getTargetFqn() {
- return targetFqn;
- }
-
- public boolean isSuccessful() {
- return successful;
- }
-
- // ------------------------------ setters -----------------------------
-
- public void setPre(boolean pre) {
- this.pre = pre;
- }
-
- public void setCache(Cache cache) {
- this.cache = cache;
- }
-
- public void setKey(Object key) {
- this.key = key;
- }
-
- public void setTransaction(Transaction transaction) {
- this.transaction = transaction;
- }
-
- public void setOriginLocal(boolean originLocal) {
- this.originLocal = originLocal;
- }
-
- public void setTargetFqn(Fqn targetFqn) {
- this.targetFqn = targetFqn;
- }
-
- public void setSuccessful(boolean successful) {
- this.successful = successful;
- }
-
- public void setType(Type type) {
- this.type = type;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
-
- EventImpl event = (EventImpl) o;
-
- if (originLocal != event.originLocal) return false;
- if (pre != event.pre) return false;
- if (successful != event.successful) return false;
- if (cache != null ? !cache.equals(event.cache) : event.cache != null) return false;
- if (key != null ? !key.equals(event.key) : event.key != null) return false;
- if (localAddress != null ? !localAddress.equals(event.localAddress) : event.localAddress != null) return false;
- if (members != null ? !members.equals(event.members) : event.members != null) return false;
- if (targetFqn != null ? !targetFqn.equals(event.targetFqn) : event.targetFqn != null) return false;
- if (transaction != null ? !transaction.equals(event.transaction) : event.transaction != null) return false;
- if (type != event.type) return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- int result = (pre ? 1 : 0);
- result = 31 * result + (cache != null ? cache.hashCode() : 0);
- result = 31 * result + (key != null ? key.hashCode() : 0);
- result = 31 * result + (transaction != null ? transaction.hashCode() : 0);
- result = 31 * result + (originLocal ? 1 : 0);
- result = 31 * result + (targetFqn != null ? targetFqn.hashCode() : 0);
- result = 31 * result + (successful ? 1 : 0);
- result = 31 * result + (type != null ? type.hashCode() : 0);
- result = 31 * result + (members != null ? members.hashCode() : 0);
- result = 31 * result + (localAddress != null ? localAddress.hashCode() : 0);
- return result;
- }
-
- @Override
- public String toString() {
- return "EventImpl{" +
- "type=" + type +
- ",pre=" + pre +
- ", cache=" + cache +
- ", key=" + key +
- ", transaction=" + transaction +
- ", originLocal=" + originLocal +
- ", targetFqn=" + targetFqn +
- ", successful=" + successful +
- ", members=" + members +
- ", localAddress=" + localAddress +
- '}';
- }
-
- public List<Address> getNewMemberList() {
- return members;
- }
-
- public Address getLocalAddress() {
- return localAddress;
- }
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/EventImpl.java (from rev 7617, core/branches/flat/src/main/java/org/horizon/notifications/event/EventImpl.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/EventImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/EventImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachelistener.event;
+
+import org.horizon.Cache;
+
+import javax.transaction.Transaction;
+
+/**
+ * Basic implementation of an event that covers all event types.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public class EventImpl implements CacheEntryActivatedEvent, CacheEntryCreatedEvent, CacheEntryEvictedEvent, CacheEntryLoadedEvent, CacheEntryModifiedEvent,
+ CacheEntryPassivatedEvent, CacheEntryRemovedEvent, CacheEntryVisitedEvent, TransactionCompletedEvent, TransactionRegisteredEvent,
+ CacheEntryInvalidatedEvent {
+ private boolean pre = false; // by default events are after the fact
+ private Cache cache;
+ private Object key;
+ private Transaction transaction;
+ private boolean originLocal = true; // by default events all originate locally
+ private boolean transactionSuccessful;
+ private Type type;
+ private Object value;
+
+ public EventImpl(boolean pre, Cache cache, Object key, Transaction transaction, boolean originLocal, boolean successful, Type type, Object value) {
+ this.pre = pre;
+ this.cache = cache;
+ this.key = key;
+ this.transaction = transaction;
+ this.originLocal = originLocal;
+ this.transactionSuccessful = successful;
+ this.type = type;
+ this.value = value;
+ }
+
+ public EventImpl() {
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public boolean isPre() {
+ return pre;
+ }
+
+ public Cache getCache() {
+ return cache;
+ }
+
+ public Object getKey() {
+ return key;
+ }
+
+ public Transaction getTransaction() {
+ return transaction;
+ }
+
+ public boolean isOriginLocal() {
+ return originLocal;
+ }
+
+ public boolean isTransactionSuccessful() {
+ return transactionSuccessful;
+ }
+
+ // ------------------------------ setters -----------------------------
+
+ public void setPre(boolean pre) {
+ this.pre = pre;
+ }
+
+ public void setCache(Cache cache) {
+ this.cache = cache;
+ }
+
+ public void setKey(Object key) {
+ this.key = key;
+ }
+
+ public void setTransaction(Transaction transaction) {
+ this.transaction = transaction;
+ }
+
+ public void setOriginLocal(boolean originLocal) {
+ this.originLocal = originLocal;
+ }
+
+ public void setTransactionSuccessful(boolean transactionSuccessful) {
+ this.transactionSuccessful = transactionSuccessful;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EventImpl event = (EventImpl) o;
+
+ if (originLocal != event.originLocal) return false;
+ if (pre != event.pre) return false;
+ if (transactionSuccessful != event.transactionSuccessful) return false;
+ if (cache != null ? !cache.equals(event.cache) : event.cache != null) return false;
+ if (key != null ? !key.equals(event.key) : event.key != null) return false;
+ if (transaction != null ? !transaction.equals(event.transaction) : event.transaction != null) return false;
+ if (type != event.type) return false;
+ if (value != null ? !value.equals(event.value) : event.value != null) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (pre ? 1 : 0);
+ result = 31 * result + (cache != null ? cache.hashCode() : 0);
+ result = 31 * result + (key != null ? key.hashCode() : 0);
+ result = 31 * result + (transaction != null ? transaction.hashCode() : 0);
+ result = 31 * result + (originLocal ? 1 : 0);
+ result = 31 * result + (transactionSuccessful ? 1 : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (value != null ? value.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "EventImpl{" +
+ "pre=" + pre +
+ ", key=" + key +
+ ", transaction=" + transaction +
+ ", originLocal=" + originLocal +
+ ", transactionSuccessful=" + transactionSuccessful +
+ ", type=" + type +
+ ", value=" + value +
+ '}';
+ }
+}
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionCompletedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/TransactionCompletedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionCompletedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -19,10 +19,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.horizon.notifications.event;
+package org.horizon.notifications.cachelistener.event;
/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.TransactionCompleted}.
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.TransactionCompleted}.
* <p/>
* Note that this event is only delivered <i>after the fact</i>, i.e., you will never see an instance of this event with
* {@link #isPre()} being set to <tt>true</tt>.
@@ -35,5 +35,5 @@
* @return if <tt>true</tt>, the transaction completed by committing successfully. If <tt>false</tt>, the
* transaction completed with a rollback.
*/
- boolean isSuccessful();
+ boolean isTransactionSuccessful();
}
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionRegisteredEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/TransactionRegisteredEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionRegisteredEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -19,10 +19,10 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.horizon.notifications.event;
+package org.horizon.notifications.cachelistener.event;
/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.TransactionRegistered}.
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachelistener.annotation.TransactionRegistered}.
* <p/>
* Note that this event is only delivered <i>after the fact</i>, i.e., you will never see an instance of this event with
* {@link #isPre()} being set to <tt>true</tt>.
Modified: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionalEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/TransactionalEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/TransactionalEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
-package org.horizon.notifications.event;
+package org.horizon.notifications.cachelistener.event;
import javax.transaction.Transaction;
Deleted: core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/ViewChangedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/ViewChangedEvent.java 2009-01-28 18:27:32 UTC (rev 7607)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachelistener/event/ViewChangedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,41 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file 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.
- */
-package org.horizon.notifications.event;
-
-import org.horizon.remoting.transport.Address;
-
-import java.util.List;
-
-/**
- * This event is passed in to any method annotated with {@link org.horizon.notifications.annotation.ViewChanged}.
- *
- * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
- * @since 1.0
- */
-public interface ViewChangedEvent extends Event {
- /**
- * @return the new view associated with this view change.
- */
- List<Address> getNewMemberList();
-
- Address getLocalAddress();
-}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java (from rev 7607, core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifier.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifier.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,29 @@
+package org.horizon.notifications.cachemanagerlistener;
+
+import org.horizon.factories.annotations.NonVolatile;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+import org.horizon.notifications.Listenable;
+import org.horizon.remoting.transport.Address;
+
+import java.util.List;
+
+/**
+ * Notifications for the cache manager
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+@NonVolatile
+(a)Scope(Scopes.GLOBAL)
+public interface CacheManagerNotifier extends Listenable {
+ /**
+ * Notifies all registered listeners of a viewChange event. Note that viewChange notifications are ALWAYS sent
+ * immediately.
+ */
+ void notifyViewChange(List<Address> members, Address myAddress);
+
+ void notifyCacheStarted(String cacheName);
+
+ void notifyCacheStopped(String cacheName);
+}
Copied: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java (from rev 7607, core/branches/flat/src/main/java/org/horizon/notifications/CacheManagerNotifierImpl.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,39 @@
+package org.horizon.notifications.cachemanagerlistener;
+
+import org.horizon.remoting.transport.Address;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Global, shared notifications. Typically on the CacheManager. See
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public class CacheManagerNotifierImpl implements CacheManagerNotifier {
+
+ public void notifyViewChange(List<Address> members, Address myAddress) {
+ // TODO: Manik: Customise this generated block
+ }
+
+ public void notifyCacheStarted(String cacheName) {
+ // TODO: Manik: Customise this generated block
+ }
+
+ public void notifyCacheStopped(String cacheName) {
+ // TODO: Manik: Customise this generated block
+ }
+
+ public void addListener(Object listener) {
+ // TODO: Manik: Customise this generated block
+ }
+
+ public void removeListener(Object listener) {
+ // TODO: Manik: Customise this generated block
+ }
+
+ public Set<Object> getListeners() {
+ return null; // TODO: Manik: Customise this generated block
+ }
+}
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStarted.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStarted.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStarted.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachemanagerlistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache is started.
+ * <p/>
+ * Methods annotated with this annotation should accept a single parameter, a {@link
+ * org.horizon.notifications.cachemanagerlistener.event.CacheStartedEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheStarted {
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStarted.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStopped.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStopped.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStopped.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachemanagerlistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when a cache is stopped.
+ * <p/>
+ * Methods annotated with this annotation should accept a single parameter, a {@link
+ * org.horizon.notifications.cachemanagerlistener.event.CacheStoppedEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target(ElementType.METHOD)
+public @interface CacheStopped {
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/CacheStopped.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/ViewChanged.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/ViewChanged.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/ViewChanged.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachemanagerlistener.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation should be used on methods that need to be notified when the cache is used in a cluster and the
+ * cluster topology changes (i.e., a member joins or leaves the cluster).
+ * <p/>
+ * Methods annotated with this annotation should accept a single parameter, a {@link
+ * org.horizon.notifications.cachemanagerlistener.event.ViewChangedEvent} otherwise a {@link
+ * org.horizon.notifications.IncorrectListenerException} will be thrown when registering your listener.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @see org.horizon.notifications.Listener
+ * @since 1.0
+ */
+// ensure this annotation is available at runtime.
+(a)Retention(RetentionPolicy.RUNTIME)
+// ensure that this annotation is applied to classes.
+(a)Target(ElementType.METHOD)
+public @interface ViewChanged {
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/annotation/ViewChanged.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStartedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStartedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStartedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachemanagerlistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachemanagerlistener.annotation.CacheStarted}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheStartedEvent extends Event {
+ String getCacheName();
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStartedEvent.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStoppedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStoppedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStoppedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachemanagerlistener.event;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachemanagerlistener.annotation.CacheStopped}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface CacheStoppedEvent extends Event {
+ String getCacheName();
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/CacheStoppedEvent.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/Event.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/Event.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/Event.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,19 @@
+package org.horizon.notifications.cachemanagerlistener.event;
+
+import org.horizon.manager.CacheManager;
+
+/**
+ * Common characteristics of events that occur on a cache manager
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public interface Event {
+ public enum Type {
+ CACHE_STARTED, CACHE_STOPPED, VIEW_CHANGED
+ }
+
+ CacheManager getCacheManager();
+
+ Type getType();
+}
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/EventImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/EventImpl.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/EventImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,109 @@
+package org.horizon.notifications.cachemanagerlistener.event;
+
+import org.horizon.manager.CacheManager;
+import org.horizon.remoting.transport.Address;
+
+import java.util.List;
+
+/**
+ * Implementation of cache manager events
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public class EventImpl implements CacheStartedEvent, CacheStoppedEvent, ViewChangedEvent {
+
+ String cacheName;
+ CacheManager cacheManager;
+ Type type;
+ List<Address> newMemberList;
+ Address localAddress;
+
+ public EventImpl() {
+ }
+
+ public EventImpl(String cacheName, CacheManager cacheManager, Type type, List<Address> newMemberList, Address localAddress) {
+ this.cacheName = cacheName;
+ this.cacheManager = cacheManager;
+ this.type = type;
+ this.newMemberList = newMemberList;
+ this.localAddress = localAddress;
+ }
+
+ public String getCacheName() {
+ return cacheName;
+ }
+
+ public void setCacheName(String cacheName) {
+ this.cacheName = cacheName;
+ }
+
+ public CacheManager getCacheManager() {
+ return cacheManager;
+ }
+
+ public void setCacheManager(CacheManager cacheManager) {
+ this.cacheManager = cacheManager;
+ }
+
+ public Type getType() {
+ return type;
+ }
+
+ public void setType(Type type) {
+ this.type = type;
+ }
+
+ public List<Address> getNewMemberList() {
+ return newMemberList;
+ }
+
+ public void setNewMemberList(List<Address> newMemberList) {
+ this.newMemberList = newMemberList;
+ }
+
+ public Address getLocalAddress() {
+ return localAddress;
+ }
+
+ public void setLocalAddress(Address localAddress) {
+ this.localAddress = localAddress;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ EventImpl event = (EventImpl) o;
+
+ if (cacheManager != null ? !cacheManager.equals(event.cacheManager) : event.cacheManager != null) return false;
+ if (cacheName != null ? !cacheName.equals(event.cacheName) : event.cacheName != null) return false;
+ if (localAddress != null ? !localAddress.equals(event.localAddress) : event.localAddress != null) return false;
+ if (newMemberList != null ? !newMemberList.equals(event.newMemberList) : event.newMemberList != null)
+ return false;
+ if (type != event.type) return false;
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = cacheName != null ? cacheName.hashCode() : 0;
+ result = 31 * result + (cacheManager != null ? cacheManager.hashCode() : 0);
+ result = 31 * result + (type != null ? type.hashCode() : 0);
+ result = 31 * result + (newMemberList != null ? newMemberList.hashCode() : 0);
+ result = 31 * result + (localAddress != null ? localAddress.hashCode() : 0);
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "EventImpl{" +
+ "cacheName='" + cacheName + '\'' +
+ ", type=" + type +
+ ", newMemberList=" + newMemberList +
+ ", localAddress=" + localAddress +
+ '}';
+ }
+}
Added: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/ViewChangedEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/ViewChangedEvent.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/ViewChangedEvent.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2000 - 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.
+ */
+package org.horizon.notifications.cachemanagerlistener.event;
+
+import org.horizon.remoting.transport.Address;
+
+import java.util.List;
+
+/**
+ * This event is passed in to any method annotated with {@link org.horizon.notifications.cachemanagerlistener.annotation.ViewChanged}.
+ *
+ * @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
+ * @since 1.0
+ */
+public interface ViewChangedEvent extends Event {
+ /**
+ * @return the new view associated with this view change.
+ */
+ List<Address> getNewMemberList();
+
+ Address getLocalAddress();
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/notifications/cachemanagerlistener/event/ViewChangedEvent.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -11,7 +11,7 @@
import org.horizon.factories.annotations.Start;
import org.horizon.factories.annotations.Stop;
import org.horizon.marshall.Marshaller;
-import org.horizon.notifications.CacheManagerNotifier;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
import org.horizon.remoting.transport.Address;
import org.horizon.remoting.transport.Transport;
Modified: core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -14,6 +14,7 @@
import org.horizon.commands.CommandsFactory;
import org.horizon.commands.VisitableCommand;
import org.horizon.factories.ComponentRegistry;
+import org.horizon.factories.GlobalComponentRegistry;
import org.horizon.interceptors.InterceptorChain;
import org.horizon.interceptors.base.CommandInterceptor;
import org.horizon.lock.LockManager;
@@ -462,6 +463,10 @@
return (ComponentRegistry) extractField(cache, "componentRegistry");
}
+ public static GlobalComponentRegistry extractGlobalComponentRegistry(CacheManager cacheManager) {
+ return (GlobalComponentRegistry) extractField(cacheManager, "globalComponentRegistry");
+ }
+
public static LockManager extractLockManager(Cache cache) {
return extractComponentRegistry(cache).getComponent(LockManager.class);
}
@@ -576,4 +581,41 @@
public static TransactionManager getTransactionManager(Cache cache) {
return cache == null ? null : extractComponent(cache, TransactionManager.class);
}
+
+ /**
+ * Replaces a component in a running cache
+ *
+ * @param cache cache in which to replace component
+ * @param componentType component type of which to replace
+ * @param replacementComponent new instance
+ * @param rewire if true, ComponentRegistry.rewire() is called after replacing.
+ * @return the original component that was replaced
+ */
+ public static <T> T replaceComponent(Cache<?, ?> cache, Class<T> componentType, T replacementComponent, boolean rewire) {
+ ComponentRegistry cr = extractComponentRegistry(cache);
+ T old = cr.getComponent(componentType);
+ cr.registerComponent(replacementComponent, componentType);
+ if (rewire) cr.rewire();
+ return old;
+ }
+
+ /**
+ * Replaces a component in a running cache manager (global component registry)
+ *
+ * @param cacheManager cache in which to replace component
+ * @param componentType component type of which to replace
+ * @param replacementComponent new instance
+ * @param rewire if true, ComponentRegistry.rewire() is called after replacing.
+ * @return the original component that was replaced
+ */
+ public static <T> T replaceComponent(CacheManager cacheManager, Class<T> componentType, T replacementComponent, boolean rewire) {
+ GlobalComponentRegistry cr = extractGlobalComponentRegistry(cacheManager);
+ T old = cr.getComponent(componentType);
+ cr.registerComponent(replacementComponent, componentType);
+ if (rewire) {
+ cr.rewire();
+ cr.rewireNamedRegistries();
+ }
+ return old;
+ }
}
Added: core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/AsyncNotificationTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,83 @@
+package org.horizon.notifications;
+
+import org.horizon.Cache;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryCreated;
+import org.horizon.notifications.cachelistener.event.CacheEntryCreatedEvent;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.CountDownLatch;
+
+@Test(groups = "functional", sequential = true)
+public class AsyncNotificationTest {
+ Cache<String, String> c;
+ CacheManager cm;
+
+ @BeforeMethod
+ public void setUp() {
+ cm = new DefaultCacheManager();
+ c = cm.getCache();
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ TestingUtil.killCacheManagers(cm);
+ }
+
+ public void testAsyncNotification() throws InterruptedException {
+
+ CountDownLatch latch = new CountDownLatch(2);
+ AbstractListener syncListener = new SyncListener(latch);
+ AbstractListener asyncListener = new AsyncListener(latch);
+ c.addListener(syncListener);
+ c.addListener(asyncListener);
+ c.put("k", "v");
+ latch.await();
+ assert syncListener.caller == Thread.currentThread();
+ assert asyncListener.caller != Thread.currentThread();
+ }
+
+ public abstract static class AbstractListener {
+ Thread caller;
+ CountDownLatch latch;
+
+ protected AbstractListener(CountDownLatch latch) {
+ this.latch = latch;
+ }
+ }
+
+ @Listener(sync = true)
+ public static class SyncListener extends AbstractListener {
+ public SyncListener(CountDownLatch latch) {
+ super(latch);
+ }
+
+ @CacheEntryCreated
+ public void handle(CacheEntryCreatedEvent e) {
+ if (e.isPre()) {
+ caller = Thread.currentThread();
+ latch.countDown();
+ }
+ }
+ }
+
+ @Listener(sync = false)
+ public static class AsyncListener extends AbstractListener {
+ public AsyncListener(CountDownLatch latch) {
+ super(latch);
+ }
+
+ @CacheEntryCreated
+ public void handle(CacheEntryCreatedEvent e) {
+ if (e.isPre()) {
+ caller = Thread.currentThread();
+ latch.countDown();
+ }
+ }
+ }
+
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerCacheLoaderTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,184 @@
+package org.horizon.notifications;
+
+import org.testng.annotations.Test;
+
+@Test(groups = "functional", sequential = true)
+public class CacheListenerCacheLoaderTest {
+ // TODO implement me!
+// private Cache<Object, Object> cache;
+// private EventLog eventLog = new EventLog();
+// private TransactionManager tm;
+// private Fqn fqn = Fqn.fromString("/test");
+//
+// @BeforeMethod(alwaysRun = true)
+// public void setUp() throws Exception
+// {
+// Configuration c = new Configuration();
+// c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+// c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+//
+// CacheLoaderConfig clc = new CacheLoaderConfig();
+// IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
+// iclc.setClassName(DummyInMemoryCacheLoader.class.getName());
+// clc.addIndividualCacheLoaderConfig(iclc);
+// clc.setPassivation(true);
+//
+// c.setCacheLoaderConfig(clc);
+// cache = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
+// eventLog.events.clear();
+// cache.addCacheListener(eventLog);
+// tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+// }
+//
+// @AfterMethod(alwaysRun = true)
+// public void tearDown() throws Exception
+// {
+// TestingUtil.killCaches(cache);
+// cache = null;
+// }
+//
+// public void testActivationAndPassivation() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// cache.get(fqn, "DOES_NOT_EXIST");
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, null, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_VISITED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_VISITED));
+//
+// assertEquals(expected, eventLog.events);
+// }
+//
+// public void testActivationAndPassivationTxNoMods() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// tm.begin();
+// Transaction tx = tm.getTransaction();
+// cache.get(fqn, "DOES_NOT_EXIST");
+// tm.commit();
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_VISITED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_VISITED));
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+// assertEquals(expected, eventLog.events);
+// }
+//
+// public void testActivationAndPassivationTxMods() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// tm.begin();
+// Transaction tx = tm.getTransaction();
+// cache.put(fqn, "key2", "value2");
+// tm.commit();
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, PUT_DATA, Collections.singletonMap("key2", "value2"), fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+// assertEquals(expected, eventLog.events);
+//
+// assert cache.get(fqn, "key").equals("value");
+// assert cache.get(fqn, "key2").equals("value2");
+// }
+//
+// public void testActivationAndPassivationTxModsWithChildren() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// cache.put(Fqn.fromRelativeElements(fqn, "child"), "key3", "value3");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// tm.begin();
+// Transaction tx = tm.getTransaction();
+// cache.put(fqn, "key2", "value2");
+// tm.commit();
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, PUT_DATA, Collections.singletonMap("key2", "value2"), fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+// assertEquals(expected, eventLog.events);
+//
+// assert cache.get(fqn, "key").equals("value");
+// assert cache.get(fqn, "key2").equals("value2");
+// }
+}
\ No newline at end of file
Added: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerPassivationTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,184 @@
+package org.horizon.notifications;
+
+import org.testng.annotations.Test;
+
+@Test(groups = "functional", sequential = true)
+public class CacheListenerPassivationTest {
+ // TODO implement me!
+// private Cache<Object, Object> cache;
+// private EventLog eventLog = new EventLog();
+// private TransactionManager tm;
+// private Fqn fqn = Fqn.fromString("/test");
+//
+// @BeforeMethod(alwaysRun = true)
+// public void setUp() throws Exception
+// {
+// Configuration c = new Configuration();
+// c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+// c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+//
+// CacheLoaderConfig clc = new CacheLoaderConfig();
+// IndividualCacheLoaderConfig iclc = new IndividualCacheLoaderConfig();
+// iclc.setClassName(DummyInMemoryCacheLoader.class.getName());
+// clc.addIndividualCacheLoaderConfig(iclc);
+// clc.setPassivation(true);
+//
+// c.setCacheLoaderConfig(clc);
+// cache = new UnitTestCacheFactory<Object, Object>().createCache(c, getClass());
+// eventLog.events.clear();
+// cache.addCacheListener(eventLog);
+// tm = cache.getConfiguration().getRuntimeConfig().getTransactionManager();
+// }
+//
+// @AfterMethod(alwaysRun = true)
+// public void tearDown() throws Exception
+// {
+// TestingUtil.killCaches(cache);
+// cache = null;
+// }
+//
+// public void testActivationAndPassivation() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// cache.get(fqn, "DOES_NOT_EXIST");
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, null, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_VISITED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_VISITED));
+//
+// assertEquals(expected, eventLog.events);
+// }
+//
+// public void testActivationAndPassivationTxNoMods() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// tm.begin();
+// Transaction tx = tm.getTransaction();
+// cache.get(fqn, "DOES_NOT_EXIST");
+// tm.commit();
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_VISITED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_VISITED));
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+// assertEquals(expected, eventLog.events);
+// }
+//
+// public void testActivationAndPassivationTxMods() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// tm.begin();
+// Transaction tx = tm.getTransaction();
+// cache.put(fqn, "key2", "value2");
+// tm.commit();
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, tx, true, null, false, null, NODE_CREATED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, PUT_DATA, Collections.singletonMap("key2", "value2"), fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+// assertEquals(expected, eventLog.events);
+//
+// assert cache.get(fqn, "key").equals("value");
+// assert cache.get(fqn, "key2").equals("value2");
+// }
+//
+// public void testActivationAndPassivationTxModsWithChildren() throws Exception
+// {
+// assertEquals("Event log should be empty", Collections.emptyList(), eventLog.events);
+// cache.put(fqn, "key", "value");
+// cache.put(Fqn.fromRelativeElements(fqn, "child"), "key3", "value3");
+// Map<Object, Object> data = new HashMap<Object, Object>();
+// data.put("key", "value");
+//
+// List<Event> expected = new ArrayList<Event>();
+//
+// // now evict the node - which should cause a passivation
+// eventLog.events.clear();
+// cache.evict(fqn);
+// expected.add(new EventImpl(true, cache, null, data, fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(false, cache, null, Collections.emptyMap(), fqn, null, true, null, false, null, NODE_PASSIVATED));
+// expected.add(new EventImpl(true, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// expected.add(new EventImpl(false, cache, null, null, fqn, null, true, null, false, null, NODE_EVICTED));
+// assertEquals(expected, eventLog.events);
+//
+// // now load the node.
+// expected.clear();
+// eventLog.events.clear();
+// tm.begin();
+// Transaction tx = tm.getTransaction();
+// cache.put(fqn, "key2", "value2");
+// tm.commit();
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, false, null, TRANSACTION_REGISTERED));
+// expected.add(new EventImpl(true, cache, null, Collections.emptyMap(), fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(false, cache, null, data, fqn, tx, true, null, false, null, NODE_ACTIVATED));
+// expected.add(new EventImpl(true, cache, PUT_DATA, data, fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, PUT_DATA, Collections.singletonMap("key2", "value2"), fqn, tx, true, null, false, null, NODE_MODIFIED));
+// expected.add(new EventImpl(false, cache, null, null, null, tx, true, null, true, null, TRANSACTION_COMPLETED));
+// assertEquals(expected, eventLog.events);
+//
+// assert cache.get(fqn, "key").equals("value");
+// assert cache.get(fqn, "key2").equals("value2");
+// }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerRemovalTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,68 @@
+package org.horizon.notifications;
+
+import org.horizon.Cache;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.horizon.notifications.cachelistener.event.Event;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * @author Manik Surtani
+ */
+@Test(groups = "functional")
+public class CacheListenerRemovalTest {
+ Cache<String, String> cache;
+ CacheManager cm;
+
+ @BeforeMethod
+ public void setUp() {
+ cm = new DefaultCacheManager();
+ cache = cm.getCache();
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ TestingUtil.killCacheManagers(cm);
+ }
+
+ public void testListenerRemoval() {
+ cache.put("x", "y");
+ AtomicInteger i = new AtomicInteger(0);
+ assert 0 == cache.getListeners().size();
+ CacheListener l = new CacheListener(i);
+ cache.addListener(l);
+ assert 1 == cache.getListeners().size();
+ assert cache.getListeners().iterator().next() == l;
+ assert 0 == i.get();
+ cache.get("x");
+ assert 1 == i.get();
+
+ // remove the listener
+ cache.removeListener(l);
+ assert 0 == cache.getListeners().size();
+ i.set(0);
+ assert 0 == i.get();
+ cache.get("x");
+ assert 0 == i.get();
+ }
+
+ @Listener
+ public static class CacheListener {
+ AtomicInteger i;
+
+ private CacheListener(AtomicInteger i) {
+ this.i = i;
+ }
+
+ @CacheEntryVisited
+ public void listen(Event e) {
+ if (e.isPre()) i.incrementAndGet();
+ }
+ }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheListenerTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,211 @@
+package org.horizon.notifications;
+
+import static org.easymock.EasyMock.*;
+import org.horizon.Cache;
+import org.horizon.config.Configuration;
+import org.horizon.context.InvocationContext;
+import org.horizon.lock.IsolationLevel;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.notifications.cachelistener.CacheNotifier;
+import org.horizon.transaction.DummyTransactionManagerLookup;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+@Test(groups = "functional", sequential = true)
+public class CacheListenerTest {
+ private Cache<Object, Object> cache;
+ private TransactionManager tm;
+ private CacheNotifier mockNotifier;
+ private CacheNotifier origNotifier;
+
+ @BeforeMethod(alwaysRun = true)
+ public void setUp() throws Exception {
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.LOCAL);
+ c.setIsolationLevel(IsolationLevel.REPEATABLE_READ);
+ c.setTransactionManagerLookupClass(DummyTransactionManagerLookup.class.getName());
+
+ CacheManager cm = new DefaultCacheManager(c);
+
+ cache = cm.getCache();
+ tm = TestingUtil.getTransactionManager(cache);
+ mockNotifier = createMock(CacheNotifier.class);
+ origNotifier = TestingUtil.replaceComponent(cache, CacheNotifier.class, mockNotifier, true);
+ }
+
+ @AfterMethod(alwaysRun = true)
+ public void tearDown() throws Exception {
+ TestingUtil.replaceComponent(cache, CacheNotifier.class, origNotifier, true);
+ TestingUtil.killCaches(cache);
+ }
+
+ private void initCacheData(Object key, Object value) {
+ initCacheData(Collections.singletonMap(key, value));
+ }
+
+ private void initCacheData(Map data) {
+ mockNotifier.notifyCacheEntryCreated(anyObject(), anyBoolean(), isA(InvocationContext.class));
+ expectLastCall().anyTimes();
+ mockNotifier.notifyCacheEntryModified(anyObject(), anyObject(), anyBoolean(), isA(InvocationContext.class));
+ expectLastCall().anyTimes();
+ replay(mockNotifier);
+ cache.putAll(data);
+ verify(mockNotifier);
+
+ // now reset the mock
+ reset(mockNotifier);
+ }
+
+ private void expectSingleEntryCreated(Object key, Object value) {
+ mockNotifier.notifyCacheEntryCreated(eq(key), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryCreated(eq(key), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq(key), isNull(), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq(key), eq(value), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ }
+
+ private void expectTransactionBoundaries(boolean successful) {
+ mockNotifier.notifyTransactionRegistered(isA(Transaction.class), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyTransactionCompleted(isA(Transaction.class), eq(successful), isA(InvocationContext.class));
+ expectLastCall().once();
+ }
+
+
+ // simple tests first
+
+ public void testCreation() throws Exception {
+ expectSingleEntryCreated("key", "value");
+ replay(mockNotifier);
+ cache.put("key", "value");
+ verify(mockNotifier);
+ }
+
+ public void testOnlyModification() throws Exception {
+ initCacheData("key", "value");
+
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value2"), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+
+ replay(mockNotifier);
+ cache.put("key", "value2");
+ verify(mockNotifier);
+ }
+
+ public void testNonexistentRemove() throws Exception {
+ cache.remove("doesNotExist");
+ replay(mockNotifier);
+ verify(mockNotifier);
+ }
+
+ public void testRemoveData() throws Exception {
+ Map data = new HashMap();
+ data.put("key", "value");
+ data.put("key2", "value2");
+ initCacheData(data);
+
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), eq("value2"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), isNull(), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ replay(mockNotifier);
+
+ cache.remove("key2");
+
+ verify(mockNotifier);
+ }
+
+ public void testPutMap() throws Exception {
+ Map<Object, Object> data = new HashMap<Object, Object>();
+ data.put("key", "value");
+ data.put("key2", "value2");
+ expectSingleEntryCreated("key", "value");
+ expectSingleEntryCreated("key2", "value2");
+
+ replay(mockNotifier);
+
+ cache.putAll(data);
+ verify(mockNotifier);
+ }
+
+ // -- now the transactional ones
+
+ public void testTxNonexistentRemove() throws Exception {
+ expectTransactionBoundaries(true);
+ replay(mockNotifier);
+ tm.begin();
+ cache.remove("doesNotExist");
+ tm.commit();
+ verify(mockNotifier);
+ }
+
+ public void testTxCreationCommit() throws Exception {
+ expectTransactionBoundaries(true);
+ expectSingleEntryCreated("key", "value");
+ replay(mockNotifier);
+ tm.begin();
+ cache.put("key", "value");
+ tm.commit();
+ verify(mockNotifier);
+ }
+
+ public void testTxCreationRollback() throws Exception {
+ expectTransactionBoundaries(false);
+ expectSingleEntryCreated("key", "value");
+ replay(mockNotifier);
+ tm.begin();
+ cache.put("key", "value");
+ tm.rollback();
+ verify(mockNotifier);
+ }
+
+ public void testTxOnlyModification() throws Exception {
+ initCacheData("key", "value");
+ expectTransactionBoundaries(true);
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryModified(eq("key"), eq("value2"), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+
+ replay(mockNotifier);
+
+ tm.begin();
+ cache.put("key", "value2");
+ tm.commit();
+
+ verify(mockNotifier);
+ }
+
+ public void testTxRemoveData() throws Exception {
+ Map data = new HashMap();
+ data.put("key", "value");
+ data.put("key2", "value2");
+ initCacheData(data);
+ expectTransactionBoundaries(true);
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), eq("value2"), eq(true), isA(InvocationContext.class));
+ expectLastCall().once();
+ mockNotifier.notifyCacheEntryRemoved(eq("key2"), isNull(), eq(false), isA(InvocationContext.class));
+ expectLastCall().once();
+ replay(mockNotifier);
+
+ tm.begin();
+ cache.remove("key2");
+ tm.commit();
+
+ verify(mockNotifier);
+ }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/CacheManagerNotifierTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,70 @@
+package org.horizon.notifications;
+
+import static org.easymock.EasyMock.*;
+import org.horizon.BaseClusteredTest;
+import org.horizon.Cache;
+import org.horizon.config.Configuration;
+import org.horizon.config.GlobalConfiguration;
+import org.horizon.manager.CacheManager;
+import org.horizon.notifications.cachemanagerlistener.CacheManagerNotifier;
+import org.horizon.remoting.transport.Address;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+@Test(groups = "unit", sequential = true, testName = "notifications.CacheManagerNotifierTest")
+public class CacheManagerNotifierTest extends BaseClusteredTest {
+ public void testViewChange() {
+ CacheManager cm1 = addClusterEnabledCacheManager();
+ CacheManager cm2 = addClusterEnabledCacheManager();
+ Configuration c = new Configuration();
+ c.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+ defineCacheOnAllManagers("cache", c);
+
+ Cache c1 = cm1.getCache("cache");
+
+ // this will mean only 1 cache in the cluster so far
+ assert cm1.getMembers().size() == 1;
+ Address myAddress = cm1.getAddress();
+ assert cm1.getMembers().contains(myAddress);
+
+ // now attach a mock notifier
+ CacheManagerNotifier mockNotifier = createMock(CacheManagerNotifier.class);
+ CacheManagerNotifier origNotifier = TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, mockNotifier, true);
+ try {
+ mockNotifier.notifyViewChange(isA(List.class), eq(myAddress));
+ replay(mockNotifier);
+ // start a second cache.
+ Cache c2 = cm2.getCache("cache");
+ TestingUtil.blockUntilViewsReceived(60000, cm1, cm2);
+ verify(mockNotifier);
+
+ } finally {
+ TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, origNotifier, true);
+ }
+ }
+
+ public void testCacheStartedAndStopped() {
+ CacheManager cm1 = addCacheManager(GlobalConfiguration.getNonClusteredDefault());
+ Cache defCache = cm1.getCache();
+ CacheManagerNotifier mockNotifier = createMock(CacheManagerNotifier.class);
+ CacheManagerNotifier origNotifier = TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, mockNotifier, true);
+ try {
+ cm1.defineCache("testCache", new Configuration());
+ mockNotifier.notifyCacheStarted("testCache");
+ replay(mockNotifier);
+ // start a second cache.
+ Cache testCache = cm1.getCache("testCache");
+ verify(mockNotifier);
+
+ reset(mockNotifier);
+ mockNotifier.notifyCacheStopped("testCache");
+ replay(mockNotifier);
+ testCache.stop();
+ verify(mockNotifier);
+ } finally {
+ TestingUtil.replaceComponent(cm1, CacheManagerNotifier.class, origNotifier, true);
+ }
+ }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/ConcurrentNotificationTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,107 @@
+package org.horizon.notifications;
+
+import org.horizon.Cache;
+import org.horizon.manager.CacheManager;
+import org.horizon.manager.DefaultCacheManager;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryCreated;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryModified;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.horizon.notifications.cachelistener.event.Event;
+import org.horizon.util.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import java.util.LinkedList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Test(groups = {"functional"}, sequential = true, testName = "notifications.ConcurrentNotificationTest")
+public class ConcurrentNotificationTest {
+ Cache<String, String> cache;
+ CacheManager cm;
+ CacheListener listener;
+
+ @BeforeMethod
+ public void setUp() {
+ cm = new DefaultCacheManager();
+ cache = cm.getCache();
+ listener = new CacheListener();
+ cache.addListener(listener);
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ TestingUtil.killCacheManagers(cm);
+ }
+
+ public void testThreads() throws Exception {
+ Thread workers[] = new Thread[20];
+ final List<Exception> exceptions = new LinkedList<Exception>();
+ final int loops = 100;
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ for (int i = 0; i < workers.length; i++) {
+ workers[i] = new Thread() {
+ public void run() {
+ try {
+ latch.await();
+ }
+ catch (InterruptedException e) {
+ }
+
+ for (int j = 0; j < loops; j++) {
+ try {
+ cache.put("key", "value");
+ }
+ catch (Exception e) {
+ exceptions.add(new Exception("Caused on thread " + getName() + " in loop " + j + " when doing a put()", e));
+ }
+
+ try {
+ cache.remove("key");
+ }
+ catch (Exception e) {
+ exceptions.add(new Exception("Caused on thread " + getName() + " in loop " + j + " when doing a remove()", e));
+ }
+
+ try {
+ cache.get("key");
+ }
+ catch (Exception e) {
+ exceptions.add(new Exception("Caused on thread " + getName() + " in loop " + j + " when doing a get()", e));
+ }
+ }
+ }
+ };
+
+ workers[i].start();
+ }
+
+ latch.countDown();
+
+ for (Thread t : workers)
+ t.join();
+
+ for (Exception e : exceptions)
+ throw e;
+
+ assert 4 * loops * workers.length == listener.counter.get();
+ }
+
+ @Listener
+ public class CacheListener {
+ private AtomicInteger counter = new AtomicInteger(0);
+
+ @CacheEntryModified
+ @CacheEntryRemoved
+ @CacheEntryVisited
+ @CacheEntryCreated
+ public void catchEvent(Event e) {
+ if (e.isPre())
+ counter.getAndIncrement();
+ }
+ }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheListener.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheListener.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,69 @@
+package org.horizon.notifications.cachelistener;
+
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachelistener.annotation.*;
+import org.horizon.notifications.cachelistener.event.Event;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Listens to everything
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+@Listener
+public class CacheListener {
+ List<Event> events = new ArrayList<Event>();
+ boolean receivedPre;
+ boolean receivedPost;
+ int invocationCount;
+
+ public void reset() {
+ events.clear();
+ receivedPost = false;
+ receivedPre = false;
+ invocationCount = 0;
+ }
+
+ public List<Event> getEvents() {
+ return events;
+ }
+
+ public boolean isReceivedPre() {
+ return receivedPre;
+ }
+
+ public boolean isReceivedPost() {
+ return receivedPost;
+ }
+
+ public int getInvocationCount() {
+ return invocationCount;
+ }
+
+
+ // handler
+
+ @CacheEntryActivated
+ @CacheEntryCreated
+ @CacheEntryEvicted
+ @CacheEntryInvalidated
+ @CacheEntryLoaded
+ @CacheEntryModified
+ @CacheEntryPassivated
+ @CacheEntryRemoved
+ @CacheEntryVisited
+ @TransactionCompleted
+ @TransactionRegistered
+ public void handle(Event e) {
+ events.add(e);
+ if (e.isPre())
+ receivedPre = true;
+ else
+ receivedPost = true;
+
+ invocationCount++;
+ }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/CacheNotifierImplTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,209 @@
+package org.horizon.notifications.cachelistener;
+
+import org.easymock.EasyMock;
+import static org.easymock.EasyMock.createNiceMock;
+import org.horizon.CacheSPI;
+import org.horizon.context.InvocationContext;
+import org.horizon.context.InvocationContextImpl;
+import org.horizon.notifications.cachelistener.event.CacheEntryEvent;
+import org.horizon.notifications.cachelistener.event.CacheEntryModifiedEvent;
+import org.horizon.notifications.cachelistener.event.CacheEntryRemovedEvent;
+import org.horizon.notifications.cachelistener.event.Event;
+import org.horizon.notifications.cachelistener.event.TransactionCompletedEvent;
+import org.horizon.notifications.cachelistener.event.TransactionRegisteredEvent;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+
+@Test(groups = "unit", sequential = true)
+public class CacheNotifierImplTest {
+ CacheNotifierImpl n;
+ CacheSPI mockCache;
+ CacheListener cl;
+ InvocationContext ctx;
+
+ @BeforeMethod
+ public void setUp() {
+ n = new CacheNotifierImpl();
+ mockCache = createNiceMock(CacheSPI.class);
+ EasyMock.expect(mockCache.getInvocationContext()).andReturn(new InvocationContextImpl()).anyTimes();
+ EasyMock.replay(mockCache);
+ n.injectDependencies(mockCache, null);
+ cl = new CacheListener();
+ n.start();
+ n.addListener(cl);
+ ctx = new InvocationContextImpl();
+ }
+
+ public void testNotifyCacheEntryCreated() {
+ n.notifyCacheEntryCreated("k", true, ctx);
+ n.notifyCacheEntryCreated("k", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_CREATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_CREATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+ }
+
+ public void testNotifyCacheEntryModified() {
+ n.notifyCacheEntryModified("k", "v1", true, ctx);
+ n.notifyCacheEntryModified("k", "v2", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_MODIFIED;
+ assert ((CacheEntryModifiedEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert ((CacheEntryModifiedEvent) cl.getEvents().get(0)).getValue().equals("v1");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_MODIFIED;
+ assert ((CacheEntryModifiedEvent) cl.getEvents().get(1)).getKey().equals("k");
+ assert ((CacheEntryModifiedEvent) cl.getEvents().get(1)).getValue().equals("v2");
+ }
+
+ public void testNotifyCacheEntryRemoved() {
+ n.notifyCacheEntryRemoved("k", "v", true, ctx);
+ n.notifyCacheEntryRemoved("k", null, false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_REMOVED;
+ assert ((CacheEntryRemovedEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert ((CacheEntryRemovedEvent) cl.getEvents().get(0)).getValue().equals("v");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_REMOVED;
+ assert ((CacheEntryRemovedEvent) cl.getEvents().get(1)).getKey().equals("k");
+ assert ((CacheEntryRemovedEvent) cl.getEvents().get(1)).getValue() == null;
+ }
+
+ public void testNotifyCacheEntryVisited() {
+ n.notifyCacheEntryVisited("k", true, ctx);
+ n.notifyCacheEntryVisited("k", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_VISITED;
+ assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_VISITED;
+ assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+
+ }
+
+ public void testNotifyCacheEntryEvicted() {
+ n.notifyCacheEntryEvicted("k", true, ctx);
+ n.notifyCacheEntryEvicted("k", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_EVICTED;
+ assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_EVICTED;
+ assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+ }
+
+ public void testNotifyCacheEntryInvalidated() {
+ n.notifyCacheEntryInvalidated("k", true, ctx);
+ n.notifyCacheEntryInvalidated("k", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_INVALIDATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_INVALIDATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+ }
+
+ public void testNotifyCacheEntryLoaded() {
+ n.notifyCacheEntryLoaded("k", true, ctx);
+ n.notifyCacheEntryLoaded("k", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_LOADED;
+ assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_LOADED;
+ assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+ }
+
+ public void testNotifyCacheEntryActivated() {
+ n.notifyCacheEntryActivated("k", true, ctx);
+ n.notifyCacheEntryActivated("k", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_ACTIVATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_ACTIVATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+ }
+
+ public void testNotifyCacheEntryPassivated() {
+ n.notifyCacheEntryPassivated("k", true, ctx);
+ n.notifyCacheEntryPassivated("k", false, ctx);
+
+ assert cl.isReceivedPost();
+ assert cl.isReceivedPre();
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.CACHE_ENTRY_PASSIVATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(0)).getKey().equals("k");
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.CACHE_ENTRY_PASSIVATED;
+ assert ((CacheEntryEvent) cl.getEvents().get(1)).getKey().equals("k");
+ }
+
+ public void testNotifyTransactionCompleted() {
+ Transaction tx = createNiceMock(Transaction.class);
+ n.notifyTransactionCompleted(tx, true, ctx);
+ n.notifyTransactionCompleted(tx, false, ctx);
+
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.TRANSACTION_COMPLETED;
+ assert ((TransactionCompletedEvent) cl.getEvents().get(0)).isTransactionSuccessful();
+ assert ((TransactionCompletedEvent) cl.getEvents().get(0)).getTransaction() == tx;
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.TRANSACTION_COMPLETED;
+ assert !((TransactionCompletedEvent) cl.getEvents().get(1)).isTransactionSuccessful();
+ assert ((TransactionCompletedEvent) cl.getEvents().get(1)).getTransaction() == tx;
+ }
+
+ public void testNotifyTransactionRegistered() {
+ InvocationContext ctx = new InvocationContextImpl();
+ Transaction tx = createNiceMock(Transaction.class);
+ n.notifyTransactionRegistered(tx, ctx);
+ n.notifyTransactionRegistered(tx, ctx);
+
+ assert cl.getInvocationCount() == 2;
+ assert cl.getEvents().get(0).getCache() == mockCache;
+ assert cl.getEvents().get(0).getType() == Event.Type.TRANSACTION_REGISTERED;
+ assert ((TransactionRegisteredEvent) cl.getEvents().get(0)).getTransaction() == tx;
+ assert cl.getEvents().get(1).getCache() == mockCache;
+ assert cl.getEvents().get(1).getType() == Event.Type.TRANSACTION_REGISTERED;
+ assert ((TransactionRegisteredEvent) cl.getEvents().get(1)).getTransaction() == tx;
+ }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachelistener/ListenerRegistrationTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,283 @@
+package org.horizon.notifications.cachelistener;
+
+import org.horizon.notifications.IncorrectListenerException;
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.horizon.notifications.cachelistener.event.CacheEntryRemovedEvent;
+import org.horizon.notifications.cachelistener.event.Event;
+import static org.testng.AssertJUnit.*;
+import org.testng.annotations.Test;
+
+import java.util.List;
+
+@Test(groups = "unit")
+public class ListenerRegistrationTest {
+ public void testControl() {
+ Object l = new TestControlListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ n.addListener(l);
+ assertEquals(1, n.getListeners().size());
+ }
+
+ public void testCacheListenerNoMethods() {
+ Object l = new TestCacheListenerNoMethodsListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ n.addListener(l);
+ assertEquals("Hello", l.toString());
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty()); // since the valid listener has no methods to listen
+ }
+
+ public void testNonAnnotatedListener() {
+ Object l = new TestNonAnnotatedListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept an un-annotated cache listener");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testNonPublicListener() {
+ Object l = new TestNonPublicListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept a private callback class");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testNonPublicListenerMethod() {
+ Object l = new TestNonPublicListenerMethodListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ n.addListener(l);
+
+ // should not fail, should just not register anything
+
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testNonVoidReturnTypeMethod() {
+ Object l = new TestNonVoidReturnTypeMethodListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept a listener method with a return type");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testIncorrectMethodSignature1() {
+ Object l = new TestIncorrectMethodSignature1Listener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept a cache listener with a bad method signature");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testIncorrectMethodSignature2() {
+ Object l = new TestIncorrectMethodSignature2Listener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept a cache listener with a bad method signature");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testIncorrectMethodSignature3() {
+ Object l = new TestIncorrectMethodSignature3Listener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept a cache listener with a bad method signature");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testUnassignableMethodSignature() {
+ Object l = new TestUnassignableMethodSignatureListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept a cache listener with a bad method signature");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ assertTrue("No listeners should be registered.", n.getListeners().isEmpty());
+ }
+
+ public void testPartlyUnassignableMethodSignature() {
+ Object l = new TestPartlyUnassignableMethodSignatureListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ try {
+ n.addListener(l);
+ fail("Should not accept a cache listener with a bad method signature");
+ }
+ catch (IncorrectListenerException icle) {
+ // expected
+ }
+ }
+
+ public void testMultipleMethods() {
+ Object l = new TestMultipleMethodsListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ n.addListener(l);
+ List invocations = n.cacheEntryVisitedListeners;
+ assertEquals(1, invocations.size());
+ invocations = n.cacheEntryRemovedListeners;
+ assertEquals(1, invocations.size());
+ assertEquals(1, n.getListeners().size());
+ }
+
+ public void testMultipleAnnotationsOneMethod() {
+ Object l = new TestMultipleAnnotationsOneMethodListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ n.addListener(l);
+ List invocations = n.cacheEntryVisitedListeners;
+ assertEquals(1, invocations.size());
+ invocations = n.cacheEntryRemovedListeners;
+ assertEquals(1, invocations.size());
+ assertEquals(1, n.getListeners().size());
+ }
+
+ public void testMultipleMethodsOneAnnotation() {
+ Object l = new TestMultipleMethodsOneAnnotationListener();
+ CacheNotifierImpl n = new CacheNotifierImpl();
+ n.addListener(l);
+ List invocations = n.cacheEntryVisitedListeners;
+ assertEquals(2, invocations.size());
+ assertEquals(1, n.getListeners().size());
+ }
+
+ @Listener
+ public class TestControlListener {
+ @CacheEntryVisited
+ @CacheEntryRemoved
+ public void callback(Event e) {
+ }
+ }
+
+ @Listener
+ public class TestCacheListenerNoMethodsListener {
+ public String toString() {
+ return "Hello";
+ }
+ }
+
+ public class TestNonAnnotatedListener {
+ public String toString() {
+ return "Hello";
+ }
+ }
+
+ @Listener
+ protected class TestNonPublicListener {
+ @CacheEntryVisited
+ public void callback() {
+ }
+ }
+
+ @Listener
+ public class TestNonPublicListenerMethodListener {
+ @CacheEntryVisited
+ protected void callback(Event e) {
+ }
+ }
+
+ @Listener
+ public class TestNonVoidReturnTypeMethodListener {
+ @CacheEntryVisited
+ public String callback(Event e) {
+ return "Hello";
+ }
+ }
+
+ @Listener
+ public class TestIncorrectMethodSignature1Listener {
+ @CacheEntryVisited
+ public void callback() {
+ }
+ }
+
+ @Listener
+ public class TestIncorrectMethodSignature2Listener {
+ @CacheEntryVisited
+ public void callback(Event e, String s) {
+ }
+ }
+
+ @Listener
+ public class TestIncorrectMethodSignature3Listener {
+ @CacheEntryVisited
+ public void callback(Event e, String... s) {
+ }
+ }
+
+ @Listener
+ public class TestUnassignableMethodSignatureListener {
+ @CacheEntryVisited
+ public void callback(CacheEntryRemovedEvent e) {
+ }
+ }
+
+ @Listener
+ public class TestPartlyUnassignableMethodSignatureListener {
+ @CacheEntryVisited
+ @CacheEntryRemoved
+ public void callback(CacheEntryRemovedEvent e) {
+ }
+ }
+
+ @Listener
+ public class TestMultipleMethodsListener {
+ @CacheEntryVisited
+ public void callback1(Event e) {
+ }
+
+ @CacheEntryRemoved
+ public void callback2(Event e) {
+ }
+ }
+
+ @Listener
+ public class TestMultipleAnnotationsOneMethodListener {
+ @CacheEntryRemoved
+ @CacheEntryVisited
+ public void callback(Event nme) {
+ }
+ }
+
+ @Listener
+ public class TestMultipleMethodsOneAnnotationListener {
+ @CacheEntryVisited
+ public void callback1(Event e) {
+ }
+
+ @CacheEntryVisited
+ public void callback2(Event e) {
+ }
+ }
+}
Added: core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java (rev 0)
+++ core/branches/flat/src/test/java/org/horizon/notifications/cachemanagerlistener/CacheManagerNotifierImplTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -0,0 +1,8 @@
+package org.horizon.notifications.cachemanagerlistener;
+
+import org.testng.annotations.Test;
+
+@Test(groups = "unit")
+public class CacheManagerNotifierImplTest {
+ // TODO implement me!
+}
Modified: core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -14,11 +14,11 @@
import org.horizon.lock.IsolationLevel;
import org.horizon.logging.Log;
import org.horizon.logging.LogFactory;
-import org.horizon.notifications.annotation.CacheEntryModified;
-import org.horizon.notifications.annotation.CacheEntryRemoved;
-import org.horizon.notifications.annotation.Listener;
-import org.horizon.notifications.event.Event;
-import org.horizon.notifications.event.TransactionalEvent;
+import org.horizon.notifications.Listener;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryModified;
+import org.horizon.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.horizon.notifications.cachelistener.event.Event;
+import org.horizon.notifications.cachelistener.event.TransactionalEvent;
import org.horizon.transaction.DummyTransactionManagerLookup;
import org.horizon.util.TestingUtil;
import static org.testng.AssertJUnit.*;
Deleted: core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java 2009-01-30 17:06:45 UTC (rev 7617)
+++ core/branches/flat/src/test/java/org/horizon/util/internals/ViewChangeListener.java 2009-01-31 00:32:22 UTC (rev 7618)
@@ -1,55 +0,0 @@
-package org.horizon.util.internals;
-
-import org.horizon.manager.CacheManager;
-import org.horizon.notifications.annotation.Listener;
-import org.horizon.notifications.annotation.ViewChanged;
-import org.horizon.notifications.event.ViewChangedEvent;
-
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-/**
- * A class that registers a cache listener with a given cache, and waits for a view change on the cache.
- * <p/>
- * Sample usage:
- * <pre>
- * Cache c = getCache();
- * ViewChangeListener vcl = new ViewChangeListener(c);
- * assert vcl.waitForViewChange(60, TimeUnit.SECONDS); // will block for up to 60 seconds for a view change on cache
- * c
- * </pre>
- *
- * @author (various)
- * @since 1.0
- */
-@Listener
-public class ViewChangeListener {
- CountDownLatch latch;
-
- /**
- * Constructs a view change listener
- *
- * @param cache cache to listen on for view change events
- */
- public ViewChangeListener(CacheManager cacheManager) {
- this.latch = new CountDownLatch(1);
- cacheManager.addListener(this);
- }
-
- @ViewChanged
- public void handleViewChange(ViewChangedEvent e) {
- if (!e.isPre()) latch.countDown();
- }
-
- /**
- * Waits for up to millis milliseconds for a view change to be received.
- *
- * @param timeout length of time to wait for a view change
- * @param unit time unit to use
- * @return true if a view change is received, false otherwise.
- * @throws InterruptedException
- */
- public boolean waitForViewChange(long timeout, TimeUnit unit) throws InterruptedException {
- return latch.await(timeout, unit);
- }
-}
\ No newline at end of file
15 years, 10 months
JBoss Cache SVN: r7617 - in core/branches/flat/src: main/java/org/horizon/config and 10 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-30 12:06:45 -0500 (Fri, 30 Jan 2009)
New Revision: 7617
Modified:
core/branches/flat/src/main/java/org/horizon/commands/remote/ClusteredGetCommand.java
core/branches/flat/src/main/java/org/horizon/config/EvictionConfig.java
core/branches/flat/src/main/java/org/horizon/context/InvocationContextImpl.java
core/branches/flat/src/main/java/org/horizon/context/TransactionContext.java
core/branches/flat/src/main/java/org/horizon/context/TransactionContextImpl.java
core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java
core/branches/flat/src/main/java/org/horizon/interceptors/InterceptorChain.java
core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java
core/branches/flat/src/main/java/org/horizon/lock/LockManager.java
core/branches/flat/src/main/java/org/horizon/lock/StripedLock.java
core/branches/flat/src/main/java/org/horizon/marshall/UnmarshalledReferences.java
core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvent.java
core/branches/flat/src/main/java/org/horizon/notifications/event/EventImpl.java
core/branches/flat/src/main/java/org/horizon/util/ImmutableListCopy.java
core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java
core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java
core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
Log:
Javadocs, comments, variable names
Modified: core/branches/flat/src/main/java/org/horizon/commands/remote/ClusteredGetCommand.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/remote/ClusteredGetCommand.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/commands/remote/ClusteredGetCommand.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -70,8 +70,7 @@
*
* @param context invocation context, ignored.
* @return a List containing 2 elements: a boolean, (true or false) and a value (Object) which is the result of
- * invoking a remote get specified by {@link #getDataCommand()}. If buddy replication is used one further
- * element is added - an Fqn of the backup subtree in which this node may be found.
+ * invoking a remote get specified by {@link #getDataCommand()}.
*/
public Object perform(InvocationContext context) throws Throwable {
if (trace)
Modified: core/branches/flat/src/main/java/org/horizon/config/EvictionConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/EvictionConfig.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/config/EvictionConfig.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -52,7 +52,7 @@
public EvictionConfig() {
// evictionCacheConfigs = new LinkedList<EvictionCacheConfig>();
-// defaultEvictionCacheConfig = new EvictionCacheConfig(Fqn.ROOT);
+// defaultEvictionCacheConfig = new EvictionCacheConfig(ROOT);
// defaultEvictionCacheConfig.setEventQueueSize(EVENT_QUEUE_SIZE_DEFAULT);
// defaultEvictionCacheConfig.setEvictionActionClassName(DefaultEvictionAction.class.getName());
}
@@ -196,10 +196,6 @@
}
- /**
- * Returns the <code>EvictionRegionConfig</code> coresponding to given region fqn, or <code>null</code> if no match
- * is found.
- */
public EvictionCacheConfig getEvictionRegionConfig(String region) {
return null;
}
Modified: core/branches/flat/src/main/java/org/horizon/context/InvocationContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/context/InvocationContextImpl.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/context/InvocationContextImpl.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -57,9 +57,6 @@
/**
* LinkedHashSet of locks acquired by the invocation. We use a LinkedHashSet because we need efficient Set semantics
* but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held
- * here). once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
*/
protected LinkedHashSet<Object> invocationLocks;
private FastCopyHashMap<Object, MVCCEntry> lookedUpEntries = null;
Modified: core/branches/flat/src/main/java/org/horizon/context/TransactionContext.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/context/TransactionContext.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/context/TransactionContext.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -71,18 +71,18 @@
List<VisitableCommand> getLocalModifications();
/**
- * Adds the node that has been removed in the scope of the current transaction.
+ * Adds the key that has been removed in the scope of the current transaction.
*
- * @param key fqn that has been removed.
- * @throws NullPointerException if the Fqn is null.
+ * @param key key that has been removed.
+ * @throws NullPointerException if the key is null.
*/
void addRemovedEntry(Object key);
/**
- * Gets the list of removed nodes.
+ * Gets the list of removed keys.
*
- * @return list of nodes removed in the current transaction scope. Note that this method will return an empty list
- * if nothing has been removed. The list returned is defensively copied.
+ * @return list of keys of entries removed in the current transaction scope. Note that this method will return an
+ * empty list if nothing has been removed. The list returned is defensively copied.
*/
List<Object> getRemovedEntries();
@@ -194,14 +194,14 @@
void setForceSyncReplication(boolean forceSyncReplication);
/**
- * Adds an Fqn to the list of uninitialized nodes created by the cache loader.
+ * Adds a key to the list of uninitialized entry keys created by the cache loader.
*
- * @param key fqn to add. Must not be null.
+ * @param key key to add. Must not be null.
*/
void addDummyEntryCreatedByCacheLoader(Object key);
/**
- * @return a list of uninitialized nodes created by the cache loader, or an empty list.
+ * @return a list of uninitialized entries created by the cache loader, or an empty list.
*/
List<Object> getDummyEntriesCreatedByCacheLoader();
Modified: core/branches/flat/src/main/java/org/horizon/context/TransactionContextImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/context/TransactionContextImpl.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/context/TransactionContextImpl.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -66,22 +66,19 @@
/**
* LinkedHashSet of locks acquired by the transaction. We use a LinkedHashSet because we need efficient Set semantics
* but also need guaranteed ordering for use by lock release code (see JBCCACHE-874).
- * <p/>
- * This needs to be unchecked since we support both MVCC (Fqns held here) or legacy Opt/Pess locking (NodeLocks held
- * here). once we drop support for opt/pess locks we can genericise this to contain Fqns. - Manik Surtani, June 2008
*/
private LinkedHashSet<Object> transactionLocks;
/**
- * A list of dummy uninitialised nodes created by the cache loader interceptor to load data for a given node in this
- * tx.
+ * A list of dummy uninitialised entries created by the cache loader interceptor to load data for a given entry in
+ * this tx.
*/
- private List<Object> dummyNodesCreatedByCacheLoader;
+ private List<Object> dummyEntriesCreatedByCacheLoader;
/**
- * List<Fqn> of nodes that have been removed by the transaction
+ * List<Object> of keys that have been removed by the transaction
*/
- private List<Object> removedNodes = null;
+ private List<Object> removedKeys = null;
private final FastCopyHashMap<Object, MVCCEntry> lookedUpEntries = new FastCopyHashMap<Object, MVCCEntry>(8);
private GlobalTransaction gtx;
@@ -115,8 +112,8 @@
localModifications = null;
option = null;
if (transactionLocks != null) transactionLocks.clear();
- if (dummyNodesCreatedByCacheLoader != null) dummyNodesCreatedByCacheLoader.clear();
- if (removedNodes != null) removedNodes.clear();
+ if (dummyEntriesCreatedByCacheLoader != null) dummyEntriesCreatedByCacheLoader.clear();
+ if (removedKeys != null) removedKeys.clear();
lookedUpEntries.clear();
}
@@ -153,13 +150,13 @@
public void addRemovedEntry(Object key) {
if (key == null) throw new NullPointerException("Key is null!");
- if (removedNodes == null) removedNodes = new LinkedList<Object>();
- removedNodes.add(key);
+ if (removedKeys == null) removedKeys = new LinkedList<Object>();
+ removedKeys.add(key);
}
public List<Object> getRemovedEntries() {
- if (removedNodes == null) return Collections.emptyList();
- return new ArrayList<Object>(removedNodes);
+ if (removedKeys == null) return Collections.emptyList();
+ return new ArrayList<Object>(removedKeys);
}
public void setTransaction(Transaction tx) {
@@ -240,14 +237,14 @@
}
public void addDummyEntryCreatedByCacheLoader(Object key) {
- if (dummyNodesCreatedByCacheLoader == null)
- dummyNodesCreatedByCacheLoader = new LinkedList<Object>();
- dummyNodesCreatedByCacheLoader.add(key);
+ if (dummyEntriesCreatedByCacheLoader == null)
+ dummyEntriesCreatedByCacheLoader = new LinkedList<Object>();
+ dummyEntriesCreatedByCacheLoader.add(key);
}
public List<Object> getDummyEntriesCreatedByCacheLoader() {
- if (dummyNodesCreatedByCacheLoader == null) return Collections.emptyList();
- return dummyNodesCreatedByCacheLoader;
+ if (dummyEntriesCreatedByCacheLoader == null) return Collections.emptyList();
+ return dummyEntriesCreatedByCacheLoader;
}
public void setOption(Option o) {
Modified: core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/factories/EntryFactoryImpl.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -165,7 +165,7 @@
*/
public boolean acquireLock(InvocationContext ctx, Object key) throws InterruptedException, TimeoutException {
// don't EVER use lockManager.isLocked() since with lock striping it may be the case that we hold the relevant
- // lock which may be shared with another Fqn that we have a lock for already.
+ // lock which may be shared with another key that we have a lock for already.
// nothing wrong, just means that we fail to record the lock. And that is a problem.
// Better to check our records and lock again if necessary.
if (!ctx.hasLockedKey(key)) {
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/InterceptorChain.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/InterceptorChain.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/InterceptorChain.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -304,11 +304,11 @@
* Returns all the interceptors that have the fully qualified name of their class equal with the supplied class
* name.
*/
- public List<CommandInterceptor> getInterceptorsWithClassName(String fqName) {
+ public List<CommandInterceptor> getInterceptorsWithClassName(String name) {
CommandInterceptor iterator = firstInChain;
List<CommandInterceptor> result = new ArrayList<CommandInterceptor>(2);
while (iterator != null) {
- if (iterator.getClass().getName().equals(fqName)) result.add(iterator);
+ if (iterator.getClass().getName().equals(name)) result.add(iterator);
iterator = iterator.getNext();
}
return result;
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/InvalidationInterceptor.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -59,9 +59,9 @@
* This interceptor acts as a replacement to the replication interceptor when the CacheImpl is configured with
* ClusteredSyncMode as INVALIDATE.
* <p/>
- * The idea is that rather than replicating changes to all caches in a cluster when CRUD (Create, Remove, Update,
- * Delete) methods are called, simply call evict(Fqn) on the remote caches for each changed node. This allows the
- * remote node to look up the value in a shared cache loader which would have been updated with the changes.
+ * The idea is that rather than replicating changes to all caches in a cluster when write methods are called, simply
+ * broadcast an {@link InvalidateCommand} on the remote caches containing all keys modified. This allows the remote
+ * cache to look up the value in a shared cache loader which would have been updated with the changes.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
* @since 1.0
Modified: core/branches/flat/src/main/java/org/horizon/lock/LockManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/lock/LockManager.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/lock/LockManager.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -104,7 +104,7 @@
void unlock(InvocationContext ctx);
/**
- * Tests whether a given owner owns a lock of lockType on a particular Fqn.
+ * Tests whether a given owner owns a lock of lockType on a particular cache entry.
*
* @param owner owner
* @return true if the owner does own the specified lock type on the specified cache entry, false otherwise.
@@ -119,7 +119,7 @@
boolean isLocked(Object key);
/**
- * Retrieves the write lock owner, if any, for the current Fqn.
+ * Retrieves the write lock owner, if any, for the specified cache entry.
*
* @return the owner of the lock, or null if not locked.
*/
Modified: core/branches/flat/src/main/java/org/horizon/lock/StripedLock.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/lock/StripedLock.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/lock/StripedLock.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -27,14 +27,14 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
/**
- * A simple implementation of lock striping, using Fqns as the keys to lock on, primarily used to help make {@link
+ * A simple implementation of lock striping, using cache entry keys to lock on, primarily used to help make {@link
* org.horizon.loader.CacheLoader} implemtations thread safe.
* <p/>
* Backed by a set of {@link java.util.concurrent.locks.ReentrantReadWriteLock} instances, and using the key hashcodes
* to determine buckets.
* <p/>
- * Since buckets are used, it doesn't matter that the Fqn in question is not removed from the lock map when no longer in
- * use, since the Fqn is not referenced in this class. Rather, the hash code is used.
+ * Since buckets are used, it doesn't matter that the key in question is not removed from the lock map when no longer in
+ * use, since the key is not referenced in this class. Rather, the hash code is used.
* <p/>
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
@@ -124,16 +124,19 @@
}
/**
- * Releases locks on all fqns passed in. Makes multiple calls to {@link #releaseLock(Object)}. This method is
+ * Releases locks on all keys passed in. Makes multiple calls to {@link #releaseLock(Object)}. This method is
* idempotent.
+ *
+ * @param keys keys to unlock
*/
public void releaseAllLocks(List<Object> keys) {
for (Object k : keys) releaseLock(k);
}
/**
- * Acquires locks on all fqns passed in. Makes multiple calls to {@link #acquireLock(Object, boolean)}
+ * Acquires locks on keys passed in. Makes multiple calls to {@link #acquireLock(Object, boolean)}
*
+ * @param keys keys to unlock
* @param exclusive whether locks are exclusive.
*/
public void acquireAllLocks(List<Object> keys, boolean exclusive) {
Modified: core/branches/flat/src/main/java/org/horizon/marshall/UnmarshalledReferences.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/UnmarshalledReferences.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/marshall/UnmarshalledReferences.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -60,7 +60,6 @@
return;
} else if (ref > sz) {
// if we are adding the reference to a position beyond the end of the list, make sure we expand the list first.
- // this can happen, weirdly enough, since marshallObject() can be called recursively, such as from marshallFqn().
for (int i = sz; i < ref; i++) referencedObjects.add(null);
}
referencedObjects.add(o);
Modified: core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvent.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/notifications/event/CacheEntryEvent.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -22,7 +22,7 @@
package org.horizon.notifications.event;
/**
- * Transactional events that additionally expose an Fqn as such events pertain to a specific cache entry.
+ * Transactional events that additionally expose a key as such events pertain to a specific cache entry.
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani</a>
* @since 1.0
Modified: core/branches/flat/src/main/java/org/horizon/notifications/event/EventImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/notifications/event/EventImpl.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/notifications/event/EventImpl.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -23,7 +23,6 @@
import org.horizon.Cache;
import org.horizon.remoting.transport.Address;
-import org.horizon.tree.Fqn;
import javax.transaction.Transaction;
import java.util.List;
@@ -43,19 +42,17 @@
private Object key;
private Transaction transaction;
private boolean originLocal = true; // by default events all originate locally
- private Fqn targetFqn;
private boolean successful;
private Type type;
private List<Address> members;
Address localAddress;
- public EventImpl(boolean pre, Cache cache, Object key, Transaction transaction, boolean originLocal, Fqn targetFqn, boolean successful, List<Address> members, Address localAddress, Type type) {
+ public EventImpl(boolean pre, Cache cache, Object key, Transaction transaction, boolean originLocal, boolean successful, List<Address> members, Address localAddress, Type type) {
this.pre = pre;
this.cache = cache;
this.key = key;
this.transaction = transaction;
this.originLocal = originLocal;
- this.targetFqn = targetFqn;
this.successful = successful;
this.type = type;
this.members = members;
@@ -89,10 +86,6 @@
return originLocal;
}
- public Fqn getTargetFqn() {
- return targetFqn;
- }
-
public boolean isSuccessful() {
return successful;
}
@@ -119,10 +112,6 @@
this.originLocal = originLocal;
}
- public void setTargetFqn(Fqn targetFqn) {
- this.targetFqn = targetFqn;
- }
-
public void setSuccessful(boolean successful) {
this.successful = successful;
}
@@ -145,7 +134,6 @@
if (key != null ? !key.equals(event.key) : event.key != null) return false;
if (localAddress != null ? !localAddress.equals(event.localAddress) : event.localAddress != null) return false;
if (members != null ? !members.equals(event.members) : event.members != null) return false;
- if (targetFqn != null ? !targetFqn.equals(event.targetFqn) : event.targetFqn != null) return false;
if (transaction != null ? !transaction.equals(event.transaction) : event.transaction != null) return false;
if (type != event.type) return false;
@@ -159,7 +147,6 @@
result = 31 * result + (key != null ? key.hashCode() : 0);
result = 31 * result + (transaction != null ? transaction.hashCode() : 0);
result = 31 * result + (originLocal ? 1 : 0);
- result = 31 * result + (targetFqn != null ? targetFqn.hashCode() : 0);
result = 31 * result + (successful ? 1 : 0);
result = 31 * result + (type != null ? type.hashCode() : 0);
result = 31 * result + (members != null ? members.hashCode() : 0);
@@ -176,7 +163,6 @@
", key=" + key +
", transaction=" + transaction +
", originLocal=" + originLocal +
- ", targetFqn=" + targetFqn +
", successful=" + successful +
", members=" + members +
", localAddress=" + localAddress +
Modified: core/branches/flat/src/main/java/org/horizon/util/ImmutableListCopy.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/util/ImmutableListCopy.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/util/ImmutableListCopy.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -41,7 +41,7 @@
* <p/>
* a it is far more efficient than making a defensive copy and then wrapping the defensive copy in a read-only wrapper.
* <p/>
- * Also used whenever a read-only reference List is needed (such as in Fqns).
+ * Also used whenever a read-only reference List is needed.
* <p/>
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
Modified: core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -407,24 +407,6 @@
// don't care
}
}
-
- // TODO fix cache loader stuff
- /*
- CacheLoaderManager clm = spi.getCacheLoaderManager();
- CacheLoader cl = clm == null ? null : clm.getCacheLoader();
- if (cl != null)
- {
- try
- {
- cl.remove(Fqn.ROOT);
- }
- catch (Exception e)
- {
- // don't care
- }
- }
- */
-
spi.stop();
}
}
Modified: core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/test/java/org/horizon/api/mvcc/PutForExternalReadTest.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -142,8 +142,8 @@
tm1.resume(t);
tm1.commit();
- assertEquals("parent fqn tx should have completed", value, cache1.get(key + "0"));
- assertEquals("parent fqn tx should have completed", value, cache2.get(key + "0"));
+ assertEquals("tx should have completed", value, cache1.get(key + "0"));
+ assertEquals("tx should have completed", value, cache2.get(key + "0"));
}
public void testExceptionSuppression() throws Exception {
Modified: core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/test/java/org/horizon/profiling/ProfileTest.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -99,7 +99,6 @@
long startTime = System.currentTimeMillis();
TaskRunner exec = new TaskRunner(NUM_THREADS);
log.warn("Starting warmup");
- // creates all the Fqns since this can be expensive and we don't really want to measure this (for now)
for (final Object key : keys) {
exec.execute(new Runnable() {
public void run() {
Modified: core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java 2009-01-30 16:48:58 UTC (rev 7616)
+++ core/branches/flat/src/test/java/org/horizon/replication/SyncCacheListenerTest.java 2009-01-30 17:06:45 UTC (rev 7617)
@@ -29,7 +29,6 @@
import javax.transaction.TransactionManager;
import java.util.List;
import java.util.Map;
-import java.util.Set;
/**
* Test out the CacheListener
@@ -161,12 +160,9 @@
cache1.put(key, val);
}
- public void put(String fqn, Map map) {
- if (map.size() == 0)
- fail("put(): map size can't be 0");
- Set<String> set = map.keySet();
- key = set.iterator().next();// take anyone
- cache1.put(fqn, map);
+ public void put(Map map) {
+ if (map.size() == 0) fail("put(): map size can't be 0");
+ cache1.putAll(map);
}
@CacheEntryModified
15 years, 10 months