JBoss Cache SVN: r7546 - in core/branches/flat/src: main/java/org/horizon/config and 6 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-20 14:24:46 -0500 (Tue, 20 Jan 2009)
New Revision: 7546
Added:
core/branches/flat/src/main/java/org/horizon/commands/RemoteCommandFactory.java
core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentFactory.java
core/branches/flat/src/main/java/org/horizon/factories/AbstractNamedCacheComponentFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java
Removed:
core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java
Modified:
core/branches/flat/src/main/java/org/horizon/commands/CommandsFactory.java
core/branches/flat/src/main/java/org/horizon/commands/CommandsFactoryImpl.java
core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java
core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java
core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java
core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java
core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java
core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java
core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java
core/branches/flat/src/main/java/org/horizon/jmx/JmxRegistrationManager.java
core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java
core/branches/flat/src/main/java/org/horizon/marshall/Marshaller.java
core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java
core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandler.java
core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandlerImpl.java
core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java
Log:
More construction stuff
Modified: core/branches/flat/src/main/java/org/horizon/commands/CommandsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/CommandsFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/commands/CommandsFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -70,7 +70,17 @@
RollbackCommand buildRollbackCommand(GlobalTransaction gtx);
- ReplicableCommand fromStream(byte methodId, Object[] args);
+ /**
+ * Initializes a {@link org.horizon.commands.ReplicableCommand} read from a data stream with components specific to
+ * the target cache instance.
+ * <p/>
+ * Implementations should also be deep, in that if the command contains other commands, these should be recursed
+ * into.
+ * <p/>
+ *
+ * @param command command to initialize. Cannot be null.
+ */
+ void initializeReplicableCommand(ReplicableCommand command);
ReplicateCommand buildReplicateCommand(List<ReplicableCommand> toReplicate);
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-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/commands/CommandsFactoryImpl.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -21,7 +21,6 @@
*/
package org.horizon.commands;
-import org.horizon.CacheException;
import org.horizon.commands.read.GetKeyValueCommand;
import org.horizon.commands.read.SizeCommand;
import org.horizon.commands.remote.ReplicateCommand;
@@ -115,70 +114,32 @@
return new ReplicateCommand(call);
}
- public ReplicableCommand fromStream(byte id, Object[] parameters) {
- ReplicableCommand command;
- switch (id) {
- case PutKeyValueCommand.METHOD_ID: {
- PutKeyValueCommand c = new PutKeyValueCommand();
- c.init(notifier);
- command = c;
+ public void initializeReplicableCommand(ReplicableCommand c) {
+ if (c == null) return;
+ switch (c.getCommandId()) {
+ case PutKeyValueCommand.METHOD_ID:
+ ((PutKeyValueCommand) c).init(notifier);
break;
- }
- case PutMapCommand.METHOD_ID: {
- PutMapCommand c = new PutMapCommand();
- c.init(notifier);
- command = c;
+ case PutMapCommand.METHOD_ID:
+ ((PutMapCommand) c).init(notifier);
break;
- }
- case RemoveCommand.METHOD_ID: {
- RemoveCommand c = new RemoveCommand();
- c.init(notifier);
- command = c;
+ case RemoveCommand.METHOD_ID:
+ ((RemoveCommand) c).init(notifier);
break;
- }
- case ReplaceCommand.METHOD_ID: {
- ReplaceCommand c = new ReplaceCommand();
- command = c;
- break;
- }
- case GetKeyValueCommand.METHOD_ID: {
- GetKeyValueCommand c = new GetKeyValueCommand();
- command = c;
- break;
- }
- case ClearCommand.METHOD_ID: {
- ClearCommand c = new ClearCommand();
- command = c;
- break;
- }
- case PrepareCommand.METHOD_ID: {
- PrepareCommand c = new PrepareCommand();
- command = c;
- break;
- }
- case CommitCommand.METHOD_ID: {
- CommitCommand c = new CommitCommand();
- command = c;
- break;
- }
- case RollbackCommand.METHOD_ID: {
- RollbackCommand c = new RollbackCommand();
- command = c;
- break;
- }
case ReplicateCommand.MULTIPLE_METHOD_ID:
- case ReplicateCommand.SINGLE_METHOD_ID: {
- ReplicateCommand c = new ReplicateCommand();
- c.initialize(interceptorChain);
- command = c;
+ case ReplicateCommand.SINGLE_METHOD_ID:
+ ReplicateCommand rc = (ReplicateCommand) c;
+ if (rc.getModifications() != null)
+ for (ReplicableCommand nested : rc.getModifications()) initializeReplicableCommand(nested);
+ initializeReplicableCommand(rc.getSingleModification());
+ rc.initialize(interceptorChain);
break;
- }
-
- default:
- throw new CacheException("Unknown command id " + id + "!");
+ case PrepareCommand.METHOD_ID:
+ PrepareCommand pc = (PrepareCommand) c;
+ if (pc.getModifications() != null)
+ for (ReplicableCommand nested : pc.getModifications()) initializeReplicableCommand(nested);
+ break;
}
- command.setParameters(id, parameters);
- return command;
}
public InvalidateCommand buildInvalidateCommand(Object fqn) {
Added: core/branches/flat/src/main/java/org/horizon/commands/RemoteCommandFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/commands/RemoteCommandFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/commands/RemoteCommandFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -0,0 +1,75 @@
+package org.horizon.commands;
+
+import org.horizon.CacheException;
+import org.horizon.commands.read.GetKeyValueCommand;
+import org.horizon.commands.remote.ReplicateCommand;
+import org.horizon.commands.tx.CommitCommand;
+import org.horizon.commands.tx.PrepareCommand;
+import org.horizon.commands.tx.RollbackCommand;
+import org.horizon.commands.write.ClearCommand;
+import org.horizon.commands.write.PutKeyValueCommand;
+import org.horizon.commands.write.PutMapCommand;
+import org.horizon.commands.write.RemoveCommand;
+import org.horizon.commands.write.ReplaceCommand;
+
+/**
+ * Specifically used to create un-initialized {@link org.horizon.commands.ReplicableCommand}s from a byte stream.
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public class RemoteCommandFactory {
+
+ /**
+ * Creates an un-initialized command. Un-initialized in the sense that parameters will be set, but any components
+ * specific to the cache in question will not be set.
+ * <p/>
+ * You would typically set these parameters using {@link org.horizon.commands.CommandsFactory#initializeReplicableCommand(ReplicableCommand)}
+ * <p/>
+ *
+ * @param id id of the command
+ * @param parameters parameters to set
+ * @return a replicable command
+ */
+ public ReplicableCommand fromStream(byte id, Object[] parameters) {
+ ReplicableCommand command;
+ switch (id) {
+ case PutKeyValueCommand.METHOD_ID:
+ command = new PutKeyValueCommand();
+ break;
+ case PutMapCommand.METHOD_ID:
+ command = new PutMapCommand();
+ break;
+ case RemoveCommand.METHOD_ID:
+ command = new RemoveCommand();
+ break;
+ case ReplaceCommand.METHOD_ID:
+ command = new ReplaceCommand();
+ break;
+ case GetKeyValueCommand.METHOD_ID:
+ command = new GetKeyValueCommand();
+ break;
+ case ClearCommand.METHOD_ID:
+ command = new ClearCommand();
+ break;
+ case PrepareCommand.METHOD_ID:
+ command = new PrepareCommand();
+ break;
+ case CommitCommand.METHOD_ID:
+ command = new CommitCommand();
+ break;
+ case RollbackCommand.METHOD_ID:
+ command = new RollbackCommand();
+ break;
+ case ReplicateCommand.MULTIPLE_METHOD_ID:
+ case ReplicateCommand.SINGLE_METHOD_ID:
+ command = new ReplicateCommand();
+ break;
+
+ default:
+ throw new CacheException("Unknown command id " + id + "!");
+ }
+ command.setParameters(id, parameters);
+ return command;
+ }
+}
Modified: core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -10,6 +10,7 @@
import org.horizon.factories.annotations.NonVolatile;
import org.horizon.factories.scopes.Scope;
import org.horizon.factories.scopes.Scopes;
+import org.horizon.remoting.transport.jgroups.JGroupsTransport;
import org.horizon.util.TypedProperties;
import java.util.Properties;
@@ -358,4 +359,31 @@
throw new CacheException("Problems cloning configuration component!", e);
}
}
+
+ /**
+ * Helper method that gets you a default constructed GlobalConfiguration, preconfigured to use the default clustering
+ * stack
+ *
+ * @return a new global configuration
+ */
+ public static GlobalConfiguration getClusteredDefault() {
+ GlobalConfiguration gc = new GlobalConfiguration();
+ gc.setTransportClass(JGroupsTransport.class.getName());
+ gc.setTransportProperties((Properties) null);
+ return gc;
+ }
+
+ /**
+ * Helper method that gets you a default constructed GlobalConfiguration, preconfigured for use in LOCAL mode
+ *
+ * @return a new global configuration
+ */
+ public static GlobalConfiguration getNonClusteredDefault() {
+ GlobalConfiguration gc = new GlobalConfiguration();
+ gc.setTransportClass(null);
+ gc.setTransportProperties((Properties) null);
+ return gc;
+ }
+
+
}
Copied: core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentFactory.java (from rev 7537, core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -0,0 +1,79 @@
+/*
+ * 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.factories;
+
+import org.horizon.config.ConfigurationException;
+import org.horizon.config.GlobalConfiguration;
+import org.horizon.factories.annotations.Inject;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+import org.horizon.logging.Log;
+import org.horizon.logging.LogFactory;
+
+/**
+ * Factory that creates components used internally within JBoss Cache, and also wires dependencies into the components.
+ * <p/>
+ * The {@link DefaultCacheFactory} is a special subclass of this, which bootstraps the construction of other components.
+ * When this class is loaded, it maintains a static list of known default factories for known components, which it then
+ * delegates to, when actually performing the construction.
+ * <p/>
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @see Inject
+ * @see ComponentRegistry
+ * @since 1.0
+ */
+(a)Scope(Scopes.GLOBAL)
+public abstract class AbstractComponentFactory {
+ protected final Log log = LogFactory.getLog(getClass());
+ protected GlobalComponentRegistry globalComponentRegistry;
+ protected GlobalConfiguration globalConfiguration;
+
+ /**
+ * Constructs a new ComponentFactory.
+ */
+ public AbstractComponentFactory() {
+ }
+
+ @Inject
+ private void injectGlobalDependencies(GlobalConfiguration globalConfiguration, GlobalComponentRegistry globalComponentRegistry) {
+ this.globalComponentRegistry = globalComponentRegistry;
+ this.globalConfiguration = globalConfiguration;
+ }
+
+ /**
+ * Constructs a component.
+ *
+ * @param componentType type of component
+ * @return a component
+ */
+ public abstract <T> T construct(Class<T> componentType);
+
+ protected void assertTypeConstructable(Class requestedType, Class... ableToConstruct) {
+ boolean canConstruct = false;
+ for (Class c : ableToConstruct) {
+ canConstruct = canConstruct || requestedType.isAssignableFrom(c);
+ }
+ if (!canConstruct) throw new ConfigurationException("Don't know how to construct " + requestedType);
+ }
+
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -81,13 +81,13 @@
public abstract class AbstractComponentRegistry implements Lifecycle {
// Be careful when changing this to 'true'. It should *never* go into the code repo with this flag set to 'true'!
- private static final boolean DEBUG_DEPENDENCIES = false;
+ private static final boolean DEBUG_DEPENDENCIES = true;
private Stack<String> debugStack = DEBUG_DEPENDENCIES ? new Stack<String>() : null;
/**
* Contains class definitions of component factories that can be used to construct certain components
*/
- private Map<Class, Class<? extends ComponentFactory>> defaultFactories = null;
+ private Map<Class, Class<? extends AbstractComponentFactory>> defaultFactories = null;
protected static final Object NULL_COMPONENT = new Object();
@@ -139,9 +139,10 @@
*
* @return set of known factory types.
*/
- private Set<Class<? extends ComponentFactory>> getHardcodedFactories() {
- Set<Class<? extends ComponentFactory>> s = new HashSet<Class<? extends ComponentFactory>>();
+ private Set<Class<? extends AbstractComponentFactory>> getHardcodedFactories() {
+ Set<Class<? extends AbstractComponentFactory>> s = new HashSet<Class<? extends AbstractComponentFactory>>();
s.add(BootstrapFactory.class);
+ s.add(EmptyConstructorNamedCacheFactory.class);
s.add(EmptyConstructorFactory.class);
s.add(InterceptorChainFactory.class);
s.add(RPCManagerFactory.class);
@@ -282,7 +283,7 @@
if (component == null) {
// create this component and add it to the registry
- ComponentFactory factory = getFactory(componentClass);
+ AbstractComponentFactory factory = getFactory(componentClass);
component = factory instanceof NamedComponentFactory ?
((NamedComponentFactory) factory).construct(componentClass, name)
: factory.construct(componentClass);
@@ -310,13 +311,13 @@
* @param componentClass type of component to construct
* @return component factory capable of constructing such components
*/
- protected ComponentFactory getFactory(Class componentClass) {
- Map<Class, Class<? extends ComponentFactory>> defaultFactoryMap = getDefaultFactoryMap();
- Class<? extends ComponentFactory> cfClass = defaultFactoryMap.get(componentClass);
+ protected AbstractComponentFactory getFactory(Class componentClass) {
+ Map<Class, Class<? extends AbstractComponentFactory>> defaultFactoryMap = getDefaultFactoryMap();
+ Class<? extends AbstractComponentFactory> cfClass = defaultFactoryMap.get(componentClass);
if (cfClass == null)
throw new ConfigurationException("No registered default factory for component " + componentClass + " found! Debug stack: " + debugStack);
// a component factory is a component too! See if one has been created and exists in the registry
- ComponentFactory cf = getComponent(cfClass);
+ AbstractComponentFactory cf = getComponent(cfClass);
if (cf == null) {
// hasn't yet been created. Create and put in registry
cf = instantiateFactory(cfClass);
@@ -327,13 +328,17 @@
}
// ensure the component factory is in the STARTED state!
- Component c = componentLookup.get(cfClass.getName());
+ Component c = lookupComponent(cfClass, cfClass.getName());
if (c.instance != cf)
throw new ConfigurationException("Component factory " + cfClass + " incorrectly registered! Debug stack: " + debugStack);
return cf;
}
- protected Map<Class, Class<? extends ComponentFactory>> getDefaultFactoryMap() {
+ protected Component lookupComponent(Class type, String componentName) {
+ return componentLookup.get(componentName);
+ }
+
+ protected Map<Class, Class<? extends AbstractComponentFactory>> getDefaultFactoryMap() {
if (defaultFactories == null) scanDefaultFactories();
return defaultFactories;
}
@@ -343,10 +348,10 @@
* created by such factories.
*/
void scanDefaultFactories() {
- Map<Class, Class<? extends ComponentFactory>> temp = new HashMap<Class, Class<? extends ComponentFactory>>();
- Set<Class<? extends ComponentFactory>> factories = getHardcodedFactories();
+ Map<Class, Class<? extends AbstractComponentFactory>> temp = new HashMap<Class, Class<? extends AbstractComponentFactory>>();
+ Set<Class<? extends AbstractComponentFactory>> factories = getHardcodedFactories();
- for (Class<? extends ComponentFactory> factory : factories) {
+ for (Class<? extends AbstractComponentFactory> factory : factories) {
// check if this implements auto-instantiable. If it doesn't have a no-arg constructor throw an exception
boolean factoryValid = true;
try {
@@ -376,7 +381,7 @@
* @param factory class of factory to be created
* @return factory instance
*/
- ComponentFactory instantiateFactory(Class<? extends ComponentFactory> factory) {
+ AbstractComponentFactory instantiateFactory(Class<? extends AbstractComponentFactory> factory) {
if (AutoInstantiableFactory.class.isAssignableFrom(factory)) {
try {
return factory.newInstance();
@@ -457,13 +462,27 @@
@SuppressWarnings("unchecked")
public <T> T getComponent(Class<T> type, String name) {
- Component wrapper = componentLookup.get(name);
+ Component wrapper = lookupComponent(type, name);
if (wrapper == null) return null;
return (T) (wrapper.instance == NULL_COMPONENT ? null : wrapper.instance);
}
/**
+ * Registers the default class loader. This method *must* be called before any other components are registered,
+ * typically called by bootstrap code. Defensively, it is called in the constructor of ComponentRegistry with a null
+ * parameter.
+ *
+ * @param loader a class loader to use by default. If this is null, the class loader used to load this instance of
+ * ComponentRegistry is used.
+ */
+ public void registerDefaultClassLoader(ClassLoader loader) {
+ registerComponent(loader == null ? getClass().getClassLoader() : loader, ClassLoader.class);
+ // make sure the class loader is non-volatile, so it survives restarts.
+ componentLookup.get(ClassLoader.class.getName()).nonVolatile = true;
+ }
+
+ /**
* Rewires components. Can only be called if the current state is WIRED or STARTED.
*/
public void rewire() {
@@ -885,7 +904,7 @@
*
* @return a set of components
*/
- public Set<Component> getRegiteredComponents() {
+ public Set<Component> getRegisteredComponents() {
HashSet<Component> defensiveCopy = new HashSet<Component>(componentLookup.values());
return Collections.unmodifiableSet(defensiveCopy);
}
Added: core/branches/flat/src/main/java/org/horizon/factories/AbstractNamedCacheComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/AbstractNamedCacheComponentFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/AbstractNamedCacheComponentFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -0,0 +1,24 @@
+package org.horizon.factories;
+
+import org.horizon.config.Configuration;
+import org.horizon.factories.annotations.Inject;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+
+/**
+ * A component factory for creating components scoped per-cache.
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+(a)Scope(Scopes.NAMED_CACHE)
+public abstract class AbstractNamedCacheComponentFactory extends AbstractComponentFactory {
+ protected Configuration configuration;
+ protected ComponentRegistry componentRegistry;
+
+ @Inject
+ private void injectGlobalDependencies(Configuration configuration, ComponentRegistry componentRegistry) {
+ this.componentRegistry = componentRegistry;
+ this.configuration = configuration;
+ }
+}
Modified: core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -35,11 +35,12 @@
*/
@DefaultFactoryFor(classes = {CacheSPI.class, Configuration.class, ComponentRegistry.class})
@NonVolatile
-public class BootstrapFactory extends ComponentFactory {
+public class BootstrapFactory extends AbstractNamedCacheComponentFactory {
CacheSPI cacheSPI;
public BootstrapFactory(CacheSPI cacheSPI, Configuration configuration, ComponentRegistry componentRegistry) {
- super(componentRegistry, configuration);
+ this.componentRegistry = componentRegistry;
+ this.configuration = configuration;
this.cacheSPI = cacheSPI;
}
Deleted: core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -1,87 +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.factories;
-
-import org.horizon.config.Configuration;
-import org.horizon.config.ConfigurationException;
-import org.horizon.factories.annotations.Inject;
-import org.horizon.factories.scopes.Scope;
-import org.horizon.factories.scopes.Scopes;
-import org.horizon.logging.Log;
-import org.horizon.logging.LogFactory;
-
-/**
- * Factory that creates components used internally within JBoss Cache, and also wires dependencies into the components.
- * <p/>
- * The {@link DefaultCacheFactory} is a special subclass of this, which bootstraps the construction of other components.
- * When this class is loaded, it maintains a static list of known default factories for known components, which it then
- * delegates to, when actually performing the construction.
- * <p/>
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @see Inject
- * @see ComponentRegistry
- * @since 1.0
- */
-(a)Scope(Scopes.NAMED_CACHE)
-public abstract class ComponentFactory {
- protected final Log log = LogFactory.getLog(getClass());
- protected ComponentRegistry componentRegistry;
- protected Configuration configuration;
-
- /**
- * Constructs a new ComponentFactory.
- */
- public ComponentFactory(ComponentRegistry componentRegistry, Configuration configuration) {
- this.componentRegistry = componentRegistry;
- this.configuration = configuration;
- }
-
- /**
- * Constructs a new ComponentFactory.
- */
- public ComponentFactory() {
- }
-
- @Inject
- private void injectDependencies(Configuration configuration, ComponentRegistry componentRegistry) {
- this.configuration = configuration;
- this.componentRegistry = componentRegistry;
- }
-
- /**
- * Constructs a component.
- *
- * @param componentType type of component
- * @return a component
- */
- public abstract <T> T construct(Class<T> componentType);
-
- protected void assertTypeConstructable(Class requestedType, Class... ableToConstruct) {
- boolean canConstruct = false;
- for (Class c : ableToConstruct) {
- canConstruct = canConstruct || requestedType.isAssignableFrom(c);
- }
- if (!canConstruct) throw new ConfigurationException("Don't know how to construct " + requestedType);
- }
-
-}
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-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -44,6 +44,8 @@
registerComponent(this, ComponentRegistry.class);
registerComponent(configuration, Configuration.class);
registerComponent(new BootstrapFactory(cache, configuration, this), BootstrapFactory.class);
+
+ globalComponents.registerNamedComponentRegistry(this, cacheName);
}
catch (Exception e) {
throw new CacheException("Unable to construct a ComponentRegistry!", e);
@@ -54,47 +56,45 @@
return log;
}
- /**
- * Registers the default class loader. This method *must* be called before any other components are registered,
- * typically called by bootstrap code. Defensively, it is called in the constructor of ComponentRegistry with a null
- * parameter.
- *
- * @param loader a class loader to use by default. If this is null, the class loader used to load this instance of
- * ComponentRegistry is used.
- */
- public void registerDefaultClassLoader(ClassLoader loader) {
- registerComponent(loader == null ? getClass().getClassLoader() : loader, ClassLoader.class);
- // make sure the class loader is non-volatile, so it survives restarts.
- componentLookup.get(ClassLoader.class.getName()).nonVolatile = true;
- }
-
-
@Override
public <T> T getComponent(Class<T> componentType, String name) {
- // first try in the local registry
- Scopes componentScope = ScopeDetector.detectScope(componentType);
- switch (componentScope) {
- case GLOBAL:
- return globalComponents.getComponent(componentType, name);
- case NAMED_CACHE:
- return super.getComponent(componentType, name);
- default:
- throw new IllegalArgumentException("Unknown component scope " + componentScope + " for component type " + componentType);
+ if (isGlobal(componentType)) {
+ return globalComponents.getComponent(componentType, name);
+ } else {
+ return super.getComponent(componentType, name);
}
}
@Override
- protected Map<Class, Class<? extends ComponentFactory>> getDefaultFactoryMap() {
+ protected Map<Class, Class<? extends AbstractComponentFactory>> getDefaultFactoryMap() {
// delegate to parent. No sense maintaining multiple copies of this map.
return globalComponents.getDefaultFactoryMap();
}
@Override
- protected ComponentFactory getFactory(Class componentClass) {
- return super.getFactory(componentClass);
+ protected Component lookupComponent(Class componentClass, String name) {
+ if (isGlobal(componentClass)) {
+ return globalComponents.lookupComponent(componentClass, name);
+ } else {
+ return super.lookupComponent(componentClass, name);
+ }
}
- public GlobalComponentRegistry getSharedComponentRegistry() {
+ public GlobalComponentRegistry getGlobalComponentRegistry() {
return globalComponents;
}
+
+ @Override
+ public void registerComponent(Object component, String name) {
+ if (isGlobal(component.getClass())) {
+ globalComponents.registerComponent(component, name);
+ } else {
+ super.registerComponent(component, name);
+ }
+ }
+
+ private boolean isGlobal(Class clazz) {
+ Scopes componentScope = ScopeDetector.detectScope(clazz);
+ return componentScope == Scopes.GLOBAL;
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -32,7 +32,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = DataContainer.class)
-public class DataContainerFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class DataContainerFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {
public <T> T construct(Class<T> componentType) {
return (T) new UnsortedDataContainer();
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -32,15 +32,15 @@
/**
* Default implementation of the {@link CacheFactory} interface.
* <p/>
- * This is a special instance of a {@link ComponentFactory} which contains bootstrap information for the {@link
+ * This is a special instance of a {@link AbstractComponentFactory} which contains bootstrap information for the {@link
* ComponentRegistry}.
* <p/>
*
* @author <a href="mailto:manik@jboss.org">Manik Surtani (manik(a)jboss.org)</a>
- * @see ComponentFactory
+ * @see AbstractComponentFactory
* @since 1.0
*/
-public class DefaultCacheFactory<K, V> extends ComponentFactory// implements CacheFactory<K, V>
+public class DefaultCacheFactory<K, V> extends AbstractNamedCacheComponentFactory// implements CacheFactory<K, V>
{
private ClassLoader defaultClassLoader;
Deleted: core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -1,69 +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.factories;
-
-
-import org.horizon.batch.BatchContainer;
-import org.horizon.commands.CommandsFactory;
-import org.horizon.config.ConfigurationException;
-import org.horizon.factories.annotations.DefaultFactoryFor;
-import org.horizon.factories.context.ContextFactory;
-import org.horizon.invocation.InvocationContextContainer;
-import org.horizon.loader.CacheLoaderManager;
-import org.horizon.marshall.Marshaller;
-import org.horizon.marshall.VersionAwareMarshaller;
-import org.horizon.notifications.CacheManagerNotifier;
-import org.horizon.notifications.CacheNotifier;
-import org.horizon.remoting.InboundInvocationHandler;
-import org.horizon.transaction.TransactionTable;
-
-/**
- * Simple factory that just uses reflection and an empty constructor of the component type.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 1.0
- */
-@DefaultFactoryFor(classes = {CacheNotifier.class, CacheManagerNotifier.class, InboundInvocationHandler.class,
- CacheLoaderManager.class, Marshaller.class, InvocationContextContainer.class,
- TransactionTable.class, BatchContainer.class, ContextFactory.class, EntryFactory.class, CommandsFactory.class})
-public class EmptyConstructorFactory extends ComponentFactory implements AutoInstantiableFactory {
- @Override
- public <T> T construct(Class<T> componentType) {
- try {
- if (componentType.isInterface()) {
- Class componentImpl;
- if (componentType.equals(Marshaller.class)) {
- componentImpl = VersionAwareMarshaller.class;
- } else {
- // add an "Impl" to the end of the class name and try again
- componentImpl = getClass().getClassLoader().loadClass(componentType.getName() + "Impl");
- }
- return componentType.cast(componentImpl.newInstance());
- } else {
- return componentType.newInstance();
- }
- }
- catch (Exception e) {
- throw new ConfigurationException("Unable to create component " + componentType, e);
- }
- }
-}
Added: core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -0,0 +1,38 @@
+package org.horizon.factories;
+
+import org.horizon.config.ConfigurationException;
+import org.horizon.factories.annotations.DefaultFactoryFor;
+import org.horizon.marshall.Marshaller;
+import org.horizon.marshall.VersionAwareMarshaller;
+import org.horizon.notifications.CacheManagerNotifier;
+import org.horizon.remoting.InboundInvocationHandler;
+
+/**
+ * // TODO: Manik: Document this!
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+@DefaultFactoryFor(classes = {InboundInvocationHandler.class, CacheManagerNotifier.class, Marshaller.class})
+public class EmptyConstructorFactory extends AbstractComponentFactory implements AutoInstantiableFactory {
+ public <T> T construct(Class<T> componentType) {
+ try {
+ if (componentType.isInterface()) {
+ Class componentImpl;
+ if (componentType.equals(Marshaller.class)) {
+ componentImpl = VersionAwareMarshaller.class;
+ } else {
+ // add an "Impl" to the end of the class name and try again
+ componentImpl = getClass().getClassLoader().loadClass(componentType.getName() + "Impl");
+ }
+ return componentType.cast(componentImpl.newInstance());
+ } else {
+ return componentType.newInstance();
+ }
+ }
+ catch (Exception e) {
+ throw new ConfigurationException("Unable to create component " + componentType, e);
+ }
+
+ }
+}
Copied: core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java (from rev 7537, core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -0,0 +1,67 @@
+/*
+ * 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.factories;
+
+
+import org.horizon.batch.BatchContainer;
+import org.horizon.commands.CommandsFactory;
+import org.horizon.config.ConfigurationException;
+import org.horizon.factories.annotations.DefaultFactoryFor;
+import org.horizon.factories.context.ContextFactory;
+import org.horizon.invocation.InvocationContextContainer;
+import org.horizon.loader.CacheLoaderManager;
+import org.horizon.marshall.Marshaller;
+import org.horizon.marshall.VersionAwareMarshaller;
+import org.horizon.notifications.CacheNotifier;
+import org.horizon.transaction.TransactionTable;
+
+/**
+ * Simple factory that just uses reflection and an empty constructor of the component type.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 1.0
+ */
+@DefaultFactoryFor(classes = {CacheNotifier.class, EntryFactory.class, CommandsFactory.class,
+ CacheLoaderManager.class, InvocationContextContainer.class,
+ TransactionTable.class, BatchContainer.class, ContextFactory.class})
+public class EmptyConstructorNamedCacheFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {
+ @Override
+ public <T> T construct(Class<T> componentType) {
+ try {
+ if (componentType.isInterface()) {
+ Class componentImpl;
+ if (componentType.equals(Marshaller.class)) {
+ componentImpl = VersionAwareMarshaller.class;
+ } else {
+ // add an "Impl" to the end of the class name and try again
+ componentImpl = getClass().getClassLoader().loadClass(componentType.getName() + "Impl");
+ }
+ return componentType.cast(componentImpl.newInstance());
+ } else {
+ return componentType.newInstance();
+ }
+ }
+ catch (Exception e) {
+ throw new ConfigurationException("Unable to create component " + componentType, e);
+ }
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorNamedCacheFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Modified: core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -9,7 +9,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = {EvictionManager.class})
-public class EvictionManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class EvictionManagerFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {
public <T> T construct(Class<T> componentType) {
if (componentType != EvictionManager.class) {
throw new IllegalStateException();
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-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -45,6 +45,7 @@
try {
// this order is important ...
globalConfiguration = configuration;
+ registerDefaultClassLoader(null);
registerComponent(this, GlobalComponentRegistry.class);
registerComponent(cacheManager, CacheManager.class);
registerComponent(configuration, GlobalConfiguration.class);
@@ -91,4 +92,12 @@
log.trace("Not registering a shutdown hook. Configured behavior = {0}", globalConfiguration.getShutdownHookBehavior());
}
}
+
+ public ComponentRegistry getNamedComponentRegistry(String name) {
+ return getComponent(ComponentRegistry.class, name);
+ }
+
+ public void registerNamedComponentRegistry(ComponentRegistry componentRegistry, String name) {
+ registerComponent(componentRegistry, name);
+ }
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -43,7 +43,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = InterceptorChain.class)
-public class InterceptorChainFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class InterceptorChainFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {
private CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) throws IllegalAccessException, InstantiationException {
CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
if (chainedInterceptor == null) {
Modified: core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -32,7 +32,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = LockManager.class)
-public class LockManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class LockManagerFactory extends AbstractComponentFactory implements AutoInstantiableFactory {
public <T> T construct(Class<T> componentType) {
return (T) new StripedLockManager();
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -8,7 +8,7 @@
* @author Manik Surtani
* @since 1.0
*/
-public abstract class NamedComponentFactory extends ComponentFactory {
+public abstract class NamedComponentFactory extends AbstractComponentFactory {
public <T> T construct(Class<T> componentType) {
Modified: core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -3,8 +3,6 @@
import org.horizon.config.ConfigurationException;
import org.horizon.executors.ExecutorFactory;
import org.horizon.factories.annotations.DefaultFactoryFor;
-import org.horizon.factories.scopes.Scope;
-import org.horizon.factories.scopes.Scopes;
import org.horizon.util.Util;
import java.util.Properties;
@@ -19,7 +17,6 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = {ExecutorService.class, Executor.class, ScheduledExecutorService.class})
-(a)Scope(Scopes.GLOBAL)
public class NamedExecutorsFactory extends NamedComponentFactory implements AutoInstantiableFactory {
@SuppressWarnings("unchecked")
@@ -28,11 +25,11 @@
Properties props;
try {
if (componentName.equals(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR)) {
- ef = (ExecutorFactory) Util.getInstance(configuration.getGlobalConfiguration().getAsyncListenerExecutorFactoryClass());
- props = configuration.getGlobalConfiguration().getAsyncListenerExecutorProperties();
+ ef = (ExecutorFactory) Util.getInstance(globalConfiguration.getAsyncListenerExecutorFactoryClass());
+ props = globalConfiguration.getAsyncListenerExecutorProperties();
} else if (componentName.equals(KnownComponentNames.ASYNC_SERIALIZATION_EXECUTOR)) {
- ef = (ExecutorFactory) Util.getInstance(configuration.getGlobalConfiguration().getAsyncSerializationExecutorFactoryClass());
- props = configuration.getGlobalConfiguration().getAsyncSerializationExecutorProperties();
+ ef = (ExecutorFactory) Util.getInstance(globalConfiguration.getAsyncSerializationExecutorFactoryClass());
+ props = globalConfiguration.getAsyncSerializationExecutorProperties();
} else {
throw new ConfigurationException("Unknown named executor " + componentName);
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -32,11 +32,11 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = RPCManager.class)
-public class RPCManagerFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
+public class RPCManagerFactory extends EmptyConstructorNamedCacheFactory implements AutoInstantiableFactory {
@Override
public <T> T construct(Class<T> componentType) {
// only do this if we have a transport configured!
- if (configuration.getGlobalConfiguration().getTransportClass() == null) return null;
+ if (globalConfiguration.getTransportClass() == null) return null;
return super.construct(componentType);
}
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -32,7 +32,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = ReplicationQueue.class)
-public class ReplicationQueueFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
+public class ReplicationQueueFactory extends EmptyConstructorNamedCacheFactory implements AutoInstantiableFactory {
@Override
public <T> T construct(Class<T> componentType) {
if ((configuration.getCacheMode() == Configuration.CacheMode.REPL_ASYNC || configuration.getCacheMode() == Configuration.CacheMode.INVALIDATION_ASYNC)
Modified: core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -33,7 +33,7 @@
*/
// TODO: Implement me
//@DefaultFactoryFor(classes = {StateTransferGenerator.class, StateTransferIntegrator.class})
-public class StateTransferFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class StateTransferFactory extends AbstractComponentFactory implements AutoInstantiableFactory {
public <T> T construct(Class<T> componentType) {
return null;
// if (componentType.equals(StateTransferIntegrator.class))
Modified: core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -32,7 +32,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = StateTransferManager.class)
-public class StateTransferManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class StateTransferManagerFactory extends AbstractComponentFactory implements AutoInstantiableFactory {
public <T> T construct(Class<T> componentType) {
return componentType.cast(new DefaultStateTransferManager());
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -35,7 +35,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = {TransactionManager.class})
-public class TransactionManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class TransactionManagerFactory extends AbstractNamedCacheComponentFactory implements AutoInstantiableFactory {
public <T> T construct(Class<T> componentType) {
// See if we had a TransactionManager injected into our config
TransactionManager transactionManager = configuration.getRuntimeConfig().getTransactionManager();
Modified: core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -2,8 +2,6 @@
import org.horizon.CacheException;
import org.horizon.factories.annotations.DefaultFactoryFor;
-import org.horizon.factories.scopes.Scope;
-import org.horizon.factories.scopes.Scopes;
import org.horizon.remoting.transport.Transport;
import org.horizon.util.Util;
@@ -14,12 +12,11 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = Transport.class)
-(a)Scope(Scopes.GLOBAL)
-public class TransportFactory extends ComponentFactory implements AutoInstantiableFactory {
+public class TransportFactory extends AbstractComponentFactory implements AutoInstantiableFactory {
@SuppressWarnings("unchecked")
public <T> T construct(Class<T> componentType) {
- String transportClass = configuration.getGlobalConfiguration().getTransportClass();
+ String transportClass = globalConfiguration.getTransportClass();
try {
if (transportClass == null) return null;
return (T) Util.getInstance(transportClass);
Modified: core/branches/flat/src/main/java/org/horizon/jmx/JmxRegistrationManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/jmx/JmxRegistrationManager.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/jmx/JmxRegistrationManager.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -161,7 +161,7 @@
private List<ResourceDMBean> getResourceDMBeans() {
List<ResourceDMBean> resourceDMBeans = new ArrayList<ResourceDMBean>();
- for (ComponentRegistry.Component component : cacheSpi.getComponentRegistry().getRegiteredComponents()) {
+ for (ComponentRegistry.Component component : cacheSpi.getComponentRegistry().getRegisteredComponents()) {
ResourceDMBean resourceDMBean = new ResourceDMBean(component.getInstance());
if (resourceDMBean.isManagedResource()) {
resourceDMBeans.add(resourceDMBean);
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-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -147,6 +147,17 @@
}
/**
+ * Constructs and starts a new instance of the CacheManager, using the global and default configurations passed in.
+ * If either of these are null, system defaults are used.
+ *
+ * @param globalConfiguration global configuration to use. If null, a default instance is created.
+ * @param defaultConfiguration default configuration to use. If null, a default instance is created.
+ */
+ public DefaultCacheManager(GlobalConfiguration globalConfiguration, Configuration defaultConfiguration) {
+ this(globalConfiguration, defaultConfiguration, true);
+ }
+
+ /**
* Constructs a new instance of the CacheManager, using the global and default configurations passed in. If either
* of these are null, system defaults are used.
*
@@ -315,7 +326,7 @@
public void start() {
// get a hold of the "default" cache to start this?
CacheSPI defaultCache = (CacheSPI) getCache();
- globalComponentRegistry = defaultCache.getComponentRegistry().getSharedComponentRegistry();
+ globalComponentRegistry = defaultCache.getComponentRegistry().getGlobalComponentRegistry();
}
public void stop() {
Modified: core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/marshall/CacheMarshallerStarobrno.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -23,9 +23,8 @@
import org.horizon.CacheException;
import org.horizon.atomic.DeltaAware;
-import org.horizon.commands.CommandsFactory;
+import org.horizon.commands.RemoteCommandFactory;
import org.horizon.commands.ReplicableCommand;
-import org.horizon.config.Configuration;
import org.horizon.io.ByteBuffer;
import org.horizon.io.ExposedByteArrayOutputStream;
import org.horizon.logging.Log;
@@ -98,15 +97,12 @@
protected Log log;
protected boolean trace;
-
- protected Configuration configuration;
+ private RemoteCommandFactory remoteCommandFactory;
protected ClassLoader defaultClassLoader;
protected boolean useRefs = false;
- public void init(Configuration configuration, ClassLoader defaultClassLoader, CommandsFactory commandsFactory) {
+ public void init(ClassLoader defaultClassLoader) {
this.defaultClassLoader = defaultClassLoader;
- this.configuration = configuration;
- this.commandsFactory = commandsFactory;
}
protected void initLogger() {
@@ -122,8 +118,6 @@
return bytes;
}
- protected CommandsFactory commandsFactory;
-
protected void marshallObject(Object o, ObjectOutputStream out, Map<Object, Integer> refMap) throws Exception {
if (o != null && o.getClass().isArray() && isKnownType(o.getClass().getComponentType())) {
marshallArray(o, out, refMap);
@@ -395,7 +389,7 @@
for (int i = 0; i < numArgs; i++) args[i] = unmarshallObject(in, refMap);
}
- return commandsFactory.fromStream((byte) methodId, args);
+ return remoteCommandFactory.fromStream((byte) methodId, args);
}
Modified: core/branches/flat/src/main/java/org/horizon/marshall/Marshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/Marshaller.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/marshall/Marshaller.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -21,6 +21,8 @@
*/
package org.horizon.marshall;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
import org.horizon.io.ByteBuffer;
import java.io.InputStream;
@@ -52,6 +54,7 @@
* @author <a href="mailto://manik@jboss.org">Manik Surtani</a>
* @since 1.0
*/
+(a)Scope(Scopes.GLOBAL)
public interface Marshaller {
/**
* Marshalls an object to a given {@link java.io.ObjectOutputStream}
Modified: core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/marshall/VersionAwareMarshaller.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -21,8 +21,6 @@
*/
package org.horizon.marshall;
-import org.horizon.commands.CommandsFactory;
-import org.horizon.config.Configuration;
import org.horizon.factories.annotations.Inject;
import org.horizon.io.ByteBuffer;
import org.horizon.io.ExposedByteArrayOutputStream;
@@ -54,12 +52,11 @@
private CacheMarshallerStarobrno defaultMarshaller;
ClassLoader defaultClassLoader;
- private Configuration configuration;
@Inject
- public void init(ClassLoader loader, Configuration configuration, CommandsFactory factory) {
+ public void init(ClassLoader loader) {
defaultMarshaller = new CacheMarshallerStarobrno();
- defaultMarshaller.init(configuration, loader, factory);
+ defaultMarshaller.init(loader);
}
protected int getCustomMarshallerVersionInt() {
Modified: core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandler.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandler.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandler.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -1,13 +1,17 @@
package org.horizon.remoting;
import org.horizon.commands.ReplicableCommand;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
/**
- * // TODO: Manik: Document this!
+ * A globally scoped component, that is able to locate named caches and invoke remotely originating calls on the
+ * appropriate cache.
*
* @author Manik Surtani
* @since 1.0
*/
+(a)Scope(Scopes.GLOBAL)
public interface InboundInvocationHandler {
/**
Modified: core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandlerImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandlerImpl.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/main/java/org/horizon/remoting/InboundInvocationHandlerImpl.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -2,6 +2,7 @@
import org.horizon.commands.ReplicableCommand;
import org.horizon.factories.ComponentRegistry;
+import org.horizon.factories.GlobalComponentRegistry;
import org.horizon.interceptors.InterceptorChain;
import org.horizon.invocation.InvocationContextContainer;
@@ -15,8 +16,16 @@
InvocationContextContainer invocationContextContainer;
ComponentRegistry componentRegistry;
InterceptorChain interceptorChain;
+ GlobalComponentRegistry gcr;
+ public void inject(GlobalComponentRegistry gcr) {
+ this.gcr = gcr;
+ }
+ private ComponentRegistry getNamedCacheComponentRegistry(String name) {
+ return gcr.getNamedComponentRegistry(name);
+ }
+
public Object handle(ReplicableCommand command) {
throw new RuntimeException("Implement me!");
Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java 2009-01-20 19:20:39 UTC (rev 7545)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerComponentRegistryTest.java 2009-01-20 19:24:46 UTC (rev 7546)
@@ -3,6 +3,7 @@
import org.horizon.Cache;
import org.horizon.config.CacheLoaderConfig;
import org.horizon.config.Configuration;
+import org.horizon.config.GlobalConfiguration;
import org.horizon.interceptors.BatchingInterceptor;
import org.horizon.interceptors.InterceptorChain;
import org.horizon.loader.CacheLoaderManager;
@@ -32,8 +33,10 @@
public void testForceSharedComponents() throws CacheNameExistsException, NamedCacheNotFoundException {
Configuration defaultCfg = new Configuration();
defaultCfg.setCacheMode(Configuration.CacheMode.REPL_SYNC);
+
// cache manager with default configuration
- cm = new DefaultCacheManager(defaultCfg);
+ cm = new DefaultCacheManager(GlobalConfiguration.getClusteredDefault(),
+ defaultCfg);
// default cache with no overrides
Cache c = cm.getCache();
17 years, 2 months
JBoss Cache SVN: r7545 - core/trunk/src/test/java/org/jboss/cache/lock.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-20 14:20:39 -0500 (Tue, 20 Jan 2009)
New Revision: 7545
Modified:
core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
Log:
more strict replication control
Modified: core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2009-01-20 18:51:26 UTC (rev 7544)
+++ core/trunk/src/test/java/org/jboss/cache/lock/IdentityLockTest.java 2009-01-20 19:20:39 UTC (rev 7545)
@@ -309,6 +309,7 @@
}
+ @Test (invocationCount = 2, successPercentage = 50) //this relies on threads.sleep fails ocasionally (pass 100 in a row on one thread)
public void testThreadedAccess_SimpleLock() throws Throwable
{
setLevelSerial();
17 years, 2 months
JBoss Cache SVN: r7544 - in core/trunk/src: test/java/org/jboss/cache/buddyreplication and 2 other directories.
by jbosscache-commits@lists.jboss.org
Author: mircea.markus
Date: 2009-01-20 13:51:26 -0500 (Tue, 20 Jan 2009)
New Revision: 7544
Modified:
core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
Log:
more strict replication control
Modified: core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java
===================================================================
--- core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-01-20 17:33:24 UTC (rev 7543)
+++ core/trunk/src/main/java/org/jboss/cache/DataContainerImpl.java 2009-01-20 18:51:26 UTC (rev 7544)
@@ -416,6 +416,7 @@
if (lockManager.isLocked(n))
{
num++;
+ if (trace) log.trace(n.getFqn() + " locked");
}
for (Object cn : n.getChildrenDirect(true))
{
Modified: core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2009-01-20 17:33:24 UTC (rev 7543)
+++ core/trunk/src/test/java/org/jboss/cache/buddyreplication/BuddyReplicationTestsBase.java 2009-01-20 18:51:26 UTC (rev 7544)
@@ -200,17 +200,23 @@
protected List<CacheSPI<Object, Object>> createCaches(int numCaches, boolean useBuddyPool) throws Exception
{
- return createCaches(1, numCaches, useBuddyPool, false);
+ List<CacheSPI<Object, Object>> spiList = createCaches(1, numCaches, useBuddyPool, false);
+ waitForSingleBuddy(spiList);
+ return spiList;
}
protected List<CacheSPI<Object, Object>> createCaches(int numCaches, boolean useBuddyPool, boolean useDataGravitation, boolean optimisticLocks) throws Exception
{
- return createCaches(1, numCaches, useBuddyPool, useDataGravitation, optimisticLocks);
+ List<CacheSPI<Object, Object>> spiList = createCaches(1, numCaches, useBuddyPool, useDataGravitation, optimisticLocks);
+ waitForSingleBuddy(spiList);
+ return spiList;
}
protected List<CacheSPI<Object, Object>> createCaches(int numCaches, boolean useBuddyPool, boolean useDataGravitation) throws Exception
{
- return createCaches(1, numCaches, useBuddyPool, useDataGravitation);
+ List<CacheSPI<Object, Object>> spiList = createCaches(1, numCaches, useBuddyPool, useDataGravitation);
+ waitForSingleBuddy(spiList);
+ return spiList;
}
protected List<CacheSPI<Object, Object>> createCachesWithCacheLoader(int numCaches, boolean useDataGravitation, boolean removeOnFind, boolean passivation) throws Exception
@@ -381,7 +387,7 @@
{
for (Cache cache : caches)
{
- if (cache != null) assertEquals(0, ((CacheSPI) cache).getNumberOfLocksHeld());
+ if (cache != null) assertEquals(cache.getLocalAddress() + " still holds locks",0, ((CacheSPI) cache).getNumberOfLocksHeld());
}
}
Modified: core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java 2009-01-20 17:33:24 UTC (rev 7543)
+++ core/trunk/src/test/java/org/jboss/cache/cluster/ReplicationQueueTest.java 2009-01-20 18:51:26 UTC (rev 7544)
@@ -99,6 +99,20 @@
verify(mockRpcManager);
}
+ public void testFailure() throws InterruptedException
+ {
+ for (int i = 0; i < COUNT; i++)
+ {
+ cache.put("/a/b/c" + i, "key", "value");
+ assertNotNull(cache.get("/a/b/c" + i, "key"));
+ replicationListener.expect(PutKeyValueCommand.class);
+ }
+ replicationListener.waitForReplicationToOccur();
+
+ for (int i = 0; i < COUNT; i++) assertNotNull("on get i = " + i, cache2.get("/a/b/c" + i, "key"));
+ }
+
+ @Test(dependsOnMethods = "testFailure") //if this method will run first then PutKeyValues might still be on wire and influence the other method
public void testFlushConcurrency() throws Exception
{
// will create multiple threads to constantly perform a cache update, and measure the number of expected invocations on the RPC manager.
@@ -159,17 +173,4 @@
assert replQ.elements.size() == 0;
}
-
- public void testFailure() throws InterruptedException
- {
- for (int i = 0; i < COUNT; i++)
- {
- cache.put("/a/b/c" + i, "key", "value");
- assertNotNull(cache.get("/a/b/c" + i, "key"));
- replicationListener.expect(PutKeyValueCommand.class);
- }
- replicationListener.waitForReplicationToOccur();
-
- for (int i = 0; i < COUNT; i++) assertNotNull("on get i = " + i, cache2.get("/a/b/c" + i, "key"));
- }
}
Modified: core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2009-01-20 17:33:24 UTC (rev 7543)
+++ core/trunk/src/test/java/org/jboss/cache/eviction/ExpirationPolicyTest.java 2009-01-20 18:51:26 UTC (rev 7544)
@@ -133,6 +133,7 @@
}
}
+ @Test (invocationCount = 5, successPercentage = 80)
public void testMaxNodes() throws Exception
{
log.info("set max nodes to 2, expire soonest to expire first");
17 years, 2 months
JBoss Cache SVN: r7543 - in core/branches/flat/src/main/java/org/horizon: factories and 1 other directory.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-20 12:33:24 -0500 (Tue, 20 Jan 2009)
New Revision: 7543
Added:
core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java
Removed:
core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java
Modified:
core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java
Log:
Transport and rpc manager is null by default and needs to be explicitly constructed
Modified: core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java 2009-01-20 17:24:43 UTC (rev 7542)
+++ core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java 2009-01-20 17:33:24 UTC (rev 7543)
@@ -10,7 +10,6 @@
import org.horizon.factories.annotations.NonVolatile;
import org.horizon.factories.scopes.Scope;
import org.horizon.factories.scopes.Scopes;
-import org.horizon.remoting.transport.jgroups.JGroupsTransport;
import org.horizon.util.TypedProperties;
import java.util.Properties;
@@ -42,7 +41,7 @@
String marshallVersion;
int objectInputStreamPoolSize;
int objectOutputStreamPoolSize;
- String transportClass = JGroupsTransport.class.getName();
+ String transportClass = null; // this defaults to a non-clustered cache.
TypedProperties transportProperties;
Configuration defaultConfiguration;
String clusterName = "Horizon-Cluster";
Modified: core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java 2009-01-20 17:24:43 UTC (rev 7542)
+++ core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java 2009-01-20 17:33:24 UTC (rev 7543)
@@ -80,7 +80,8 @@
@Scope(Scopes.NAMED_CACHE)
public abstract class AbstractComponentRegistry implements Lifecycle {
- private static final boolean DEBUG_DEPENDENCIES = true;
+ // Be careful when changing this to 'true'. It should *never* go into the code repo with this flag set to 'true'!
+ private static final boolean DEBUG_DEPENDENCIES = false;
private Stack<String> debugStack = DEBUG_DEPENDENCIES ? new Stack<String>() : null;
/**
@@ -143,7 +144,7 @@
s.add(BootstrapFactory.class);
s.add(EmptyConstructorFactory.class);
s.add(InterceptorChainFactory.class);
- s.add(RuntimeConfigAwareFactory.class);
+ s.add(RPCManagerFactory.class);
s.add(TransactionManagerFactory.class);
s.add(ReplicationQueueFactory.class);
s.add(StateTransferManagerFactory.class);
Copied: core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java (from rev 7537, core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java 2009-01-20 17:33:24 UTC (rev 7543)
@@ -0,0 +1,42 @@
+/*
+ * 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.factories;
+
+import org.horizon.config.RuntimeConfig;
+import org.horizon.factories.annotations.DefaultFactoryFor;
+import org.horizon.remoting.RPCManager;
+
+/**
+ * An extension of the EmptyConstructorFactory that places a component in the {@link RuntimeConfig} after creating it.
+ *
+ * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
+ * @since 1.0
+ */
+@DefaultFactoryFor(classes = RPCManager.class)
+public class RPCManagerFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
+ @Override
+ public <T> T construct(Class<T> componentType) {
+ // only do this if we have a transport configured!
+ if (configuration.getGlobalConfiguration().getTransportClass() == null) return null;
+ return super.construct(componentType);
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/factories/RPCManagerFactory.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Deleted: core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java 2009-01-20 17:24:43 UTC (rev 7542)
+++ core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java 2009-01-20 17:33:24 UTC (rev 7543)
@@ -1,55 +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.factories;
-
-import org.horizon.config.ConfigurationException;
-import org.horizon.config.RuntimeConfig;
-import org.horizon.factories.annotations.DefaultFactoryFor;
-import org.horizon.remoting.RPCManager;
-import org.horizon.util.BeanUtils;
-
-import java.lang.reflect.Method;
-
-/**
- * An extension of the EmptyConstructorFactory that places a component in the {@link RuntimeConfig} after creating it.
- *
- * @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
- * @since 1.0
- */
-@DefaultFactoryFor(classes = RPCManager.class)
-public class RuntimeConfigAwareFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
- @Override
- public <T> T construct(Class<T> componentType) {
- T component = super.construct(componentType);
-
- Method setter = BeanUtils.setterMethod(RuntimeConfig.class, componentType);
- if (setter != null) {
- try {
- setter.invoke(configuration.getRuntimeConfig(), component);
- }
- catch (Exception e) {
- throw new ConfigurationException("Unable to put newly constructed component of type " + componentType + " in the RuntimeConfig", e);
- }
- }
- return component;
- }
-}
Modified: core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java 2009-01-20 17:24:43 UTC (rev 7542)
+++ core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java 2009-01-20 17:33:24 UTC (rev 7543)
@@ -21,6 +21,7 @@
public <T> T construct(Class<T> componentType) {
String transportClass = configuration.getGlobalConfiguration().getTransportClass();
try {
+ if (transportClass == null) return null;
return (T) Util.getInstance(transportClass);
} catch (Exception e) {
throw new CacheException("Unable to create transport of type " + transportClass, e);
17 years, 2 months
JBoss Cache SVN: r7542 - core/branches/flat/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-20 12:24:43 -0500 (Tue, 20 Jan 2009)
New Revision: 7542
Modified:
core/branches/flat/src/test/resources/log4j.xml
Log:
Log file in source control. Do NOT check in more verbose versions of this file!
Modified: core/branches/flat/src/test/resources/log4j.xml
===================================================================
--- core/branches/flat/src/test/resources/log4j.xml 2009-01-20 17:24:23 UTC (rev 7541)
+++ core/branches/flat/src/test/resources/log4j.xml 2009-01-20 17:24:43 UTC (rev 7542)
@@ -45,7 +45,7 @@
<!-- ================ -->
<category name="org.horizon">
- <priority value="TRACE"/>
+ <priority value="INFO"/>
</category>
<category name="org.horizon.profiling">
17 years, 2 months
JBoss Cache SVN: r7541 - core/branches/flat/src/test/resources.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-20 12:24:23 -0500 (Tue, 20 Jan 2009)
New Revision: 7541
Modified:
core/branches/flat/src/test/resources/log4j.xml
Log:
Log file in source control. Do NOT check in more verbose versions of this file!
Modified: core/branches/flat/src/test/resources/log4j.xml
===================================================================
--- core/branches/flat/src/test/resources/log4j.xml 2009-01-20 17:20:34 UTC (rev 7540)
+++ core/branches/flat/src/test/resources/log4j.xml 2009-01-20 17:24:23 UTC (rev 7541)
@@ -53,7 +53,7 @@
</category>
<category name="org.horizon.factories">
- <priority value="TRACE"/>
+ <priority value="WARN"/>
</category>
<!-- ======================= -->
@@ -62,8 +62,8 @@
<root>
<priority value="WARN"/>
- <appender-ref ref="CONSOLE"/>
- <!--<appender-ref ref="FILE"/>-->
+ <!--<appender-ref ref="CONSOLE"/>-->
+ <appender-ref ref="FILE"/>
</root>
</log4j:configuration>
17 years, 2 months
JBoss Cache SVN: r7540 - in core/branches/flat/src/main/java/org/horizon: interceptors and 1 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-20 12:20:34 -0500 (Tue, 20 Jan 2009)
New Revision: 7540
Modified:
core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java
core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java
core/branches/flat/src/main/java/org/horizon/interceptors/InterceptorChain.java
core/branches/flat/src/main/java/org/horizon/interceptors/InvocationContextInterceptor.java
core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java
core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManager.java
core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java
Log:
Removed old deprecation annotations
Modified: core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java 2009-01-20 17:12:00 UTC (rev 7539)
+++ core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java 2009-01-20 17:20:34 UTC (rev 7540)
@@ -34,7 +34,6 @@
// TODO: Implement me
//@DefaultFactoryFor(classes = {StateTransferGenerator.class, StateTransferIntegrator.class})
public class StateTransferFactory extends ComponentFactory implements AutoInstantiableFactory {
- @SuppressWarnings("deprecation")
public <T> T construct(Class<T> componentType) {
return null;
// if (componentType.equals(StateTransferIntegrator.class))
Modified: core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java 2009-01-20 17:12:00 UTC (rev 7539)
+++ core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java 2009-01-20 17:20:34 UTC (rev 7540)
@@ -33,7 +33,6 @@
*/
@DefaultFactoryFor(classes = StateTransferManager.class)
public class StateTransferManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
- @SuppressWarnings("deprecation")
public <T> T construct(Class<T> componentType) {
return componentType.cast(new DefaultStateTransferManager());
}
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-20 17:12:00 UTC (rev 7539)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/InterceptorChain.java 2009-01-20 17:20:34 UTC (rev 7540)
@@ -232,7 +232,6 @@
/**
* Walks the command through the interceptor chain. The received ctx is being passed in.
*/
- @SuppressWarnings("deprecation")
public Object invoke(InvocationContext ctx, VisitableCommand command) {
try {
return command.acceptVisitor(ctx, firstInChain);
Modified: core/branches/flat/src/main/java/org/horizon/interceptors/InvocationContextInterceptor.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/interceptors/InvocationContextInterceptor.java 2009-01-20 17:12:00 UTC (rev 7539)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/InvocationContextInterceptor.java 2009-01-20 17:20:34 UTC (rev 7540)
@@ -95,7 +95,6 @@
return handleAll(ctx, command, null, true);
}
- @SuppressWarnings("deprecation")
private Object handleAll(InvocationContext ctx, VisitableCommand command, GlobalTransaction gtx, boolean scrubContextOnCompletion) throws Throwable {
Option optionOverride = ctx.getOptionOverrides();
boolean suppressExceptions = false;
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-20 17:12:00 UTC (rev 7539)
+++ core/branches/flat/src/main/java/org/horizon/interceptors/TxInterceptor.java 2009-01-20 17:20:34 UTC (rev 7540)
@@ -420,7 +420,6 @@
*
* @throws Throwable
*/
- @SuppressWarnings("deprecation")
private Object handleCommitRollback(InvocationContext ctx, VisitableCommand command) throws Throwable {
GlobalTransaction gtx = ctx.getGlobalTransaction();
Object result;
@@ -509,7 +508,6 @@
* Handles a local prepare - invoked by the sync handler. Tests if the current tx matches the gtx passed in to the
* method call and passes the prepare() call up the chain.
*/
- @SuppressWarnings("deprecation")
public Object runPreparePhase(InvocationContext ctx, GlobalTransaction gtx, List<VisitableCommand> modifications) throws Throwable {
// running a 2-phase commit.
VisitableCommand prepareCommand = buildPrepareCommand(gtx, modifications, false);
Modified: core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManager.java 2009-01-20 17:12:00 UTC (rev 7539)
+++ core/branches/flat/src/main/java/org/horizon/loader/CacheLoaderManager.java 2009-01-20 17:20:34 UTC (rev 7540)
@@ -178,7 +178,6 @@
* @return a cache loader
* @throws Exception
*/
- @SuppressWarnings("deprecation")
private CacheLoader<Object, Object> createCacheLoader(CacheLoaderConfig.IndividualCacheLoaderConfig cfg, CacheSPI<Object, Object> cache) throws Exception {
// create loader
CacheLoader<Object, Object> tmpLoader = cfg.getCacheLoader() == null ? createInstance(cfg.getClassName()) : cfg.getCacheLoader();
Modified: core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java 2009-01-20 17:12:00 UTC (rev 7539)
+++ core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java 2009-01-20 17:20:34 UTC (rev 7540)
@@ -131,7 +131,6 @@
throw new RuntimeException("Implement me");
}
- @SuppressWarnings("deprecation")
private Object callRemote(DataCommand dataCommand) throws Exception {
if (trace) log.trace("cache=" + cache.getCacheManager().getAddress() + "; calling with " + dataCommand);
// ClusteredGetCommand clusteredGet = commandsFactory.buildClusteredGetCommand(false, dataCommand);
17 years, 2 months
JBoss Cache SVN: r7538 - core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-20 11:59:44 -0500 (Tue, 20 Jan 2009)
New Revision: 7538
Modified:
core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java
Log:
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-20 16:51:26 UTC (rev 7537)
+++ core/branches/flat/src/main/java/org/horizon/remoting/transport/jgroups/JGroupsTransport.java 2009-01-20 16:59:44 UTC (rev 7538)
@@ -134,33 +134,35 @@
// in order of preference - we first look for an external JGroups file, then a set of XML properties, and
// finally the legacy JGroups String properties.
String cfg;
- if (p.containsKey(CONFIGURATION_FILE)) {
- cfg = p.getProperty(CONFIGURATION_FILE);
- try {
- channel = new JChannel(new FileLookup().lookupFileLocation(cfg));
- } catch (Exception e) {
- // move on to next method to configure the channel
- channel = null;
+ if (p != null) {
+ if (p.containsKey(CONFIGURATION_FILE)) {
+ cfg = p.getProperty(CONFIGURATION_FILE);
+ try {
+ channel = new JChannel(new FileLookup().lookupFileLocation(cfg));
+ } catch (Exception e) {
+ // move on to next method to configure the channel
+ channel = null;
+ }
}
- }
- if (channel == null && p.containsKey(CONFIGURATION_XML)) {
- cfg = p.getProperty(CONFIGURATION_XML);
- try {
- channel = new JChannel(XmlConfigHelper.stringToElement(cfg));
- } catch (Exception e) {
- // move on to next method to configure the channel
- channel = null;
+ if (channel == null && p.containsKey(CONFIGURATION_XML)) {
+ cfg = p.getProperty(CONFIGURATION_XML);
+ try {
+ channel = new JChannel(XmlConfigHelper.stringToElement(cfg));
+ } catch (Exception e) {
+ // move on to next method to configure the channel
+ channel = null;
+ }
}
- }
- if (channel == null && p.containsKey(CONFIGURATION_STRING)) {
- cfg = p.getProperty(CONFIGURATION_STRING);
- try {
- channel = new JChannel(cfg);
- } catch (Exception e) {
- // move on to next method to configure the channel
- channel = null;
+ if (channel == null && p.containsKey(CONFIGURATION_STRING)) {
+ cfg = p.getProperty(CONFIGURATION_STRING);
+ try {
+ channel = new JChannel(cfg);
+ } catch (Exception e) {
+ // move on to next method to configure the channel
+ channel = null;
+ }
}
}
17 years, 2 months
JBoss Cache SVN: r7537 - in core/branches/flat/src: main/java/org/horizon/config and 11 other directories.
by jbosscache-commits@lists.jboss.org
Author: manik.surtani(a)jboss.com
Date: 2009-01-20 11:51:26 -0500 (Tue, 20 Jan 2009)
New Revision: 7537
Added:
core/branches/flat/src/main/java/org/horizon/ComponentStatus.java
core/branches/flat/src/main/java/org/horizon/config/AbstractConfigurationBean.java
core/branches/flat/src/main/java/org/horizon/config/AbstractNamedCacheConfigurationBean.java
core/branches/flat/src/main/java/org/horizon/factories/AutoInstantiableFactory.java
core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java
core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java
core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java
Removed:
core/branches/flat/src/main/java/org/horizon/CacheStatus.java
core/branches/flat/src/main/java/org/horizon/config/ConfigurationComponent.java
Modified:
core/branches/flat/src/main/java/org/horizon/Cache.java
core/branches/flat/src/main/java/org/horizon/CacheDelegate.java
core/branches/flat/src/main/java/org/horizon/config/CacheLoaderConfig.java
core/branches/flat/src/main/java/org/horizon/config/Configuration.java
core/branches/flat/src/main/java/org/horizon/config/CustomInterceptorConfig.java
core/branches/flat/src/main/java/org/horizon/config/EvictionCacheConfig.java
core/branches/flat/src/main/java/org/horizon/config/EvictionConfig.java
core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
core/branches/flat/src/main/java/org/horizon/config/PluggableConfigurationComponent.java
core/branches/flat/src/main/java/org/horizon/config/RuntimeConfig.java
core/branches/flat/src/main/java/org/horizon/eviction/EvictionAlgorithmConfigBase.java
core/branches/flat/src/main/java/org/horizon/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java
core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java
core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java
core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java
core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java
core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java
core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java
core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java
core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java
core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java
core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java
core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java
core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java
core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java
core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java
core/branches/flat/src/main/java/org/horizon/tree/TreeCache.java
core/branches/flat/src/main/java/org/horizon/tree/TreeCacheImpl.java
core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java
core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java
core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java
core/branches/flat/src/test/resources/log4j.xml
Log:
Component registry fixes
Modified: core/branches/flat/src/main/java/org/horizon/Cache.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/Cache.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/Cache.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -56,7 +56,7 @@
*
* @param key key with which the specified value is to be associated.
* @param value value to be associated with the specified key.
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link ComponentStatus#STARTED}.
*/
void putForExternalRead(K key, V value);
@@ -68,7 +68,7 @@
void setInvocationContext(InvocationContext ctx);
- CacheStatus getCacheStatus();
+ ComponentStatus getCacheStatus();
/**
* @return true if a batch was successfully started; false if one was available and already running.
Modified: core/branches/flat/src/main/java/org/horizon/CacheDelegate.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/CacheDelegate.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/CacheDelegate.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -336,7 +336,7 @@
return componentRegistry;
}
- public CacheStatus getCacheStatus() {
+ public ComponentStatus getCacheStatus() {
return componentRegistry.getState();
}
Deleted: core/branches/flat/src/main/java/org/horizon/CacheStatus.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/CacheStatus.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/CacheStatus.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -1,191 +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;
-
-import org.horizon.logging.Log;
-import org.horizon.logging.LogFactory;
-
-/**
- * Various states that an object that has a four stage lifecycle (i.e. <code>create()</code>, <code>start()</code>,
- * <code>stop()</code> and <code>destroy()</code>) might be in.
- *
- * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
- * @since 1.0
- */
-public enum CacheStatus {
- /**
- * Object has been instantiated, but create() has not been called.
- */
- INSTANTIATED,
- /**
- * The <code>create()</code> method has been called but not yet completed.
- */
- CREATING,
- /**
- * The <code>create()</code> method has been completed but <code>start()</code> has not been called.
- */
- CREATED,
- /**
- * The <code>start()</code> method has been called but has not yet completed.
- */
- STARTING,
- /**
- * The <code>start()</code> method has completed.
- */
- STARTED,
- /**
- * The <code>stop()</code> method has been called but has not yet completed.
- */
- STOPPING,
- /**
- * The <code>stop()</code> method has completed but <code>destroy()</code> has not yet been called. Conceptually
- * equivalent to {@link #CREATED}.
- */
- STOPPED,
- /**
- * The <code>destroy()</code> method has been called but has not yet completed.
- */
- DESTROYING,
- /**
- * The <code>destroy()</code> method has completed. Conceptually equivalent to {@link #INSTANTIATED}.
- */
- DESTROYED,
- /**
- * A failure occurred during the execution of <code>create()</code>, <code>start()</code>, <code>stop()</code> or
- * <code>destroy()</code>. The next logical transition is to call <code>destroy()</code>.
- */
- FAILED;
-
- private static final Log log = LogFactory.getLog(CacheStatus.class);
-
- public boolean createAllowed() {
- switch (this) {
- case CREATING:
- case CREATED:
- case STARTING:
- case STARTED:
- case STOPPED:
- case FAILED:
- case STOPPING:
- case DESTROYING:
- return false;
- default:
- return true;
- }
- }
-
- public boolean needToDestroyFailedCache() {
- if (this == CacheStatus.FAILED) {
- log.debug("need to call destroy() since current state is " +
- this);
- return true;
- }
-
- return false;
- }
-
- public boolean startAllowed() {
- switch (this) {
- case INSTANTIATED:
- case DESTROYED:
- case STARTING:
- case STARTED:
- case FAILED:
- case STOPPING:
- case DESTROYING:
- return false;
- default:
- return true;
- }
- }
-
- public boolean needCreateBeforeStart() {
- switch (this) {
- case INSTANTIATED:
- case DESTROYED:
- log.debug("start() called while current state is " +
- this + " -- call create() first");
- return true;
- default:
- return false;
- }
- }
-
- public boolean stopAllowed() {
- switch (this) {
- case INSTANTIATED:
- case CREATED:
- case STOPPED:
- case DESTROYED:
- log.debug("Ignoring call to stop() as current state is " + this);
- return false;
- case CREATING:
- case STARTING:
- case STOPPING:
- case DESTROYING:
- log.warn("Ignoring call to stop() as current state is " + this);
- return false;
- case FAILED:
- case STARTED:
- default:
- return true;
- }
-
- }
-
- public boolean destroyAllowed() {
- switch (this) {
- case INSTANTIATED:
- case DESTROYED:
- log.debug("Ignoring call to destroy() as current state is " + this);
- return false;
- case CREATING:
- case STARTING:
- case STOPPING:
- case DESTROYING:
- log.warn("Ignoring call to destroy() as current state iswhile cache is " + this);
- return false;
- case STARTED:
- // stop first
- return false;
- case CREATED:
- case STOPPED:
- case FAILED:
- default:
- return true;
- }
- }
-
- public boolean needStopBeforeDestroy() {
- if (this == CacheStatus.STARTED) {
- log.warn("destroy() called while current state is " +
- this + " -- call stop() first");
- return true;
- }
-
- return false;
- }
-
- public boolean allowInvocations() {
- return (this == CacheStatus.STARTED);
- }
-}
Copied: core/branches/flat/src/main/java/org/horizon/ComponentStatus.java (from rev 7526, core/branches/flat/src/main/java/org/horizon/CacheStatus.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/ComponentStatus.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/ComponentStatus.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -0,0 +1,191 @@
+/*
+ * 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;
+
+import org.horizon.logging.Log;
+import org.horizon.logging.LogFactory;
+
+/**
+ * Various states that an object that has a four stage lifecycle (i.e. <code>create()</code>, <code>start()</code>,
+ * <code>stop()</code> and <code>destroy()</code>) might be in.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @since 1.0
+ */
+public enum ComponentStatus {
+ /**
+ * Object has been instantiated, but create() has not been called.
+ */
+ INSTANTIATED,
+ /**
+ * The <code>create()</code> method has been called but not yet completed.
+ */
+ CREATING,
+ /**
+ * The <code>create()</code> method has been completed but <code>start()</code> has not been called.
+ */
+ CREATED,
+ /**
+ * The <code>start()</code> method has been called but has not yet completed.
+ */
+ STARTING,
+ /**
+ * The <code>start()</code> method has completed.
+ */
+ STARTED,
+ /**
+ * The <code>stop()</code> method has been called but has not yet completed.
+ */
+ STOPPING,
+ /**
+ * The <code>stop()</code> method has completed but <code>destroy()</code> has not yet been called. Conceptually
+ * equivalent to {@link #CREATED}.
+ */
+ STOPPED,
+ /**
+ * The <code>destroy()</code> method has been called but has not yet completed.
+ */
+ DESTROYING,
+ /**
+ * The <code>destroy()</code> method has completed. Conceptually equivalent to {@link #INSTANTIATED}.
+ */
+ DESTROYED,
+ /**
+ * A failure occurred during the execution of <code>create()</code>, <code>start()</code>, <code>stop()</code> or
+ * <code>destroy()</code>. The next logical transition is to call <code>destroy()</code>.
+ */
+ FAILED;
+
+ private static final Log log = LogFactory.getLog(ComponentStatus.class);
+
+ public boolean createAllowed() {
+ switch (this) {
+ case CREATING:
+ case CREATED:
+ case STARTING:
+ case STARTED:
+ case STOPPED:
+ case FAILED:
+ case STOPPING:
+ case DESTROYING:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ public boolean needToDestroyFailedCache() {
+ if (this == ComponentStatus.FAILED) {
+ log.debug("need to call destroy() since current state is " +
+ this);
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean startAllowed() {
+ switch (this) {
+ case INSTANTIATED:
+ case DESTROYED:
+ case STARTING:
+ case STARTED:
+ case FAILED:
+ case STOPPING:
+ case DESTROYING:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ public boolean needCreateBeforeStart() {
+ switch (this) {
+ case INSTANTIATED:
+ case DESTROYED:
+ log.debug("start() called while current state is " +
+ this + " -- call create() first");
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ public boolean stopAllowed() {
+ switch (this) {
+ case INSTANTIATED:
+ case CREATED:
+ case STOPPED:
+ case DESTROYED:
+ log.debug("Ignoring call to stop() as current state is " + this);
+ return false;
+ case CREATING:
+ case STARTING:
+ case STOPPING:
+ case DESTROYING:
+ log.warn("Ignoring call to stop() as current state is " + this);
+ return false;
+ case FAILED:
+ case STARTED:
+ default:
+ return true;
+ }
+
+ }
+
+ public boolean destroyAllowed() {
+ switch (this) {
+ case INSTANTIATED:
+ case DESTROYED:
+ log.debug("Ignoring call to destroy() as current state is " + this);
+ return false;
+ case CREATING:
+ case STARTING:
+ case STOPPING:
+ case DESTROYING:
+ log.warn("Ignoring call to destroy() as current state iswhile cache is " + this);
+ return false;
+ case STARTED:
+ // stop first
+ return false;
+ case CREATED:
+ case STOPPED:
+ case FAILED:
+ default:
+ return true;
+ }
+ }
+
+ public boolean needStopBeforeDestroy() {
+ if (this == ComponentStatus.STARTED) {
+ log.warn("destroy() called while current state is " +
+ this + " -- call stop() first");
+ return true;
+ }
+
+ return false;
+ }
+
+ public boolean allowInvocations() {
+ return (this == ComponentStatus.STARTED);
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/ComponentStatus.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Copied: core/branches/flat/src/main/java/org/horizon/config/AbstractConfigurationBean.java (from rev 7526, core/branches/flat/src/main/java/org/horizon/config/ConfigurationComponent.java)
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/AbstractConfigurationBean.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/config/AbstractConfigurationBean.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -0,0 +1,185 @@
+/*
+ * 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.config;
+
+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.util.TypedProperties;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+
+/**
+ * Base superclass of Cache configuration classes that expose some properties that can be changed after the cache is
+ * started.
+ *
+ * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
+ * @see #testImmutability(String)
+ * @since 1.0
+ */
+(a)Scope(Scopes.NAMED_CACHE)
+public abstract class AbstractConfigurationBean implements CloneableConfigurationComponent {
+ private static final long serialVersionUID = 4879873994727821938L;
+
+ protected transient Log log = LogFactory.getLog(getClass());
+// private transient CacheSPI cache; // back-reference to test whether the cache is running.
+ // private transient ComponentRegistry cr;
+ // a workaround to get over immutability checks
+ private boolean accessible;
+ protected List<String> overriddenConfigurationElements = new LinkedList<String>();
+
+ protected AbstractConfigurationBean() {
+ }
+
+// public void passCacheToChildConfig(AbstractConfigurationBean child) {
+// if (child != null) {
+// child.setCache(cache);
+// }
+// }
+
+// protected void addChildConfig(AbstractConfigurationBean child) {
+// if (child != null) children.add(child);
+// if (child != null && children.add(child))
+// child.setCache(cache);
+// }
+
+// protected void addChildConfigs(Collection<? extends AbstractConfigurationBean> toAdd) {
+// if (toAdd != null) {
+// for (AbstractConfigurationBean child : toAdd)
+// addChildConfig(child);
+// }
+// }
+//
+// protected void removeChildConfig(AbstractConfigurationBean child) {
+// children.remove(child);
+// }
+
+// protected void removeChildConfigs(Collection<? extends AbstractConfigurationBean> toRemove) {
+// if (toRemove != null) {
+// for (AbstractConfigurationBean child : toRemove)
+// removeChildConfig(child);
+// }
+// }
+//
+// protected void replaceChildConfig(AbstractConfigurationBean oldConfig, AbstractConfigurationBean newConfig) {
+// removeChildConfig(oldConfig);
+// addChildConfig(newConfig);
+// }
+
+// protected void replaceChildConfigs(Collection<? extends AbstractConfigurationBean> oldConfigs,
+// Collection<? extends AbstractConfigurationBean> newConfigs) {
+// synchronized (children) {
+// removeChildConfigs(oldConfigs);
+// addChildConfigs(newConfigs);
+// }
+// }
+
+ /**
+ * Safely converts a String to upper case.
+ *
+ * @param s string to convert
+ * @return the string in upper case, or null if s is null.
+ */
+ protected String uc(String s) {
+ return s == null ? null : s.toUpperCase(Locale.ENGLISH);
+ }
+
+ /**
+ * Converts a given {@link Properties} instance to an instance of {@link TypedProperties}
+ *
+ * @param p properties to convert
+ * @return TypedProperties instance
+ */
+ protected TypedProperties toTypedProperties(Properties p) {
+ return TypedProperties.toTypedProperties(p);
+ }
+
+ protected TypedProperties toTypedProperties(String s) {
+ TypedProperties tp = new TypedProperties();
+ if (s != null && s.trim().length() > 0) {
+ InputStream stream = new ByteArrayInputStream(s.getBytes());
+ try {
+ tp.load(stream);
+ } catch (IOException e) {
+ throw new ConfigurationException("Unable to parse properties string " + s, e);
+ }
+ }
+ return tp;
+ }
+
+ /**
+ * Tests whether the component this configuration bean intents to configure has already started.
+ *
+ * @return true if the component has started; false otherwise.
+ */
+ protected abstract boolean hasComponentStarted();
+
+ /**
+ * Checks field modifications via setters
+ *
+ * @param fieldName
+ */
+ protected void testImmutability(String fieldName) {
+ try {
+ if (!accessible && hasComponentStarted() && !getClass().getDeclaredField(fieldName).isAnnotationPresent(Dynamic.class)) {
+ throw new ConfigurationException("Attempted to modify a non-Dynamic configuration element [" + fieldName + "] after the component has started!");
+ }
+ }
+ catch (NoSuchFieldException e) {
+ log.warn("Field " + fieldName + " not found!!");
+ }
+ finally {
+ accessible = false;
+ }
+
+ // now mark this as overridden
+ overriddenConfigurationElements.add(fieldName);
+ }
+
+// public void setCache(CacheSPI cache) {
+// this.cache = cache;
+// synchronized (children) {
+// for (AbstractConfigurationBean child : children) {
+// child.setCache(cache);
+// }
+// }
+// }
+
+// @Start
+// private void start() {
+// setCache(cr.getComponent(CacheSPI.class));
+// }
+
+ @Override
+ public CloneableConfigurationComponent clone() throws CloneNotSupportedException {
+ AbstractConfigurationBean c = (AbstractConfigurationBean) super.clone();
+// c.setCache(null);
+ return c;
+ }
+}
Property changes on: core/branches/flat/src/main/java/org/horizon/config/AbstractConfigurationBean.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: core/branches/flat/src/main/java/org/horizon/config/AbstractNamedCacheConfigurationBean.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/AbstractNamedCacheConfigurationBean.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/config/AbstractNamedCacheConfigurationBean.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -0,0 +1,28 @@
+package org.horizon.config;
+
+import org.horizon.ComponentStatus;
+import org.horizon.factories.ComponentRegistry;
+import org.horizon.factories.annotations.Inject;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+
+/**
+ * Adds named cache specific features to the {@link org.horizon.config.AbstractConfigurationBean}.
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+(a)Scope(Scopes.NAMED_CACHE)
+public abstract class AbstractNamedCacheConfigurationBean extends AbstractConfigurationBean {
+
+ protected ComponentRegistry cr;
+
+ @Inject
+ private void inject(ComponentRegistry cr) {
+ this.cr = cr;
+ }
+
+ protected boolean hasComponentStarted() {
+ return cr != null && cr.getState() != null && cr.getState() == ComponentStatus.STARTED;
+ }
+}
Modified: core/branches/flat/src/main/java/org/horizon/config/CacheLoaderConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/CacheLoaderConfig.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/CacheLoaderConfig.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -38,7 +38,7 @@
* @author <a href="mailto:galder.zamarreno@jboss.com">Galder Zamarreno</a>
* @since 1.0
*/
-public class CacheLoaderConfig extends ConfigurationComponent {
+public class CacheLoaderConfig extends AbstractNamedCacheConfigurationBean {
private static final long serialVersionUID = 2210349340378984424L;
private boolean passivation;
@@ -68,8 +68,6 @@
public void addIndividualCacheLoaderConfig(IndividualCacheLoaderConfig clc) {
testImmutability("cacheLoaderConfigs");
cacheLoaderConfigs.add(clc);
- // Ensure this config gets our back ref to the cache
- addChildConfig(clc);
}
public List<IndividualCacheLoaderConfig> getIndividualCacheLoaderConfigs() {
@@ -78,8 +76,6 @@
public void setIndividualCacheLoaderConfigs(List<IndividualCacheLoaderConfig> configs) {
testImmutability("cacheLoaderConfigs");
- // Ensure these configs get our back ref to the cache
- replaceChildConfigs(this.cacheLoaderConfigs, configs);
this.cacheLoaderConfigs = configs == null ? new ArrayList<IndividualCacheLoaderConfig>() : configs;
}
@@ -227,7 +223,6 @@
public void setSingletonStoreConfig(SingletonStoreConfig singletonStoreConfig) {
testImmutability("singletonStoreConfig");
- replaceChildConfig(this.singletonStoreConfig, singletonStoreConfig);
this.singletonStoreConfig = singletonStoreConfig;
}
Modified: core/branches/flat/src/main/java/org/horizon/config/Configuration.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/Configuration.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/Configuration.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -21,6 +21,7 @@
*/
package org.horizon.config;
+import org.horizon.factories.annotations.Inject;
import org.horizon.factories.annotations.NonVolatile;
import org.horizon.factories.annotations.Start;
import org.horizon.lock.IsolationLevel;
@@ -38,11 +39,12 @@
* @since 1.0
*/
@NonVolatile
-public class Configuration extends ConfigurationComponent {
+public class Configuration extends AbstractNamedCacheConfigurationBean {
private static final long serialVersionUID = 5553791890144997466L;
private boolean invocationBatchingEnabled;
private Map<String, EvictionCacheConfig> evictionCacheConfigs = new HashMap<String, EvictionCacheConfig>(4);
+ private GlobalConfiguration globalConfiguration;
public EvictionCacheConfig getEvictionCacheConfig(String cacheName) {
return evictionCacheConfigs.values().iterator().next();
@@ -52,6 +54,15 @@
evictionCacheConfigs.put(cacheName, ecc);
}
+ public GlobalConfiguration getGlobalConfiguration() {
+ return globalConfiguration;
+ }
+
+ @Inject
+ private void injectGlobalConfiguration(GlobalConfiguration globalConfiguration) {
+ this.globalConfiguration = globalConfiguration;
+ }
+
/**
* Cache replication mode.
*/
@@ -255,7 +266,6 @@
public void setCacheLoaderConfig(CacheLoaderConfig config) {
testImmutability("cacheLoaderConfig");
- replaceChildConfig(this.cacheLoaderConfig, config);
this.cacheLoaderConfig = config;
}
Deleted: core/branches/flat/src/main/java/org/horizon/config/ConfigurationComponent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/ConfigurationComponent.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/ConfigurationComponent.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -1,192 +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.config;
-
-import org.horizon.CacheSPI;
-import org.horizon.CacheStatus;
-import org.horizon.factories.ComponentRegistry;
-import org.horizon.factories.annotations.Inject;
-import org.horizon.factories.annotations.Start;
-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.util.TypedProperties;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * Base superclass of Cache configuration classes that expose some properties that can be changed after the cache is
- * started.
- *
- * @author <a href="brian.stansberry(a)jboss.com">Brian Stansberry</a>
- * @see #testImmutability(String)
- * @since 1.0
- */
-(a)Scope(Scopes.NAMED_CACHE)
-public abstract class ConfigurationComponent implements CloneableConfigurationComponent {
- private static final long serialVersionUID = 4879873994727821938L;
-
- protected transient Log log = LogFactory.getLog(getClass());
- private transient CacheSPI cache; // back-reference to test whether the cache is running.
- private final Set<ConfigurationComponent> children = Collections.synchronizedSet(new HashSet<ConfigurationComponent>());
- private transient ComponentRegistry cr;
- // a workaround to get over immutability checks
- private boolean accessible;
- protected List<String> overriddenConfigurationElements = new LinkedList<String>();
-
- protected ConfigurationComponent() {
- }
-
- public void passCacheToChildConfig(ConfigurationComponent child) {
- if (child != null) {
- child.setCache(cache);
- }
- }
-
- protected void addChildConfig(ConfigurationComponent child) {
- if (child != null && children.add(child))
- child.setCache(cache);
- }
-
- protected void addChildConfigs(Collection<? extends ConfigurationComponent> toAdd) {
- if (toAdd != null) {
- for (ConfigurationComponent child : toAdd)
- addChildConfig(child);
- }
- }
-
- protected void removeChildConfig(ConfigurationComponent child) {
- children.remove(child);
- }
-
- protected void removeChildConfigs(Collection<? extends ConfigurationComponent> toRemove) {
- if (toRemove != null) {
- for (ConfigurationComponent child : toRemove)
- removeChildConfig(child);
- }
- }
-
- protected void replaceChildConfig(ConfigurationComponent oldConfig, ConfigurationComponent newConfig) {
- removeChildConfig(oldConfig);
- addChildConfig(newConfig);
- }
-
- protected void replaceChildConfigs(Collection<? extends ConfigurationComponent> oldConfigs,
- Collection<? extends ConfigurationComponent> newConfigs) {
- synchronized (children) {
- removeChildConfigs(oldConfigs);
- addChildConfigs(newConfigs);
- }
- }
-
- /**
- * Safely converts a String to upper case.
- *
- * @param s string to convert
- * @return the string in upper case, or null if s is null.
- */
- protected String uc(String s) {
- return s == null ? null : s.toUpperCase(Locale.ENGLISH);
- }
-
- /**
- * Converts a given {@link Properties} instance to an instance of {@link TypedProperties}
- *
- * @param p properties to convert
- * @return TypedProperties instance
- */
- protected TypedProperties toTypedProperties(Properties p) {
- return TypedProperties.toTypedProperties(p);
- }
-
- protected TypedProperties toTypedProperties(String s) {
- TypedProperties tp = new TypedProperties();
- if (s != null && s.trim().length() > 0) {
- InputStream stream = new ByteArrayInputStream(s.getBytes());
- try {
- tp.load(stream);
- } catch (IOException e) {
- throw new ConfigurationException("Unable to parse properties string " + s, e);
- }
- }
- return tp;
- }
-
- /**
- * Checks field modifications via setters
- *
- * @param fieldName
- */
- protected void testImmutability(String fieldName) {
- try {
- if (!accessible && cache != null && cache.getCacheStatus() != null && cache.getCacheStatus() == CacheStatus.STARTED && !getClass().getDeclaredField(fieldName).isAnnotationPresent(Dynamic.class)) {
- throw new ConfigurationException("Attempted to modify a non-Dynamic configuration element [" + fieldName + "] after the cache has started!");
- }
- }
- catch (NoSuchFieldException e) {
- log.warn("Field " + fieldName + " not found!!");
- }
- finally {
- accessible = false;
- }
-
- // now mark this as overridden
- overriddenConfigurationElements.add(fieldName);
- }
-
- public void setCache(CacheSPI cache) {
- this.cache = cache;
- synchronized (children) {
- for (ConfigurationComponent child : children) {
- child.setCache(cache);
- }
- }
- }
-
- @Inject
- private void injectDependencies(ComponentRegistry cr) {
- this.cr = cr;
- }
-
- @Start
- private void start() {
- setCache(cr.getComponent(CacheSPI.class));
- }
-
- @Override
- public CloneableConfigurationComponent clone() throws CloneNotSupportedException {
- ConfigurationComponent c = (ConfigurationComponent) super.clone();
- c.setCache(null);
- return c;
- }
-}
Modified: core/branches/flat/src/main/java/org/horizon/config/CustomInterceptorConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/CustomInterceptorConfig.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/CustomInterceptorConfig.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -31,7 +31,7 @@
* @since 1.0
*/
@Immutable
-public class CustomInterceptorConfig extends ConfigurationComponent {
+public class CustomInterceptorConfig extends AbstractNamedCacheConfigurationBean {
private CommandInterceptor interceptor;
private boolean isFirst;
private boolean isLast;
Modified: core/branches/flat/src/main/java/org/horizon/config/EvictionCacheConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/EvictionCacheConfig.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/EvictionCacheConfig.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -23,7 +23,7 @@
import org.horizon.logging.LogFactory;
-public class EvictionCacheConfig extends ConfigurationComponent {
+public class EvictionCacheConfig extends AbstractNamedCacheConfigurationBean {
/**
* The serialVersionUID
*/
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-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/EvictionConfig.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -27,7 +27,7 @@
import java.util.List;
import java.util.concurrent.TimeUnit;
-public class EvictionConfig extends ConfigurationComponent {
+public class EvictionConfig extends AbstractNamedCacheConfigurationBean {
/**
* The serialVersionUID
*/
Modified: core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/GlobalConfiguration.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -1,7 +1,16 @@
package org.horizon.config;
import org.horizon.CacheException;
+import org.horizon.ComponentStatus;
import org.horizon.Version;
+import org.horizon.executors.DefaultExecutorFactory;
+import org.horizon.executors.DefaultScheduledExecutorFactory;
+import org.horizon.factories.GlobalComponentRegistry;
+import org.horizon.factories.annotations.Inject;
+import org.horizon.factories.annotations.NonVolatile;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+import org.horizon.remoting.transport.jgroups.JGroupsTransport;
import org.horizon.util.TypedProperties;
import java.util.Properties;
@@ -12,32 +21,35 @@
* @author Manik Surtani
* @since 1.0
*/
-public class GlobalConfiguration extends ConfigurationComponent {
+@NonVolatile
+(a)Scope(Scopes.GLOBAL)
+public class GlobalConfiguration extends AbstractConfigurationBean {
/**
* Default replication version, from {@link org.horizon.Version#getVersionShort}.
*/
public static final short DEFAULT_REPLICATION_VERSION = Version.getVersionShort();
- String asyncListenerExecutorFactoryClass;
+ String asyncListenerExecutorFactoryClass = DefaultExecutorFactory.class.getName();
TypedProperties asyncListenerExecutorProperties;
- String asyncSerializationExecutorFactoryClass;
+ String asyncSerializationExecutorFactoryClass = DefaultExecutorFactory.class.getName();
TypedProperties asyncSerializationExecutorProperties;
- String evictionScheduledExecutorFactoryClass;
+ String evictionScheduledExecutorFactoryClass = DefaultScheduledExecutorFactory.class.getName();
TypedProperties evictionScheduledExecutorProperties;
- String replicationQueueScheduledExecutorFactoryClass;
+ String replicationQueueScheduledExecutorFactoryClass = DefaultScheduledExecutorFactory.class.getName();
TypedProperties replicationQueueScheduledExecutorProperties;
String marshallerClass;
String marshallVersion;
int objectInputStreamPoolSize;
int objectOutputStreamPoolSize;
- String transportClass;
+ String transportClass = JGroupsTransport.class.getName();
TypedProperties transportProperties;
Configuration defaultConfiguration;
String clusterName = "Horizon-Cluster";
ShutdownHookBehavior shutdownHookBehavior = ShutdownHookBehavior.DEFAULT;
short replicationVersion = DEFAULT_REPLICATION_VERSION;
+ private GlobalComponentRegistry gcr;
/**
* Behavior of the JVM shutdown hook registered by the cache
@@ -57,7 +69,15 @@
DONT_REGISTER
}
+ @Inject
+ private void injectDependencies(GlobalComponentRegistry gcr) {
+ this.gcr = gcr;
+ }
+ protected boolean hasComponentStarted() {
+ return gcr != null && gcr.getState() != null && gcr.getState() == ComponentStatus.STARTED;
+ }
+
public String getAsyncListenerExecutorFactoryClass() {
return asyncListenerExecutorFactoryClass;
}
Modified: core/branches/flat/src/main/java/org/horizon/config/PluggableConfigurationComponent.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/PluggableConfigurationComponent.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/PluggableConfigurationComponent.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -33,7 +33,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 1.0
*/
-public abstract class PluggableConfigurationComponent extends ConfigurationComponent {
+public abstract class PluggableConfigurationComponent extends AbstractNamedCacheConfigurationBean {
protected String className;
protected Properties properties;
Modified: core/branches/flat/src/main/java/org/horizon/config/RuntimeConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/config/RuntimeConfig.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/config/RuntimeConfig.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -27,7 +27,7 @@
import javax.transaction.TransactionManager;
import java.util.concurrent.ExecutorService;
-public class RuntimeConfig extends ConfigurationComponent {
+public class RuntimeConfig extends AbstractNamedCacheConfigurationBean {
/**
* The serialVersionUID
*/
Modified: core/branches/flat/src/main/java/org/horizon/eviction/EvictionAlgorithmConfigBase.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/eviction/EvictionAlgorithmConfigBase.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/eviction/EvictionAlgorithmConfigBase.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -21,7 +21,7 @@
*/
package org.horizon.eviction;
-import org.horizon.config.ConfigurationComponent;
+import org.horizon.config.AbstractNamedCacheConfigurationBean;
import org.horizon.config.ConfigurationException;
import org.horizon.config.Dynamic;
import org.horizon.config.EvictionAlgorithmConfig;
@@ -34,7 +34,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 1.0
*/
-public abstract class EvictionAlgorithmConfigBase extends ConfigurationComponent implements EvictionAlgorithmConfig {
+public abstract class EvictionAlgorithmConfigBase extends AbstractNamedCacheConfigurationBean implements EvictionAlgorithmConfig {
private static final long serialVersionUID = 4591691674370188932L;
protected String evictionAlgorithmClassName;
Modified: core/branches/flat/src/main/java/org/horizon/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/eviction/algorithms/NULL/NullEvictionAlgorithmConfig.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -21,7 +21,7 @@
*/
package org.horizon.eviction.algorithms.NULL;
-import org.horizon.config.ConfigurationComponent;
+import org.horizon.config.AbstractNamedCacheConfigurationBean;
import org.horizon.config.ConfigurationException;
import org.horizon.config.EvictionAlgorithmConfig;
@@ -31,7 +31,7 @@
* @author Manik Surtani
* @since 1.0
*/
-public class NullEvictionAlgorithmConfig extends ConfigurationComponent implements EvictionAlgorithmConfig {
+public class NullEvictionAlgorithmConfig extends AbstractNamedCacheConfigurationBean implements EvictionAlgorithmConfig {
private static final long serialVersionUID = -6591180473728241737L;
/**
Modified: core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/AbstractComponentRegistry.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -22,11 +22,12 @@
package org.horizon.factories;
import org.horizon.CacheException;
-import org.horizon.CacheStatus;
+import org.horizon.ComponentStatus;
import org.horizon.Version;
import org.horizon.config.Configuration;
import org.horizon.config.ConfigurationException;
import org.horizon.config.RuntimeConfig;
+import org.horizon.factories.annotations.ComponentName;
import org.horizon.factories.annotations.DefaultFactoryFor;
import org.horizon.factories.annotations.Destroy;
import org.horizon.factories.annotations.Inject;
@@ -40,6 +41,7 @@
import org.horizon.util.BeanUtils;
import org.horizon.util.ReflectionUtil;
+import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
@@ -48,6 +50,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Stack;
/**
* A registry where components which have been created are stored. Components are stored as singletons, registered
@@ -62,13 +65,13 @@
* <p/>
* Default factories are treated as components too and will need to be wired before being used.
* <p/>
- * The registry can exist in one of several states, as defined by the {@link CacheStatus} enumeration. In terms of the
- * cache, state changes in the following manner: <ul> <li>INSTANTIATED - when first constructed</li> <li>CONSTRUCTED -
- * when created using the DefaultCacheFactory</li> <li>STARTED - when {@link org.horizon.Cache#start()} is called</li>
- * <li>STOPPED - when {@link org.horizon.Cache#stop()} is called</li> </ul>
+ * The registry can exist in one of several states, as defined by the {@link org.horizon.ComponentStatus} enumeration.
+ * In terms of the cache, state changes in the following manner: <ul> <li>INSTANTIATED - when first constructed</li>
+ * <li>CONSTRUCTED - when created using the DefaultCacheFactory</li> <li>STARTED - when {@link
+ * org.horizon.Cache#start()} is called</li> <li>STOPPED - when {@link org.horizon.Cache#stop()} is called</li> </ul>
* <p/>
* Cache configuration can only be changed and will only be reinjected if the cache is not in the {@link
- * org.horizon.CacheStatus#STARTED} state.
+ * org.horizon.ComponentStatus#STARTED} state.
*
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 1.0
@@ -76,6 +79,10 @@
@NonVolatile
@Scope(Scopes.NAMED_CACHE)
public abstract class AbstractComponentRegistry implements Lifecycle {
+
+ private static final boolean DEBUG_DEPENDENCIES = true;
+ private Stack<String> debugStack = DEBUG_DEPENDENCIES ? new Stack<String>() : null;
+
/**
* Contains class definitions of component factories that can be used to construct certain components
*/
@@ -86,14 +93,14 @@
// component and method containers
final Map<String, Component> componentLookup = new HashMap<String, Component>();
- CacheStatus state = CacheStatus.INSTANTIATED;
+ ComponentStatus state = ComponentStatus.INSTANTIATED;
/**
* Retrieves the state of the registry
*
* @return state of the registry
*/
- public CacheStatus getState() {
+ public ComponentStatus getState() {
return state;
}
@@ -144,6 +151,8 @@
s.add(LockManagerFactory.class);
s.add(DataContainerFactory.class);
s.add(EvictionManagerFactory.class);
+ s.add(NamedExecutorsFactory.class);
+ s.add(TransportFactory.class);
return s;
}
@@ -159,6 +168,8 @@
}
public void registerComponent(Object component, String name) {
+ if (component == null)
+ throw new NullPointerException("Cannot register a null component under name [" + name + "]");
Component old = componentLookup.get(name);
if (old != null) {
@@ -176,7 +187,7 @@
old.methodsScanned = false;
c = old;
- if (state == CacheStatus.STARTED) populateLifecycleMethods();
+ if (state == ComponentStatus.STARTED) populateLifecycleMethods();
} else {
c = new Component();
c.name = name;
@@ -205,15 +216,36 @@
@SuppressWarnings("unchecked")
protected void invokeInjectionMethod(Object o, Method m) {
Class[] dependencies = m.getParameterTypes();
+ Annotation[][] parameterAnnotations = m.getParameterAnnotations();
Object[] params = new Object[dependencies.length];
for (int i = 0; i < dependencies.length; i++) {
- params[i] = getOrCreateComponent(dependencies[i]);
+ params[i] = getOrCreateComponent(dependencies[i], getComponentName(dependencies[i], parameterAnnotations, i));
}
ReflectionUtil.invokeAccessibly(o, m, params);
}
+ private String getComponentName(Class component, Annotation[][] annotations, int paramNumber) {
+ String name;
+ if (annotations == null ||
+ annotations.length <= paramNumber ||
+ (name = findComponentName(annotations[paramNumber])) == null) return component.getName();
+
+ return name;
+ }
+
+ private String findComponentName(Annotation[] anns) {
+ if (anns != null && anns.length > 0) {
+ for (Annotation a : anns) {
+ if (a instanceof ComponentName) {
+ return ((ComponentName) a).value();
+ }
+ }
+ }
+ return null;
+ }
+
/**
* Retrieves a component if one exists, and if not, attempts to find a factory capable of constructing the component
* (factories annotated with the {@link DefaultFactoryFor} annotation that is capable of creating the component
@@ -234,9 +266,14 @@
* @throws ConfigurationException if there is a problem with consructing or wiring the instance.
*/
protected <T> T getOrCreateComponent(Class<T> componentClass) {
+ return getOrCreateComponent(componentClass, componentClass.getName());
+ }
- T component = getComponent(componentClass);
+ protected <T> T getOrCreateComponent(Class<T> componentClass, String name) {
+ if (DEBUG_DEPENDENCIES) debugStack.push(name);
+ T component = getComponent(componentClass, name);
+
if (component == null) {
// first see if this has been injected externally.
component = getFromConfiguration(componentClass);
@@ -245,7 +282,9 @@
if (component == null) {
// create this component and add it to the registry
ComponentFactory factory = getFactory(componentClass);
- component = factory.construct(componentClass);
+ component = factory instanceof NamedComponentFactory ?
+ ((NamedComponentFactory) factory).construct(componentClass, name)
+ : factory.construct(componentClass);
attemptedFactoryConstruction = true;
}
@@ -259,6 +298,7 @@
}
}
+ if (DEBUG_DEPENDENCIES) debugStack.pop();
return component;
}
@@ -273,14 +313,14 @@
Map<Class, Class<? extends ComponentFactory>> defaultFactoryMap = getDefaultFactoryMap();
Class<? extends ComponentFactory> cfClass = defaultFactoryMap.get(componentClass);
if (cfClass == null)
- throw new ConfigurationException("No registered default factory for component " + componentClass + " found!");
+ throw new ConfigurationException("No registered default factory for component " + componentClass + " found! Debug stack: " + debugStack);
// a component factory is a component too! See if one has been created and exists in the registry
ComponentFactory cf = getComponent(cfClass);
if (cf == null) {
// hasn't yet been created. Create and put in registry
cf = instantiateFactory(cfClass);
if (cf == null)
- throw new ConfigurationException("Unable to locate component factory for component " + componentClass);
+ throw new ConfigurationException("Unable to locate component factory for component " + componentClass + " Debug stack: " + debugStack);
// we simply register this factory. Registration will take care of constructing any dependencies.
registerComponent(cf, cfClass);
}
@@ -288,7 +328,7 @@
// ensure the component factory is in the STARTED state!
Component c = componentLookup.get(cfClass.getName());
if (c.instance != cf)
- throw new ConfigurationException("Component factory " + cfClass + " incorrectly registered!");
+ throw new ConfigurationException("Component factory " + cfClass + " incorrectly registered! Debug stack: " + debugStack);
return cf;
}
@@ -302,14 +342,30 @@
* created by such factories.
*/
void scanDefaultFactories() {
- defaultFactories = new HashMap<Class, Class<? extends ComponentFactory>>();
-
+ Map<Class, Class<? extends ComponentFactory>> temp = new HashMap<Class, Class<? extends ComponentFactory>>();
Set<Class<? extends ComponentFactory>> factories = getHardcodedFactories();
for (Class<? extends ComponentFactory> factory : factories) {
+ // check if this implements auto-instantiable. If it doesn't have a no-arg constructor throw an exception
+ boolean factoryValid = true;
+ try {
+ if (AutoInstantiableFactory.class.isAssignableFrom(factory) && factory.getConstructor() == null) {
+ factoryValid = false;
+ }
+ } catch (Exception e) {
+ factoryValid = false;
+ }
+
+ if (!factoryValid)
+ throw new RuntimeException("Factory class " + factory + " implements AutoInstantiableFactory but does not expose a public, no-arg constructor! Debug stack: " + debugStack);
+
DefaultFactoryFor dFFAnnotation = factory.getAnnotation(DefaultFactoryFor.class);
- for (Class targetClass : dFFAnnotation.classes()) defaultFactories.put(targetClass, factory);
+ if (dFFAnnotation != null) {
+ for (Class targetClass : dFFAnnotation.classes()) temp.put(targetClass, factory);
+ }
}
+
+ defaultFactories = temp;
}
/**
@@ -320,13 +376,17 @@
* @return factory instance
*/
ComponentFactory instantiateFactory(Class<? extends ComponentFactory> factory) {
- try {
- return factory.newInstance();
+ if (AutoInstantiableFactory.class.isAssignableFrom(factory)) {
+ try {
+ return factory.newInstance();
+ }
+ catch (Exception e) {
+ // unable to get a hold of an instance!!
+ throw new ConfigurationException("Unable to instantiate factory " + factory + " Debug stack: " + debugStack, e);
+ }
+ } else {
+ throw new ConfigurationException("Cannot auto-instantiate factory " + factory + " as it doesn't implement " + AutoInstantiableFactory.class.getSimpleName() + "! Debug stack: " + debugStack);
}
- catch (Exception e) {
- // unable to get a hold of an instance!!
- throw new ConfigurationException("Unable to instantiate factory " + factory, e);
- }
}
/**
@@ -390,9 +450,13 @@
* @param type type to find
* @return component, or null
*/
+ public <T> T getComponent(Class<T> type) {
+ return getComponent(type, type.getName());
+ }
+
@SuppressWarnings("unchecked")
- public <T> T getComponent(Class<T> type) {
- Component wrapper = componentLookup.get(type.getName());
+ public <T> T getComponent(Class<T> type, String name) {
+ Component wrapper = componentLookup.get(name);
if (wrapper == null) return null;
return (T) (wrapper.instance == NULL_COMPONENT ? null : wrapper.instance);
@@ -472,7 +536,7 @@
/**
* Creates the components needed by a cache instance and sets the cache status to {@link
- * org.horizon.CacheStatus#CREATED} when it is done.
+ * org.horizon.ComponentStatus#CREATED} when it is done.
*/
public void create() {
if (!state.createAllowed()) {
@@ -492,7 +556,7 @@
/**
* This starts the components in the cache, connecting to channels, starting service threads, etc. If the cache is
- * not in the {@link org.horizon.CacheStatus#CREATED} state, {@link #create()} will be invoked first.
+ * not in the {@link org.horizon.ComponentStatus#CREATED} state, {@link #create()} will be invoked first.
*/
public void start() {
boolean createdInStart = false;
@@ -516,8 +580,8 @@
}
/**
- * Stops the cache and sets the cache status to {@link org.horizon.CacheStatus#STOPPED} once it is done. If the
- * cache is not in the {@link org.horizon.CacheStatus#STARTED} state, this is a no-op.
+ * Stops the cache and sets the cache status to {@link org.horizon.ComponentStatus#STOPPED} once it is done. If the
+ * cache is not in the {@link org.horizon.ComponentStatus#STARTED} state, this is a no-op.
*/
public void stop() {
if (!state.stopAllowed()) {
@@ -525,7 +589,7 @@
}
// Trying to stop() from FAILED is valid, but may not work
- boolean failed = state == CacheStatus.FAILED;
+ boolean failed = state == ComponentStatus.FAILED;
try {
internalStop();
@@ -538,16 +602,16 @@
handleLifecycleTransitionFailure(t);
}
finally {
- if (!failed) state = CacheStatus.STOPPED;
+ if (!failed) state = ComponentStatus.STOPPED;
}
}
/**
- * Destroys the cache and frees up any resources. Sets the cache status to {@link CacheStatus#DESTROYED} when it is
- * done.
+ * Destroys the cache and frees up any resources. Sets the cache status to {@link
+ * org.horizon.ComponentStatus#DESTROYED} when it is done.
* <p/>
- * If the cache is in {@link org.horizon.CacheStatus#STARTED} when this method is called, it will first call {@link
- * #stop()} to stop the cache.
+ * If the cache is in {@link org.horizon.ComponentStatus#STARTED} when this method is called, it will first call
+ * {@link #stop()} to stop the cache.
*/
public void destroy() {
if (!state.destroyAllowed()) {
@@ -567,7 +631,7 @@
}
finally {
// We always progress to destroyed
- state = CacheStatus.DESTROYED;
+ state = ComponentStatus.DESTROYED;
}
}
// ------------------------------ END: Publicly available lifecycle methods -----------------------------
@@ -581,7 +645,7 @@
* @param t throwable thrown during failure
*/
private void handleLifecycleTransitionFailure(Throwable t) {
- state = CacheStatus.FAILED;
+ state = ComponentStatus.FAILED;
if (t instanceof CacheException)
throw (CacheException) t;
else if (t instanceof RuntimeException)
@@ -596,10 +660,10 @@
* The actual create implementation.
*/
private void internalCreate() {
- state = CacheStatus.CREATING;
+ state = ComponentStatus.CREATING;
resetNonVolatile();
rewire();
- state = CacheStatus.CREATED;
+ state = ComponentStatus.CREATED;
}
private void internalStart(boolean createdInStart) throws CacheException, IllegalArgumentException {
@@ -610,7 +674,7 @@
rewire();
}
- state = CacheStatus.STARTING;
+ state = ComponentStatus.STARTING;
// start all internal components
// first cache all start, stop and destroy methods.
@@ -630,7 +694,7 @@
addShutdownHook();
getLog().info("JBoss Cache version: " + Version.printVersion());
- state = CacheStatus.STARTED;
+ state = ComponentStatus.STARTED;
}
protected void addShutdownHook() {
@@ -645,7 +709,7 @@
* Actual stop
*/
private void internalStop() {
- state = CacheStatus.STOPPING;
+ state = ComponentStatus.STOPPING;
removeShutdownHook();
List<PrioritizedMethod> stopMethods = new ArrayList<PrioritizedMethod>(componentLookup.size());
@@ -656,7 +720,7 @@
// fire all STOP methods according to priority
for (PrioritizedMethod em : stopMethods) em.invoke();
- state = CacheStatus.STOPPED;
+ state = ComponentStatus.STOPPED;
}
/**
@@ -664,7 +728,7 @@
*/
private void internalDestroy() {
- state = CacheStatus.DESTROYING;
+ state = ComponentStatus.DESTROYING;
resetNonVolatile();
@@ -676,7 +740,7 @@
// fire all DESTROY methods according to priority
for (PrioritizedMethod em : destroyMethods) em.invoke();
- state = CacheStatus.DESTROYED;
+ state = ComponentStatus.DESTROYED;
}
// ------------------------------ END: Actual internal lifecycle methods --------------------------------
@@ -684,8 +748,8 @@
/**
* Asserts whether invocations are allowed on the cache or not. Returns <tt>true</tt> if invocations are to be
* allowed, <tt>false</tt> otherwise. If the origin of the call is remote and the cache status is {@link
- * org.horizon.CacheStatus#STARTING}, this method will block for up to {@link Configuration#getStateRetrievalTimeout()}
- * millis, checking for a valid state.
+ * org.horizon.ComponentStatus#STARTING}, this method will block for up to {@link
+ * Configuration#getStateRetrievalTimeout()} millis, checking for a valid state.
*
* @param originLocal true if the call originates locally (i.e., from the {@link org.horizon.CacheDelegate} or false
* if it originates remotely, i.e., from the {@link org.horizon.marshall.CommandAwareRpcDispatcher}.
@@ -701,7 +765,7 @@
getLog().trace("Is remotely originating.");
// else if this is a remote call and the status is STARTING, wait until the cache starts.
- if (state == CacheStatus.STARTING) {
+ if (state == ComponentStatus.STARTING) {
getLog().trace("Cache is starting; block.");
try {
blockUntilCacheStarts();
@@ -717,9 +781,9 @@
}
/**
- * Blocks until the current cache instance is in its {@link org.horizon.CacheStatus#STARTED started} phase. Blocks
- * for up to {@link Configuration#getStateRetrievalTimeout()} milliseconds, throwing an IllegalStateException if the
- * cache doesn't reach this state even after this maximum wait time.
+ * Blocks until the current cache instance is in its {@link org.horizon.ComponentStatus#STARTED started} phase.
+ * Blocks for up to {@link Configuration#getStateRetrievalTimeout()} milliseconds, throwing an IllegalStateException
+ * if the cache doesn't reach this state even after this maximum wait time.
*
* @throws InterruptedException if interrupted while waiting
* @throws IllegalStateException if even after waiting the cache has not started.
Added: core/branches/flat/src/main/java/org/horizon/factories/AutoInstantiableFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/AutoInstantiableFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/AutoInstantiableFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -0,0 +1,15 @@
+package org.horizon.factories;
+
+/**
+ * Component factories that implement this interface can be instantiated automatically by component registries when
+ * looking up components. Typically, most component factories will implement this. One known exception is the {@link
+ * org.horizon.factories.BootstrapFactory}.
+ * <p/>
+ * Anything implementing this interface should expose a public, no-arg constructor.
+ * <p/>
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public interface AutoInstantiableFactory {
+}
Modified: core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/BootstrapFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -44,13 +44,21 @@
}
@Override
- protected <T> T construct(Class<T> componentType) {
- if (componentType.isAssignableFrom(CacheSPI.class) ||
- componentType.isAssignableFrom(Configuration.class) ||
- componentType.isAssignableFrom(ComponentRegistry.class)) {
- return componentType.cast(cacheSPI);
+ public <T> T construct(Class<T> componentType) {
+ Object comp = null;
+ if (componentType.isAssignableFrom(CacheSPI.class)) {
+ comp = cacheSPI;
+ } else if (componentType.isAssignableFrom(Configuration.class)) {
+ comp = configuration;
+ } else if (componentType.isAssignableFrom(ComponentRegistry.class)) {
+ comp = componentRegistry;
}
+ if (comp == null) throw new CacheException("Don't know how to handle type " + componentType);
- throw new CacheException("Don't know how to handle type " + componentType);
+ try {
+ return componentType.cast(comp);
+ } catch (Exception e) {
+ throw new CacheException("Problems casting bootstrap component " + comp.getClass() + " to type " + componentType, e);
+ }
}
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/ComponentFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -74,7 +74,7 @@
* @param componentType type of component
* @return a component
*/
- protected abstract <T> T construct(Class<T> componentType);
+ public abstract <T> T construct(Class<T> componentType);
protected void assertTypeConstructable(Class requestedType, Class... ableToConstruct) {
boolean canConstruct = false;
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-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/ComponentRegistry.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -3,6 +3,7 @@
import org.horizon.CacheException;
import org.horizon.CacheSPI;
import org.horizon.config.Configuration;
+import org.horizon.config.ConfigurationException;
import org.horizon.factories.scopes.ScopeDetector;
import org.horizon.factories.scopes.Scopes;
import org.horizon.logging.Log;
@@ -33,13 +34,16 @@
try {
this.cacheName = cacheName;
- this.log = LogFactory.getLog(ComponentRegistry.class.getName() + ":" + cacheName);
+ if (cacheName == null) throw new ConfigurationException("Cache name cannot be null!");
+ StringBuilder sb = new StringBuilder(ComponentRegistry.class.getName()).append(cacheName);
+ this.log = LogFactory.getLog(sb.toString());
+ if (globalComponents == null) throw new NullPointerException("GlobalComponentRegistry cannot be null!");
+ this.globalComponents = globalComponents;
+
registerDefaultClassLoader(null);
registerComponent(this, ComponentRegistry.class);
registerComponent(configuration, Configuration.class);
registerComponent(new BootstrapFactory(cache, configuration, this), BootstrapFactory.class);
-
- this.globalComponents = globalComponents;
}
catch (Exception e) {
throw new CacheException("Unable to construct a ComponentRegistry!", e);
@@ -66,16 +70,16 @@
@Override
- public <T> T getComponent(Class<T> componentType) {
+ public <T> T getComponent(Class<T> componentType, String name) {
// first try in the local registry
Scopes componentScope = ScopeDetector.detectScope(componentType);
switch (componentScope) {
case GLOBAL:
- return globalComponents.getComponent(componentType);
+ return globalComponents.getComponent(componentType, name);
case NAMED_CACHE:
- return super.getComponent(componentType);
+ return super.getComponent(componentType, name);
default:
- throw new IllegalArgumentException("Unknown component scope " + componentScope);
+ throw new IllegalArgumentException("Unknown component scope " + componentScope + " for component type " + componentType);
}
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/DataContainerFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -32,8 +32,8 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = DataContainer.class)
-public class DataContainerFactory extends ComponentFactory {
- protected <T> T construct(Class<T> componentType) {
+public class DataContainerFactory extends ComponentFactory implements AutoInstantiableFactory {
+ public <T> T construct(Class<T> componentType) {
return (T) new UnsortedDataContainer();
}
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/DefaultCacheFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -102,7 +102,7 @@
}
@Override
- protected <T> T construct(Class<T> componentType) {
+ public <T> T construct(Class<T> componentType) {
throw new UnsupportedOperationException("Should never be invoked - this is a bootstrap factory.");
}
}
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-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/EmptyConstructorFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -31,7 +31,9 @@
import org.horizon.loader.CacheLoaderManager;
import org.horizon.marshall.Marshaller;
import org.horizon.marshall.VersionAwareMarshaller;
+import org.horizon.notifications.CacheManagerNotifier;
import org.horizon.notifications.CacheNotifier;
+import org.horizon.remoting.InboundInvocationHandler;
import org.horizon.transaction.TransactionTable;
/**
@@ -40,12 +42,12 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 1.0
*/
-@DefaultFactoryFor(classes = {CacheNotifier.class,
+@DefaultFactoryFor(classes = {CacheNotifier.class, CacheManagerNotifier.class, InboundInvocationHandler.class,
CacheLoaderManager.class, Marshaller.class, InvocationContextContainer.class,
TransactionTable.class, BatchContainer.class, ContextFactory.class, EntryFactory.class, CommandsFactory.class})
-public class EmptyConstructorFactory extends ComponentFactory {
+public class EmptyConstructorFactory extends ComponentFactory implements AutoInstantiableFactory {
@Override
- protected <T> T construct(Class<T> componentType) {
+ public <T> T construct(Class<T> componentType) {
try {
if (componentType.isInterface()) {
Class componentImpl;
Modified: core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/EvictionManagerFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -9,8 +9,8 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = {EvictionManager.class})
-public class EvictionManagerFactory extends ComponentFactory {
- protected <T> T construct(Class<T> componentType) {
+public class EvictionManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
+ public <T> T construct(Class<T> componentType) {
if (componentType != EvictionManager.class) {
throw new IllegalStateException();
}
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-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/GlobalComponentRegistry.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -4,8 +4,11 @@
import org.horizon.config.GlobalConfiguration;
import static org.horizon.config.GlobalConfiguration.ShutdownHookBehavior.DEFAULT;
import static org.horizon.config.GlobalConfiguration.ShutdownHookBehavior.REGISTER;
+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.manager.CacheManager;
import javax.management.MBeanServerFactory;
import java.util.ArrayList;
@@ -16,6 +19,7 @@
* @author Manik Surtani
* @since 1.0
*/
+(a)Scope(Scopes.GLOBAL)
public class GlobalComponentRegistry extends AbstractComponentRegistry {
private Log log = LogFactory.getLog(GlobalComponentRegistry.class);
@@ -36,11 +40,14 @@
*
* @param configuration configuration with which this is created
*/
- public GlobalComponentRegistry(GlobalConfiguration configuration) {
+ public GlobalComponentRegistry(GlobalConfiguration configuration, CacheManager cacheManager) {
+ if (configuration == null) throw new NullPointerException("GlobalConfiguration cannot be null!");
try {
+ // this order is important ...
globalConfiguration = configuration;
+ registerComponent(this, GlobalComponentRegistry.class);
+ registerComponent(cacheManager, CacheManager.class);
registerComponent(configuration, GlobalConfiguration.class);
- registerComponent(this, GlobalComponentRegistry.class);
}
catch (Exception e) {
throw new CacheException("Unable to construct a GlobalComponentRegistry!", e);
Modified: core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/InterceptorChainFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -43,7 +43,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = InterceptorChain.class)
-public class InterceptorChainFactory extends ComponentFactory {
+public class InterceptorChainFactory extends ComponentFactory implements AutoInstantiableFactory {
private CommandInterceptor createInterceptor(Class<? extends CommandInterceptor> clazz) throws IllegalAccessException, InstantiationException {
CommandInterceptor chainedInterceptor = componentRegistry.getComponent(clazz);
if (chainedInterceptor == null) {
@@ -185,7 +185,7 @@
}
@Override
- protected <T> T construct(Class<T> componentType) {
+ public <T> T construct(Class<T> componentType) {
try {
return componentType.cast(buildInterceptorChain());
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/LockManagerFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -32,8 +32,8 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = LockManager.class)
-public class LockManagerFactory extends ComponentFactory {
- protected <T> T construct(Class<T> componentType) {
+public class LockManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
+ public <T> T construct(Class<T> componentType) {
return (T) new StripedLockManager();
}
}
Added: core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/NamedComponentFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -0,0 +1,26 @@
+package org.horizon.factories;
+
+/**
+ * A specialized type of component factory that knows how to create named components, identified with the {@link
+ * org.horizon.factories.annotations.ComponentName} annotation on the classes requested in {@link
+ * org.horizon.factories.annotations.Inject} annotated methods.
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+public abstract class NamedComponentFactory extends ComponentFactory {
+
+ public <T> T construct(Class<T> componentType) {
+
+ // by default, use the FQCN of the component type.
+ return construct(componentType, componentType.getName());
+ }
+
+ /**
+ * Constructs a component.
+ *
+ * @param componentType type of component
+ * @return a component
+ */
+ public abstract <T> T construct(Class<T> componentType, String componentName);
+}
Added: core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/NamedExecutorsFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -0,0 +1,46 @@
+package org.horizon.factories;
+
+import org.horizon.config.ConfigurationException;
+import org.horizon.executors.ExecutorFactory;
+import org.horizon.factories.annotations.DefaultFactoryFor;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+import org.horizon.util.Util;
+
+import java.util.Properties;
+import java.util.concurrent.Executor;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.ScheduledExecutorService;
+
+/**
+ * A factory that specifically knows how to create named executors.
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+@DefaultFactoryFor(classes = {ExecutorService.class, Executor.class, ScheduledExecutorService.class})
+(a)Scope(Scopes.GLOBAL)
+public class NamedExecutorsFactory extends NamedComponentFactory implements AutoInstantiableFactory {
+
+ @SuppressWarnings("unchecked")
+ public <T> T construct(Class<T> componentType, String componentName) {
+ ExecutorFactory ef;
+ Properties props;
+ try {
+ if (componentName.equals(KnownComponentNames.ASYNC_NOTIFICATION_EXECUTOR)) {
+ ef = (ExecutorFactory) Util.getInstance(configuration.getGlobalConfiguration().getAsyncListenerExecutorFactoryClass());
+ props = configuration.getGlobalConfiguration().getAsyncListenerExecutorProperties();
+ } else if (componentName.equals(KnownComponentNames.ASYNC_SERIALIZATION_EXECUTOR)) {
+ ef = (ExecutorFactory) Util.getInstance(configuration.getGlobalConfiguration().getAsyncSerializationExecutorFactoryClass());
+ props = configuration.getGlobalConfiguration().getAsyncSerializationExecutorProperties();
+ } else {
+ throw new ConfigurationException("Unknown named executor " + componentName);
+ }
+ } catch (ConfigurationException ce) {
+ throw ce;
+ } catch (Exception e) {
+ throw new ConfigurationException("Unable to instantiate ExecutorFactory for named component " + componentName, e);
+ }
+ return (T) ef.getExecutor(props);
+ }
+}
Modified: core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/ReplicationQueueFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -32,7 +32,7 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = ReplicationQueue.class)
-public class ReplicationQueueFactory extends EmptyConstructorFactory {
+public class ReplicationQueueFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
@Override
public <T> T construct(Class<T> componentType) {
if ((configuration.getCacheMode() == Configuration.CacheMode.REPL_ASYNC || configuration.getCacheMode() == Configuration.CacheMode.INVALIDATION_ASYNC)
Modified: core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/RuntimeConfigAwareFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -36,9 +36,9 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = RPCManager.class)
-public class RuntimeConfigAwareFactory extends EmptyConstructorFactory {
+public class RuntimeConfigAwareFactory extends EmptyConstructorFactory implements AutoInstantiableFactory {
@Override
- protected <T> T construct(Class<T> componentType) {
+ public <T> T construct(Class<T> componentType) {
T component = super.construct(componentType);
Method setter = BeanUtils.setterMethod(RuntimeConfig.class, componentType);
Modified: core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/StateTransferFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -33,9 +33,9 @@
*/
// TODO: Implement me
//@DefaultFactoryFor(classes = {StateTransferGenerator.class, StateTransferIntegrator.class})
-public class StateTransferFactory extends ComponentFactory {
+public class StateTransferFactory extends ComponentFactory implements AutoInstantiableFactory {
@SuppressWarnings("deprecation")
- protected <T> T construct(Class<T> componentType) {
+ public <T> T construct(Class<T> componentType) {
return null;
// if (componentType.equals(StateTransferIntegrator.class))
// {
Modified: core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/StateTransferManagerFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -32,9 +32,9 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = StateTransferManager.class)
-public class StateTransferManagerFactory extends ComponentFactory {
+public class StateTransferManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
@SuppressWarnings("deprecation")
- protected <T> T construct(Class<T> componentType) {
+ public <T> T construct(Class<T> componentType) {
return componentType.cast(new DefaultStateTransferManager());
}
}
Modified: core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/factories/TransactionManagerFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -35,8 +35,8 @@
* @since 1.0
*/
@DefaultFactoryFor(classes = {TransactionManager.class})
-public class TransactionManagerFactory extends ComponentFactory {
- protected <T> T construct(Class<T> componentType) {
+public class TransactionManagerFactory extends ComponentFactory implements AutoInstantiableFactory {
+ public <T> T construct(Class<T> componentType) {
// See if we had a TransactionManager injected into our config
TransactionManager transactionManager = configuration.getRuntimeConfig().getTransactionManager();
TransactionManagerLookup lookup = null;
Added: core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java (rev 0)
+++ core/branches/flat/src/main/java/org/horizon/factories/TransportFactory.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -0,0 +1,29 @@
+package org.horizon.factories;
+
+import org.horizon.CacheException;
+import org.horizon.factories.annotations.DefaultFactoryFor;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
+import org.horizon.remoting.transport.Transport;
+import org.horizon.util.Util;
+
+/**
+ * Factory for Transport implementations
+ *
+ * @author Manik Surtani
+ * @since 1.0
+ */
+@DefaultFactoryFor(classes = Transport.class)
+(a)Scope(Scopes.GLOBAL)
+public class TransportFactory extends ComponentFactory implements AutoInstantiableFactory {
+
+ @SuppressWarnings("unchecked")
+ public <T> T construct(Class<T> componentType) {
+ String transportClass = configuration.getGlobalConfiguration().getTransportClass();
+ try {
+ return (T) Util.getInstance(transportClass);
+ } catch (Exception e) {
+ throw new CacheException("Unable to create transport of type " + transportClass, e);
+ }
+ }
+}
Modified: core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/loader/ClusteredCacheLoader.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -22,7 +22,7 @@
package org.horizon.loader;
import net.jcip.annotations.ThreadSafe;
-import org.horizon.CacheStatus;
+import org.horizon.ComponentStatus;
import org.horizon.commands.CommandsFactory;
import org.horizon.commands.DataCommand;
import org.horizon.config.CacheLoaderConfig.IndividualCacheLoaderConfig;
@@ -65,7 +65,7 @@
* @return true if the cache is in its STARTED state.
*/
protected boolean isCacheReady() {
- return cache.getCacheStatus() == CacheStatus.STARTED;
+ return cache.getCacheStatus() == ComponentStatus.STARTED;
}
@Inject
Modified: core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/manager/CacheManager.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -2,6 +2,8 @@
import org.horizon.Cache;
import org.horizon.config.Configuration;
+import org.horizon.factories.scopes.Scope;
+import org.horizon.factories.scopes.Scopes;
import org.horizon.lifecycle.Lifecycle;
import org.horizon.notifications.Listenable;
import org.horizon.remoting.transport.Address;
@@ -45,6 +47,7 @@
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik(a)jboss.org</a>)
* @since 1.0
*/
+(a)Scope(Scopes.GLOBAL)
public interface CacheManager extends Lifecycle, Listenable {
/**
* Defines a named cache. Named caches can be defined by using this method, in which case the configuration passed
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-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/manager/DefaultCacheManager.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -157,7 +157,7 @@
public DefaultCacheManager(GlobalConfiguration globalConfiguration, Configuration defaultConfiguration, boolean start) {
this.globalConfiguration = globalConfiguration == null ? new GlobalConfiguration() : globalConfiguration.clone();
this.globalConfiguration.setDefaultConfiguration(defaultConfiguration == null ? new Configuration() : defaultConfiguration.clone());
- globalComponentRegistry = new GlobalComponentRegistry(globalConfiguration);
+ globalComponentRegistry = new GlobalComponentRegistry(this.globalConfiguration, this);
if (start) start();
}
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-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/remoting/RPCManagerImpl.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -7,6 +7,7 @@
import org.horizon.config.GlobalConfiguration;
import org.horizon.factories.KnownComponentNames;
import org.horizon.factories.annotations.ComponentName;
+import org.horizon.factories.annotations.Inject;
import org.horizon.factories.annotations.Start;
import org.horizon.factories.annotations.Stop;
import org.horizon.marshall.Marshaller;
@@ -34,6 +35,7 @@
AtomicLong replicationFailures = new AtomicLong(0);
boolean statisticsEnabled = false; // by default, don't gather statistics.
+ @Inject
public void injectDependencies(GlobalConfiguration globalConfiguration, Transport t, InboundInvocationHandler handler,
Marshaller marshaller,
@ComponentName(KnownComponentNames.ASYNC_SERIALIZATION_EXECUTOR) ExecutorService e,
Modified: core/branches/flat/src/main/java/org/horizon/tree/TreeCache.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/tree/TreeCache.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/tree/TreeCache.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -23,7 +23,7 @@
import org.horizon.Cache;
import org.horizon.CacheException;
-import org.horizon.CacheStatus;
+import org.horizon.ComponentStatus;
import org.horizon.config.Configuration;
import org.horizon.context.InvocationContext;
import org.horizon.interceptors.base.CommandInterceptor;
@@ -114,7 +114,7 @@
* @param fqn <b><i>absolute</i></b> {@link Fqn} to the {@link Node} to be accessed.
* @param key key with which the specified value is to be associated.
* @param value value to be associated with the specified key.
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.ComponentStatus#STARTED}.
*/
void putForExternalRead(Fqn fqn, K key, V value);
@@ -240,7 +240,7 @@
*
* @return the CacheStatus. Will not return <code>null</code>.
*/
- CacheStatus getCacheStatus();
+ ComponentStatus getCacheStatus();
/**
* @return the current invocation context for the current invocation and cache instance.
@@ -322,14 +322,14 @@
* @param newParent new location under which to attach the node being moved.
* @throws NodeNotExistsException may throw one of these if the target node does not exist or if a different thread
* has moved this node elsewhere already.
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.ComponentStatus#STARTED}.
*/
void move(Fqn nodeToMove, Fqn newParent) throws NodeNotExistsException;
/**
* Convenience method that takes in string representations of Fqns. Otherwise identical to {@link #move(Fqn, Fqn)}
*
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.ComponentStatus#STARTED}.
*/
void move(String nodeToMove, String newParent) throws NodeNotExistsException;
@@ -340,7 +340,7 @@
* @param fqn
* @return map of data, or an empty map
* @throws CacheException
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.ComponentStatus#STARTED}.
*/
Map<K, V> getData(Fqn fqn);
@@ -357,7 +357,7 @@
* A convenience method to retrieving a node and getting keys from the node directly.
*
* @param fqn name of the node
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.ComponentStatus#STARTED}.
*/
Set<K> getKeys(Fqn fqn);
@@ -365,7 +365,7 @@
* Convenience method that takes in a String represenation of the Fqn. Otherwise identical to {@link
* #clearData(Fqn)}.
*
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.ComponentStatus#STARTED}.
*/
void clearData(String fqn);
@@ -375,7 +375,7 @@
* A convenience method to retrieving a node and getting keys from the node directly.
*
* @param fqn name of the node
- * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.CacheStatus#STARTED}.
+ * @throws IllegalStateException if {@link #getCacheStatus()} would not return {@link org.horizon.ComponentStatus#STARTED}.
*/
void clearData(Fqn fqn);
Modified: core/branches/flat/src/main/java/org/horizon/tree/TreeCacheImpl.java
===================================================================
--- core/branches/flat/src/main/java/org/horizon/tree/TreeCacheImpl.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/tree/TreeCacheImpl.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -23,7 +23,7 @@
import org.horizon.Cache;
import org.horizon.CacheException;
-import org.horizon.CacheStatus;
+import org.horizon.ComponentStatus;
import org.horizon.atomic.AtomicMap;
import org.horizon.config.Configuration;
import org.horizon.context.InvocationContext;
@@ -331,7 +331,7 @@
return cache;
}
- public CacheStatus getCacheStatus() {
+ public ComponentStatus getCacheStatus() {
return cache.getCacheStatus();
}
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-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/main/java/org/horizon/util/TestingUtil.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -10,13 +10,14 @@
import org.horizon.Cache;
import org.horizon.CacheDelegate;
import org.horizon.CacheSPI;
-import org.horizon.CacheStatus;
+import org.horizon.ComponentStatus;
import org.horizon.commands.CommandsFactory;
import org.horizon.commands.VisitableCommand;
import org.horizon.factories.ComponentRegistry;
import org.horizon.interceptors.InterceptorChain;
import org.horizon.interceptors.base.CommandInterceptor;
import org.horizon.lock.LockManager;
+import org.horizon.manager.CacheManager;
import org.horizon.tree.TreeCache;
import javax.transaction.TransactionManager;
@@ -364,13 +365,21 @@
}
}
+ public static void killCacheManagers(CacheManager... cacheManagers) {
+ if (cacheManagers != null) {
+ for (CacheManager cm : cacheManagers) {
+ if (cm != null) cm.stop();
+ }
+ }
+ }
+
/**
* Kills a cache - stops it, clears any data in any cache loaders, and rolls back any associated txs
*/
public static void killCaches(Cache... caches) {
for (Cache c : caches) {
try {
- if (c != null && c.getCacheStatus() == CacheStatus.STARTED) {
+ if (c != null && c.getCacheStatus() == ComponentStatus.STARTED) {
CacheSPI spi = (CacheSPI) c;
if (spi.getTransactionManager() != null) {
try {
@@ -429,7 +438,7 @@
*/
public static void killTransactions(Cache... caches) {
for (Cache c : caches) {
- if (c != null && c.getCacheStatus() == CacheStatus.STARTED) {
+ if (c != null && c.getCacheStatus() == ComponentStatus.STARTED) {
CacheSPI ci = (CacheSPI) c;
if (ci.getTransactionManager() != null) {
try {
@@ -507,7 +516,7 @@
* @param cacheStatus status to wait for
* @param timeout timeout to wait for
*/
- public static void blockUntilCacheStatusAchieved(Cache cache, CacheStatus cacheStatus, long timeout) {
+ public static void blockUntilCacheStatusAchieved(Cache cache, ComponentStatus cacheStatus, long timeout) {
CacheSPI spi = (CacheSPI) cache;
long killTime = System.currentTimeMillis() + timeout;
while (System.currentTimeMillis() < killTime) {
Modified: core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/test/java/org/horizon/UnitTestCacheManager.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -8,6 +8,8 @@
import org.horizon.config.Configuration;
/**
+ * Always use this cache manager when writing unit tests. This allows for parallel tests to run.
+ *
* @author dpospisi
*/
public class UnitTestCacheManager {
Modified: core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java
===================================================================
--- core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/test/java/org/horizon/manager/CacheManagerTest.java 2009-01-20 16:51:26 UTC (rev 7537)
@@ -1,8 +1,9 @@
package org.horizon.manager;
import org.horizon.Cache;
-import org.horizon.CacheStatus;
+import org.horizon.ComponentStatus;
import org.horizon.config.Configuration;
+import org.horizon.util.TestingUtil;
import org.testng.annotations.Test;
/**
@@ -12,50 +13,62 @@
@Test(groups = "functional")
public class CacheManagerTest {
public void testDefaultCache() throws CacheNameExistsException {
- DefaultCacheManager cm = new DefaultCacheManager();
+ CacheManager cm = new DefaultCacheManager();
- assert cm.getCache().getCacheStatus() == CacheStatus.STARTED;
- assert cm.getCache().getName().equals(DefaultCacheManager.DEFAULT_CACHE_NAME);
+ try {
+ assert cm.getCache().getCacheStatus() == ComponentStatus.STARTED;
+ assert cm.getCache().getName().equals(DefaultCacheManager.DEFAULT_CACHE_NAME);
- try {
- cm.defineCache(DefaultCacheManager.DEFAULT_CACHE_NAME, new Configuration());
- assert false : "Should fail";
+ try {
+ cm.defineCache(DefaultCacheManager.DEFAULT_CACHE_NAME, new Configuration());
+ assert false : "Should fail";
+ }
+ catch (IllegalArgumentException e) {
+ // ok
+ assert true : "Allowed";
+ }
+ } finally {
+ TestingUtil.killCacheManagers(cm);
}
- catch (IllegalArgumentException e) {
- // ok
- assert true : "Allowed";
- }
}
public void testClashingNames() throws CacheNameExistsException {
- DefaultCacheManager cm = new DefaultCacheManager();
- Configuration c = new Configuration();
+ CacheManager cm = new DefaultCacheManager();
+ try {
+ Configuration c = new Configuration();
- cm.defineCache("aCache", c);
- try {
cm.defineCache("aCache", c);
- assert false : "Should fail";
+ try {
+ cm.defineCache("aCache", c);
+ assert false : "Should fail";
+ }
+ catch (CacheNameExistsException cnee) {
+ // expected
+ assert true : "Expected";
+ }
+ } finally {
+ TestingUtil.killCacheManagers(cm);
}
- catch (CacheNameExistsException cnee) {
- // expected
- assert true : "Expected";
- }
}
public void testStartAndStop() {
DefaultCacheManager cm = new DefaultCacheManager();
- Cache c1 = cm.getCache("cache1");
- Cache c2 = cm.getCache("cache2");
- Cache c3 = cm.getCache("cache3");
+ try {
+ Cache c1 = cm.getCache("cache1");
+ Cache c2 = cm.getCache("cache2");
+ Cache c3 = cm.getCache("cache3");
- assert c1.getCacheStatus() == CacheStatus.STARTED;
- assert c2.getCacheStatus() == CacheStatus.STARTED;
- assert c3.getCacheStatus() == CacheStatus.STARTED;
+ assert c1.getCacheStatus() == ComponentStatus.STARTED;
+ assert c2.getCacheStatus() == ComponentStatus.STARTED;
+ assert c3.getCacheStatus() == ComponentStatus.STARTED;
- cm.stop();
+ cm.stop();
- assert c1.getCacheStatus() == CacheStatus.STOPPED;
- assert c2.getCacheStatus() == CacheStatus.STOPPED;
- assert c3.getCacheStatus() == CacheStatus.STOPPED;
+ assert c1.getCacheStatus() == ComponentStatus.STOPPED;
+ assert c2.getCacheStatus() == ComponentStatus.STOPPED;
+ assert c3.getCacheStatus() == ComponentStatus.STOPPED;
+ } finally {
+ TestingUtil.killCacheManagers(cm);
+ }
}
}
Modified: core/branches/flat/src/test/resources/log4j.xml
===================================================================
--- core/branches/flat/src/test/resources/log4j.xml 2009-01-20 16:12:13 UTC (rev 7536)
+++ core/branches/flat/src/test/resources/log4j.xml 2009-01-20 16:51:26 UTC (rev 7537)
@@ -45,15 +45,15 @@
<!-- ================ -->
<category name="org.horizon">
- <priority value="WARN"/>
+ <priority value="TRACE"/>
</category>
- <category name="org.horizon.profiling">
+ <category name="org.horizon.profiling">
<priority value="WARN"/>
</category>
<category name="org.horizon.factories">
- <priority value="WARN"/>
+ <priority value="TRACE"/>
</category>
<!-- ======================= -->
17 years, 2 months