@Stateless @Depends({ "org.hornetq:module=JMS,name=\"" + HarvesterMDB.HARVESTER_QUEUE_NAME + "\",type=Queue",
public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> 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]); } }
@Stateless @Depends("org.hornetq:module=JMS,name=\"DSSTaskQueue\",type=Queue") public class MailManagerBean implements MailManager {
public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> 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 handleClassAnnotations(Class<?> clazz, InjectionContainer container) { Depends dep = container.getAnnotation(Depends.class, clazz); if (dep == null) return; for (String dependency : dep.value()) { container.getDependencyPolicy().addDependency(dependency); } }