public void inject(InjectionContainer container) { try { Util.rebind(container.getEnc(), encName, obj); } catch (NamingException e) { throw new RuntimeException(new StringBuilder().append("could not bind enc name '").append(encName).append("' for ").append(error).append(" for container ").append(container.getIdentifier()).append(e.getMessage()).toString()); } } }
public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> 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 handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> 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 inject(InjectionContainer container) { try { Util.rebind(container.getEnc(), encName, new LinkRef(jndiName)); } catch (NamingException e) { throw new RuntimeException(new StringBuilder().append("could not bind enc name '").append(encName).append("' for ").append(error).append(" for container ").append(container.getIdentifier()).append(e.getMessage()).toString()); } } }
public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors) { PersistenceUnit ref = method.getAnnotation(PersistenceUnit.class); if (ref == null) return; if (!method.getName().startsWith("set")) throw new RuntimeException("@PersistenceUnit can only be used with a set method: " + method); String encName = ref.name(); if (encName == null || encName.equals("")) { encName = InjectionUtil.getEncName(method); } else { encName = "env/" + encName; } if (!container.getEncInjectors().containsKey(encName)) { container.getEncInjectors().put(encName, new PuEncInjector(encName, method.getParameterTypes()[0], ref.unitName(), "@PersistenceUnit")); try { if (!method.isAnnotationPresent(IgnoreDependency.class)) addPUDependency(ref.unitName(), container); } catch (NameNotFoundException e) { throw new RuntimeException("Illegal @PersistenceUnit on " + method + " :" + e.getMessage()); } } injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc())); }
private void addInjector(InjectionContainer container, String encName, AnnotatedElement annotatedElement) { Injector jndiInjector; if(annotatedElement instanceof Method) jndiInjector = new JndiMethodInjector((Method)annotatedElement, encName, container.getEnc()); else if(annotatedElement instanceof Field) jndiInjector = new JndiFieldInjector((Field)annotatedElement, encName, container.getEnc()); else throw new IllegalStateException("Annotated element for '" + encName + "' is niether Method nor Field: " + annotatedElement); container.getInjectors().add(jndiInjector); }
Context encCtx = container.getEnc(); if (!container.getEncInjectors().containsKey(serviceRefName))
private void addInjector(InjectionContainer container, String encName, AnnotatedElement annotatedElement) { Injector jndiInjector = null; if(annotatedElement instanceof Method) { Method method = (Method) annotatedElement; jndiInjector = new JndiMethodInjector(method, encName, container.getEnc()); addInjector(container, method, method.getDeclaringClass(), jndiInjector); } else if(annotatedElement instanceof Field) { Field field = (Field) annotatedElement; jndiInjector = new JndiFieldInjector(field, encName, container.getEnc()); addInjector(container, field, field.getDeclaringClass(), jndiInjector); } else throw new IllegalStateException("Annotated element for '" + encName + "' is niether Method nor Field: " + annotatedElement); }
public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors) { PersistenceUnit ref = field.getAnnotation(PersistenceUnit.class); if (ref == null) return; String encName = ref.name(); if (encName == null || encName.equals("")) { encName = InjectionUtil.getEncName(field); } else { encName = "env/" + encName; } if (!container.getEncInjectors().containsKey(encName)) { container.getEncInjectors().put(encName, new PuEncInjector(encName, field.getType(), ref.unitName(), "@PersistenceUnit")); try { if (!field.isAnnotationPresent(IgnoreDependency.class)) addPUDependency(ref.unitName(), container); } catch (NameNotFoundException e) { throw new RuntimeException("Illegal @PersistenceUnit on " + field + " :" + e.getMessage()); } } injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc())); } }
public void handleFieldAnnotations(Field field, InjectionContainer container, Map<AccessibleObject, Injector> injectors) { EJB ref = container.getAnnotation(EJB.class, field); if(ref == null) return; String encName = getEncName(ref, field); injectors.put(field, new JndiFieldInjector(field, encName, container.getEnc())); }
Context encCtx = container.getEnc(); if (!container.getEncInjectors().containsKey(serviceRefName))
public void handleMethodAnnotations(Method method, InjectionContainer container, Map<AccessibleObject, Injector> injectors) { EJB ref = container.getAnnotation(EJB.class, method); if(ref == null) return; String encName = getEncName(ref, method); injectors.put(method, new JndiMethodInjector(method, encName, container.getEnc())); }
encName, container.getEnc()));
public void inject(InjectionContainer container) { try { Util.rebind(container.getEnc(), name, getEnvEntryValue(container.getClassloader())); } catch (Exception e) { throw new RuntimeException("Invalid <env-entry> name: " + name, e); } }
encName, container.getEnc()));
public void inject(InjectionContainer container) { Object factory = null; try { factory = PersistenceUnitHandler.getFactory(injectionType, unitName, container); } catch (NameNotFoundException e) { throw new RuntimeException(e); } if (factory == null) { throw new RuntimeException("Failed to locate " + error + " of unit name: " + unitName + " for " + container.getIdentifier()); } try { Util.rebind(container.getEnc(), encName, factory); } catch (Exception e) { throw new RuntimeException("Failed to bind " + error + " of unit name: " + unitName + " ref-name" + encName + " for container " + container.getIdentifier(), e); } } }
/** * Create and add a {@link Injector} into the <code>container</code>, for the passed <code>encName</code> * and <code>annotatedElement</code> * * @param container The container to which the injector will be added * @param encName The ENC name * @param annotatedElement The annotated field/method */ private void addInjector(InjectionContainer container, String encName, AnnotatedElement annotatedElement) { Injector jndiInjector; if(annotatedElement instanceof Method) { BeanProperty prop = BeanPropertyFactory.create((Method) annotatedElement); jndiInjector = new JndiPropertyInjector(prop, encName, container.getEnc()); } else if(annotatedElement instanceof Field) { BeanProperty prop = BeanPropertyFactory.create((Field) annotatedElement); jndiInjector = new JndiPropertyInjector(prop, encName, container.getEnc()); } else { throw new IllegalStateException("Annotated element for '" + encName + "' is niether Method nor Field: " + annotatedElement); } // add the injector container.getInjectors().add(jndiInjector); }
JndiPropertyInjector propInjector = new JndiPropertyInjector(prop, encName, container.getEnc()); container.getInjectors().add(propInjector);
public void inject(InjectionContainer container) { try { Context envCtx = container.getEnc(); ClassLoader loader = container.getClassloader(); UnifiedVirtualFile vfsRoot = UnifiedVirtualFileFactory.getInstance().create(container.getRootFile()); new ServiceReferenceHandler().bindServiceRef(envCtx, name, vfsRoot, loader, sref); } catch (Exception e) { throw new WebServiceException("Unable to bind ServiceRef [enc=" + name + "]", e); } }