JndiInjectHandlerpublic class JndiInjectHandler extends Object implements InjectionHandlerSearches bean class for all @Inject and create Injectors |
Fields Summary |
---|
private static final Logger | log |
Methods Summary |
---|
public void | handleClassAnnotations(java.lang.Class clazz, InjectionContainer container)
// complete
| public void | handleFieldAnnotations(java.lang.reflect.Field field, InjectionContainer container, java.util.Map injectors)
JndiInject ref = field.getAnnotation(JndiInject.class);
if (ref != null)
{
String encName = InjectionUtil.getEncName(field);
if (!container.getEncInjectors().containsKey(encName))
{
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.jndiName(), "@JndiInject"));
}
injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc()));
}
| public void | handleMethodAnnotations(java.lang.reflect.Method method, InjectionContainer container, java.util.Map injectors)
JndiInject ref = method.getAnnotation(JndiInject.class);
if (ref != null)
{
if (!method.getName().startsWith("set"))
throw new RuntimeException("@EJB can only be used with a set method: " + method);
String encName = InjectionUtil.getEncName(method);
if (!container.getEncInjectors().containsKey(encName))
{
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.jndiName(), "@JndiInject"));
}
injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc()));
}
| public void | loadXml(org.jboss.metamodel.descriptor.EnvironmentRefGroup xml, InjectionContainer container)
if (xml == null) return;
if (xml.getJndiRefs() == null) return;
for (JndiRef ref : xml.getJndiRefs())
{
if (ref.getMappedName() == null || ref.getMappedName().equals(""))
throw new RuntimeException("mapped-name is required for " + ref.getJndiRefName() + " of container " + container.getIdentifier());
String encName = "env/" + ref.getJndiRefName();
if (!container.getEncInjectors().containsKey(encName))
{
container.getEncInjectors().put(encName, new LinkRefEncInjector(encName, ref.getMappedName(), "jndi ref"));
}
InjectionUtil.injectionTarget(encName, ref, container, container.getEncInjections());
}
|
|