@Override public void visitEnd() { String value = getValue(); if (value == null || value.equals("")) { // Set the class name if there is no value value = getAnnotationMetadata().getJClass().getName(); if (value.contains("/")) { value = value.substring(value.lastIndexOf("/") + 1); } } getAnnotationMetadata().setManagedBeanName(value); }
@Override public void visitEnd() { String value = getValue(); if (value == null || value.equals("")) { // Set the class name if there is no value value = getAnnotationMetadata().getJClass().getName(); if (value.contains("/")) { value = value.substring(value.lastIndexOf("/") + 1); } } getAnnotationMetadata().setManagedBeanName(value); }
/** * Gets the ENC name for the given metadata. * @param commonMetadata the metadata to analyze. * @param o the given object associated to the metadata (used for logging). * @return the given ENC name * @throws ENCBindingException if no name has been defined on the given name * and the metadata is invalid. */ private String getName(final ISharedMetadata commonMetadata, final Object o) throws ENCBindingException { if (commonMetadata instanceof CommonFieldMetadata) { CommonFieldMetadata<?, ?, ?> fieldAnnotationMetadata = (CommonFieldMetadata<?, ?, ?>) commonMetadata; return fieldAnnotationMetadata.getClassMetadata().getJClass().getName().replace("/", ".") + "/" + fieldAnnotationMetadata.getJField().getName(); } if (commonMetadata instanceof CommonMethodMetadata) { CommonMethodMetadata<?, ?, ?> methodAnnotationMetadata = (CommonMethodMetadata<?, ?, ?>) commonMetadata; StringBuilder propertyBuilder = new StringBuilder(methodAnnotationMetadata.getJMethod().getName()); propertyBuilder.delete(0, GETTER_LENGTH); propertyBuilder.setCharAt(0, Character.toLowerCase(propertyBuilder.charAt(0))); propertyBuilder.insert(0, methodAnnotationMetadata.getClassMetadata().getJClass().getName().replace("/", ".") + "/"); return propertyBuilder.toString(); } // Last case is the Class case. throw new ENCBindingException("There is no defined name in the object '" + o + "' that is defined on the class '" + commonMetadata + "'."); }
/** * Gets the ENC name for the given metadata. * @param commonMetadata the metadata to analyze. * @param o the given object associated to the metadata (used for logging). * @return the given ENC name * @throws ENCBindingException if no name has been defined on the given name * and the metadata is invalid. */ private String getName(final ISharedMetadata commonMetadata, final Object o) throws ENCBindingException { if (commonMetadata instanceof CommonFieldMetadata) { CommonFieldMetadata<?, ?, ?> fieldAnnotationMetadata = (CommonFieldMetadata<?, ?, ?>) commonMetadata; return fieldAnnotationMetadata.getClassMetadata().getJClass().getName().replace("/", ".") + "/" + fieldAnnotationMetadata.getJField().getName(); } if (commonMetadata instanceof CommonMethodMetadata) { CommonMethodMetadata<?, ?, ?> methodAnnotationMetadata = (CommonMethodMetadata<?, ?, ?>) commonMetadata; StringBuilder propertyBuilder = new StringBuilder(methodAnnotationMetadata.getJMethod().getName()); propertyBuilder.delete(0, GETTER_LENGTH); propertyBuilder.setCharAt(0, Character.toLowerCase(propertyBuilder.charAt(0))); propertyBuilder.insert(0, methodAnnotationMetadata.getClassMetadata().getJClass().getName().replace("/", ".") + "/"); return propertyBuilder.toString(); } // Last case is the Class case. throw new ENCBindingException("There is no defined name in the object '" + o + "' that is defined on the class '" + commonMetadata + "'."); }
/** * Returns the value of the @RunAs annotation if present, null otherwise * @param servlet The given servlet * @param metadata The webapp metadata * @return The value of the @RunAs annotation if present, null otherwise */ private String runAsAnnotationValue(final Servlet servlet, final IWarDeployableMetadata metadata) { Collection<IWarClassMetadata> classes = metadata.getWarClassMetadataCollection(); for (IWarClassMetadata clazz : classes) { String className = clazz.getJClass().getName(); className = className.replace("/", "."); // Found a @RunAs annotation declaration into the servlet class if (className.equals(servlet.getServletClass()) && clazz.getRunAs() != null) { return clazz.getRunAs(); } } // No @RunAs annotation found return null; }
private static Map<String, IWarClassMetadata> findPOJOWebService(final IWarDeployableMetadata warDeployableMetadata) { Map<String, IWarClassMetadata> services = new Hashtable<String, IWarClassMetadata>(); Collection<IWarClassMetadata> classes = warDeployableMetadata.getWarClassMetadataCollection(); for (IWarClassMetadata clazz : classes) { // 512 is the marker byte for interface in ASM boolean isInterface = (clazz.getJClass().getAccess() & 512) != 0; boolean isAbstract= (clazz.getJClass().getAccess() & 1024) != 0; // Only deal with concrete classes annotated with @WebService or @WebServiceProvider boolean isAnnotated = (clazz.getWebServiceMarker() != null); if (!isInterface && !isAbstract && isAnnotated) { String classname = clazz.getJClass().getName().replace('/', '.'); services.put(classname, clazz); } } return services; }
/** * Add the given ENC name for the given field or method. * @param encName the name of the ENC value * @param commonMetadata the field or method or null object */ protected void addFieldOrMethodENC(final String encName, final ISharedMetadata commonMetadata) { // Don't do anything if there is no field/method if (commonMetadata == null) { return; } // Add ENC injection target if (commonMetadata instanceof CommonFieldMetadata) { CommonFieldMetadata<?, ?, ?> fieldAnnotationMetadata = (CommonFieldMetadata<?, ?, ?>) commonMetadata; String fieldName = fieldAnnotationMetadata.getJField().getName(); this.bindingHolder.addFieldInjectionTarget(fieldAnnotationMetadata.getClassMetadata().getJClass().getName().replace('/', '.'), new InjectionTargetEncImpl(fieldName, encName)); } else if (commonMetadata instanceof CommonMethodMetadata) { CommonMethodMetadata<?, ?, ?> methodAnnotationMetadata = (CommonMethodMetadata<?, ?, ?>) commonMetadata; String methodName = methodAnnotationMetadata.getJMethod().getName(); this.bindingHolder.addMethodInjectionTarget(methodAnnotationMetadata.getClassMetadata().getJClass().getName().replace('/', '.'), new InjectionTargetEncImpl(methodName, encName)); } }
/** * Add the given ENC name for the given field or method. * @param encName the name of the ENC value * @param commonMetadata the field or method or null object */ protected void addFieldOrMethodENC(final String encName, final ISharedMetadata commonMetadata) { // Don't do anything if there is no field/method if (commonMetadata == null) { return; } // Add ENC injection target if (commonMetadata instanceof CommonFieldMetadata) { CommonFieldMetadata<?, ?, ?> fieldAnnotationMetadata = (CommonFieldMetadata<?, ?, ?>) commonMetadata; String fieldName = fieldAnnotationMetadata.getJField().getName(); this.bindingHolder.addFieldInjectionTarget(fieldAnnotationMetadata.getClassMetadata().getJClass().getName().replace('/', '.'), new InjectionTargetEncImpl(fieldName, encName)); } else if (commonMetadata instanceof CommonMethodMetadata) { CommonMethodMetadata<?, ?, ?> methodAnnotationMetadata = (CommonMethodMetadata<?, ?, ?>) commonMetadata; String methodName = methodAnnotationMetadata.getJMethod().getName(); this.bindingHolder.addMethodInjectionTarget(methodAnnotationMetadata.getClassMetadata().getJClass().getName().replace('/', '.'), new InjectionTargetEncImpl(methodName, encName)); } }
/** * Adds the given resource to the list of bindings. * @param jAnnotationResource the given resource. */ protected void addResource(final IJAnnotationResource jAnnotationResource, final ISharedMetadata commonMetadata) { // Check Managed Beans if (jAnnotationResource.getLookup() == null) { for (ICommonClassMetadata<?, ?, ?> iCommonClassMetadata : this.getClassMetadataCollection()) { if (jAnnotationResource.getType() != null && iCommonClassMetadata.getJClass().getName().equals(jAnnotationResource.getType().replace(".", "/"))) { String managedBeanName = iCommonClassMetadata.getManagedBeanName(); if (managedBeanName != null) { // Add a lookup to the ManagedBean jAnnotationResource.setLookup("java:module/".concat(managedBeanName)); } } } } this.bindingHolder.addResourceBinding(new ENCBinding<IJAnnotationResource>(jAnnotationResource.getName(), jAnnotationResource)); addFieldOrMethodENC(jAnnotationResource.getName(), commonMetadata); }
/** * Adds the given resource to the list of bindings. * @param jAnnotationResource the given resource. */ protected void addResource(final IJAnnotationResource jAnnotationResource, final ISharedMetadata commonMetadata) { // Check Managed Beans if (jAnnotationResource.getLookup() == null) { for (ICommonClassMetadata<?, ?, ?> iCommonClassMetadata : this.getClassMetadataCollection()) { if (jAnnotationResource.getType() != null && iCommonClassMetadata.getJClass().getName().equals(jAnnotationResource.getType().replace(".", "/"))) { String managedBeanName = iCommonClassMetadata.getManagedBeanName(); if (managedBeanName != null) { // Add a lookup to the ManagedBean jAnnotationResource.setLookup("java:module/".concat(managedBeanName)); } } } } this.bindingHolder.addResourceBinding(new ENCBinding<IJAnnotationResource>(jAnnotationResource.getName(), jAnnotationResource)); addFieldOrMethodENC(jAnnotationResource.getName(), commonMetadata); }
String classname = decode(metadata.getJClass().getName()); reference.setDeclaringClass(classname); String classname = decode(metadata.getClassMetadata().getJClass().getName()); reference.setDeclaringClass(classname); String classname = decode(metadata.getClassMetadata().getJClass().getName()); reference.setDeclaringClass(classname);
String classname = decode(metadata.getJClass().getName()); reference.setDeclaringClass(classname); String classname = decode(metadata.getClassMetadata().getJClass().getName()); reference.setDeclaringClass(classname); String classname = decode(metadata.getClassMetadata().getJClass().getName()); reference.setDeclaringClass(classname);