@Override protected InjectionTarget createDescriptor() { return new InjectionTarget(); }
public StringBuffer printInjectableResourceInfo (StringBuffer toStringBuffer) { if( isInjectable() ) { for (InjectionTarget target : getInjectionTargets()) { if( target.isFieldInjectable() ) { toStringBuffer.append("Field-Injectable Resource. Class name = "). append(target.getClassName()).append(" Field name="). append(target.getFieldName()); } else { toStringBuffer.append("Method-Injectable Resource. Class name ="). append(target.getClassName()).append(" Method ="). append(target.getMethodName()); } } } else { toStringBuffer.append("Non-Injectable Resource"); } return toStringBuffer; }
private Field getField(InjectionTarget target, Class resourceClass) throws Exception { Field f = target.getField(); (target.getFieldName()); target.setField(f); "injection-manager.field-not-found", "InjectionManager exception. Field: {0} not found in class: {1}", target.getFieldName(), resourceClass));
private String getComponentEnvName( Class annotatedClass, String fieldName, List<InjectionCapable> injectionResources ) { for (InjectionCapable injectionCapable : injectionResources) { for (com.sun.enterprise.deployment.InjectionTarget target : injectionCapable.getInjectionTargets()) { if( target.isFieldInjectable() ) { // make sure it's a field and not a method if ( annotatedClass.getName().equals(target.getClassName() ) && target.getFieldName().equals( fieldName ) ) { String name = injectionCapable.getComponentEnvName(); if ( ! name.startsWith("java:") ) { name = "java:comp/env/" + name; } return name; } } } } return null; }
InjectionTarget target = new InjectionTarget(); target.setFieldName(f.getName()); target.setClassName(targetClassName); target.setMetadataSource(MetadataSource.ANNOTATION); InjectionTarget target = new InjectionTarget(); target.setMethodName(m.getName()); target.setClassName(targetClassName); target.setMetadataSource(MetadataSource.ANNOTATION);
if( (target.getFieldName() == null) && (target.getMethodName() == null) ) { String injectTargetName = target.getTargetName(); String targetClassName = target.getClassName(); ClassLoader classLoader = getBundleDescriptor().getClassLoader(); target.setMethodName(next.getName()); if( injectable.getInjectResourceType() == null ) { Class[] paramTypes = next.getParameterTypes(); target.setFieldName(injectTargetName); if( injectable.getInjectResourceType() == null ) { String resourceType = f.getType().getName();
if (target.isFieldInjectable()) { java.lang.reflect.Field f = target.getField(); if(f == null) { String fName = target.getFieldName(); Class targetClass = cl.loadClass(target.getClassName()); try { f = targetClass.getDeclaredField(target.getFieldName()); } catch(java.lang.NoSuchFieldException nsfe) {}// ignoring exception if (target.isMethodInjectable()) { Method m = target.getMethod(); if(m == null) { String mName = target.getMethodName(); Class targetClass = cl.loadClass(target.getClassName()); try { m = targetClass.getDeclaredMethod(target.getMethodName()); } catch(java.lang.NoSuchMethodException nsfe) {}// ignoring exception
if (!clazz.getName().equals(target.getClassName())) continue; if( target.isFieldInjectable() ) { f.set(instance, value); } else if( target.isMethodInjectable() ) {
/** * Define implementation of getInjectableResourceByClass here so it * isn't replicated across appclient, web, ejb descriptors. */ protected List<InjectionCapable> getInjectableResourcesByClass(String className, JndiNameEnvironment jndiNameEnv) { List<InjectionCapable> injectables = new LinkedList<InjectionCapable>(); for (InjectionCapable next : getInjectableResources(jndiNameEnv)) { if (next.isInjectable()) { for (InjectionTarget target : next.getInjectionTargets()) { if (target.getClassName().equals(className)) { injectables.add(next); } } } } return injectables; }
private Method getMethod(InjectionCapable resource, InjectionTarget target, Class resourceClass) throws Exception { Method m = target.getMethod(); if(next.getName().equals(target.getMethodName())) { m = next; target.setMethod(m); "injection-manager.method-not-found", "InjectionManager exception. Method: void {0} ({1}) not found in class: {2}", target.getMethodName(), resource.getInjectResourceType(), resourceClass));
/** * write the descriptor class to a DOM tree and return it * * @param parent node in the DOM tree * @param node name for the root element of this xml fragment * @param the descriptor to write * @return the DOM tree top node */ public Node writeDescriptor(Node parent, String nodeName, InjectionTarget descriptor) { Node myNode = appendChild(parent, nodeName); appendTextChild(myNode, TagNames.INJECTION_TARGET_CLASS, descriptor.getClassName()); appendTextChild(myNode, TagNames.INJECTION_TARGET_NAME, descriptor.getTargetName()); return myNode; }
InjectionTarget target = new InjectionTarget(); target.setFieldName(f.getName()); target.setClassName(targetClassName); target.setMetadataSource(MetadataSource.ANNOTATION); InjectionTarget target = new InjectionTarget(); target.setMethodName(m.getName()); target.setClassName(targetClassName); target.setMetadataSource(MetadataSource.ANNOTATION);
if( (target.getFieldName() == null) && (target.getMethodName() == null) ) { String injectTargetName = target.getTargetName(); String targetClassName = target.getClassName(); ClassLoader classLoader = getBundleDescriptor().getClassLoader(); target.setMethodName(next.getName()); if( injectable.getInjectResourceType() == null ) { Class[] paramTypes = next.getParameterTypes(); target.setFieldName(injectTargetName); if( injectable.getInjectResourceType() == null ) { String resourceType = f.getType().getName();
for (InjectionCapable injectionCapable : injectionResources) { for (com.sun.enterprise.deployment.InjectionTarget target : injectionCapable.getInjectionTargets()) { if( target.isFieldInjectable() ) { // make sure it's a field and not a method if ( annotatedClass.getName().equals(target.getClassName() ) && target.getFieldName().equals( annotatedField.getJavaMember().getName() ) ) { String type = injectionCapable.getInjectResourceType(); try {
if (!clazz.getName().equals(target.getClassName())) continue; if( target.isFieldInjectable() ) { f.set(instance, value); } else if( target.isMethodInjectable() ) {
/** * Define implementation of getInjectableResourceByClass here so it * isn't replicated across appclient, web, ejb descriptors. */ protected List<InjectionCapable> getInjectableResourcesByClass(String className, JndiNameEnvironment jndiNameEnv) { List<InjectionCapable> injectables = new LinkedList<InjectionCapable>(); for (InjectionCapable next : getInjectableResources(jndiNameEnv)) { if (next.isInjectable()) { for (InjectionTarget target : next.getInjectionTargets()) { if (target.getClassName().equals(className)) { injectables.add(next); } } } } return injectables; }
private Method getMethod(InjectionCapable resource, InjectionTarget target, Class resourceClass) throws Exception { Method m = target.getMethod(); if(next.getName().equals(target.getMethodName())) { m = next; target.setMethod(m); "injection-manager.method-not-found", "InjectionManager exception. Method: void {0} ({1}) not found in class: {2}", target.getMethodName(), resource.getInjectResourceType(), resourceClass));
/** * write the descriptor class to a DOM tree and return it * * @param parent node in the DOM tree * @param node name for the root element of this xml fragment * @param the descriptor to write * @return the DOM tree top node */ public Node writeDescriptor(Node parent, String nodeName, InjectionTarget descriptor) { Node myNode = appendChild(parent, nodeName); appendTextChild(myNode, TagNames.INJECTION_TARGET_CLASS, descriptor.getClassName()); appendTextChild(myNode, TagNames.INJECTION_TARGET_NAME, descriptor.getTargetName()); return myNode; }
InjectionTarget target = new InjectionTarget(); target.setFieldName(f.getName()); target.setClassName(targetClassName); target.setMetadataSource(MetadataSource.ANNOTATION); InjectionTarget target = new InjectionTarget(); target.setMethodName(m.getName()); target.setClassName(targetClassName); target.setMetadataSource(MetadataSource.ANNOTATION);
public StringBuffer printInjectableResourceInfo (StringBuffer toStringBuffer) { if( isInjectable() ) { for (InjectionTarget target : getInjectionTargets()) { if( target.isFieldInjectable() ) { toStringBuffer.append("Field-Injectable Resource. Class name = "). append(target.getClassName()).append(" Field name="). append(target.getFieldName()); } else { toStringBuffer.append("Method-Injectable Resource. Class name ="). append(target.getClassName()).append(" Method ="). append(target.getMethodName()); } } } else { toStringBuffer.append("Non-Injectable Resource"); } return toStringBuffer; }