[jboss-cvs] JBossAS SVN: r64920 - in projects/microcontainer/trunk: dependency/src/main/org/jboss/dependency/spi and 7 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Aug 28 13:53:21 EDT 2007
Author: adrian at jboss.org
Date: 2007-08-28 13:53:20 -0400 (Tue, 28 Aug 2007)
New Revision: 64920
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractMetaDataVisitor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AnnotationMetaDataVisitor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeMetaDataVisitor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PreprocessMetaDataVisitor.java
Modified:
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java
projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/helpers/UnmodifiableDependencyInfo.java
projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/AbstractDependencyTest.java
projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/CardinalityTestCase.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/helpers/UnmodifiableKernelControllerContext.java
Log:
Refactoring to remove wrong/unnecessary methods from KernelControllerContext. Also fixed some generics while there.
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractController.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -84,8 +84,8 @@
private Set<AbstractController> childControllers = new CopyOnWriteArraySet<AbstractController>();
/** The callback items */
- private Map<Object, Set<CallbackItem>> installCallbacks = new ConcurrentHashMap<Object, Set<CallbackItem>>();
- private Map<Object, Set<CallbackItem>> uninstallCallbacks = new ConcurrentHashMap<Object, Set<CallbackItem>>();
+ private Map<Object, Set<CallbackItem<?>>> installCallbacks = new ConcurrentHashMap<Object, Set<CallbackItem<?>>>();
+ private Map<Object, Set<CallbackItem<?>>> uninstallCallbacks = new ConcurrentHashMap<Object, Set<CallbackItem<?>>>();
/** Whether an on demand context has been enabled */
private boolean onDemandEnabled = true;
@@ -548,7 +548,7 @@
String dependsOn = null;
if (dependencies != null)
{
- Set set = dependencies.getIDependOn(null);
+ Set<DependencyItem> set = dependencies.getIDependOn(null);
if (set != null)
dependsOn = set.toString();
}
@@ -685,7 +685,7 @@
ControllerState fromState = context.getState();
Controller fromController = context.getController();
- Set fromContexts = null;
+ Set<ControllerContext> fromContexts = null;
int currentIndex = -1;
if (ControllerState.ERROR.equals(fromState))
@@ -1026,20 +1026,21 @@
/**
* Add callback item under demand name.
*
+ * @param <T> the callback item type
* @param name demand name
* @param isInstallPhase install or uninstall phase
* @param callback callback item
*/
- protected void addCallback(Object name, boolean isInstallPhase, CallbackItem callback)
+ protected <T> void addCallback(Object name, boolean isInstallPhase, CallbackItem<T> callback)
{
lockWrite();
try
{
- Map<Object, Set<CallbackItem>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
- Set<CallbackItem> callbacks = map.get(name);
+ Map<Object, Set<CallbackItem<?>>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
+ Set<CallbackItem<?>> callbacks = map.get(name);
if (callbacks == null)
{
- callbacks = new HashSet<CallbackItem>();
+ callbacks = new HashSet<CallbackItem<?>>();
map.put(name, callbacks);
}
callbacks.add(callback);
@@ -1053,17 +1054,18 @@
/**
* Remove callback item under demand name.
*
+ * @param <T> the callback item type
* @param name demand name
* @param isInstallPhase install or uninstall phase
* @param callback callback item
*/
- protected void removeCallback(Object name, boolean isInstallPhase, CallbackItem callback)
+ protected <T> void removeCallback(Object name, boolean isInstallPhase, CallbackItem<T> callback)
{
lockWrite();
try
{
- Map<Object, Set<CallbackItem>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
- Set<CallbackItem> callbacks = map.get(name);
+ Map<Object, Set<CallbackItem<?>>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
+ Set<CallbackItem<?>> callbacks = map.get(name);
if (callbacks != null)
{
callbacks.remove(callback);
@@ -1084,7 +1086,7 @@
* @param isInstallPhase install or uninstall phase
* @return callback items from dependency info
*/
- protected Set<CallbackItem> getDependencyCallbacks(ControllerContext context, boolean isInstallPhase)
+ protected Set<CallbackItem<?>> getDependencyCallbacks(ControllerContext context, boolean isInstallPhase)
{
DependencyInfo di = context.getDependencyInfo();
if (di != null)
@@ -1101,14 +1103,14 @@
* @param isInstallPhase install or uninstall phase
* @return all matching registered callbacks or empty set if no such item
*/
- protected Set<CallbackItem> getCallbacks(Object name, boolean isInstallPhase)
+ protected Set<CallbackItem<?>> getCallbacks(Object name, boolean isInstallPhase)
{
lockRead();
try
{
- Map<Object, Set<CallbackItem>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
- Set<CallbackItem> callbacks = map.get(name);
- return callbacks != null ? callbacks : new HashSet<CallbackItem>();
+ Map<Object, Set<CallbackItem<?>>> map = (isInstallPhase ? installCallbacks : uninstallCallbacks);
+ Set<CallbackItem<?>> callbacks = map.get(name);
+ return callbacks != null ? callbacks : new HashSet<CallbackItem<?>>();
}
finally
{
@@ -1125,11 +1127,11 @@
* @param isInstallPhase install or uninstall phase
* @param type install or uninstall type
*/
- protected void resolveCallbacks(Set<CallbackItem> callbacks, ControllerState state, boolean execute, boolean isInstallPhase, boolean type)
+ protected void resolveCallbacks(Set<CallbackItem<?>> callbacks, ControllerState state, boolean execute, boolean isInstallPhase, boolean type)
{
if (callbacks != null && callbacks.isEmpty() == false)
{
- for (CallbackItem callback : callbacks)
+ for (CallbackItem<?> callback : callbacks)
{
if (callback.getWhenRequired().equals(state))
{
@@ -1169,21 +1171,22 @@
try
{
// existing owner callbacks
- Set<CallbackItem> installs = getDependencyCallbacks(context, true);
+ Set<CallbackItem<?>> installs = getDependencyCallbacks(context, true);
resolveCallbacks(installs, state, isInstallPhase, isInstallPhase, true);
- Set<CallbackItem> uninstalls = getDependencyCallbacks(context, false);
+ Set<CallbackItem<?>> uninstalls = getDependencyCallbacks(context, false);
resolveCallbacks(uninstalls, state, isInstallPhase == false, isInstallPhase, false);
// change callbacks, applied only if context is autowire candidate
- if (isAutowireCandidate(context))
+ DependencyInfo dependencyInfo = context.getDependencyInfo();
+ if (dependencyInfo != null && dependencyInfo.isAutowireCandidate())
{
// match callbacks by name
- Set<CallbackItem> existingCallbacks = getCallbacks(context.getName(), isInstallPhase);
+ Set<CallbackItem<?>> existingCallbacks = getCallbacks(context.getName(), isInstallPhase);
// match by classes
Collection<Class<?>> classes = getClassesImplemented(context.getTarget());
if (classes != null && classes.isEmpty() == false)
{
- for (Class clazz : classes)
+ for (Class<?> clazz : classes)
{
existingCallbacks.addAll(getCallbacks(clazz, isInstallPhase));
}
@@ -1192,7 +1195,7 @@
// Do the installs if we are at the required state
if (existingCallbacks != null && existingCallbacks.isEmpty() == false)
{
- for(CallbackItem callback : existingCallbacks)
+ for(CallbackItem<?> callback : existingCallbacks)
{
if (state.equals(callback.getDependentState()))
{
@@ -1276,15 +1279,15 @@
* @param clazz current class
* @param classes classes holder set
*/
- protected void traverseClass(Class clazz, Set<Class<?>> classes)
+ protected void traverseClass(Class<?> clazz, Set<Class<?>> classes)
{
if (clazz != null && Object.class.equals(clazz) == false)
{
classes.add(clazz);
traverseClass(clazz.getSuperclass(), classes);
- Class[] interfaces = clazz.getInterfaces();
+ Class<?>[] interfaces = clazz.getInterfaces();
// traverse interfaces
- for (Class intface : interfaces)
+ for (Class<?> intface : interfaces)
{
traverseClass(intface, classes);
}
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/plugins/AbstractDependencyInfo.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -54,16 +54,17 @@
private Set<DependencyItem> unresolved = new CopyOnWriteArraySet<DependencyItem>();
/** Install callbacks */
- private Set<CallbackItem> installCallbacks = new CopyOnWriteArraySet<CallbackItem>();
+ private Set<CallbackItem<?>> installCallbacks = new CopyOnWriteArraySet<CallbackItem<?>>();
/** Uninstall callbacks */
- private Set<CallbackItem> uninstallCallbacks = new CopyOnWriteArraySet<CallbackItem>();
+ private Set<CallbackItem<?>> uninstallCallbacks = new CopyOnWriteArraySet<CallbackItem<?>>();
/** Lifecycle callbacks */
private List<LifecycleCallbackItem> lifecycleCallbacks = new CopyOnWriteArrayList<LifecycleCallbackItem>();
-
-
+ /** Whether this is an autowire candidate */
+ private boolean autowireCandidate = true;
+
/**
* Create an abstract dependency info
*/
@@ -71,7 +72,7 @@
{
}
- public Set<DependencyItem> getIDependOn(Class type)
+ public Set<DependencyItem> getIDependOn(Class<?> type)
{
if (type == null || iDependOn.isEmpty())
return iDependOn;
@@ -101,7 +102,7 @@
flushJBossObjectCache();
}
- public Set<DependencyItem> getDependsOnMe(Class type)
+ public Set<DependencyItem> getDependsOnMe(Class<?> type)
{
if (type == null || dependsOnMe.isEmpty())
return dependsOnMe;
@@ -151,36 +152,36 @@
return unresolved;
}
- public void addInstallItem(CallbackItem callbackItem)
+ public <T> void addInstallItem(CallbackItem<T> callbackItem)
{
installCallbacks.add(callbackItem);
flushJBossObjectCache();
}
- public void removeInstallItem(CallbackItem callbackItem)
+ public <T> void removeInstallItem(CallbackItem<T> callbackItem)
{
installCallbacks.remove(callbackItem);
flushJBossObjectCache();
}
- public Set<CallbackItem> getInstallItems()
+ public Set<CallbackItem<?>> getInstallItems()
{
return installCallbacks;
}
- public void addUninstallItem(CallbackItem callbackItem)
+ public <T> void addUninstallItem(CallbackItem<T> callbackItem)
{
uninstallCallbacks.add(callbackItem);
flushJBossObjectCache();
}
- public void removeUninstallItem(CallbackItem callbackItem)
+ public <T> void removeUninstallItem(CallbackItem<T> callbackItem)
{
uninstallCallbacks.remove(callbackItem);
flushJBossObjectCache();
}
- public Set<CallbackItem> getUninstallItems()
+ public Set<CallbackItem<?>> getUninstallItems()
{
return uninstallCallbacks;
}
@@ -195,6 +196,16 @@
return lifecycleCallbacks;
}
+ public boolean isAutowireCandidate()
+ {
+ return autowireCandidate;
+ }
+
+ public void setAutowireCandidate(boolean candidate)
+ {
+ this.autowireCandidate = candidate;
+ }
+
public void toString(JBossStringBuilder buffer)
{
buffer.append("idependOn=").append(iDependOn);
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/DependencyInfo.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -40,7 +40,7 @@
* @param type the class of the dependency or null for all types
* @return our dependencies
*/
- Set<DependencyItem> getIDependOn(Class type);
+ Set<DependencyItem> getIDependOn(Class<?> type);
/**
* Return what depends upon me
@@ -48,7 +48,7 @@
* @param type the class of the dependency or null for all types
* @return what depends upon this
*/
- Set<DependencyItem> getDependsOnMe(Class type);
+ Set<DependencyItem> getDependsOnMe(Class<?> type);
/**
* Add a dependency
@@ -97,44 +97,48 @@
/**
* Add a callback reference
*
+ * @param <T> the callback item type
* @param callbackItem the callback to add
*/
- void addInstallItem(CallbackItem callbackItem);
+ <T> void addInstallItem(CallbackItem<T> callbackItem);
/**
* Remove a callback reference
*
+ * @param <T> the callback item type
* @param callbackItem the callback to remove
*/
- void removeInstallItem(CallbackItem callbackItem);
+ <T> void removeInstallItem(CallbackItem<T> callbackItem);
/**
* Return install callbacks.
*
* @return our install callbacks
*/
- Set<CallbackItem> getInstallItems();
+ Set<CallbackItem<?>> getInstallItems();
/**
* Add a callback reference
*
+ * @param <T> the callback item type
* @param callbackItem the callback to add
*/
- void addUninstallItem(CallbackItem callbackItem);
+ <T> void addUninstallItem(CallbackItem<T> callbackItem);
/**
* Remove a callback reference
*
+ * @param <T> the callback item type
* @param callbackItem the callback to remove
*/
- void removeUninstallItem(CallbackItem callbackItem);
+ <T> void removeUninstallItem(CallbackItem<T> callbackItem);
/**
* Return uninstall callbacks.
*
* @return our uninstall callbacks
*/
- Set<CallbackItem> getUninstallItems();
+ Set<CallbackItem<?>> getUninstallItems();
/**
* Add a lifecycle callback
@@ -149,4 +153,18 @@
* @return our lifecycle callbacks
*/
List<LifecycleCallbackItem> getLifecycleCallbacks();
+
+ /**
+ * Can we use this context for autowiring.
+ *
+ * @return true if context can be used for autowiring
+ */
+ boolean isAutowireCandidate();
+
+ /**
+ * Set whether this is an autowire candidate
+ *
+ * @param candidate true if it is a candidate for autowiring
+ */
+ void setAutowireCandidate(boolean candidate);
}
\ No newline at end of file
Modified: projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/helpers/UnmodifiableDependencyInfo.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/helpers/UnmodifiableDependencyInfo.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/dependency/src/main/org/jboss/dependency/spi/helpers/UnmodifiableDependencyInfo.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -48,12 +48,12 @@
this.delegate = delegate;
}
- public Set<DependencyItem> getIDependOn(Class type)
+ public Set<DependencyItem> getIDependOn(Class<?> type)
{
return delegate.getIDependOn(type);
}
- public Set<DependencyItem> getDependsOnMe(Class type)
+ public Set<DependencyItem> getDependsOnMe(Class<?> type)
{
return delegate.getDependsOnMe(type);
}
@@ -88,32 +88,32 @@
return delegate.getUnresolvedDependencies();
}
- public void addInstallItem(CallbackItem callbackItem)
+ public <T> void addInstallItem(CallbackItem<T> callbackItem)
{
throw new UnsupportedOperationException("Cannot execute add on unmodifiable wrapper.");
}
- public void removeInstallItem(CallbackItem callbackItem)
+ public <T> void removeInstallItem(CallbackItem<T> callbackItem)
{
throw new UnsupportedOperationException("Cannot execute remove on unmodifiable wrapper.");
}
- public Set<CallbackItem> getInstallItems()
+ public Set<CallbackItem<?>> getInstallItems()
{
return delegate.getInstallItems();
}
- public void addUninstallItem(CallbackItem callbackItem)
+ public <T> void addUninstallItem(CallbackItem<T> callbackItem)
{
throw new UnsupportedOperationException("Cannot execute add on unmodifiable wrapper.");
}
- public void removeUninstallItem(CallbackItem callbackItem)
+ public <T> void removeUninstallItem(CallbackItem<T> callbackItem)
{
throw new UnsupportedOperationException("Cannot execute remove on unmodifiable wrapper.");
}
- public Set<CallbackItem> getUninstallItems()
+ public Set<CallbackItem<?>> getUninstallItems()
{
return delegate.getUninstallItems();
}
@@ -127,4 +127,14 @@
{
return delegate.getLifecycleCallbacks();
}
+
+ public boolean isAutowireCandidate()
+ {
+ return delegate.isAutowireCandidate();
+ }
+
+ public void setAutowireCandidate(boolean candidate)
+ {
+ throw new UnsupportedOperationException("Cannot execute set on unmodifiable wrapper.");
+ }
}
Modified: projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/AbstractDependencyTest.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/AbstractDependencyTest.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/AbstractDependencyTest.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -171,7 +171,7 @@
* @return the delegate
* @throws Exception for any error
*/
- public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
{
AbstractTestDelegate delegate = new AbstractTestDelegate(clazz);
delegate.enableSecurity = true;
Modified: projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/CardinalityTestCase.java
===================================================================
--- projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/CardinalityTestCase.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/dependency/src/tests/org/jboss/test/dependency/controller/test/CardinalityTestCase.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -50,7 +50,7 @@
* @return the delegate
* @throws Exception for any error
*/
- public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ public static AbstractTestDelegate getDelegate(Class<?> clazz) throws Exception
{
return new AbstractTestDelegate(clazz);
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/beans/metadata/spi/MetaDataVisitor.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -67,16 +67,18 @@
/**
* Add an install callback
*
+ * @param <T> the callback item type
* @param callback the callback
*/
- void addInstallCallback(CallbackItem callback);
+ <T> void addInstallCallback(CallbackItem<T> callback);
/**
* Add an uninstall callback
*
+ * @param <T> the callback item type
* @param callback the callback
*/
- void addUninstallCallback(CallbackItem callback);
+ <T> void addUninstallCallback(CallbackItem<T> callback);
/**
* Visit the node
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/CallbackAnnotationPlugin.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -56,10 +56,10 @@
protected boolean isMetaDataAlreadyPresent(T info, C annotation, KernelControllerContext context)
{
DependencyInfo dependency = context.getDependencyInfo();
- Set<CallbackItem> callbacks = getCallbacks(dependency);
+ Set<CallbackItem<?>> callbacks = getCallbacks(dependency);
if (callbacks != null && callbacks.isEmpty() == false)
{
- for(CallbackItem ci : callbacks)
+ for(CallbackItem<?> ci : callbacks)
{
if (isEqual(info, ci))
return true;
@@ -68,9 +68,9 @@
return false;
}
- protected abstract boolean isEqual(T info, CallbackItem ci);
+ protected abstract boolean isEqual(T info, CallbackItem<?> ci);
- protected abstract Set<CallbackItem> getCallbacks(DependencyInfo dependency);
+ protected abstract Set<CallbackItem<?>> getCallbacks(DependencyInfo dependency);
protected List<? extends MetaDataVisitorNode> internalApplyAnnotation(T info, C annotation, KernelControllerContext context)
{
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/InstallCallbackAnnotationPlugin.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -47,7 +47,7 @@
super(Install.class);
}
- protected Set<CallbackItem> getCallbacks(DependencyInfo dependency)
+ protected Set<CallbackItem<?>> getCallbacks(DependencyInfo dependency)
{
return dependency.getInstallItems();
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/annotations/UninstallCallbackAnnotationPlugin.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -47,7 +47,7 @@
super(Uninstall.class);
}
- protected Set<CallbackItem> getCallbacks(DependencyInfo dependency)
+ protected Set<CallbackItem<?>> getCallbacks(DependencyInfo dependency)
{
return dependency.getUninstallItems();
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelController.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -63,7 +63,7 @@
protected Map<Object, List<KernelControllerContext>> suppliers = new ConcurrentHashMap<Object, List<KernelControllerContext>>();
/** The contexts by class Map<Class, Set<ControllerContext>> */
- protected Map<Class, ClassContext> contextsByClass = new ConcurrentHashMap<Class, ClassContext>();
+ protected Map<Class<?>, ClassContext> contextsByClass = new ConcurrentHashMap<Class<?>, ClassContext>();
/**
* Create an abstract kernel controller
@@ -102,7 +102,7 @@
if (list != null && list.isEmpty() == false)
return list.get(0);
else if (name instanceof Class)
- return getContextByClass((Class)name);
+ return getContextByClass((Class<?>) name);
else
return null;
}
@@ -230,7 +230,7 @@
* @param clazz the class type
* @return contexts by class
*/
- protected Set<KernelControllerContext> getContexts(Class clazz)
+ protected Set<KernelControllerContext> getContexts(Class<?> clazz)
{
ClassContext classContext = contextsByClass.get(clazz);
if (classContext != null)
@@ -248,7 +248,7 @@
/**
* @return all instantiated contexts whose target is instance of this class clazz param
*/
- public Set<KernelControllerContext> getInstantiatedContexts(Class clazz)
+ public Set<KernelControllerContext> getInstantiatedContexts(Class<?> clazz)
{
lockRead();
try
@@ -262,7 +262,7 @@
}
}
- public Set<KernelControllerContext> getContexts(Class clazz, ControllerState state)
+ public Set<KernelControllerContext> getContexts(Class<?> clazz, ControllerState state)
{
lockRead();
try
@@ -326,7 +326,7 @@
* @param addition whether this is an addition
* @param trace whether trace is enabled
*/
- protected void traverseBean(KernelControllerContext context, Class clazz, boolean addition, boolean trace)
+ protected void traverseBean(KernelControllerContext context, Class<?> clazz, boolean addition, boolean trace)
{
if (clazz == null || clazz == Object.class)
{
@@ -364,9 +364,9 @@
}
// traverse superclass
traverseBean(context, clazz.getSuperclass(), addition, trace);
- Class[] interfaces = clazz.getInterfaces();
+ Class<?>[] interfaces = clazz.getInterfaces();
// traverse interfaces
- for(Class intface : interfaces)
+ for(Class<?> intface : interfaces)
{
traverseBean(context, intface, addition, trace);
}
@@ -384,7 +384,7 @@
*
* @return context whose target is instance of this class clazz param or null if zero or multiple such instances
*/
- public KernelControllerContext getContextByClass(Class clazz)
+ public KernelControllerContext getContextByClass(Class<?> clazz)
{
Set<KernelControllerContext> contexts = getInstantiatedContexts(clazz);
int numberOfMatchingBeans = 0;
@@ -408,13 +408,4 @@
}
return contexts.iterator().next();
}
-
- protected boolean isAutowireCandidate(ControllerContext context)
- {
- if (context instanceof KernelControllerContext)
- {
- return ((KernelControllerContext)context).isAutowireCandidate();
- }
- return super.isAutowireCandidate(context);
- }
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractKernelControllerContext.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -23,26 +23,18 @@
import java.security.AccessControlContext;
import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.Iterator;
import java.util.Set;
-import java.util.Stack;
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.metadata.spi.BeanMetaData;
-import org.jboss.beans.metadata.spi.MetaDataVisitor;
-import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
import org.jboss.dependency.plugins.AbstractControllerContext;
import org.jboss.dependency.plugins.AbstractDependencyInfo;
-import org.jboss.dependency.spi.CallbackItem;
import org.jboss.dependency.spi.Controller;
import org.jboss.dependency.spi.ControllerMode;
-import org.jboss.dependency.spi.ControllerState;
import org.jboss.dependency.spi.DependencyInfo;
import org.jboss.dependency.spi.DependencyItem;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.config.Configurator;
-import org.jboss.kernel.plugins.annotations.BeanAnnotationAdapterFactory;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
@@ -101,6 +93,8 @@
ControllerMode mode = metaData.getMode();
if (mode != null)
setMode(mode);
+ boolean autowireCandidate = metaData.isAutowireCandidate();
+ getDependencyInfo().setAutowireCandidate(autowireCandidate);
if (System.getSecurityManager() != null)
accessContext = AccessController.getContext();
}
@@ -169,11 +163,6 @@
return installScope;
}
- public boolean isAutowireCandidate()
- {
- return metaData != null && metaData.isAutowireCandidate();
- }
-
public void setInstallScope(ScopeKey key)
{
this.installScope = key;
@@ -200,7 +189,7 @@
if (metaData == null)
return;
if (isInitialProcessed) return;
- PreprocessMetaDataVisitor visitor = new PreprocessMetaDataVisitor(metaData);
+ PreprocessMetaDataVisitor visitor = new PreprocessMetaDataVisitor(metaData, this);
AccessController.doPrivileged(visitor);
isInitialProcessed = true;
}
@@ -216,7 +205,7 @@
return;
}
if (isDescribeProcessed) return;
- DescribedMetaDataVisitor visitor = new DescribedMetaDataVisitor(metaData);
+ DescribedMetaDataVisitor visitor = new DescribedMetaDataVisitor(metaData, this);
AccessController.doPrivileged(visitor);
isDescribeProcessed = true;
}
@@ -275,233 +264,4 @@
{
return Configurator.getClassLoader(getBeanMetaData());
}
-
- public void applyMetaData() throws Throwable
- {
- // handle custom annotations
- AnnotationMetaDataVisitor annotationsVisitor = new AnnotationMetaDataVisitor(metaData);
- annotationsVisitor.before();
- try
- {
- BeanAnnotationAdapterFactory.getBeanAnnotationAdapter().applyAnnotations(annotationsVisitor);
- }
- finally
- {
- annotationsVisitor.after();
- }
- }
-
- protected abstract class AbstractMetaDataVistor implements MetaDataVisitor
- {
- /**
- * The current context for when the dependencies are required
- */
- protected ControllerState contextState = ControllerState.INSTANTIATED;
-
- /**
- * The metadata
- */
- protected BeanMetaData bmd;
-
- /**
- * Visited branch stack
- */
- protected Stack<MetaDataVisitorNode> visitorNodeStack;
-
- protected AbstractMetaDataVistor(BeanMetaData bmd)
- {
- this.bmd = bmd;
- this.visitorNodeStack = new Stack<MetaDataVisitorNode>();
- }
-
- public void initialVisit(MetaDataVisitorNode node)
- {
- visitorNodeStack.push(node);
- try
- {
- internalInitialVisit(node);
- }
- finally
- {
- visitorNodeStack.pop();
- }
- }
-
- public void describeVisit(MetaDataVisitorNode node)
- {
- visitorNodeStack.push(node);
- try
- {
- internalDescribeVisit(node);
- }
- finally
- {
- visitorNodeStack.pop();
- }
- }
-
- protected void internalInitialVisit(MetaDataVisitorNode node)
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- log.trace("Initial visit node " + node);
-
- // Visit the children of this node
- Iterator children = node.getChildren();
- if (children != null)
- {
- ControllerState restoreState = contextState;
- while (children.hasNext())
- {
- MetaDataVisitorNode child = (MetaDataVisitorNode) children.next();
- try
- {
- child.initialVisit(this);
- }
- finally
- {
- contextState = restoreState;
- }
- }
- }
- }
-
- protected void internalDescribeVisit(MetaDataVisitorNode node)
- {
- boolean trace = log.isTraceEnabled();
- if (trace)
- log.trace("Describe visit node " + node);
-
- // Visit the children of this node
- Iterator children = node.getChildren();
- if (children != null)
- {
- ControllerState restoreState = contextState;
- while (children.hasNext())
- {
- MetaDataVisitorNode child = (MetaDataVisitorNode) children.next();
- try
- {
- child.describeVisit(this);
- }
- finally
- {
- contextState = restoreState;
- }
- }
- }
- }
-
- public KernelControllerContext getControllerContext()
- {
- return AbstractKernelControllerContext.this;
- }
-
- public ControllerState getContextState()
- {
- return contextState;
- }
-
- public void addDependency(DependencyItem dependency)
- {
- getDependencyInfo().addIDependOn(dependency);
- }
-
- public void addInstallCallback(CallbackItem callback)
- {
- getDependencyInfo().addInstallItem(callback);
- }
-
- public void addUninstallCallback(CallbackItem callback)
- {
- getDependencyInfo().addUninstallItem(callback);
- }
-
- public void setContextState(ControllerState contextState)
- {
- this.contextState = contextState;
- }
-
- public Stack<MetaDataVisitorNode> visitorNodeStack()
- {
- return visitorNodeStack;
- }
-
- }
-
- /**
- * A visitor for the metadata that looks for dependencies.
- */
- protected class PreprocessMetaDataVisitor extends AbstractMetaDataVistor implements PrivilegedAction<Object>
- {
- /**
- * Create a new MetaDataVisitor.
- *
- * @param bmd the bean metadata
- */
- public PreprocessMetaDataVisitor(BeanMetaData bmd)
- {
- super(bmd);
- }
-
- /**
- * Visit the bean metadata node, this is the starting point
- */
- public Object run()
- {
- bmd.initialVisit(this);
- visitorNodeStack = null;
- return null;
- }
- }
-
- /**
- * A visitor for the metadata that looks for dependencies.
- */
- protected class DescribedMetaDataVisitor extends AbstractMetaDataVistor implements PrivilegedAction<Object>
- {
- /**
- * Create a new MetaDataVisitor.
- *
- * @param bmd the bean meta data
- */
- public DescribedMetaDataVisitor(BeanMetaData bmd)
- {
- super(bmd);
- }
-
- /**
- * Visit the bean metadata node, this is the starting point
- */
- public Object run()
- {
- bmd.describeVisit(this);
- visitorNodeStack = null;
- return null;
- }
- }
-
- /**
- * A visitor for the annotation meta data.
- */
- private class AnnotationMetaDataVisitor extends AbstractMetaDataVistor
- {
- public AnnotationMetaDataVisitor(BeanMetaData bmd)
- {
- super(bmd);
- }
-
- // push bean meta data as first node
- public void before()
- {
- visitorNodeStack.push(bmd);
- }
-
- // remove bean meta data
- public void after()
- {
- visitorNodeStack.pop();
- visitorNodeStack = null;
- }
- }
}
\ No newline at end of file
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractMetaDataVisitor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractMetaDataVisitor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AbstractMetaDataVisitor.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -0,0 +1,187 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.dependency;
+
+import java.util.Iterator;
+import java.util.Stack;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.beans.metadata.spi.MetaDataVisitor;
+import org.jboss.beans.metadata.spi.MetaDataVisitorNode;
+import org.jboss.dependency.spi.CallbackItem;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.dependency.spi.DependencyInfo;
+import org.jboss.dependency.spi.DependencyItem;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.logging.Logger;
+
+/**
+ * AbstractMetaDataVistor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractMetaDataVisitor implements MetaDataVisitor
+{
+ /** The log */
+ private static final Logger log = Logger.getLogger(AbstractMetaDataVisitor.class);
+
+ /** The current context for when the dependencies are required */
+ protected ControllerState contextState = ControllerState.INSTANTIATED;
+
+ /* The metadata */
+ protected BeanMetaData bmd;
+
+ /** The controller context */
+ protected KernelControllerContext context;
+
+ /**
+ * Visited branch stack
+ */
+ protected Stack<MetaDataVisitorNode> visitorNodeStack;
+
+ protected AbstractMetaDataVisitor(BeanMetaData bmd, KernelControllerContext context)
+ {
+ this.bmd = bmd;
+ this.context = context;
+ this.visitorNodeStack = new Stack<MetaDataVisitorNode>();
+ }
+
+ public void initialVisit(MetaDataVisitorNode node)
+ {
+ visitorNodeStack.push(node);
+ try
+ {
+ internalInitialVisit(node);
+ }
+ finally
+ {
+ visitorNodeStack.pop();
+ }
+ }
+
+ public void describeVisit(MetaDataVisitorNode node)
+ {
+ visitorNodeStack.push(node);
+ try
+ {
+ internalDescribeVisit(node);
+ }
+ finally
+ {
+ visitorNodeStack.pop();
+ }
+ }
+
+ protected void internalInitialVisit(MetaDataVisitorNode node)
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Initial visit node " + node);
+
+ // Visit the children of this node
+ Iterator<? extends MetaDataVisitorNode> children = node.getChildren();
+ if (children != null)
+ {
+ ControllerState restoreState = contextState;
+ while (children.hasNext())
+ {
+ MetaDataVisitorNode child = children.next();
+ try
+ {
+ child.initialVisit(this);
+ }
+ finally
+ {
+ contextState = restoreState;
+ }
+ }
+ }
+ }
+
+ protected void internalDescribeVisit(MetaDataVisitorNode node)
+ {
+ boolean trace = log.isTraceEnabled();
+ if (trace)
+ log.trace("Describe visit node " + node);
+
+ // Visit the children of this node
+ Iterator<? extends MetaDataVisitorNode> children = node.getChildren();
+ if (children != null)
+ {
+ ControllerState restoreState = contextState;
+ while (children.hasNext())
+ {
+ MetaDataVisitorNode child = children.next();
+ try
+ {
+ child.describeVisit(this);
+ }
+ finally
+ {
+ contextState = restoreState;
+ }
+ }
+ }
+ }
+
+ public KernelControllerContext getControllerContext()
+ {
+ return context;
+ }
+
+ public ControllerState getContextState()
+ {
+ return contextState;
+ }
+
+ public DependencyInfo getDependencyInfo()
+ {
+ return context.getDependencyInfo();
+ }
+
+ public void addDependency(DependencyItem dependency)
+ {
+ getDependencyInfo().addIDependOn(dependency);
+ }
+
+ public <T> void addInstallCallback(CallbackItem<T> callback)
+ {
+ getDependencyInfo().addInstallItem(callback);
+ }
+
+ public <T> void addUninstallCallback(CallbackItem<T> callback)
+ {
+ getDependencyInfo().addUninstallItem(callback);
+ }
+
+ public void setContextState(ControllerState contextState)
+ {
+ this.contextState = contextState;
+ }
+
+ public Stack<MetaDataVisitorNode> visitorNodeStack()
+ {
+ return visitorNodeStack;
+ }
+
+}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AnnotationMetaDataVisitor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AnnotationMetaDataVisitor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/AnnotationMetaDataVisitor.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -0,0 +1,51 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.dependency;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * AnnotationMetaDataVisitor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class AnnotationMetaDataVisitor extends AbstractMetaDataVisitor
+{
+ public AnnotationMetaDataVisitor(KernelControllerContext context)
+ {
+ super(context.getBeanMetaData(), context);
+ }
+
+ // push bean meta data as first node
+ public void before()
+ {
+ visitorNodeStack.push(bmd);
+ }
+
+ // remove bean meta data
+ public void after()
+ {
+ visitorNodeStack.pop();
+ visitorNodeStack = null;
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/CallbackDependencyItem.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -40,7 +40,7 @@
{
private Cardinality cardinality;
- public CallbackDependencyItem(Object name, Class demandClass, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality)
+ public CallbackDependencyItem(Object name, Class<?> demandClass, ControllerState whenRequired, ControllerState dependentState, Cardinality cardinality)
{
super(name, demandClass, whenRequired, dependentState);
if (cardinality == null)
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeAction.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -25,6 +25,7 @@
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.classadapter.spi.DependencyBuilderListItem;
+import org.jboss.kernel.plugins.annotations.BeanAnnotationAdapterFactory;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.dependency.KernelControllerContext;
import org.jboss.kernel.spi.metadata.KernelMetaDataRepository;
@@ -57,7 +58,17 @@
dependencyItem.addDependency(context);
}
}
- context.applyMetaData();
+ // handle custom annotations
+ AnnotationMetaDataVisitor annotationsVisitor = new AnnotationMetaDataVisitor(context);
+ annotationsVisitor.before();
+ try
+ {
+ BeanAnnotationAdapterFactory.getBeanAnnotationAdapter().applyAnnotations(annotationsVisitor);
+ }
+ finally
+ {
+ annotationsVisitor.after();
+ }
}
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeMetaDataVisitor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeMetaDataVisitor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/DescribeMetaDataVisitor.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.dependency;
+
+import java.security.PrivilegedAction;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * DescribedMetaDataVisitor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class DescribedMetaDataVisitor extends AbstractMetaDataVisitor implements PrivilegedAction<Object>
+{
+ /**
+ * Create a new MetaDataVisitor.
+ *
+ * @param bmd the bean meta data
+ * @param context the context
+ */
+ public DescribedMetaDataVisitor(BeanMetaData bmd, KernelControllerContext context)
+ {
+ super(bmd, context);
+ }
+
+ /**
+ * Visit the bean metadata node, this is the starting point
+ */
+ public Object run()
+ {
+ bmd.describeVisit(this);
+ visitorNodeStack = null;
+ return null;
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/InstantiateAction.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -23,6 +23,7 @@
import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.dependency.spi.DependencyInfo;
import org.jboss.joinpoint.spi.Joinpoint;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.config.KernelConfigurator;
@@ -62,7 +63,8 @@
context.setBeanInfo(info);
}
- if (context.isAutowireCandidate())
+ DependencyInfo dependencyInfo = context.getDependencyInfo();
+ if (dependencyInfo != null && dependencyInfo.isAutowireCandidate())
controller.addInstantiatedContext(context);
}
catch (Throwable t)
@@ -88,7 +90,8 @@
// ((KernelControllerContextAware) object).unsetKernelControllerContext(context);
KernelController controller = (KernelController) context.getController();
- if (context.isAutowireCandidate())
+ DependencyInfo dependencyInfo = context.getDependencyInfo();
+ if (dependencyInfo != null && dependencyInfo.isAutowireCandidate())
controller.removeInstantiatedContext(context);
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PreprocessMetaDataVisitor.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PreprocessMetaDataVisitor.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dependency/PreprocessMetaDataVisitor.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2007, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.dependency;
+
+import java.security.PrivilegedAction;
+
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+
+/**
+ * PreprocessMetaDataVisitor.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+class PreprocessMetaDataVisitor extends AbstractMetaDataVisitor implements PrivilegedAction<Object>
+{
+ /**
+ * Create a new MetaDataVisitor.
+ *
+ * @param bmd the bean metadata
+ * @param context the controller context
+ */
+ public PreprocessMetaDataVisitor(BeanMetaData bmd, KernelControllerContext context)
+ {
+ super(bmd, context);
+ }
+
+ /**
+ * Visit the bean metadata node, this is the starting point
+ */
+ public Object run()
+ {
+ bmd.initialVisit(this);
+ visitorNodeStack = null;
+ return null;
+ }
+}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelController.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -80,7 +80,7 @@
* @param clazz the type
* @return the contexts
*/
- Set<KernelControllerContext> getInstantiatedContexts(Class clazz);
+ Set<KernelControllerContext> getInstantiatedContexts(Class<?> clazz);
/**
* Get all contexts of a type which are at least in state.
@@ -89,7 +89,7 @@
* @param state the required state
* @return the contexts
*/
- Set<KernelControllerContext> getContexts(Class clazz, ControllerState state);
+ Set<KernelControllerContext> getContexts(Class<?> clazz, ControllerState state);
/**
* If zero or multiple instances match class clazz
@@ -98,7 +98,7 @@
* @param clazz the type
* @return context whose target is instance of this class clazz param or null if zero or multiple such instances
*/
- KernelControllerContext getContextByClass(Class clazz);
+ KernelControllerContext getContextByClass(Class<?> clazz);
/**
* Add instantiated context into contextsByClass map
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/KernelControllerContext.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -106,19 +106,4 @@
* @param key the scope key
*/
void setInstallScope(ScopeKey key);
-
- /**
- * Can we use this context for autowiring.
- *
- * @return true if context can be used for autowiring
- */
- boolean isAutowireCandidate();
-
- /**
- * Do apply meta data.
- * Hide details of applying annotations.
- *
- * @throws Throwable for any error
- */
- void applyMetaData() throws Throwable;
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/helpers/UnmodifiableKernelControllerContext.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/helpers/UnmodifiableKernelControllerContext.java 2007-08-28 17:07:50 UTC (rev 64919)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/dependency/helpers/UnmodifiableKernelControllerContext.java 2007-08-28 17:53:20 UTC (rev 64920)
@@ -97,11 +97,6 @@
throw new UnsupportedOperationException("Cannot execute set on unmodifiable wrapper.");
}
- public boolean isAutowireCandidate()
- {
- return delegate.isAutowireCandidate();
- }
-
public void setName(Object name)
{
throw new UnsupportedOperationException("Cannot execute set on unmodifiable wrapper.");
@@ -126,9 +121,4 @@
{
delegate.set(name, value);
}
-
- public void applyMetaData() throws Throwable
- {
- delegate.applyMetaData();
- }
}
More information about the jboss-cvs-commits
mailing list