You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by sg...@apache.org on 2008/07/23 16:05:56 UTC
svn commit: r679090 - in
/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi:
framework/component/ framework/constant/ framework/container/
framework/crypto/ framework/interceptor/ framework/locking/ framework/util/
interceptor/util/ service...
Author: sgoeschl
Date: Wed Jul 23 07:05:55 2008
New Revision: 679090
URL: http://svn.apache.org/viewvc?rev=679090&view=rev
Log:
Removed read/write lock implementation since it was never properly implemented and used.
Removed:
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/AvalonLoggerFacade.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/GenericLock.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/LockException.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/LoggerFacade.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/MultiLevelLock.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/MultiLevelLock2.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/locking/ReadWriteLock.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/util/ReadWriteLock.java
Modified:
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/AvalonServiceComponentImpl.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponentImpl.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonYaafiConstants.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorFactory.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorInvocationHandler.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderImpl.java
turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/AvalonServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/AvalonServiceComponentImpl.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/AvalonServiceComponentImpl.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/AvalonServiceComponentImpl.java Wed Jul 23 07:05:55 2008
@@ -42,7 +42,6 @@
import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorFactory;
import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorService;
import org.apache.fulcrum.yaafi.framework.role.RoleEntry;
-import org.apache.fulcrum.yaafi.framework.util.ReadWriteLock;
import org.apache.fulcrum.yaafi.framework.util.Validate;
/**
@@ -61,12 +60,11 @@
* @param roleEntry The information extracted from the role configuration file
* @param parentLogger the logger of the service container
* @param logger The logger for the service instance
- * @param readWriteLock the read/write lock to synchronize access to services
*/
public AvalonServiceComponentImpl(
- RoleEntry roleEntry, Logger parentLogger, Logger logger, ReadWriteLock readWriteLock )
+ RoleEntry roleEntry, Logger parentLogger, Logger logger)
{
- super( roleEntry, parentLogger, logger, readWriteLock );
+ super( roleEntry, parentLogger, logger );
}
/////////////////////////////////////////////////////////////////////////
@@ -118,23 +116,19 @@
this.getImplementationClazz()
);
- if( (this.getRoleEntry().hasDynamicProxy()) &&
- (isInterceptor == false ) )
+ if( (this.getRoleEntry().hasDynamicProxy()) && (isInterceptor == false ) )
{
if( this.getParentLogger().isDebugEnabled() )
{
this.getParentLogger().debug( "Creating a dynamic proxy for " + this.getShorthand() );
}
- ReadWriteLock readWriteLock = this.getReadWriteLock();
-
Object proxyInstance = AvalonInterceptorFactory.create(
this.getName(),
this.getShorthand(),
this.getServiceManager(),
this.getRoleEntry().getInterceptorList(),
- this.getRawInstance(false),
- readWriteLock
+ this.getRawInstance(false)
);
this.setProxyInstance(proxyInstance);
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponentImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponentImpl.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponentImpl.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/component/ServiceComponentImpl.java Wed Jul 23 07:05:55 2008
@@ -26,7 +26,6 @@
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.fulcrum.yaafi.framework.role.RoleEntry;
-import org.apache.fulcrum.yaafi.framework.util.ReadWriteLock;
import org.apache.fulcrum.yaafi.framework.util.ToStringBuilder;
import org.apache.fulcrum.yaafi.framework.util.Validate;
@@ -70,29 +69,23 @@
/** The Avalon Parameters passed to the service component instance */
private Parameters parameters;
- /** read/write lock to snychronize access to services */
- private ReadWriteLock readWriteLock;
-
/**
* Constructor to parse the configuration.
*
* @param roleEntry The information extracted from the role configuration file
* @param parentLogger the logger of the service container
* @param logger The logger for the service instance
- * @param readWriteLock the read/write lock to synchronize access to services
*/
public ServiceComponentImpl(
- RoleEntry roleEntry, Logger parentLogger, Logger logger, ReadWriteLock readWriteLock )
+ RoleEntry roleEntry, Logger parentLogger, Logger logger)
{
Validate.notNull( roleEntry, "roleEntry" );
Validate.notNull( parentLogger, "parentLogger" );
Validate.notNull( logger, "logger" );
- Validate.notNull( readWriteLock, "readWriteLock" );
this.roleEntry = roleEntry;
this.parentLogger = parentLogger;
this.logger = logger;
- this.readWriteLock = readWriteLock;
}
/////////////////////////////////////////////////////////////////////////
@@ -199,7 +192,6 @@
this.context = null;
this.configuration = null;
this.parameters = null;
- this.readWriteLock = null;
}
/**
@@ -407,12 +399,4 @@
{
this.proxy = proxy;
}
-
- /**
- * @return Returns the readWriteLock.
- */
- protected final ReadWriteLock getReadWriteLock()
- {
- return readWriteLock;
- }
}
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonYaafiConstants.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonYaafiConstants.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonYaafiConstants.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/constant/AvalonYaafiConstants.java Wed Jul 23 07:05:55 2008
@@ -51,13 +51,6 @@
String URN_AVALON_CLASSLOADER = "urn:avalon:classloader";
/////////////////////////////////////////////////////////////////////////
- // YAAFI keys for Context
- /////////////////////////////////////////////////////////////////////////
-
- /** define the Merlin component classloader (ClassLoader) */
- String URN_YAAFI_KERNELLOCK = "urn:yaafi:kernellock";
-
- /////////////////////////////////////////////////////////////////////////
// ECM keys for Context
/////////////////////////////////////////////////////////////////////////
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/container/ServiceContainerImpl.java Wed Jul 23 07:05:55 2008
@@ -51,7 +51,6 @@
import org.apache.fulcrum.yaafi.framework.role.RoleEntry;
import org.apache.fulcrum.yaafi.framework.util.ConfigurationUtil;
import org.apache.fulcrum.yaafi.framework.util.InputStreamLocator;
-import org.apache.fulcrum.yaafi.framework.util.ReadWriteLock;
import org.apache.fulcrum.yaafi.framework.util.StringUtils;
import org.apache.fulcrum.yaafi.framework.util.ToStringBuilder;
import org.apache.fulcrum.yaafi.framework.util.Validate;
@@ -129,7 +128,7 @@
/** The type of container where YAAFI is embedded */
private String containerFlavour;
- /** The ms to wait before triggering a reconfiguration */
+ /** The ms to wait before triggering a reconfiguration of the container os service */
private int reconfigurationDelay;
/** global flag for enabling/disabling dynamic proxies */
@@ -141,9 +140,6 @@
/** The list of ServiceManagers as fallback service lookup */
private ArrayList fallbackServiceManagerList;
- /** Read/Write lock to synchronize acess to services */
- private ReadWriteLock readWriteLock;
-
/** the configuration for running the ComponentConfigurationPropertiesResolver */
private Configuration componentConfigurationPropertiesResolverConfig;
@@ -188,7 +184,6 @@
{
Validate.notNull( logger, "logger" );
this.logger = logger;
- this.readWriteLock = new ReadWriteLock(URN_YAAFI_KERNELLOCK, logger);
}
/**
@@ -484,56 +479,49 @@
*
* @see org.apache.avalon.framework.activity.Disposable#dispose()
*/
- public void dispose()
+ public synchronized void dispose()
{
- Object lock = null;
-
if( this.isDisposed )
{
return;
}
- try
+ if( this.getLogger() != null )
{
- lock = this.getWriteLock();
+ this.getLogger().debug("Disposing all services");
+ }
- if( this.getLogger() != null )
- {
- this.getLogger().debug("Disposing all services");
- }
+ // wait some time so
- // decommision all servcies
+ this.waitForReconfiguration();
- this.decommisionAll( this.getServiceList() );
+ // decommision all servcies
- // dispose all servcies
+ this.decommisionAll( this.getServiceList() );
- this.disposeAll( this.getServiceList() );
+ // dispose all servcies
- // clean up
+ this.disposeAll( this.getServiceList() );
- this.getServiceList().clear();
- this.getServiceMap().clear();
+ // clean up
- this.componentRolesLocation = null;
- this.componentConfigurationLocation = null;
- this.context = null;
- this.parametersLocation = null;
- this.roleConfiguration = null;
- this.serviceConfiguration = null;
- this.parameters = null;
- this.fallbackServiceManagerList = null;
- this.defaultInterceptorServiceList = null;
- this.isDisposed = true;
+ this.getServiceList().clear();
+ this.getServiceMap().clear();
- if( this.getLogger() != null )
- {
- this.getLogger().debug( "All services are disposed" );
- }
- }
- finally
+ this.componentRolesLocation = null;
+ this.componentConfigurationLocation = null;
+ this.context = null;
+ this.parametersLocation = null;
+ this.roleConfiguration = null;
+ this.serviceConfiguration = null;
+ this.parameters = null;
+ this.fallbackServiceManagerList = null;
+ this.defaultInterceptorServiceList = null;
+ this.isDisposed = true;
+
+ if( this.getLogger() != null )
{
- this.releaseLock(lock);
+ this.getLogger().debug( "All services are disposed" );
}
}
@@ -544,70 +532,62 @@
*
* @see org.apache.avalon.framework.configuration.Reconfigurable#reconfigure(org.apache.avalon.framework.configuration.Configuration)
*/
- public void reconfigure(Configuration configuration)
+ public synchronized void reconfigure(Configuration configuration)
throws ConfigurationException
{
Validate.notNull( configuration, "configuration" );
- Object lock = null;
int exceptionCounter = 0;
ServiceComponent serviceComponent = null;
this.getLogger().warn("Reconfiguring all services ...");
- try
- {
- // 1) lock the service container
+ // 1) wait for some time
- lock = this.getWriteLock();
+ this.waitForReconfiguration();
- // 2) store the new configuration
+ // 2) store the new configuration
- this.serviceConfiguration = configuration;
+ this.serviceConfiguration = configuration;
- Properties componentConfigurationProperties = this.loadComponentConfigurationProperties();
+ Properties componentConfigurationProperties = this.loadComponentConfigurationProperties();
- ConfigurationUtil.expand(
- this.getLogger(),
- (DefaultConfiguration) this.serviceConfiguration,
- componentConfigurationProperties
- );
+ ConfigurationUtil.expand(
+ this.getLogger(),
+ (DefaultConfiguration) this.serviceConfiguration,
+ componentConfigurationProperties
+ );
- // 3) reconfigure the services
+ // 3) reconfigure the services
- for( int i=0; i<this.getServiceList().size(); i++ )
- {
- serviceComponent = (ServiceComponent) this.getServiceList().get(i);
+ for( int i=0; i<this.getServiceList().size(); i++ )
+ {
+ serviceComponent = (ServiceComponent) this.getServiceList().get(i);
- Configuration serviceComponentConfiguraton = this.getServiceConfiguration().getChild(
- serviceComponent.getShorthand()
- );
+ Configuration serviceComponentConfiguraton = this.getServiceConfiguration().getChild(
+ serviceComponent.getShorthand()
+ );
- try
- {
- serviceComponent.setConfiguration(serviceComponentConfiguraton);
- serviceComponent.reconfigure();
- }
- catch(Throwable t)
- {
- String msg = "Reconfiguring of " + serviceComponent.getShorthand() + " failed";
- this.getLogger().error(msg);
- exceptionCounter++;
- }
- }
-
- // 4) check the result
-
- if( exceptionCounter > 0 )
- {
- String msg = "The reconfiguration failed with " + exceptionCounter + " exception(s)";
- this.getLogger().error(msg);
- throw new ConfigurationException(msg);
- }
+ try
+ {
+ serviceComponent.setConfiguration(serviceComponentConfiguraton);
+ serviceComponent.reconfigure();
+ }
+ catch(Throwable t)
+ {
+ String msg = "Reconfiguring of " + serviceComponent.getShorthand() + " failed";
+ this.getLogger().error(msg);
+ exceptionCounter++;
+ }
}
- finally
+
+ // 4) check the result
+
+ if( exceptionCounter > 0 )
{
- this.releaseLock(lock);
+ String msg = "The reconfiguration failed with " + exceptionCounter + " exception(s)";
+ this.getLogger().error(msg);
+ throw new ConfigurationException(msg);
}
}
@@ -618,82 +598,50 @@
/**
* @see org.apache.fulcrum.yaafi.framework.container.ServiceLifecycleManager#getRoleEntry(java.lang.String)
*/
- public RoleEntry getRoleEntry(String name)
+ public synchronized RoleEntry getRoleEntry(String name)
throws ServiceException
{
- Object lock = null;
-
- try
- {
- lock = this.getReadLock();
- return this.getServiceComponentEx(name).getRoleEntry();
- }
- finally
- {
- this.releaseLock(lock);
- }
+ return this.getServiceComponentEx(name).getRoleEntry();
}
/**
* @see org.apache.fulcrum.yaafi.framework.container.ServiceLifecycleManager#getRoleEntries()
*/
- public RoleEntry[] getRoleEntries()
+ public synchronized RoleEntry[] getRoleEntries()
{
- Object lock = null;
-
- try
- {
- lock = this.getReadLock();
-
- List serviceList = this.getServiceList();
- ServiceComponent serviceComponent = null;
- RoleEntry[] result = new RoleEntry[serviceList.size()];
-
- for( int i=0; i<result.length; i++ )
- {
- serviceComponent = (ServiceComponent) serviceList.get(i);
- result[i] = serviceComponent.getRoleEntry();
- }
+ List serviceList = this.getServiceList();
+ ServiceComponent serviceComponent = null;
+ RoleEntry[] result = new RoleEntry[serviceList.size()];
- return result;
- }
- finally
+ for( int i=0; i<result.length; i++ )
{
- this.releaseLock(lock);
+ serviceComponent = (ServiceComponent) serviceList.get(i);
+ result[i] = serviceComponent.getRoleEntry();
}
+
+ return result;
}
/**
* @see org.apache.fulcrum.yaafi.framework.container.ServiceLifecycleManager#reconfigure(java.lang.String[])
*/
- public void reconfigure(String[] names) throws ServiceException,
+ public synchronized void reconfigure(String[] names) throws ServiceException,
ConfigurationException
{
Validate.notNull(names,"names");
Validate.noNullElements(names,"names");
+
+ this.waitForReconfiguration();
- Object lock = null;
-
- try
+ for( int i=0; i<names.length; i++ )
{
- // get exclusive access
-
- lock = this.getWriteLock();
+ // ensure that the service exists since during our reconfiguration
+ // we might use a stle recofniguration entry
- for( int i=0; i<names.length; i++ )
- {
- // ensure that the service exists since during our reconfiguration
- // we might use a stle recofniguration entry
-
- if( this.getServiceMap().get(names[i]) != null )
- {
- this.reconfigure(names[i]);
- }
- }
- }
- finally
- {
- this.release(lock);
+ if( this.getServiceMap().get(names[i]) != null )
+ {
+ this.reconfigure(names[i]);
+ }
}
}
@@ -705,25 +653,24 @@
Validate.notEmpty( name, "name" );
boolean result = false;
- Object lock = null;
- ServiceComponent serviceComponent = null;
-
- // look at our available service
- try
- {
- lock = this.getReadLock();
- serviceComponent = this.getLocalServiceComponent(name);
- result = ( serviceComponent != null ? true : false );
- }
- finally
+ synchronized(this)
{
- this.releaseLock(lock);
+ // look at our available service
+
+ result = (this.getLocalServiceComponent(name) != null);
+
+ // look at fallback service managers
+
+ if(!result)
+ {
+ result = this.hasFallbackService(name);
+ }
}
// if we haven't found anything ask the parent ServiceManager
- if( ( result == false ) && ( this.hasParentServiceManager() ) )
+ if( (!result) && ( this.hasParentServiceManager() ) )
{
result = this.getParentServiceManager().hasService(name);
}
@@ -746,58 +693,41 @@
{
Validate.notEmpty( name, "name" );
- Object lock = null;
Object result = null;
ServiceComponent serviceManagerComponent = null;
- // look at our available service
-
try
{
- lock = this.getReadLock();
-
- // check our local services
-
- serviceManagerComponent = this.getLocalServiceComponent(name);
-
- if( serviceManagerComponent != null )
+ synchronized (this)
{
- result = serviceManagerComponent.getInstance();
+ // 1) check our local services
- if((result != null) && this.getLogger().isDebugEnabled())
- {
- String msg = "Located the service '" + name + "' in the local container";
- this.getLogger().debug(msg);
- }
- }
+ serviceManagerComponent = this.getLocalServiceComponent(name);
- // look at fallback service managers
-
- if(result == null)
- {
- for(int i=0; i<this.fallbackServiceManagerList.size(); i++)
+ if( serviceManagerComponent != null )
{
- String serviceManagerComponentName = (String) fallbackServiceManagerList.get(i);
- serviceManagerComponent = this.getLocalServiceComponent(serviceManagerComponentName);
+ result = serviceManagerComponent.getInstance();
- if(serviceManagerComponent != null)
+ if((result != null) && this.getLogger().isDebugEnabled())
{
- ServiceManager currServiceManager = (ServiceManager) serviceManagerComponent.getInstance();
-
- if (currServiceManager.hasService(name))
- {
- result = currServiceManager.lookup(name);
-
- if((result != null) && this.getLogger().isDebugEnabled())
- {
- String msg = "Located the service '" + name + "' using the fallback service manager '" + serviceManagerComponentName + "'";
- this.getLogger().debug(msg);
- }
- }
+ String msg = "Located the service '" + name + "' in the local container";
+ this.getLogger().debug(msg);
}
}
- }
+ // 2) look at fallback service managers
+
+ if(result == null)
+ {
+ result = this.getFallbackService(name);
+ }
+ }
+ }
+ catch(ServiceException e)
+ {
+ String msg = "Failed to lookup a service " + name;
+ this.getLogger().error( msg, e );
+ throw e;
}
catch( Throwable t )
{
@@ -805,24 +735,17 @@
this.getLogger().error( msg, t );
throw new ServiceException( name, msg, t );
}
- finally
- {
- this.releaseLock(lock);
- }
- // if we haven't found anything ask the parent ServiceManager
+ // 3) if we haven't found anything ask the parent ServiceManager
- if( result == null )
+ if( (result == null) && this.hasParentServiceManager() )
{
- if( this.hasParentServiceManager() )
- {
- result = this.getParentServiceManager().lookup(name);
+ result = this.getParentServiceManager().lookup(name);
- if((result != null) && this.getLogger().isDebugEnabled())
- {
- String msg = "Located the service '" + name + "' using the parent service manager";
- this.getLogger().debug(msg);
- }
+ if((result != null) && this.getLogger().isDebugEnabled())
+ {
+ String msg = "Located the service '" + name + "' using the parent service manager";
+ this.getLogger().debug(msg);
}
}
@@ -850,20 +773,11 @@
/**
* @see org.apache.fulcrum.yaafi.framework.container.ServiceContainer#decommision(java.lang.String)
*/
- public void decommision(String name) throws ServiceException
+ public synchronized void decommision(String name) throws ServiceException
{
- Object lock = null;
-
- try
- {
- lock = this.getWriteLock();
- ServiceComponent serviceComponent = this.getServiceComponentEx(name);
- this.decommision(serviceComponent);
- }
- finally
- {
- this.releaseLock(lock);
- }
+ this.waitForReconfiguration();
+ ServiceComponent serviceComponent = this.getServiceComponentEx(name);
+ this.decommision(serviceComponent);
}
/**
@@ -871,19 +785,13 @@
*/
public Parameters getParameters()
{
- Object lock = null;
-
- try
- {
- lock = this.getReadLock();
- return this.parameters;
- }
- finally
- {
- this.releaseLock(lock);
- }
+ return this.parameters;
}
+ /////////////////////////////////////////////////////////////////////////
+ // Service Implementation
+ /////////////////////////////////////////////////////////////////////////
+
/**
* @see java.lang.Object#toString()
*/
@@ -907,10 +815,6 @@
return toStringBuilder.toString();
}
- /////////////////////////////////////////////////////////////////////////
- // Service Implementation
- /////////////////////////////////////////////////////////////////////////
-
/**
* Create a role configuration parser based on the container flavour.
* @return the role configuration parser
@@ -979,7 +883,7 @@
}
/**
- * Try to get a local service component
+ * Try to get a local service component.
*
* @param name the name of the service component
* @return the service component if any
@@ -992,6 +896,88 @@
}
/**
+ * Try to get a service component provided by a fallback service
+ * manager.
+ *
+ * @param name the name of the service component
+ * @return the service component if any
+ * @throws Exception getting the service failed
+ */
+ private Object getFallbackService(String name) throws Exception
+ {
+
+ Validate.notEmpty( name, "name" );
+
+ Object result = null;
+ ServiceComponent serviceManagerComponent = null;
+
+ for(int i=0; i<this.fallbackServiceManagerList.size(); i++)
+ {
+ String serviceManagerComponentName = (String) fallbackServiceManagerList.get(i);
+ serviceManagerComponent = this.getLocalServiceComponent(serviceManagerComponentName);
+
+ if(serviceManagerComponent != null)
+ {
+ ServiceManager currServiceManager = (ServiceManager) serviceManagerComponent.getInstance();
+
+ if (currServiceManager.hasService(name))
+ {
+ result = currServiceManager.lookup(name);
+
+ if((result != null) && this.getLogger().isDebugEnabled())
+ {
+ String msg = "Located the service '" + name + "' using the fallback service manager '" + serviceManagerComponentName + "'";
+ this.getLogger().debug(msg);
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Try to get a service provided by a fallback service manager.
+ *
+ * @param name the name of the service component
+ * @return the service component if any
+ */
+ private boolean hasFallbackService(String name)
+ {
+ Validate.notEmpty( name, "name" );
+
+ ServiceComponent serviceManagerComponent = null;
+
+ for(int i=0; i<this.fallbackServiceManagerList.size(); i++)
+ {
+ String serviceManagerComponentName = (String) fallbackServiceManagerList.get(i);
+ serviceManagerComponent = this.getLocalServiceComponent(serviceManagerComponentName);
+
+ if(serviceManagerComponent != null)
+ {
+ ServiceManager currServiceManager;
+
+ try
+ {
+ currServiceManager = (ServiceManager) serviceManagerComponent.getInstance();
+ if (currServiceManager.hasService(name))
+ {
+ return true;
+ }
+ }
+ catch (Exception e)
+ {
+ String msg = "Unable to invoke fallback service manager '" + serviceManagerComponentName + "'";
+ this.getLogger().error(msg, e);
+ throw new RuntimeException(msg);
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
* @param string The location of the component configuration file
*/
private void setComponentConfigurationLocation(String string)
@@ -1089,13 +1075,6 @@
componentFlavour
);
- // add the read/write lock to the context
-
- serviceComponentContext.put(
- URN_YAAFI_KERNELLOCK,
- this.readWriteLock
- );
-
// create the remaining Avalon artifacts for the service component
Logger serviceComponentLogger = this.getLogger().getChildLogger(
@@ -1259,8 +1238,7 @@
// create an appropriate instance of role configuration parser
- RoleConfigurationParser roleConfigurationParser =
- this.createRoleConfigurationParser();
+ RoleConfigurationParser roleConfigurationParser = this.createRoleConfigurationParser();
// extract the role entries
@@ -1292,15 +1270,15 @@
serviceComponent = new AvalonServiceComponentImpl(
roleEntry,
this.getLogger(),
- logger,
- this.readWriteLock
+ logger
);
result.add( serviceComponent );
}
catch( Throwable t )
{
- String msg = "Failed to load the service " + serviceComponent.getName();
+ String serviceComponentName = ( serviceComponent != null ? serviceComponent.getName() : "unknown" );
+ String msg = "Failed to load the service " + serviceComponentName;
this.getLogger().error( msg, t );
throw new ConfigurationException( msg, t );
}
@@ -1412,7 +1390,9 @@
/**
* Creates a locator to find a resource either in the file system or in
- * the classpath
+ * the classpath.
+ *
+ * @return the locator
*/
private InputStreamLocator createInputStreamLocator()
{
@@ -1424,7 +1404,7 @@
*
* @param dir The applicationRootDir to set.
*/
- private File setApplicationRootDir(File dir)
+ private void setApplicationRootDir(File dir)
{
this.getLogger().debug( "Setting applicationRootDir to " + dir.getAbsolutePath() );
@@ -1432,7 +1412,6 @@
Validate.isTrue(dir.exists(),"applicationRootDir does not exist");
this.applicationRootDir = dir;
- return this.applicationRootDir;
}
/**
@@ -1456,14 +1435,14 @@
*/
private boolean hasParentServiceManager()
{
- return (this.getParentServiceManager() != null ? true : false );
+ return (this.getParentServiceManager() != null);
}
/**
* Set the temporary directory of the container.
*
* @param dir The tempRootDir to set.
*/
- private File setTempRootDir(File dir)
+ private void setTempRootDir(File dir)
{
this.getLogger().debug( "Setting tempRootDir to " + dir.getAbsolutePath() );
@@ -1472,7 +1451,6 @@
Validate.isTrue(dir.canWrite(),"tempRootDir is not writeable");
this.tempRootDir = dir;
- return this.tempRootDir;
}
/**
@@ -1603,66 +1581,26 @@
}
/**
- * @return a read lock
+ * @return the containers class loader
*/
- private Object getReadLock()
+ private ClassLoader getClassLoader()
{
- try
- {
- return this.readWriteLock.getReadLock(AVALON_CONTAINER_YAAFI);
- }
- catch (InterruptedException e)
- {
- String msg = "Interrupted while getting read lock";
- throw new RuntimeException(msg);
- }
+ return this.getClass().getClassLoader();
}
/**
- * @return a write lock
+ * Wait for the time configured as 'reconfigurationDelay' before
+ * reconfiguring the container or services.
*/
- private Object getWriteLock()
+ private void waitForReconfiguration()
{
- Object result = null;
-
try
{
- result = this.readWriteLock.getWriteLock(AVALON_CONTAINER_YAAFI);
-
- // wait for a certain time to get non-proxied services
- // either finished or blocked
-
- try
- {
- Thread.sleep( this.reconfigurationDelay );
- }
- catch (InterruptedException e)
- {
- // nothing to do
- }
-
- return result;
+ Thread.sleep(this.reconfigurationDelay);
}
- catch (InterruptedException e)
+ catch(InterruptedException e)
{
- String msg = "Interrupted while getting read lock";
- throw new RuntimeException(msg);
+ // nothing to do
}
}
-
- /**
- * Release the read/write lock.
- */
- private void releaseLock(Object lock)
- {
- this.readWriteLock.releaseLock(lock, AVALON_CONTAINER_YAAFI);
- }
-
- /**
- * @return the containers class loader
- */
- private ClassLoader getClassLoader()
- {
- return this.getClass().getClassLoader();
- }
}
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/crypto/CryptoStreamFactory.java Wed Jul 23 07:05:55 2008
@@ -22,9 +22,6 @@
import org.apache.fulcrum.yaafi.framework.reflection.Clazz;
import java.io.InputStream;
-import java.io.IOException;
-import java.security.GeneralSecurityException;
-import java.lang.reflect.InvocationTargetException;
/**
* Factory class to get a decrypting input stream for reading configuration
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorFactory.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorFactory.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorFactory.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorFactory.java Wed Jul 23 07:05:55 2008
@@ -27,7 +27,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.fulcrum.yaafi.framework.constant.AvalonYaafiConstants;
import org.apache.fulcrum.yaafi.framework.reflection.Clazz;
-import org.apache.fulcrum.yaafi.framework.util.ReadWriteLock;
import org.apache.fulcrum.yaafi.framework.util.Validate;
@@ -47,7 +46,6 @@
* @param serviceManager the corresponding service manager
* @param serviceInterceptorList the list of interceptors to be installed
* @param serviceDelegate the service implementation
- * @param readWriteLock the YAAFI kernel lock
* @return a dynamic proxy
* @throws ServiceException an interceptor was not found
*/
@@ -56,8 +54,7 @@
String serviceShorthand,
ServiceManager serviceManager,
String[] serviceInterceptorList,
- Object serviceDelegate,
- ReadWriteLock readWriteLock )
+ Object serviceDelegate )
throws ServiceException
{
Validate.notEmpty(serviceName,"serviceName");
@@ -65,7 +62,6 @@
Validate.notNull(serviceManager,"serviceManager");
Validate.notNull(serviceInterceptorList,"serviceInterceptorList");
Validate.notNull(serviceDelegate,"serviceDelegate");
- Validate.notNull(readWriteLock,"readWriteLock");
Object result = null;
@@ -84,8 +80,7 @@
serviceName,
serviceShorthand,
serviceDelegate,
- avalonInterceptorServices,
- readWriteLock
+ avalonInterceptorServices
);
result = Proxy.newProxyInstance(
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorInvocationHandler.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorInvocationHandler.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorInvocationHandler.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/framework/interceptor/AvalonInterceptorInvocationHandler.java Wed Jul 23 07:05:55 2008
@@ -23,8 +23,8 @@
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
-import org.apache.fulcrum.yaafi.framework.util.ReadWriteLock;
import org.apache.fulcrum.yaafi.framework.util.Validate;
+import org.apache.fulcrum.yaafi.framework.util.ToStringBuilder;
/**
* The InvocationHandler invoked when a service call is routed through
@@ -47,9 +47,6 @@
/** the list of interceptors to be invoked */
private AvalonInterceptorService [] serviceInterceptorList;
- /** read/write lock to snychronize access to services */
- private ReadWriteLock readWriteLock;
-
/** counts the current transactions */
private static volatile long transactionCounter = 0L;
@@ -63,26 +60,22 @@
* @param serviceShorthand the shorthand of the service being intercepted
* @param serviceDelegate the real service implementation
* @param serviceInterceptorList the list of interceptors to be invoked
- * @param readWriteLock the YAAFI kernel lock
*/
public AvalonInterceptorInvocationHandler(
String serviceName,
String serviceShorthand,
Object serviceDelegate,
- AvalonInterceptorService [] serviceInterceptorList,
- ReadWriteLock readWriteLock )
+ AvalonInterceptorService [] serviceInterceptorList )
{
Validate.notEmpty(serviceName,"serviceName");
Validate.notEmpty(serviceShorthand,"serviceShorthand");
Validate.notNull(serviceDelegate,"serviceDelegate");
Validate.notNull(serviceInterceptorList,"serviceInterceptorList");
- Validate.notNull(readWriteLock,"readWriteLock");
this.serviceName = serviceName;
this.serviceShorthand = serviceShorthand;
this.serviceDelegate = serviceDelegate;
this.serviceInterceptorList = serviceInterceptorList;
- this.readWriteLock = readWriteLock;
}
/**
@@ -130,7 +123,14 @@
*/
public String toString()
{
- return super.toString();
+ ToStringBuilder toStringBuilder = new ToStringBuilder(this);
+
+ toStringBuilder.append("serviceShorthand",this.serviceShorthand);
+ toStringBuilder.append("serviceName",this.serviceName);
+ toStringBuilder.append("serviceDelegate",this.serviceDelegate);
+ toStringBuilder.append("transactionId",this.transactionId);
+
+ return toStringBuilder.toString();
}
/**
@@ -140,7 +140,6 @@
throws Throwable
{
Object result = null;
- Object lock = null;
// create the interceptor context for current method call
@@ -159,7 +158,6 @@
try
{
context.incrementInvocationDepth();
- lock = this.getReadWriteLock().getReadLock(this.serviceName);
this.onEntry(context);
result = method.invoke( this.getServiceDelegate(), args );
this.onExit(context,result);
@@ -170,16 +168,8 @@
this.onError(context,e.getTargetException());
throw e.getTargetException();
}
- catch (Throwable t)
- {
- throw t;
- }
finally
{
- // return the read lock
-
- this.getReadWriteLock().releaseLock(lock,this.serviceName);
-
// decrement the service invocation depth
context.decrementInvocationDepth();
@@ -235,14 +225,6 @@
}
/**
- * @return Returns the readWriteLock.
- */
- private final ReadWriteLock getReadWriteLock()
- {
- return readWriteLock;
- }
-
- /**
* Creates a transaction id using the thread local storage
* @param context current interceptor context
* @return was a new transaction started
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderImpl.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderImpl.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/interceptor/util/ArgumentToStringBuilderImpl.java Wed Jul 23 07:05:55 2008
@@ -99,7 +99,7 @@
public ArgumentToStringBuilderImpl(Object target, int maxArgLength)
{
this(target,
- MAX_LINE_LENGTH,
+ maxArgLength,
ArgumentToStringBuilderImpl.defaultMode
);
}
Modified: turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java?rev=679090&r1=679089&r2=679090&view=diff
==============================================================================
--- turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java (original)
+++ turbine/fulcrum/trunk/yaafi/src/java/org/apache/fulcrum/yaafi/service/advice/AdviceServiceImpl.java Wed Jul 23 07:05:55 2008
@@ -32,10 +32,8 @@
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-import org.apache.fulcrum.yaafi.framework.constant.AvalonYaafiConstants;
import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorFactory;
import org.apache.fulcrum.yaafi.framework.interceptor.AvalonInterceptorInvocationHandler;
-import org.apache.fulcrum.yaafi.framework.util.ReadWriteLock;
import org.apache.fulcrum.yaafi.framework.util.Validate;
/**
@@ -53,9 +51,6 @@
/** the service manager supplied by the Avalon framework */
private ServiceManager serviceManager;
- /** the YAAFI kernel lock */
- private ReadWriteLock readWriteLock;
-
/** the list of default interceptors */
private String[] defaultInterceptorList;
@@ -76,7 +71,7 @@
*/
public void contextualize(Context context) throws ContextException
{
- this.readWriteLock = (ReadWriteLock) context.get(AvalonYaafiConstants.URN_YAAFI_KERNELLOCK);
+ // nothing to do
}
/**
@@ -152,15 +147,7 @@
if ((object != null ) && Proxy.isProxyClass(object.getClass()))
{
invocationHandler = Proxy.getInvocationHandler(object);
-
- if (invocationHandler instanceof AvalonInterceptorInvocationHandler)
- {
- return true;
- }
- else
- {
- return false;
- }
+ return invocationHandler instanceof AvalonInterceptorInvocationHandler;
}
return false;
@@ -222,8 +209,7 @@
name,
this.getServiceManager(),
interceptorList,
- object,
- this.getReadWriteLock()
+ object
);
}
catch (ServiceException e)
@@ -237,14 +223,6 @@
}
/**
- * @return Returns the readWriteLock.
- */
- private ReadWriteLock getReadWriteLock()
- {
- return readWriteLock;
- }
-
- /**
* @return Returns the serviceManager.
*/
private ServiceManager getServiceManager()