use of com.sun.enterprise.deployment.InjectionTarget in project Payara by payara.
the class EntityManagerReferenceHandler method processEmRef.
/**
* Process a particular annotation which type is the same as the
* one returned by @see getAnnotationType(). All information
* pertinent to the annotation and its context is encapsulated
* in the passed AnnotationInfo instance.
*/
protected HandlerProcessingResult processEmRef(AnnotationInfo ainfo, ResourceContainerContext[] rcContexts, PersistenceContext emRefAn) throws AnnotationProcessorException {
EntityManagerReferenceDescriptor[] emRefs = null;
if (ElementType.FIELD.equals(ainfo.getElementType())) {
Field f = (Field) ainfo.getAnnotatedElement();
String targetClassName = f.getDeclaringClass().getName();
String logicalName = emRefAn.name();
// applying with default
if (logicalName.equals("")) {
logicalName = targetClassName + "/" + f.getName();
}
emRefs = getEmReferenceDescriptors(logicalName, rcContexts);
InjectionTarget target = new InjectionTarget();
target.setFieldName(f.getName());
target.setClassName(targetClassName);
target.setMetadataSource(MetadataSource.ANNOTATION);
for (EntityManagerReferenceDescriptor emRef : emRefs) {
emRef.addInjectionTarget(target);
if (emRef.getName().length() == 0) {
// a new one
processNewEmRefAnnotation(emRef, logicalName, emRefAn);
}
}
} else if (ElementType.METHOD.equals(ainfo.getElementType())) {
Method m = (Method) ainfo.getAnnotatedElement();
String targetClassName = m.getDeclaringClass().getName();
String logicalName = emRefAn.name();
if (logicalName.equals("")) {
// Derive javabean property name.
String propertyName = getInjectionMethodPropertyName(m, ainfo);
// prefixing with fully qualified type name
logicalName = targetClassName + "/" + propertyName;
}
validateInjectionMethod(m, ainfo);
emRefs = getEmReferenceDescriptors(logicalName, rcContexts);
InjectionTarget target = new InjectionTarget();
target.setMethodName(m.getName());
target.setClassName(targetClassName);
target.setMetadataSource(MetadataSource.ANNOTATION);
for (EntityManagerReferenceDescriptor emRef : emRefs) {
emRef.addInjectionTarget(target);
if (emRef.getName().length() == 0) {
// a new one
processNewEmRefAnnotation(emRef, logicalName, emRefAn);
}
}
} else if (ElementType.TYPE.equals(ainfo.getElementType())) {
// name() is required for TYPE-level usage
String logicalName = emRefAn.name();
if ("".equals(logicalName)) {
log(Level.SEVERE, ainfo, localStrings.getLocalString("enterprise.deployment.annotation.handlers.nonametypelevel", "TYPE-Level annotation symbol on class must specify name."));
return getDefaultFailedResult();
}
emRefs = getEmReferenceDescriptors(logicalName, rcContexts);
for (EntityManagerReferenceDescriptor emRef : emRefs) {
if (emRef.getName().length() == 0) {
// a new one
processNewEmRefAnnotation(emRef, logicalName, emRefAn);
}
}
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.InjectionTarget in project Payara by payara.
the class InjectionTargetTest method check.
public Result check(Descriptor descriptor) {
this.descriptor = descriptor;
result = getInitializedResult();
compName = getVerifierContext().getComponentNameConstructor();
ClassLoader cl = getVerifierContext().getClassLoader();
List<InjectionCapable> injectables = getInjectables(getClassName());
for (InjectionCapable injectionCapable : injectables) {
Set<InjectionTarget> iTargets = injectionCapable.getInjectionTargets();
for (InjectionTarget target : iTargets) {
try {
if (target.isFieldInjectable()) {
Class classObj = Class.forName(getClassName(), false, cl);
Field field = classObj.getDeclaredField(target.getFieldName());
testMethodModifiers(field.getModifiers(), "field", field);
}
if (target.isMethodInjectable()) {
Class classObj = Class.forName(getClassName(), false, cl);
Method method = getInjectedMethod(classObj, target.getMethodName());
if (method == null)
continue;
testMethodModifiers(method.getModifiers(), "method", method);
}
}// ignore as it will be caught in other tests
catch (Exception e) {
}
}
}
if (result.getStatus() != Result.FAILED) {
addGoodDetails(result, compName);
result.passed(smh.getLocalString(getClass().getName() + ".passed", "Valid injection method(s)."));
}
return result;
}
use of com.sun.enterprise.deployment.InjectionTarget in project Payara by payara.
the class MessageDestinationRefNode method writeDescriptor.
@Override
public Node writeDescriptor(Node parent, String nodeName, MessageDestinationReferenceDescriptor desc) {
Node msgDestRefNode = appendChild(parent, nodeName);
writeLocalizedDescriptions(msgDestRefNode, desc);
appendTextChild(msgDestRefNode, TagNames.MESSAGE_DESTINATION_REFERENCE_NAME, desc.getName());
appendTextChild(msgDestRefNode, TagNames.MESSAGE_DESTINATION_TYPE, desc.getDestinationType());
appendTextChild(msgDestRefNode, TagNames.MESSAGE_DESTINATION_USAGE, desc.getUsage());
appendTextChild(msgDestRefNode, TagNames.MESSAGE_DESTINATION_LINK, desc.getMessageDestinationLinkName());
appendTextChild(msgDestRefNode, TagNames.MAPPED_NAME, desc.getMappedName());
if (desc.isInjectable()) {
InjectionTargetNode ijNode = new InjectionTargetNode();
for (InjectionTarget target : desc.getInjectionTargets()) {
ijNode.writeDescriptor(msgDestRefNode, TagNames.INJECTION_TARGET, target);
}
}
appendTextChild(msgDestRefNode, TagNames.LOOKUP_NAME, desc.getLookupName());
return msgDestRefNode;
}
use of com.sun.enterprise.deployment.InjectionTarget in project Payara by payara.
the class ResourceEnvRefNode method writeDescriptor.
@Override
public Node writeDescriptor(Node parent, String nodeName, ResourceEnvReferenceDescriptor descriptor) {
Node ejbResNode = appendChild(parent, nodeName);
writeLocalizedDescriptions(ejbResNode, descriptor);
appendTextChild(ejbResNode, TagNames.RESOURCE_ENV_REFERENCE_NAME, descriptor.getName());
appendTextChild(ejbResNode, TagNames.RESOURCE_ENV_REFERENCE_TYPE, descriptor.getRefType());
appendTextChild(ejbResNode, TagNames.MAPPED_NAME, descriptor.getMappedName());
if (descriptor.isInjectable()) {
InjectionTargetNode ijNode = new InjectionTargetNode();
for (InjectionTarget target : descriptor.getInjectionTargets()) {
ijNode.writeDescriptor(ejbResNode, TagNames.INJECTION_TARGET, target);
}
}
appendTextChild(ejbResNode, TagNames.LOOKUP_NAME, descriptor.getLookupName());
return ejbResNode;
}
Aggregations