DependsHandlerpublic class DependsHandler extends Object implements InjectionHandler
Fields Summary |
---|
private static final Logger | log |
Methods Summary |
---|
public void | handleClassAnnotations(java.lang.Class clazz, InjectionContainer container)
Depends dep = (Depends)container.getAnnotation(Depends.class, clazz);
if (dep == null) return;
for (String dependency : dep.value())
{
container.getDependencyPolicy().addDependency(dependency);
}
| public void | handleFieldAnnotations(java.lang.reflect.Field field, InjectionContainer container, java.util.Map injectors)
Depends dep = container.getAnnotation(Depends.class, field.getDeclaringClass(), field);
if (dep != null)
{
String[] names = dep.value();
if (names.length != 1)
throw new RuntimeException("@Depends on a field can only take one object name: " + field);
ObjectName on = null;
try
{
on = new ObjectName(names[0]);
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException(e);
}
// don't replace other injections
if (injectors.get(field) == null)
injectors.put(field, new DependsFieldInjector(field, on));
container.getDependencyPolicy().addDependency(names[0]);
}
| public void | handleMethodAnnotations(java.lang.reflect.Method method, InjectionContainer container, java.util.Map injectors)
Depends dep = container.getAnnotation(Depends.class, method.getDeclaringClass(), method);
if (dep != null)
{
if (!method.getName().startsWith("set"))
throw new RuntimeException("@EJB can only be used with a set method: " + method);
String[] names = dep.value();
if (names.length != 1)
throw new RuntimeException("@Depends on a field can only take one object name: " + method);
ObjectName on = null;
try
{
on = new ObjectName(names[0]);
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException(e);
}
// don't replace other injections
if (injectors.get(method) == null)
injectors.put(method, new DependsMethodInjector(method, on));
container.getDependencyPolicy().addDependency(names[0]);
}
| public void | loadXml(org.jboss.metamodel.descriptor.EnvironmentRefGroup xml, InjectionContainer container)
|
|