You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/05/06 23:52:40 UTC
svn commit: r653936 [2/6] - in /tapestry/tapestry5/trunk/tapestry-ioc/src:
main/java/org/apache/tapestry/ioc/
main/java/org/apache/tapestry/ioc/internal/
main/java/org/apache/tapestry/ioc/internal/services/
main/java/org/apache/tapestry/ioc/internal/ut...
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryImpl.java Tue May 6 14:52:36 2008
@@ -62,53 +62,53 @@
static final String LOGGER_SOURCE_SERVICE_ID = "LoggerSource";
- private final OneShotLock _lock = new OneShotLock();
+ private final OneShotLock lock = new OneShotLock();
- private final OneShotLock _eagerLoadLock = new OneShotLock();
+ private final OneShotLock eagerLoadLock = new OneShotLock();
- private final Map<String, Object> _builtinServices = newCaseInsensitiveMap();
+ private final Map<String, Object> builtinServices = newCaseInsensitiveMap();
- private final Map<String, Class> _builtinTypes = newCaseInsensitiveMap();
+ private final Map<String, Class> builtinTypes = newCaseInsensitiveMap();
- private final RegistryShutdownHubImpl _registryShutdownHub;
+ private final RegistryShutdownHubImpl registryShutdownHub;
- private final LoggerSource _loggerSource;
+ private final LoggerSource loggerSource;
/**
* Map from service id to the Module that contains the service.
*/
- private final Map<String, Module> _serviceIdToModule = newCaseInsensitiveMap();
+ private final Map<String, Module> serviceIdToModule = newCaseInsensitiveMap();
- private final Map<String, ServiceLifecycle> _lifecycles = newCaseInsensitiveMap();
+ private final Map<String, ServiceLifecycle> lifecycles = newCaseInsensitiveMap();
- private final PerthreadManager _perthreadManager;
+ private final PerthreadManager perthreadManager;
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
- private final ServiceActivityTracker _tracker;
+ private final ServiceActivityTracker tracker;
- private SymbolSource _symbolSource;
+ private SymbolSource symbolSource;
- private final List<Module> _modules = newList();
+ private final List<Module> modules = newList();
/**
* From marker type to a list of marked service instances.
*/
- private final Map<Class, List<ServiceDef>> _markerToServiceDef = newMap();
+ private final Map<Class, List<ServiceDef>> markerToServiceDef = newMap();
public static final class OrderedConfigurationToOrdererAdaptor<T> implements OrderedConfiguration<T>
{
- private final Orderer<T> _orderer;
+ private final Orderer<T> orderer;
public OrderedConfigurationToOrdererAdaptor(Orderer<T> orderer)
{
- _orderer = orderer;
+ this.orderer = orderer;
}
public void add(String id, T object, String... constraints)
{
- _orderer.add(id, object, constraints);
+ orderer.add(id, object, constraints);
}
}
@@ -121,35 +121,35 @@
*/
public RegistryImpl(Collection<ModuleDef> moduleDefs, ClassFactory classFactory, LoggerSource loggerSource)
{
- _loggerSource = loggerSource;
+ this.loggerSource = loggerSource;
final ServiceActivityTrackerImpl scoreboardAndTracker = new ServiceActivityTrackerImpl();
- _tracker = scoreboardAndTracker;
+ tracker = scoreboardAndTracker;
addBuiltin(SERVICE_ACTIVITY_SCOREBOARD_SERVICE_ID, ServiceActivityScoreboard.class, scoreboardAndTracker);
- addBuiltin(LOGGER_SOURCE_SERVICE_ID, LoggerSource.class, _loggerSource);
+ addBuiltin(LOGGER_SOURCE_SERVICE_ID, LoggerSource.class, this.loggerSource);
- _classFactory = classFactory;
+ this.classFactory = classFactory;
- addBuiltin(CLASS_FACTORY_SERVICE_ID, ClassFactory.class, _classFactory);
+ addBuiltin(CLASS_FACTORY_SERVICE_ID, ClassFactory.class, this.classFactory);
Logger logger = loggerForBuiltinService(PERTHREAD_MANAGER_SERVICE_ID);
- _perthreadManager = new PerthreadManagerImpl(logger);
+ perthreadManager = new PerthreadManagerImpl(logger);
- addBuiltin(PERTHREAD_MANAGER_SERVICE_ID, PerthreadManager.class, _perthreadManager);
+ addBuiltin(PERTHREAD_MANAGER_SERVICE_ID, PerthreadManager.class, perthreadManager);
logger = loggerForBuiltinService(REGISTRY_SHUTDOWN_HUB_SERVICE_ID);
- _registryShutdownHub = new RegistryShutdownHubImpl(logger);
+ registryShutdownHub = new RegistryShutdownHubImpl(logger);
- addBuiltin(REGISTRY_SHUTDOWN_HUB_SERVICE_ID, RegistryShutdownHub.class, _registryShutdownHub);
+ addBuiltin(REGISTRY_SHUTDOWN_HUB_SERVICE_ID, RegistryShutdownHub.class, registryShutdownHub);
- _lifecycles.put("singleton", new SingletonServiceLifecycle());
+ lifecycles.put("singleton", new SingletonServiceLifecycle());
- _registryShutdownHub.addRegistryShutdownListener(new RegistryShutdownListener()
+ registryShutdownHub.addRegistryShutdownListener(new RegistryShutdownListener()
{
public void registryDidShutdown()
{
@@ -159,28 +159,28 @@
for (ModuleDef def : moduleDefs)
{
- logger = _loggerSource.getLogger(def.getLoggerName());
+ logger = this.loggerSource.getLogger(def.getLoggerName());
- Module module = new ModuleImpl(this, _tracker, def, classFactory, logger);
+ Module module = new ModuleImpl(this, tracker, def, classFactory, logger);
- _modules.add(module);
+ modules.add(module);
for (String serviceId : def.getServiceIds())
{
ServiceDef serviceDef = module.getServiceDef(serviceId);
- Module existing = _serviceIdToModule.get(serviceId);
+ Module existing = serviceIdToModule.get(serviceId);
if (existing != null) throw new RuntimeException(IOCMessages.serviceIdConflict(serviceId, existing
.getServiceDef(serviceId), serviceDef));
- _serviceIdToModule.put(serviceId, module);
+ serviceIdToModule.put(serviceId, module);
// The service is defined but will not have gone further than that.
- _tracker.define(serviceDef, Status.DEFINED);
+ tracker.define(serviceDef, Status.DEFINED);
for (Class marker : serviceDef.getMarkers())
- InternalUtils.addToMapList(_markerToServiceDef, marker, serviceDef);
+ InternalUtils.addToMapList(markerToServiceDef, marker, serviceDef);
}
}
@@ -197,11 +197,11 @@
*/
public void performRegistryStartup()
{
- _eagerLoadLock.lock();
+ eagerLoadLock.lock();
List<EagerLoadServiceProxy> proxies = CollectionFactory.newList();
- for (Module m : _modules)
+ for (Module m : modules)
m.collectEagerLoadServices(proxies);
// TAPESTRY-2267: Gather up all the proxies before instantiating any of them.
@@ -216,22 +216,22 @@
public Logger getServiceLogger(String serviceId)
{
- Module module = _serviceIdToModule.get(serviceId);
+ Module module = serviceIdToModule.get(serviceId);
assert module != null;
- return _loggerSource.getLogger(module.getLoggerName() + "." + serviceId);
+ return loggerSource.getLogger(module.getLoggerName() + "." + serviceId);
}
private Logger loggerForBuiltinService(String serviceId)
{
- return _loggerSource.getLogger(TapestryIOCModule.class + "." + serviceId);
+ return loggerSource.getLogger(TapestryIOCModule.class + "." + serviceId);
}
private <T> void addBuiltin(final String serviceId, final Class<T> serviceInterface, T service)
{
- _builtinTypes.put(serviceId, serviceInterface);
- _builtinServices.put(serviceId, service);
+ builtinTypes.put(serviceId, serviceInterface);
+ builtinServices.put(serviceId, service);
// Make sure each of the builtin services is also available via the Builtin annotation
// marker.
@@ -270,23 +270,23 @@
};
for (Class marker : serviceDef.getMarkers())
- InternalUtils.addToMapList(_markerToServiceDef, marker, serviceDef);
+ InternalUtils.addToMapList(markerToServiceDef, marker, serviceDef);
- _tracker.define(serviceDef, Status.BUILTIN);
+ tracker.define(serviceDef, Status.BUILTIN);
}
public synchronized void shutdown()
{
- _lock.lock();
+ lock.lock();
- _registryShutdownHub.fireRegistryDidShutdown();
+ registryShutdownHub.fireRegistryDidShutdown();
SerializationSupport.clearProvider(this);
}
public <T> T getService(String serviceId, Class<T> serviceInterface)
{
- _lock.check();
+ lock.check();
T result = checkForBuiltinService(serviceId, serviceInterface);
if (result != null) return result;
@@ -301,7 +301,7 @@
private <T> T checkForBuiltinService(String serviceId, Class<T> serviceInterface)
{
- Object service = _builtinServices.get(serviceId);
+ Object service = builtinServices.get(serviceId);
if (service == null) return null;
@@ -311,23 +311,23 @@
}
catch (ClassCastException ex)
{
- throw new RuntimeException(IOCMessages.serviceWrongInterface(serviceId, _builtinTypes
+ throw new RuntimeException(IOCMessages.serviceWrongInterface(serviceId, builtinTypes
.get(serviceId), serviceInterface));
}
}
public void cleanupThread()
{
- _lock.check();
+ lock.check();
- _perthreadManager.cleanup();
+ perthreadManager.cleanup();
}
private Module locateModuleForService(String serviceId)
{
- Module module = _serviceIdToModule.get(serviceId);
+ Module module = serviceIdToModule.get(serviceId);
- if (module == null) throw new RuntimeException(IOCMessages.noSuchService(serviceId, _serviceIdToModule
+ if (module == null) throw new RuntimeException(IOCMessages.noSuchService(serviceId, serviceIdToModule
.keySet()));
return module;
@@ -335,7 +335,7 @@
public <T> Collection<T> getUnorderedConfiguration(ServiceDef serviceDef, Class<T> objectType)
{
- _lock.check();
+ lock.check();
final Collection<T> result = newList();
@@ -347,7 +347,7 @@
}
};
- Collection<Module> modules = _modules;
+ Collection<Module> modules = this.modules;
for (Module m : modules)
addToUnorderedConfiguration(configuration, objectType, serviceDef, m);
@@ -358,7 +358,7 @@
@SuppressWarnings("unchecked")
public <T> List<T> getOrderedConfiguration(ServiceDef serviceDef, Class<T> objectType)
{
- _lock.check();
+ lock.check();
String serviceId = serviceDef.getServiceId();
Logger logger = getServiceLogger(serviceId);
@@ -367,7 +367,7 @@
OrderedConfiguration<T> configuration = new OrderedConfigurationToOrdererAdaptor<T>(orderer);
- Collection<Module> modules = _modules;
+ Collection<Module> modules = this.modules;
for (Module m : modules)
addToOrderedConfiguration(configuration, objectType, serviceDef, m);
@@ -393,7 +393,7 @@
public <K, V> Map<K, V> getMappedConfiguration(ServiceDef serviceDef, Class<K> keyType, Class<V> objectType)
{
- _lock.check();
+ lock.check();
// When the key type is String, then a case insensitive map is used for both cases.
@@ -408,7 +408,7 @@
}
};
- Collection<Module> modules = _modules;
+ Collection<Module> modules = this.modules;
for (Module m : modules)
addToMappedConfiguration(configuration, keyToContribution, keyType, objectType, serviceDef, m);
@@ -442,7 +442,7 @@
boolean debug = logger.isDebugEnabled();
- ObjectLocator locator = new ServiceResourcesImpl(this, module, serviceDef, _classFactory, logger);
+ ObjectLocator locator = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
for (ContributionDef def : contributions)
{
@@ -471,7 +471,7 @@
boolean debug = logger.isDebugEnabled();
- ObjectLocator locator = new ServiceResourcesImpl(this, module, serviceDef, _classFactory, logger);
+ ObjectLocator locator = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
for (ContributionDef def : contributions)
{
@@ -495,7 +495,7 @@
Logger logger = getServiceLogger(serviceId);
boolean debug = logger.isDebugEnabled();
- ObjectLocator locator = new ServiceResourcesImpl(this, module, serviceDef, _classFactory, logger);
+ ObjectLocator locator = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
for (ContributionDef def : contributions)
{
@@ -510,7 +510,7 @@
public <T> T getService(Class<T> serviceInterface)
{
- _lock.check();
+ lock.check();
List<String> serviceIds = findServiceIdsForInterface(serviceInterface);
@@ -540,10 +540,10 @@
{
List<String> result = newList();
- for (Module module : _modules)
+ for (Module module : modules)
result.addAll(module.findServiceIdsForInterface(serviceInterface));
- for (Map.Entry<String, Object> entry : _builtinServices.entrySet())
+ for (Map.Entry<String, Object> entry : builtinServices.entrySet())
{
if (serviceInterface.isInstance(entry.getValue())) result.add(entry.getKey());
}
@@ -555,9 +555,9 @@
public ServiceLifecycle getServiceLifecycle(String scope)
{
- _lock.check();
+ lock.check();
- ServiceLifecycle result = _lifecycles.get(scope);
+ ServiceLifecycle result = lifecycles.get(scope);
if (result == null)
{
@@ -572,7 +572,7 @@
public List<ServiceDecorator> findDecoratorsForService(ServiceDef serviceDef)
{
- _lock.check();
+ lock.check();
assert serviceDef != null;
@@ -580,13 +580,13 @@
Orderer<ServiceDecorator> orderer = new Orderer<ServiceDecorator>(logger);
- for (Module module : _modules)
+ for (Module module : modules)
{
Set<DecoratorDef> decorators = module.findMatchingDecoratorDefs(serviceDef);
if (decorators.isEmpty()) continue;
- ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, _classFactory, logger);
+ ServiceResources resources = new ServiceResourcesImpl(this, module, serviceDef, classFactory, logger);
for (DecoratorDef dd : decorators)
{
@@ -601,14 +601,14 @@
public ClassFab newClass(Class serviceInterface)
{
- _lock.check();
+ lock.check();
- return _classFactory.newClass(serviceInterface);
+ return classFactory.newClass(serviceInterface);
}
private <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator)
{
- _lock.check();
+ lock.check();
AnnotationProvider effectiveProvider = annotationProvider != null ? annotationProvider : new NullAnnotationProvider();
@@ -632,13 +632,13 @@
{
if (provider == null) return null;
- for (Class marker : _markerToServiceDef.keySet())
+ for (Class marker : markerToServiceDef.keySet())
{
if (provider.getAnnotation(marker) == null) continue;
List<ServiceDef> matches = newList();
- for (ServiceDef def : _markerToServiceDef.get(marker))
+ for (ServiceDef def : markerToServiceDef.get(marker))
{
if (objectType.isAssignableFrom(def.getServiceInterface())) matches.add(def);
}
@@ -676,21 +676,21 @@
public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
{
- _lock.check();
+ lock.check();
return getObject(objectType, annotationProvider, this);
}
public void addRegistryShutdownListener(RegistryShutdownListener listener)
{
- _lock.check();
+ lock.check();
- _registryShutdownHub.addRegistryShutdownListener(listener);
+ registryShutdownHub.addRegistryShutdownListener(listener);
}
public String expandSymbols(String input)
{
- _lock.check();
+ lock.check();
// Again, a bit of work to avoid instantiating the SymbolSource until absolutely necessary.
@@ -704,9 +704,9 @@
*/
private synchronized SymbolSource getSymbolSource()
{
- if (_symbolSource == null) _symbolSource = getService(SYMBOL_SOURCE_SERVICE_ID, SymbolSource.class);
+ if (symbolSource == null) symbolSource = getService(SYMBOL_SOURCE_SERVICE_ID, SymbolSource.class);
- return _symbolSource;
+ return symbolSource;
}
public <T> T autobuild(Class<T> clazz)
@@ -738,7 +738,7 @@
failure = ex;
}
- String description = _classFactory.getConstructorLocation(constructor).toString();
+ String description = classFactory.getConstructorLocation(constructor).toString();
throw new RuntimeException(IOCMessages.autobuildConstructorError(description, failure), failure);
}
@@ -771,7 +771,7 @@
}
};
- ClassFab cf = _classFactory.newClass(interfaceClass);
+ ClassFab cf = classFactory.newClass(interfaceClass);
String description = String.format("<Autobuild proxy %s(%s)>", implementationClass
.getName(), interfaceClass.getName());
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/RegistryWrapper.java Tue May 6 14:52:36 2008
@@ -19,58 +19,58 @@
import org.apache.tapestry.ioc.Registry;
/**
- * A wrapper around {@link InternalRegistry} that exists to expand symbols in a service id before
- * invoking {@link ObjectLocator#getService(Class)}.
+ * A wrapper around {@link InternalRegistry} that exists to expand symbols in a service id before invoking {@link
+ * ObjectLocator#getService(Class)}.
*/
public class RegistryWrapper implements Registry
{
- private final InternalRegistry _registry;
+ private final InternalRegistry registry;
public RegistryWrapper(final InternalRegistry registry)
{
- _registry = registry;
+ this.registry = registry;
}
public void cleanupThread()
{
- _registry.cleanupThread();
+ registry.cleanupThread();
}
public void shutdown()
{
- _registry.shutdown();
+ registry.shutdown();
}
public <T> T getObject(Class<T> objectType, AnnotationProvider annotationProvider)
{
- return _registry.getObject(objectType, annotationProvider);
+ return registry.getObject(objectType, annotationProvider);
}
public <T> T getService(String serviceId, Class<T> serviceInterface)
{
- String expandedServiceId = _registry.expandSymbols(serviceId);
+ String expandedServiceId = registry.expandSymbols(serviceId);
- return _registry.getService(expandedServiceId, serviceInterface);
+ return registry.getService(expandedServiceId, serviceInterface);
}
public <T> T getService(Class<T> serviceInterface)
{
- return _registry.getService(serviceInterface);
+ return registry.getService(serviceInterface);
}
public <T> T autobuild(Class<T> clazz)
{
- return _registry.autobuild(clazz);
+ return registry.autobuild(clazz);
}
public void performRegistryStartup()
{
- _registry.performRegistryStartup();
+ registry.performRegistryStartup();
}
public <T> T proxy(Class<T> interfaceClass, Class<? extends T> implementationClass)
{
- return _registry.proxy(interfaceClass, implementationClass);
+ return registry.proxy(interfaceClass, implementationClass);
}
}
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/SerializationSupport.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/SerializationSupport.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/SerializationSupport.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/SerializationSupport.java Tue May 6 14:52:36 2008
@@ -29,7 +29,7 @@
// We use a weak reference so that the underlying Registry can be reclaimed by the garbage collector
// even if it is not explicitly shut down.
- private static WeakReference<ServiceProxyProvider> _providerRef;
+ private static WeakReference<ServiceProxyProvider> providerRef;
static synchronized void setProvider(ServiceProxyProvider proxyProvider)
{
@@ -37,12 +37,12 @@
if (existing != null) LOGGER.error(IOCMessages.overlappingServiceProxyProviders());
- _providerRef = new WeakReference<ServiceProxyProvider>(proxyProvider);
+ providerRef = new WeakReference<ServiceProxyProvider>(proxyProvider);
}
private static ServiceProxyProvider currentProvider()
{
- return _providerRef == null ? null : _providerRef.get();
+ return providerRef == null ? null : providerRef.get();
}
static synchronized void clearProvider(ServiceProxyProvider proxyProvider)
@@ -61,7 +61,7 @@
// Good. It's all the expected simple case, without duelling registries. Kill the reference
// to the registry.
- _providerRef = null;
+ providerRef = null;
}
static synchronized Object readResolve(String serviceId)
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceActivityTrackerImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceActivityTrackerImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceActivityTrackerImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceActivityTrackerImpl.java Tue May 6 14:52:36 2008
@@ -25,52 +25,52 @@
import java.util.TreeMap;
public class ServiceActivityTrackerImpl implements ServiceActivityScoreboard,
- ServiceActivityTracker
+ ServiceActivityTracker
{
public static class MutableServiceActivity implements ServiceActivity
{
- private final ServiceDef _serviceDef;
+ private final ServiceDef serviceDef;
- private Status _status;
+ private Status status;
public MutableServiceActivity(ServiceDef serviceDef, Status status)
{
- _serviceDef = serviceDef;
- _status = status;
+ this.serviceDef = serviceDef;
+ this.status = status;
}
public String getServiceId()
{
- return _serviceDef.getServiceId();
+ return serviceDef.getServiceId();
}
public Class getServiceInterface()
{
- return _serviceDef.getServiceInterface();
+ return serviceDef.getServiceInterface();
}
public String getScope()
{
- return _serviceDef.getServiceScope();
+ return serviceDef.getServiceScope();
}
// Mutable properties must be synchronized
public synchronized Status getStatus()
{
- return _status;
+ return status;
}
synchronized void setStatus(Status status)
{
- _status = status;
+ this.status = status;
}
}
/**
* Tree map keeps everything in order by key (serviceId).
*/
- private final Map<String, MutableServiceActivity> _serviceIdToServiceStatus = new TreeMap<String, MutableServiceActivity>();
+ private final Map<String, MutableServiceActivity> serviceIdToServiceStatus = new TreeMap<String, MutableServiceActivity>();
public synchronized List<ServiceActivity> getServiceActivity()
{
@@ -83,7 +83,7 @@
List<ServiceActivity> result = CollectionFactory.newList();
- result.addAll(_serviceIdToServiceStatus.values());
+ result.addAll(serviceIdToServiceStatus.values());
return result;
}
@@ -100,13 +100,13 @@
public synchronized void define(ServiceDef serviceDef, Status initialStatus)
{
- _serviceIdToServiceStatus.put(serviceDef.getServiceId(), new MutableServiceActivity(
+ serviceIdToServiceStatus.put(serviceDef.getServiceId(), new MutableServiceActivity(
serviceDef, initialStatus));
}
public synchronized void setStatus(String serviceId, Status status)
{
- _serviceIdToServiceStatus.get(serviceId).setStatus(status);
+ serviceIdToServiceStatus.get(serviceId).setStatus(status);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBinderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBinderImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBinderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBinderImpl.java Tue May 6 14:52:36 2008
@@ -33,19 +33,19 @@
public class ServiceBinderImpl implements ServiceBinder, ServiceBindingOptions
{
- private final OneShotLock _lock = new OneShotLock();
+ private final OneShotLock lock = new OneShotLock();
- private final ServiceDefAccumulator _accumulator;
+ private final ServiceDefAccumulator accumulator;
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
- private final Set<Class> _defaultMarkers;
+ private final Set<Class> defaultMarkers;
public ServiceBinderImpl(ServiceDefAccumulator accumulator, ClassFactory classFactory, Set<Class> defaultMarkers)
{
- _accumulator = accumulator;
- _classFactory = classFactory;
- _defaultMarkers = defaultMarkers;
+ this.accumulator = accumulator;
+ this.classFactory = classFactory;
+ this.defaultMarkers = defaultMarkers;
}
private String _serviceId;
@@ -62,7 +62,7 @@
public void finish()
{
- _lock.lock();
+ lock.lock();
flush();
}
@@ -82,17 +82,17 @@
public String getDescription()
{
- return _classFactory.getConstructorLocation(constructor).toString();
+ return classFactory.getConstructorLocation(constructor).toString();
}
};
// Combine service-specific markers with those inherited form the module.
- Set<Class> markers = CollectionFactory.newSet(_defaultMarkers);
+ Set<Class> markers = CollectionFactory.newSet(defaultMarkers);
markers.addAll(_markers);
ServiceDef serviceDef = new ServiceDefImpl(_serviceInterface, _serviceId, markers, _scope, _eagerLoad, source);
- _accumulator.addServiceDef(serviceDef);
+ accumulator.addServiceDef(serviceDef);
_serviceId = null;
_serviceInterface = null;
@@ -122,7 +122,7 @@
notNull(serviceInterface, "serviceIterface");
notNull(serviceImplementation, "serviceImplementation");
- _lock.check();
+ lock.check();
flush();
@@ -151,7 +151,7 @@
public ServiceBindingOptions eagerLoad()
{
- _lock.check();
+ lock.check();
_eagerLoad = true;
@@ -162,7 +162,7 @@
{
notBlank(id, "id");
- _lock.check();
+ lock.check();
_serviceId = id;
@@ -173,7 +173,7 @@
{
notBlank(scope, "scope");
- _lock.check();
+ lock.check();
_scope = scope;
@@ -182,7 +182,7 @@
public <T extends Annotation> ServiceBindingOptions withMarker(Class<T>... marker)
{
- _lock.check();
+ lock.check();
InternalUtils.validateMarkerAnnotations(marker);
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvoker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvoker.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvoker.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceBuilderMethodInvoker.java Tue May 6 14:52:36 2008
@@ -22,31 +22,30 @@
import java.util.Map;
/**
- * Basic implementation of {@link org.apache.tapestry.ioc.ObjectCreator} that handles invoking a
- * method on the module builder, and figures out the correct parameters to pass into the annotated
- * method.
+ * Basic implementation of {@link org.apache.tapestry.ioc.ObjectCreator} that handles invoking a method on the module
+ * builder, and figures out the correct parameters to pass into the annotated method.
*/
public class ServiceBuilderMethodInvoker extends AbstractServiceCreator
{
- private final Method _builderMethod;
+ private final Method builderMethod;
public ServiceBuilderMethodInvoker(ServiceBuilderResources resources,
String creatorDescription, Method method)
{
super(resources, creatorDescription);
- _builderMethod = method;
+ builderMethod = method;
}
/**
- * Returns a map that includes (possibly) an additional mapping containing the collected
- * configuration data. This involves scanning the builder method's parameters.
+ * Returns a map that includes (possibly) an additional mapping containing the collected configuration data. This
+ * involves scanning the builder method's parameters.
*/
private Map<Class, Object> getParameterDefaultsWithConfigurations()
{
return getParameterDefaultsWithConfiguration(
- _builderMethod.getParameterTypes(),
- _builderMethod.getGenericParameterTypes());
+ builderMethod.getParameterTypes(),
+ builderMethod.getGenericParameterTypes());
}
/**
@@ -57,7 +56,7 @@
// Defer getting (and possibly instantitating) the module builder until the last possible
// moment. If the method is static, there's no need to even get the builder.
- Object moduleBuilder = InternalUtils.isStatic(_builderMethod) ? null : _resources
+ Object moduleBuilder = InternalUtils.isStatic(builderMethod) ? null : resources
.getModuleBuilder();
Object result = null;
@@ -66,14 +65,14 @@
try
{
Object[] parameters = InternalUtils.calculateParametersForMethod(
- _builderMethod,
- _resources,
+ builderMethod,
+ resources,
getParameterDefaultsWithConfigurations());
- if (_logger.isDebugEnabled())
- _logger.debug(IOCMessages.invokingMethod(_creatorDescription));
+ if (logger.isDebugEnabled())
+ logger.debug(IOCMessages.invokingMethod(creatorDescription));
- result = _builderMethod.invoke(moduleBuilder, parameters);
+ result = builderMethod.invoke(moduleBuilder, parameters);
}
catch (InvocationTargetException ite)
{
@@ -86,14 +85,14 @@
if (failure != null)
throw new RuntimeException(IOCMessages.builderMethodError(
- _creatorDescription,
- _serviceId,
+ creatorDescription,
+ serviceId,
failure), failure);
if (result == null)
throw new RuntimeException(IOCMessages.builderMethodReturnedNull(
- _creatorDescription,
- _serviceId));
+ creatorDescription,
+ serviceId));
return result;
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDecoratorImpl.java Tue May 6 14:52:36 2008
@@ -31,50 +31,50 @@
*/
public class ServiceDecoratorImpl implements ServiceDecorator
{
- private final ModuleBuilderSource _moduleBuilderSource;
+ private final ModuleBuilderSource moduleBuilderSource;
- private final String _serviceId;
+ private final String serviceId;
- private final Map<Class, Object> _parameterDefaults = newMap();
+ private final Map<Class, Object> parameterDefaults = newMap();
private final Logger _logger;
- private final ServiceResources _resources;
+ private final ServiceResources resources;
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
- private final Method _decoratorMethod;
+ private final Method decoratorMethod;
- private final Class _serviceInterface;
+ private final Class serviceInterface;
public ServiceDecoratorImpl(Method method, ModuleBuilderSource moduleBuilderSource,
ServiceResources resources, ClassFactory classFactory)
{
- _serviceId = resources.getServiceId();
- _decoratorMethod = method;
- _moduleBuilderSource = moduleBuilderSource;
- _resources = resources;
- _serviceInterface = resources.getServiceInterface();
+ serviceId = resources.getServiceId();
+ decoratorMethod = method;
+ this.moduleBuilderSource = moduleBuilderSource;
+ this.resources = resources;
+ serviceInterface = resources.getServiceInterface();
_logger = resources.getLogger();
- _classFactory = classFactory;
+ this.classFactory = classFactory;
- _parameterDefaults.put(String.class, _serviceId);
- _parameterDefaults.put(ServiceResources.class, resources);
- _parameterDefaults.put(Logger.class, _logger);
- _parameterDefaults.put(Class.class, _serviceInterface);
+ parameterDefaults.put(String.class, serviceId);
+ parameterDefaults.put(ServiceResources.class, resources);
+ parameterDefaults.put(Logger.class, _logger);
+ parameterDefaults.put(Class.class, serviceInterface);
}
private String methodId()
{
- return InternalUtils.asString(_decoratorMethod, _classFactory);
+ return InternalUtils.asString(decoratorMethod, classFactory);
}
public Object createInterceptor(Object delegate)
{
// Create a copy of the parameters map so that Object.class points to the delegate instance.
- Map<Class, Object> parameterDefaults = newMap(_parameterDefaults);
+ Map<Class, Object> parameterDefaults = newMap(this.parameterDefaults);
parameterDefaults.put(Object.class, delegate);
if (_logger.isDebugEnabled()) _logger.debug(IOCMessages.invokingMethod(methodId()));
@@ -82,17 +82,17 @@
Object result = null;
Throwable failure = null;
- Object moduleBuilder = InternalUtils.isStatic(_decoratorMethod) ? null
- : _moduleBuilderSource.getModuleBuilder();
+ Object moduleBuilder = InternalUtils.isStatic(decoratorMethod) ? null
+ : moduleBuilderSource.getModuleBuilder();
try
{
Object[] parameters = InternalUtils.calculateParametersForMethod(
- _decoratorMethod,
- _resources,
+ decoratorMethod,
+ resources,
parameterDefaults);
- result = _decoratorMethod.invoke(moduleBuilder, parameters);
+ result = decoratorMethod.invoke(moduleBuilder, parameters);
}
catch (InvocationTargetException ite)
{
@@ -106,17 +106,17 @@
if (failure != null)
throw new RuntimeException(IOCMessages.decoratorMethodError(
- _decoratorMethod,
- _serviceId,
+ decoratorMethod,
+ serviceId,
failure), failure);
- if (result != null && !_serviceInterface.isInstance(result))
+ if (result != null && !serviceInterface.isInstance(result))
{
_logger.warn(IOCMessages.decoratorReturnedWrongType(
- _decoratorMethod,
- _serviceId,
+ decoratorMethod,
+ serviceId,
result,
- _serviceInterface));
+ serviceInterface));
// Change the result to null so that we won't use the interceptor,
// and so that ClassCastExceptions don't occur later down the pipeline.
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceDefImpl.java Tue May 6 14:52:36 2008
@@ -23,17 +23,17 @@
public class ServiceDefImpl implements ServiceDef
{
- private final Class _serviceInterface;
+ private final Class serviceInterface;
- private final String _serviceId;
+ private final String serviceId;
- private final String _scope;
+ private final String scope;
- private final boolean _eagerLoad;
+ private final boolean eagerLoad;
- private final ObjectCreatorSource _source;
+ private final ObjectCreatorSource source;
- private final Set<Class> _markers;
+ private final Set<Class> markers;
/**
* @param serviceInterface interface implemented by the service (or the service implementation class, for
@@ -47,49 +47,49 @@
ServiceDefImpl(Class serviceInterface, String serviceId, Set<Class> markers, String scope,
boolean eagerLoad, ObjectCreatorSource source)
{
- _serviceInterface = serviceInterface;
- _serviceId = serviceId;
- _scope = scope;
- _eagerLoad = eagerLoad;
- _source = source;
+ this.serviceInterface = serviceInterface;
+ this.serviceId = serviceId;
+ this.scope = scope;
+ this.eagerLoad = eagerLoad;
+ this.source = source;
- _markers = markers;
+ this.markers = markers;
}
@Override
public String toString()
{
- return _source.getDescription();
+ return source.getDescription();
}
public ObjectCreator createServiceCreator(ServiceBuilderResources resources)
{
- return _source.constructCreator(resources);
+ return source.constructCreator(resources);
}
public String getServiceId()
{
- return _serviceId;
+ return serviceId;
}
public Class getServiceInterface()
{
- return _serviceInterface;
+ return serviceInterface;
}
public String getServiceScope()
{
- return _scope;
+ return scope;
}
public boolean isEagerLoad()
{
- return _eagerLoad;
+ return eagerLoad;
}
public Set<Class> getMarkers()
{
- return _markers;
+ return markers;
}
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceProxyToken.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceProxyToken.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceProxyToken.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceProxyToken.java Tue May 6 14:52:36 2008
@@ -23,18 +23,18 @@
*/
class ServiceProxyToken implements Serializable
{
- private final String _serviceId;
+ private final String serviceId;
ServiceProxyToken(String serviceId)
{
- _serviceId = serviceId;
+ this.serviceId = serviceId;
}
Object readResolve() throws ObjectStreamException
{
try
{
- return SerializationSupport.readResolve(_serviceId);
+ return SerializationSupport.readResolve(serviceId);
}
catch (Exception ex)
{
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceResourcesImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceResourcesImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ServiceResourcesImpl.java Tue May 6 14:52:36 2008
@@ -28,49 +28,48 @@
import java.util.Map;
/**
- * Implementation of {@link org.apache.tapestry.ioc.ServiceBuilderResources}. We just have one
- * implementation that fills the purposes of methods that need a
- * {@link org.apache.tapestry.ioc.ServiceResources} (which includes service decorator methods) as
- * well as methods that need a {@link org.apache.tapestry.ioc.ServiceBuilderResources} (which is
- * just service builder methods). Since it is most commonly used for the former, we'll just leave
- * the name as ServiceResourcesImpl.
+ * Implementation of {@link org.apache.tapestry.ioc.ServiceBuilderResources}. We just have one implementation that fills
+ * the purposes of methods that need a {@link org.apache.tapestry.ioc.ServiceResources} (which includes service
+ * decorator methods) as well as methods that need a {@link org.apache.tapestry.ioc.ServiceBuilderResources} (which is
+ * just service builder methods). Since it is most commonly used for the former, we'll just leave the name as
+ * ServiceResourcesImpl.
*/
public class ServiceResourcesImpl extends ObjectLocatorImpl implements ServiceBuilderResources
{
- private final ServiceDef _serviceDef;
+ private final ServiceDef serviceDef;
- private final Logger _logger;
+ private final Logger logger;
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
public ServiceResourcesImpl(InternalRegistry registry, Module module, ServiceDef serviceDef,
ClassFactory classFactory, Logger logger)
{
super(registry, module);
- _serviceDef = serviceDef;
- _classFactory = classFactory;
- _logger = logger;
+ this.serviceDef = serviceDef;
+ this.classFactory = classFactory;
+ this.logger = logger;
}
public String getServiceId()
{
- return _serviceDef.getServiceId();
+ return serviceDef.getServiceId();
}
public Class getServiceInterface()
{
- return _serviceDef.getServiceInterface();
+ return serviceDef.getServiceInterface();
}
public Logger getLogger()
{
- return _logger;
+ return logger;
}
public <T> Collection<T> getUnorderedConfiguration(Class<T> valueType)
{
- Collection<T> result = getRegistry().getUnorderedConfiguration(_serviceDef, valueType);
+ Collection<T> result = getRegistry().getUnorderedConfiguration(serviceDef, valueType);
logConfiguration(result);
@@ -79,13 +78,13 @@
private void logConfiguration(Collection configuration)
{
- if (_logger.isDebugEnabled())
- _logger.debug(IOCMessages.constructedConfiguration(configuration));
+ if (logger.isDebugEnabled())
+ logger.debug(IOCMessages.constructedConfiguration(configuration));
}
public <T> List<T> getOrderedConfiguration(Class<T> valueType)
{
- List<T> result = getRegistry().getOrderedConfiguration(_serviceDef, valueType);
+ List<T> result = getRegistry().getOrderedConfiguration(serviceDef, valueType);
logConfiguration(result);
@@ -94,9 +93,9 @@
public <K, V> Map<K, V> getMappedConfiguration(Class<K> keyType, Class<V> valueType)
{
- Map<K, V> result = getRegistry().getMappedConfiguration(_serviceDef, keyType, valueType);
+ Map<K, V> result = getRegistry().getMappedConfiguration(serviceDef, keyType, valueType);
- if (_logger.isDebugEnabled()) _logger.debug(IOCMessages.constructedConfiguration(result));
+ if (logger.isDebugEnabled()) logger.debug(IOCMessages.constructedConfiguration(result));
return result;
}
@@ -116,7 +115,7 @@
if (constructor == null)
throw new RuntimeException(IOCMessages.noAutobuildConstructor(clazz));
- String description = _classFactory.getConstructorLocation(constructor).toString();
+ String description = classFactory.getConstructorLocation(constructor).toString();
ObjectCreator creator = new ConstructorServiceCreator(this, description, constructor);
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapper.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingConfigurationWrapper.java Tue May 6 14:52:36 2008
@@ -23,49 +23,49 @@
*/
public class ValidatingConfigurationWrapper<T> implements Configuration<T>
{
- private final String _serviceId;
+ private final String serviceId;
- private final ContributionDef _contributionDef;
+ private final ContributionDef contributionDef;
- private final Logger _logger;
+ private final Logger logger;
- private final Configuration<T> _delegate;
+ private final Configuration<T> delegate;
- private final Class _expectedType;
+ private final Class expectedType;
// Need a strategy for determing the right order for this mass of parameters!
public ValidatingConfigurationWrapper(String serviceId, Logger logger, Class expectedType,
ContributionDef contributionDef, Configuration<T> delegate)
{
- _serviceId = serviceId;
- _logger = logger;
- _expectedType = expectedType;
- _contributionDef = contributionDef;
- _delegate = delegate;
+ this.serviceId = serviceId;
+ this.logger = logger;
+ this.expectedType = expectedType;
+ this.contributionDef = contributionDef;
+ this.delegate = delegate;
}
public void add(T object)
{
if (object == null)
{
- _logger.warn(IOCMessages.contributionWasNull(_serviceId, _contributionDef));
+ logger.warn(IOCMessages.contributionWasNull(serviceId, contributionDef));
return;
}
// Sure, we say it is type T ... but is it really?
- if (!_expectedType.isInstance(object))
+ if (!expectedType.isInstance(object))
{
- _logger.warn(IOCMessages.contributionWrongValueType(
- _serviceId,
- _contributionDef,
+ logger.warn(IOCMessages.contributionWrongValueType(
+ serviceId,
+ contributionDef,
object.getClass(),
- _expectedType));
+ expectedType));
return;
}
- _delegate.add(object);
+ delegate.add(object);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapper.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingMappedConfigurationWrapper.java Tue May 6 14:52:36 2008
@@ -21,12 +21,9 @@
import java.util.Map;
/**
- * Provides two forms of validation for mapped configurations:
- * <ul>
- * <li>If either key or value is null, then a warning is logged </li>
- * <li>If the key has previously been stored (by some other
- * {@link org.apache.tapestry.ioc.def.ContributionDef}, then a warning is logged</li>
- * </ul>
+ * Provides two forms of validation for mapped configurations: <ul> <li>If either key or value is null, then a warning
+ * is logged </li> <li>If the key has previously been stored (by some other {@link
+ * org.apache.tapestry.ioc.def.ContributionDef}, then a warning is logged</li> </ul>
* <p/>
* When a warning is logged, the key/value pair is not added to the delegate.
*
@@ -35,79 +32,79 @@
*/
public class ValidatingMappedConfigurationWrapper<K, V> implements MappedConfiguration<K, V>
{
- private final String _serviceId;
+ private final String serviceId;
- private final ContributionDef _contributionDef;
+ private final ContributionDef contributionDef;
- private final Logger _logger;
+ private final Logger logger;
- private final Class<K> _expectedKeyType;
+ private final Class<K> expectedKeyType;
- private final Class<V> _expectedValueType;
+ private final Class<V> expectedValueType;
- private final Map<K, ContributionDef> _keyToContributor;
+ private final Map<K, ContributionDef> keyToContributor;
- private final MappedConfiguration<K, V> _delegate;
+ private final MappedConfiguration<K, V> delegate;
public ValidatingMappedConfigurationWrapper(String serviceId, ContributionDef contributionDef,
Logger logger, Class<K> expectedKeyType, Class<V> expectedValueType,
Map<K, ContributionDef> keyToContributor,
MappedConfiguration<K, V> delegate)
{
- _serviceId = serviceId;
- _contributionDef = contributionDef;
- _logger = logger;
- _expectedKeyType = expectedKeyType;
- _expectedValueType = expectedValueType;
- _keyToContributor = keyToContributor;
- _delegate = delegate;
+ this.serviceId = serviceId;
+ this.contributionDef = contributionDef;
+ this.logger = logger;
+ this.expectedKeyType = expectedKeyType;
+ this.expectedValueType = expectedValueType;
+ this.keyToContributor = keyToContributor;
+ this.delegate = delegate;
}
public void add(K key, V value)
{
if (key == null)
{
- _logger.warn(IOCMessages.contributionKeyWasNull(_serviceId, _contributionDef));
+ logger.warn(IOCMessages.contributionKeyWasNull(serviceId, contributionDef));
return;
}
if (value == null)
{
- _logger.warn(IOCMessages.contributionWasNull(_serviceId, _contributionDef));
+ logger.warn(IOCMessages.contributionWasNull(serviceId, contributionDef));
return;
}
- if (!_expectedKeyType.isInstance(key))
+ if (!expectedKeyType.isInstance(key))
{
- _logger.warn(IOCMessages.contributionWrongKeyType(_serviceId, _contributionDef, key
- .getClass(), _expectedKeyType));
+ logger.warn(IOCMessages.contributionWrongKeyType(serviceId, contributionDef, key
+ .getClass(), expectedKeyType));
return;
}
- if (!_expectedValueType.isInstance(value))
+ if (!expectedValueType.isInstance(value))
{
- _logger.warn(IOCMessages.contributionWrongValueType(_serviceId, _contributionDef, value
- .getClass(), _expectedValueType));
+ logger.warn(IOCMessages.contributionWrongValueType(serviceId, contributionDef, value
+ .getClass(), expectedValueType));
return;
}
- ContributionDef existing = _keyToContributor.get(key);
+ ContributionDef existing = keyToContributor.get(key);
if (existing != null)
{
- _logger.warn(IOCMessages.contributionDuplicateKey(
- _serviceId,
- _contributionDef,
+ logger.warn(IOCMessages.contributionDuplicateKey(
+ serviceId,
+ contributionDef,
existing));
return;
}
- _delegate.add(key, value);
+ delegate.add(key, value);
// Remember that this key is provided by this contribution, when looking
// for future conflicts.
- _keyToContributor.put(key, _contributionDef);
+ keyToContributor.put(key, contributionDef);
}
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/ValidatingOrderedConfigurationWrapper.java Tue May 6 14:52:36 2008
@@ -19,47 +19,46 @@
import org.slf4j.Logger;
/**
- * Implements validation of values provided to an
- * {@link org.apache.tapestry.ioc.OrderedConfiguration}. If you provide an incorrect value type,
- * the value is converted to null but added anyway. This ensures that incorrect values contributed
- * in don't screw up the {@link org.apache.tapestry.ioc.internal.util.Orderer} (and generate a bunch
- * of error messages there).
+ * Implements validation of values provided to an {@link org.apache.tapestry.ioc.OrderedConfiguration}. If you provide
+ * an incorrect value type, the value is converted to null but added anyway. This ensures that incorrect values
+ * contributed in don't screw up the {@link org.apache.tapestry.ioc.internal.util.Orderer} (and generate a bunch of
+ * error messages there).
*
* @param <T>
*/
public class ValidatingOrderedConfigurationWrapper<T> implements OrderedConfiguration<T>
{
- private final String _serviceId;
+ private final String serviceId;
- private final ContributionDef _contributionDef;
+ private final ContributionDef contributionDef;
- private final Logger _logger;
+ private final Logger logger;
- private final Class _expectedType;
+ private final Class expectedType;
- private final OrderedConfiguration<T> _delegate;
+ private final OrderedConfiguration<T> delegate;
public ValidatingOrderedConfigurationWrapper(String serviceId, ContributionDef contributionDef,
Logger logger, Class expectedType, OrderedConfiguration<T> delegate)
{
- _serviceId = serviceId;
- _contributionDef = contributionDef;
- _logger = logger;
- _expectedType = expectedType;
- _delegate = delegate;
+ this.serviceId = serviceId;
+ this.contributionDef = contributionDef;
+ this.logger = logger;
+ this.expectedType = expectedType;
+ this.delegate = delegate;
}
public void add(String id, T object, String... constraints)
{
- _delegate.add(id, validVersionOf(object), constraints);
+ delegate.add(id, validVersionOf(object), constraints);
}
private T validVersionOf(T object)
{
- if (object == null || _expectedType.isInstance(object)) return object;
+ if (object == null || expectedType.isInstance(object)) return object;
- _logger.warn(IOCMessages.contributionWrongValueType(_serviceId, _contributionDef, object
- .getClass(), _expectedType));
+ logger.warn(IOCMessages.contributionWrongValueType(serviceId, contributionDef, object
+ .getClass(), expectedType));
return null;
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractFab.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractFab.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractFab.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractFab.java Tue May 6 14:52:36 2008
@@ -24,30 +24,30 @@
*/
public class AbstractFab
{
- protected final OneShotLock _lock = new OneShotLock();
+ protected final OneShotLock lock = new OneShotLock();
- private final CtClass _ctClass;
+ private final CtClass ctClass;
- private final CtClassSource _source;
+ private final CtClassSource source;
- private final Logger _logger;
+ private final Logger logger;
public AbstractFab(CtClassSource source, CtClass ctClass, Logger logger)
{
- _ctClass = ctClass;
- _source = source;
- _logger = logger;
+ this.ctClass = ctClass;
+ this.source = source;
+ this.logger = logger;
}
public void addInterface(Class interfaceClass)
{
- _lock.check();
+ lock.check();
- CtClass ctInterfaceClass = _source.toCtClass(interfaceClass);
+ CtClass ctInterfaceClass = source.toCtClass(interfaceClass);
try
{
- for (CtClass existing : _ctClass.getInterfaces())
+ for (CtClass existing : ctClass.getInterfaces())
if (existing == ctInterfaceClass) return;
}
catch (Exception ex)
@@ -55,7 +55,7 @@
// Don't think this code is actually reachable.
}
- _ctClass.addInterface(ctInterfaceClass);
+ ctClass.addInterface(ctInterfaceClass);
}
protected CtClass[] toCtClasses(Class[] inputClasses)
@@ -77,26 +77,26 @@
protected CtClass toCtClass(Class inputClass)
{
- return _source.toCtClass(inputClass);
+ return source.toCtClass(inputClass);
}
public Class createClass()
{
- _lock.lock();
+ lock.lock();
- if (_logger.isDebugEnabled()) _logger.debug(String.format("Creating class from %s", this));
+ if (logger.isDebugEnabled()) logger.debug(String.format("Creating class from %s", this));
- return _source.createClass(_ctClass);
+ return source.createClass(ctClass);
}
protected CtClass getCtClass()
{
- return _ctClass;
+ return ctClass;
}
protected CtClassSource getSource()
{
- return _source;
+ return source;
}
}
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractInvocation.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractInvocation.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractInvocation.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AbstractInvocation.java Tue May 6 14:52:36 2008
@@ -25,53 +25,53 @@
*/
public abstract class AbstractInvocation implements Invocation
{
- private final Method _method;
+ private final Method method;
- private Throwable _thrown;
+ private Throwable thrown;
- private Object _result;
+ private Object result;
@Override
public String toString()
{
- return String.format("Invocation[%s]", _method);
+ return String.format("Invocation[%s]", method);
}
protected AbstractInvocation(Method method)
{
- _method = method;
+ this.method = method;
}
public String getMethodName()
{
- return _method.getName();
+ return method.getName();
}
public Class getResultType()
{
- return _method.getReturnType();
+ return method.getReturnType();
}
public int getParameterCount()
{
- return _method.getParameterTypes().length;
+ return method.getParameterTypes().length;
}
public Class getParameterType(int index)
{
- return _method.getParameterTypes()[index];
+ return method.getParameterTypes()[index];
}
public boolean isFail()
{
- return _thrown != null;
+ return thrown != null;
}
public <T extends Throwable> T getThrown(Class<T> throwableClass)
{
Defense.notNull(throwableClass, "throwableClass");
- if (throwableClass.isInstance(_thrown)) return throwableClass.cast(_thrown);
+ if (throwableClass.isInstance(thrown)) return throwableClass.cast(thrown);
return null;
}
@@ -80,27 +80,27 @@
{
Defense.notNull(thrown, "thrown");
- for (Class t : _method.getExceptionTypes())
+ for (Class t : method.getExceptionTypes())
{
if (t.isInstance(thrown))
{
- _thrown = thrown;
+ this.thrown = thrown;
return;
}
}
throw new IllegalArgumentException(String.format("Exception %s is not a declared exception of method %s.",
- thrown.getClass().getName(), _method));
+ thrown.getClass().getName(), method));
}
public Object getResult()
{
- return _result;
+ return result;
}
public void overrideResult(Object newResult)
{
- _result = newResult;
- _thrown = null;
+ result = newResult;
+ thrown = null;
}
}
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectDecoratorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectDecoratorImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectDecoratorImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectDecoratorImpl.java Tue May 6 14:52:36 2008
@@ -25,11 +25,11 @@
public class AspectDecoratorImpl implements AspectDecorator
{
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
public AspectDecoratorImpl(@Builtin ClassFactory classFactory)
{
- _classFactory = classFactory;
+ this.classFactory = classFactory;
}
public <T> T build(Class<T> serviceInterface, T delegate, MethodAdvice advice, String description)
@@ -63,7 +63,7 @@
public void adviseMethod(Method method, MethodAdvice advice)
{
if (_builder == null)
- _builder = new AspectInterceptorBuilderImpl<T>(_classFactory, serviceInterface, delegate,
+ _builder = new AspectInterceptorBuilderImpl<T>(classFactory, serviceInterface, delegate,
description);
_builder.adviseMethod(method, advice);
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectInterceptorBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectInterceptorBuilderImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectInterceptorBuilderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/AspectInterceptorBuilderImpl.java Tue May 6 14:52:36 2008
@@ -39,18 +39,19 @@
private static final int PRIVATE_FINAL = Modifier.PRIVATE | Modifier.FINAL;
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
- private final Class<T> _serviceInterface;
+ private final Class<T> serviceInterface;
- private final ClassFab _interceptorFab;
+ private final ClassFab interceptorFab;
- private final String _delegateFieldName;
+ private final String delegateFieldName;
- private final String _description;
+ private final String description;
- private boolean _sawToString;
- private final OneShotLock _lock = new OneShotLock();
+ private boolean sawToString;
+
+ private final OneShotLock lock = new OneShotLock();
private static class Injection
{
@@ -66,26 +67,26 @@
}
}
- private final List<Injection> _injections = CollectionFactory.newList();
+ private final List<Injection> injections = CollectionFactory.newList();
- private final Map<Object, Injection> _objectToInjection = CollectionFactory.newMap();
+ private final Map<Object, Injection> objectToInjection = CollectionFactory.newMap();
- private final Set<Method> _remainingMethods = CollectionFactory.newSet();
+ private final Set<Method> remainingMethods = CollectionFactory.newSet();
- private final Set<Method> _advisedMethods = CollectionFactory.newSet();
+ private final Set<Method> advisedMethods = CollectionFactory.newSet();
public AspectInterceptorBuilderImpl(ClassFactory classFactory, Class<T> serviceInterface, T delegate,
String description)
{
- _classFactory = classFactory;
- _serviceInterface = serviceInterface;
- _description = description;
+ this.classFactory = classFactory;
+ this.serviceInterface = serviceInterface;
+ this.description = description;
- _interceptorFab = _classFactory.newClass(serviceInterface);
+ interceptorFab = this.classFactory.newClass(serviceInterface);
- _delegateFieldName = inject(_serviceInterface, delegate);
+ delegateFieldName = inject(serviceInterface, delegate);
- _remainingMethods.addAll(Arrays.asList(serviceInterface.getMethods()));
+ remainingMethods.addAll(Arrays.asList(serviceInterface.getMethods()));
}
public void adviseMethod(Method method, MethodAdvice advice)
@@ -93,16 +94,16 @@
Defense.notNull(method, "method");
Defense.notNull(advice, "advice");
- _lock.check();
+ lock.check();
- if (_advisedMethods.contains(method))
+ if (advisedMethods.contains(method))
throw new IllegalArgumentException(String.format("Method %s has already been advised.", method));
- if (!_remainingMethods.contains(method))
+ if (!remainingMethods.contains(method))
throw new IllegalArgumentException(
- String.format("Method %s is not defined for interface %s.", method, _serviceInterface));
+ String.format("Method %s is not defined for interface %s.", method, serviceInterface));
- _sawToString |= ClassFabUtils.isToString(method);
+ sawToString |= ClassFabUtils.isToString(method);
String invocationClassName = createInvocationClass(method);
@@ -112,7 +113,7 @@
String aspectFieldName = inject(MethodAdvice.class, advice);
builder.addln("%s invocation = new %s(%s, %s, $$);", Invocation.class.getName(), invocationClassName,
- methodFieldName, _delegateFieldName);
+ methodFieldName, delegateFieldName);
builder.addln("%s.advise(invocation);", aspectFieldName);
@@ -140,18 +141,18 @@
builder.end();
- _interceptorFab.addMethod(Modifier.PUBLIC, new MethodSignature(method), builder.toString());
+ interceptorFab.addMethod(Modifier.PUBLIC, new MethodSignature(method), builder.toString());
- _remainingMethods.remove(method);
- _advisedMethods.add(method);
+ remainingMethods.remove(method);
+ advisedMethods.add(method);
}
private String createInvocationClass(Method method)
{
- String baseName = _serviceInterface.getSimpleName() + "$" + method.getName();
+ String baseName = serviceInterface.getSimpleName() + "$" + method.getName();
String className = ClassFabUtils.generateClassName(baseName);
- ClassFab invocationFab = _classFactory.newClass(className, AbstractInvocation.class);
+ ClassFab invocationFab = classFactory.newClass(className, AbstractInvocation.class);
List<Class> constructorTypes = CollectionFactory.newList();
@@ -159,8 +160,8 @@
constructorTypes.add(Method.class); // And passed up to the super class
- invocationFab.addField("_delegate", PRIVATE_FINAL, _serviceInterface);
- constructorTypes.add(_serviceInterface);
+ invocationFab.addField("_delegate", PRIVATE_FINAL, serviceInterface);
+ constructorTypes.add(serviceInterface);
BodyBuilder constructorBuilder = new BodyBuilder().begin().addln("super($1);").addln("_delegate = $2;");
@@ -298,7 +299,7 @@
public T build()
{
- _lock.lock();
+ lock.lock();
// Hit all the methods that haven't been referenced so far.
@@ -306,14 +307,14 @@
// And if we haven't seend a toString(), we can add it now.
- if (!_sawToString)
- _interceptorFab.addToString(_description);
+ if (!sawToString)
+ interceptorFab.addToString(description);
Object[] parameters = createConstructor();
try
{
- Class c = _interceptorFab.createClass();
+ Class c = interceptorFab.createClass();
// There's only ever the one constructor.
@@ -321,7 +322,7 @@
Object interceptor = cc.newInstance(parameters);
- return _serviceInterface.cast(interceptor);
+ return serviceInterface.cast(interceptor);
}
catch (Exception ex)
{
@@ -333,14 +334,14 @@
{
// Time to add the constructor.
- Class[] parameterTypes = new Class[_injections.size()];
- Object[] parameters = new Object[_injections.size()];
+ Class[] parameterTypes = new Class[injections.size()];
+ Object[] parameters = new Object[injections.size()];
BodyBuilder builder = new BodyBuilder().begin();
- for (int i = 0; i < _injections.size(); i++)
+ for (int i = 0; i < injections.size(); i++)
{
- Injection injection = _injections.get(i);
+ Injection injection = injections.get(i);
builder.addln("%s = $%d;", injection._fieldName, i + 1);
@@ -350,39 +351,39 @@
builder.end();
- _interceptorFab.addConstructor(parameterTypes, null, builder.toString());
+ interceptorFab.addConstructor(parameterTypes, null, builder.toString());
return parameters;
}
private void addPassthruMethods()
{
- for (Method m : _remainingMethods)
+ for (Method m : remainingMethods)
{
- _sawToString |= ClassFabUtils.isToString(m);
+ sawToString |= ClassFabUtils.isToString(m);
MethodSignature sig = new MethodSignature(m);
- String body = String.format("return ($r) %s.%s($$);", _delegateFieldName, m.getName());
+ String body = String.format("return ($r) %s.%s($$);", delegateFieldName, m.getName());
- _interceptorFab.addMethod(Modifier.PUBLIC, sig, body);
+ interceptorFab.addMethod(Modifier.PUBLIC, sig, body);
}
}
private <T> String inject(Class<T> fieldType, T injectedValue)
{
- Injection injection = _objectToInjection.get(injectedValue);
+ Injection injection = objectToInjection.get(injectedValue);
if (injection == null)
{
- String name = "_" + fieldType.getSimpleName().toLowerCase() + "_" + _injections.size();
+ String name = "_" + fieldType.getSimpleName().toLowerCase() + "_" + injections.size();
- _interceptorFab.addField(name, PRIVATE_FINAL, fieldType);
+ interceptorFab.addField(name, PRIVATE_FINAL, fieldType);
injection = new Injection(name, fieldType, injectedValue);
- _injections.add(injection);
- _objectToInjection.put(injectedValue, injection);
+ injections.add(injection);
+ objectToInjection.put(injectedValue, injection);
}
return injection._fieldName;
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/BridgeBuilder.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/BridgeBuilder.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/BridgeBuilder.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/BridgeBuilder.java Tue May 6 14:52:36 2008
@@ -28,35 +28,34 @@
import java.util.List;
/**
- * Used by the {@link org.apache.tapestry.ioc.internal.services.PipelineBuilderImpl} to create
- * bridge classes and to create instances of bridge classes. A bridge class implements the
- * <em>service</em> interface. Within the chain, bridge 1 is passed to filter 1. Invoking methods
- * on bridge 1 will invoke methods on filter 2.
+ * Used by the {@link org.apache.tapestry.ioc.internal.services.PipelineBuilderImpl} to create bridge classes and to
+ * create instances of bridge classes. A bridge class implements the <em>service</em> interface. Within the chain,
+ * bridge 1 is passed to filter 1. Invoking methods on bridge 1 will invoke methods on filter 2.
*/
class BridgeBuilder<S, F>
{
- private final Logger _logger;
+ private final Logger logger;
- private final Class<S> _serviceInterface;
+ private final Class<S> serviceInterface;
- private final Class<F> _filterInterface;
+ private final Class<F> filterInterface;
- private final ClassFab _classFab;
+ private final ClassFab classFab;
- private final FilterMethodAnalyzer _filterMethodAnalyzer;
+ private final FilterMethodAnalyzer filterMethodAnalyzer;
- private Constructor _constructor;
+ private Constructor constructor;
BridgeBuilder(Logger logger, Class<S> serviceInterface, Class<F> filterInterface,
ClassFactory classFactory)
{
- _logger = logger;
- _serviceInterface = serviceInterface;
- _filterInterface = filterInterface;
+ this.logger = logger;
+ this.serviceInterface = serviceInterface;
+ this.filterInterface = filterInterface;
- _classFab = classFactory.newClass(_serviceInterface);
+ classFab = classFactory.newClass(this.serviceInterface);
- _filterMethodAnalyzer = new FilterMethodAnalyzer(serviceInterface);
+ filterMethodAnalyzer = new FilterMethodAnalyzer(serviceInterface);
}
private void createClass()
@@ -66,7 +65,7 @@
createInfrastructure();
- MethodIterator mi = new MethodIterator(_serviceInterface);
+ MethodIterator mi = new MethodIterator(serviceInterface);
while (mi.hasNext())
{
@@ -75,7 +74,7 @@
boolean toStringMethodExists = mi.getToString();
- mi = new MethodIterator(_filterInterface);
+ mi = new MethodIterator(filterInterface);
while (mi.hasNext())
{
@@ -95,25 +94,25 @@
{
String toString = format(
"<PipelineBridge from %s to %s>",
- _serviceInterface.getName(),
- _filterInterface.getName());
- _classFab.addToString(toString);
+ serviceInterface.getName(),
+ filterInterface.getName());
+ classFab.addToString(toString);
}
- Class bridgeClass = _classFab.createClass();
+ Class bridgeClass = classFab.createClass();
- _constructor = bridgeClass.getConstructors()[0];
+ constructor = bridgeClass.getConstructors()[0];
}
private void createInfrastructure()
{
- _classFab.addField("_next", Modifier.PRIVATE | Modifier.FINAL, _serviceInterface);
- _classFab.addField("_filter", Modifier.PRIVATE | Modifier.FINAL, _filterInterface);
+ classFab.addField("_next", Modifier.PRIVATE | Modifier.FINAL, serviceInterface);
+ classFab.addField("_filter", Modifier.PRIVATE | Modifier.FINAL, filterInterface);
- _classFab.addConstructor(new Class[]
- {_serviceInterface, _filterInterface}, null, "{ _next = $1; _filter = $2; }");
+ classFab.addConstructor(new Class[]
+ { serviceInterface, filterInterface }, null, "{ _next = $1; _filter = $2; }");
- _classFab.addInterface(_serviceInterface);
+ classFab.addInterface(serviceInterface);
}
/**
@@ -124,13 +123,13 @@
*/
public S instantiateBridge(S nextBridge, F filter)
{
- if (_constructor == null) createClass();
+ if (constructor == null) createClass();
try
{
- Object instance = _constructor.newInstance(nextBridge, filter);
+ Object instance = constructor.newInstance(nextBridge, filter);
- return _serviceInterface.cast(instance);
+ return serviceInterface.cast(instance);
}
catch (Exception ex)
{
@@ -146,18 +145,17 @@
{
MethodSignature ms = (MethodSignature) i.next();
- _logger.error(ServiceMessages
- .extraFilterMethod(ms, _filterInterface, _serviceInterface));
+ logger.error(ServiceMessages
+ .extraFilterMethod(ms, filterInterface, serviceInterface));
}
}
/**
- * Finds a matching method in filterMethods for the given service method. A matching method has
- * the same signature as the service interface method, but with an additional parameter matching
- * the service interface itself.
+ * Finds a matching method in filterMethods for the given service method. A matching method has the same signature
+ * as the service interface method, but with an additional parameter matching the service interface itself.
* <p/>
- * The matching method signature from the list of filterMethods is removed and code generation
- * strategies for making the two methods call each other are added.
+ * The matching method signature from the list of filterMethods is removed and code generation strategies for making
+ * the two methods call each other are added.
*/
private void addBridgeMethod(MethodSignature ms, List filterMethods)
{
@@ -167,7 +165,7 @@
{
MethodSignature fms = (MethodSignature) i.next();
- int position = _filterMethodAnalyzer.findServiceInterfacePosition(ms, fms);
+ int position = filterMethodAnalyzer.findServiceInterfacePosition(ms, fms);
if (position >= 0)
{
@@ -177,19 +175,19 @@
}
}
- String message = ServiceMessages.unmatchedServiceMethod(ms, _filterInterface);
+ String message = ServiceMessages.unmatchedServiceMethod(ms, filterInterface);
- _logger.error(message);
+ logger.error(message);
String code = format("throw new %s(\"%s\");", RuntimeException.class.getName(), message);
- _classFab.addMethod(Modifier.PUBLIC, ms, code);
+ classFab.addMethod(Modifier.PUBLIC, ms, code);
}
/**
- * Adds a method to the class which bridges from the service method to the corresponding method
- * in the filter interface. The next service (either another Bridge, or the terminator at the
- * end of the pipeline) is passed to the filter).
+ * Adds a method to the class which bridges from the service method to the corresponding method in the filter
+ * interface. The next service (either another Bridge, or the terminator at the end of the pipeline) is passed to
+ * the filter).
*/
private void addBridgeMethod(int position, MethodSignature ms, MethodSignature fms)
{
@@ -233,7 +231,7 @@
// This should work, unless the exception types turn out to not be compatble. We still
// don't do a check on that, and not sure that Javassist does either!
- _classFab.addMethod(Modifier.PUBLIC, ms, buffer.toString());
+ classFab.addMethod(Modifier.PUBLIC, ms, buffer.toString());
}
}
\ No newline at end of file
Modified: tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java?rev=653936&r1=653935&r2=653936&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java (original)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/main/java/org/apache/tapestry/ioc/internal/services/ChainBuilderImpl.java Tue May 6 14:52:36 2008
@@ -26,17 +26,17 @@
public class ChainBuilderImpl implements ChainBuilder
{
- private final ClassFactory _classFactory;
+ private final ClassFactory classFactory;
/**
* Map, keyed on service interface, of implementation Class.
*/
- private final Map<Class, Class> _cache = newConcurrentMap();
+ private final Map<Class, Class> cache = newConcurrentMap();
public ChainBuilderImpl(@Builtin ClassFactory classFactory)
{
- _classFactory = classFactory;
+ this.classFactory = classFactory;
}
@SuppressWarnings("unchecked")
@@ -49,12 +49,12 @@
private Class findImplementationClass(Class commandInterface)
{
- Class result = _cache.get(commandInterface);
+ Class result = cache.get(commandInterface);
if (result == null)
{
result = constructImplementationClass(commandInterface);
- _cache.put(commandInterface, result);
+ cache.put(commandInterface, result);
}
return result;
@@ -68,7 +68,7 @@
String name = ClassFabUtils.generateClassName(commandInterface);
- ClassFab cf = _classFactory.newClass(name, Object.class);
+ ClassFab cf = classFactory.newClass(name, Object.class);
addInfrastructure(cf, commandInterface);
@@ -105,7 +105,7 @@
BodyBuilder builder = new BodyBuilder();
builder.addln("_commands = (%s[]) $1.toArray(new %<s[0]);", commandInterface.getName());
- cf.addConstructor(new Class[]{List.class}, null, builder.toString());
+ cf.addConstructor(new Class[] { List.class }, null, builder.toString());
}
@SuppressWarnings("unchecked")