/** * Inject a value for a Resource from JNDI into an object * @param injectable the object to inject */ public void inject (Object injectable) { if (_target != null) { if (_target instanceof Field) injectField((Field)_target, injectable); else injectMethod((Method)_target, injectable); } else throw new IllegalStateException ("No method or field to inject with "+getJndiName()); }
public Injection getInjection (String jndiName, Class<?> clazz, Method method, Class<?> paramClass) { if (clazz == null || method == null || paramClass == null) return null; List<Injection> injections = getInjections(clazz.getCanonicalName()); if (injections == null) return null; Iterator<Injection> itor = injections.iterator(); Injection injection = null; while (itor.hasNext() && injection == null) { Injection i = itor.next(); if (i.isMethod() && i.getTarget().getName().equals(method.getName()) && paramClass.equals(i.getParamClass())) injection = i; } return injection; }
public void add (Injection injection) { if ((injection==null) || injection.getTargetClass()==null) return; if (LOG.isDebugEnabled()) LOG.debug("Adding injection for class="+(injection.getTargetClass()+ " on a "+(injection.getTarget().getName()))); List<Injection> injections = (List<Injection>)_injectionMap.get(injection.getTargetClass().getCanonicalName()); if (injections==null) { injections = new ArrayList<Injection>(); _injectionMap.put(injection.getTargetClass().getCanonicalName(), injections); } injections.add(injection); }
injection = new Injection(); injection.setTarget(clazz, field, type); injection.setJndiName(name); injection.setMappingName(mappedName); injections.add(injection);
Injection injection = new Injection(); injection.setJndiName(jndiName); injection.setTarget(clazz, targetName, valueClass); injections.add(injection);
public Injection getInjection (String jndiName, Class<?> clazz, Field field) { if (field == null || clazz == null) return null; List<Injection> injections = getInjections(clazz.getCanonicalName()); if (injections == null) return null; Iterator<Injection> itor = injections.iterator(); Injection injection = null; while (itor.hasNext() && injection == null) { Injection i = itor.next(); if (i.isField() && field.getName().equals(i.getTarget().getName())) injection = i; } return injection; }
/** * The Resource must already exist in the ENC of this webapp. * @return the injected valud * @throws NamingException if unable to lookup value */ public Object lookupInjectedValue () throws NamingException { InitialContext context = new InitialContext(); return context.lookup("java:comp/env/"+getJndiName()); }
public void inject (Object injectable) { if (injectable==null) return; //Get all injections pertinent to the Object by //looking at it's class hierarchy Class<?> clazz = injectable.getClass(); while (clazz != null) { List<Injection> injections = _injectionMap.get(clazz.getCanonicalName()); if (injections != null) { for (Injection i : injections) i.inject(injectable); } clazz = clazz.getSuperclass(); } } }
injection = new Injection(); injection.setTarget(clazz, method,paramType,resourceType); injection.setJndiName(name); injection.setMappingName(mappedName); injections.add(injection);
Injection injection = new Injection(); injection.setJndiName(jndiName); injection.setTarget(clazz, targetName, valueClass); injections.add(injection);
public Injection getInjection (String jndiName, Class<?> clazz, Field field) { if (field == null || clazz == null) return null; List<Injection> injections = getInjections(clazz.getCanonicalName()); if (injections == null) return null; Iterator<Injection> itor = injections.iterator(); Injection injection = null; while (itor.hasNext() && injection == null) { Injection i = itor.next(); if (i.isField() && field.getName().equals(i.getTarget().getName())) injection = i; } return injection; }
/** * The Resource must already exist in the ENC of this webapp. * @return the injected valud * @throws NamingException */ public Object lookupInjectedValue () throws NamingException { InitialContext context = new InitialContext(); return context.lookup("java:comp/env/"+getJndiName()); }
public void inject (Object injectable) { if (injectable==null) return; //Get all injections pertinent to the Object by //looking at it's class hierarchy Class<?> clazz = injectable.getClass(); while (clazz != null) { List<Injection> injections = _injectionMap.get(clazz.getCanonicalName()); if (injections != null) { for (Injection i : injections) i.inject(injectable); } clazz = clazz.getSuperclass(); } } }
injection = new Injection(); injection.setTarget(clazz, field, type); injection.setJndiName(name); injection.setMappingName(mappedName); injections.add(injection);
Injection injection = new Injection(); injection.setJndiName(jndiName); injection.setTarget(clazz, targetName, valueClass); injections.add(injection);
/** * Inject a value for a Resource from JNDI into an object * @param injectable */ public void inject (Object injectable) { if (_target != null) { if (_target instanceof Field) injectField((Field)_target, injectable); else injectMethod((Method)_target, injectable); } else throw new IllegalStateException ("No method or field to inject with "+getJndiName()); }
public Injection getInjection (String jndiName, Class<?> clazz, Method method, Class<?> paramClass) { if (clazz == null || method == null || paramClass == null) return null; List<Injection> injections = getInjections(clazz.getCanonicalName()); if (injections == null) return null; Iterator<Injection> itor = injections.iterator(); Injection injection = null; while (itor.hasNext() && injection == null) { Injection i = itor.next(); if (i.isMethod() && i.getTarget().getName().equals(method.getName()) && paramClass.equals(i.getParamClass())) injection = i; } return injection; }
public void add (Injection injection) { if ((injection==null) || injection.getTargetClass()==null) return; if (LOG.isDebugEnabled()) LOG.debug("Adding injection for class="+(injection.getTargetClass()+ " on a "+(injection.getTarget().getName()))); List<Injection> injections = (List<Injection>)_injectionMap.get(injection.getTargetClass().getCanonicalName()); if (injections==null) { injections = new ArrayList<Injection>(); _injectionMap.put(injection.getTargetClass().getCanonicalName(), injections); } injections.add(injection); }
public Injection getInjection (String jndiName, Class<?> clazz, Field field) { if (field == null || clazz == null) return null; List<Injection> injections = getInjections(clazz.getCanonicalName()); if (injections == null) return null; Iterator<Injection> itor = injections.iterator(); Injection injection = null; while (itor.hasNext() && injection == null) { Injection i = itor.next(); if (i.isField() && field.getName().equals(i.getTarget().getName())) injection = i; } return injection; }
/** * The Resource must already exist in the ENC of this webapp. * @return the injected valud * @throws NamingException */ public Object lookupInjectedValue () throws NamingException { InitialContext context = new InitialContext(); return context.lookup("java:comp/env/"+getJndiName()); }