use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl in project Payara by payara.
the class ExcludeDefaultInterceptorsHandler method processAnnotation.
protected HandlerProcessingResult processAnnotation(AnnotationInfo ainfo, EjbContext[] ejbContexts) throws AnnotationProcessorException {
EjbBundleDescriptorImpl ejbBundle = ((EjbDescriptor) ejbContexts[0].getDescriptor()).getEjbBundleDescriptor();
for (EjbContext next : ejbContexts) {
EjbDescriptor ejbDescriptor = (EjbDescriptor) next.getDescriptor();
// Create binding information.
InterceptorBindingDescriptor binding = new InterceptorBindingDescriptor();
binding.setEjbName(ejbDescriptor.getName());
binding.setExcludeDefaultInterceptors(true);
if (ElementType.METHOD.equals(ainfo.getElementType())) {
Method m = (Method) ainfo.getAnnotatedElement();
MethodDescriptor md = new MethodDescriptor(m, MethodDescriptor.EJB_BEAN);
binding.setBusinessMethod(md);
} else if (ElementType.CONSTRUCTOR.equals(ainfo.getElementType())) {
Constructor c = (Constructor) ainfo.getAnnotatedElement();
Class cl = c.getDeclaringClass();
Class[] ctorParamTypes = c.getParameterTypes();
String[] parameterClassNames = (new MethodDescriptor()).getParameterClassNamesFor(null, ctorParamTypes);
MethodDescriptor md = new MethodDescriptor(cl.getSimpleName(), null, parameterClassNames, MethodDescriptor.EJB_BEAN);
binding.setBusinessMethod(md);
}
ejbBundle.prependInterceptorBinding(binding);
}
return getDefaultProcessedResult();
}
use of org.glassfish.ejb.deployment.descriptor.EjbBundleDescriptorImpl in project Payara by payara.
the class NameMapper method initGeneratedRelationshipMaps.
private void initGeneratedRelationshipMaps() {
EjbBundleDescriptorImpl bundleDescriptor = getBundleDescriptor();
Set relationships = bundleDescriptor.getRelationships();
_generatedRelToInverseRelMap = new HashMap();
_relToInverseGeneratedRelMap = new HashMap();
// null check
if (relationships != null) {
Iterator iterator = relationships.iterator();
List generatedRels = new ArrayList();
int counter = 0;
// gather list of generated cmr fields by examining source and sink
while (iterator.hasNext()) {
RelationshipDescriptor relationship = (RelationshipDescriptor) iterator.next();
if (relationship.getSource().getCMRField() == null)
generatedRels.add(relationship);
if (relationship.getSink().getCMRField() == null)
generatedRels.add(relationship);
}
// now update the maps to contain this info
iterator = generatedRels.iterator();
while (iterator.hasNext()) {
RelationshipDescriptor relationship = (RelationshipDescriptor) iterator.next();
RelationRoleDescriptor source = relationship.getSource();
String sourceEjbName = source.getOwner().getName();
String sourceCMRField = source.getCMRField();
boolean sourceIsNull = (sourceCMRField == null);
RelationRoleDescriptor sink = relationship.getSink();
String sinkEjbName = sink.getOwner().getName();
String ejbName = (sourceIsNull ? sourceEjbName : sinkEjbName);
String otherEjbName = (sourceIsNull ? sinkEjbName : sourceEjbName);
List ejbField = Arrays.asList(new String[] { otherEjbName, (sourceIsNull ? sink.getCMRField() : sourceCMRField) });
PersistenceDescriptor pDescriptor = ((EjbCMPEntityDescriptor) bundleDescriptor.getEjbByName(ejbName)).getPersistenceDescriptor();
List generatedField = null;
String uniqueName = null;
// with this name
do {
counter++;
uniqueName = GENERATED_CMR_FIELD_PREFIX + counter;
} while (hasField(pDescriptor, uniqueName));
generatedField = Arrays.asList(new String[] { ejbName, uniqueName });
_generatedRelToInverseRelMap.put(generatedField, ejbField);
_relToInverseGeneratedRelMap.put(ejbField, generatedField);
}
}
}
Aggregations