/** * @deprecated resolve until a bean name is acquired, do not depend on a business interface */ @Deprecated protected void addDependency(InjectionContainer container, String link, Class<?> businessIntf) { log.warn("EJBTHREE-1828: calling deprecated addDependency"); EJBContainer refCon = (EJBContainer) container.resolveEjbContainer(link, businessIntf); // Do not depend on myself if(container.equals(refCon)) return; ((JBoss5DependencyPolicy) container.getDependencyPolicy()).addDependency(link, businessIntf); }
protected void addJNDIDependency(InjectionContainer container, String jndiName) { // Do not depend on myself if(container.hasJNDIBinding(jndiName)) return; ((JBoss5DependencyPolicy) container.getDependencyPolicy()).addJNDIName(jndiName); } }
public static void addPUDependency(String unitName, InjectionContainer container) throws NameNotFoundException { if(container instanceof ExtendedInjectionContainer) { ExtendedInjectionContainer eic = (ExtendedInjectionContainer) container; try { String dependency = eic.resolvePersistenceUnitSupplier(unitName); container.getDependencyPolicy().addDependency(dependency); } catch(IllegalArgumentException e) { throw new IllegalArgumentException("Container " + container + ERROR_MESSAGE_FAILED_TO_RESOVLE_PU + unitName, e); } return; } throw new UnsupportedOperationException("Container " + container + " does not implement ExtendedInjectionContainer, can't resolve persistence unit " + unitName); }
/** * @deprecated resolve until a bean name is acquired, do not depend on a business interface */ @Deprecated protected void addDependency(InjectionContainer container, Class<?> businessIntf) { log.warn("EJBTHREE-1828: calling deprecated addDependency"); EJBContainer refCon = null; try { refCon = (EJBContainer) container.resolveEjbContainer(businessIntf); } catch(NameNotFoundException e) { // ignore } // Do not depend on myself if(container.equals(refCon)) return; ((JBoss5DependencyPolicy) container.getDependencyPolicy()).addDependency(businessIntf); }
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]); } }
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); } }