use of com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor in project Payara by payara.
the class EjbDescriptor method applyInterceptors.
/**
* Derive all interceptors that are applicable to this bean.
* @param bindingTranslator
*/
public void applyInterceptors(InterceptorBindingTranslator bindingTranslator) {
// Apply this ejb to the ordered set of all interceptor bindings
// for this ejb-jar. The results will contain all interceptor
// information that applies to the ejb. There is no notion of
// default interceptors within the results. Default interceptors
// are used during the translation process but once we derive
// the per-ejb interceptor information there is only a notion of
// class-level ordering and method-level ordering. Any applicable
// default interceptors will have been applied to the class-level.
TranslationResults results = bindingTranslator.apply(getName());
allInterceptorClasses.clear();
allInterceptorClasses.addAll(results.allInterceptorClasses);
interceptorChain.clear();
interceptorChain.addAll(results.classInterceptorChain);
methodInterceptorsMap.clear();
methodInterceptorsMap.putAll(results.methodInterceptorsMap);
for (EjbInterceptor interceptor : allInterceptorClasses) {
for (Object ejbRefObj : interceptor.getEjbReferenceDescriptors()) {
addEjbReferenceDescriptor((EjbReference) ejbRefObj);
}
for (Object msgDestRefObj : interceptor.getMessageDestinationReferenceDescriptors()) {
addMessageDestinationReferenceDescriptor((MessageDestinationReferenceDescriptor) msgDestRefObj);
}
for (Object envPropObj : interceptor.getEnvironmentProperties()) {
addOrMergeEnvironmentProperty((EnvironmentProperty) envPropObj);
}
for (Object servRefObj : interceptor.getServiceReferenceDescriptors()) {
addServiceReferenceDescriptor((ServiceReferenceDescriptor) servRefObj);
}
for (Object resRefObj : interceptor.getResourceReferenceDescriptors()) {
addResourceReferenceDescriptor((ResourceReferenceDescriptor) resRefObj);
}
for (Object resourceEnvRefObj : interceptor.getResourceEnvReferenceDescriptors()) {
addResourceEnvReferenceDescriptor((ResourceEnvReferenceDescriptor) resourceEnvRefObj);
}
for (EntityManagerFactoryReferenceDescriptor entMgrFacRef : interceptor.getEntityManagerFactoryReferenceDescriptors()) {
addEntityManagerFactoryReferenceDescriptor(entMgrFacRef);
}
for (EntityManagerReferenceDescriptor entMgrRef : interceptor.getEntityManagerReferenceDescriptors()) {
addEntityManagerReferenceDescriptor(entMgrRef);
}
}
}
use of com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor in project Payara by payara.
the class EjbDescriptor method addEntityManagerFactoryReferenceDescriptor.
@Override
public final void addEntityManagerFactoryReferenceDescriptor(EntityManagerFactoryReferenceDescriptor reference) {
try {
EntityManagerFactoryReferenceDescriptor existing = getEntityManagerFactoryReferenceByName(reference.getName());
for (InjectionTarget next : reference.getInjectionTargets()) {
existing.addInjectionTarget(next);
}
} catch (IllegalArgumentException e) {
if (getEjbBundleDescriptor() != null) {
reference.setReferringBundleDescriptor(getEjbBundleDescriptor());
}
if (env != null)
env.addEntityManagerFactoryReferenceDescriptor(reference);
else
entityManagerFactoryReferences.add(reference);
}
}
use of com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor in project Payara by payara.
the class EntityManagerFactoryReferenceHandler method processEmfRef.
/**
* 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 processEmfRef(AnnotationInfo ainfo, ResourceContainerContext[] rcContexts, PersistenceUnit emfRefAn) throws AnnotationProcessorException {
EntityManagerFactoryReferenceDescriptor[] emfRefs = null;
if (ElementType.FIELD.equals(ainfo.getElementType())) {
Field f = (Field) ainfo.getAnnotatedElement();
String targetClassName = f.getDeclaringClass().getName();
String logicalName = emfRefAn.name();
// applying with default
if (logicalName.equals("")) {
logicalName = targetClassName + "/" + f.getName();
}
emfRefs = getEmfReferenceDescriptors(logicalName, rcContexts);
InjectionTarget target = new InjectionTarget();
target.setFieldName(f.getName());
target.setClassName(targetClassName);
target.setMetadataSource(MetadataSource.ANNOTATION);
for (EntityManagerFactoryReferenceDescriptor emfRef : emfRefs) {
emfRef.addInjectionTarget(target);
if (emfRef.getName().length() == 0) {
// a new one
processNewEmfRefAnnotation(emfRef, logicalName, emfRefAn);
}
}
} else if (ElementType.METHOD.equals(ainfo.getElementType())) {
Method m = (Method) ainfo.getAnnotatedElement();
String targetClassName = m.getDeclaringClass().getName();
String logicalName = emfRefAn.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);
emfRefs = getEmfReferenceDescriptors(logicalName, rcContexts);
InjectionTarget target = new InjectionTarget();
target.setMethodName(m.getName());
target.setClassName(targetClassName);
target.setMetadataSource(MetadataSource.ANNOTATION);
for (EntityManagerFactoryReferenceDescriptor emfRef : emfRefs) {
emfRef.addInjectionTarget(target);
if (emfRef.getName().length() == 0) {
// a new one
processNewEmfRefAnnotation(emfRef, logicalName, emfRefAn);
}
}
} else if (ElementType.TYPE.equals(ainfo.getElementType())) {
// name() is required for TYPE-level usage
String logicalName = emfRefAn.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();
}
emfRefs = getEmfReferenceDescriptors(logicalName, rcContexts);
for (EntityManagerFactoryReferenceDescriptor emfRef : emfRefs) {
if (emfRef.getName().length() == 0) {
// a new one
processNewEmfRefAnnotation(emfRef, logicalName, emfRefAn);
}
}
}
return getDefaultProcessedResult();
}
use of com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor in project Payara by payara.
the class PUTransactionType method check.
public Result check(Descriptor descriptor) {
ApplicationClientDescriptor appClient = (ApplicationClientDescriptor) descriptor;
Result result = getInitializedResult();
addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
// default status is PASSED
result.setStatus(Result.PASSED);
for (PersistenceUnitsDescriptor pus : appClient.getExtensionsDescriptors(PersistenceUnitsDescriptor.class)) {
for (PersistenceUnitDescriptor nextPU : pus.getPersistenceUnitDescriptors()) {
if ("JTA".equals(nextPU.getTransactionType())) {
result.failed(smh.getLocalString(getClass().getName() + ".puName", "Found a persistence unit by name [ {0} ] in persistence unit root [ {1} ] with JTA transaction type.", new Object[] { nextPU.getName(), nextPU.getPuRoot() }));
}
}
}
for (EntityManagerFactoryReferenceDescriptor emfRef : appClient.getEntityManagerFactoryReferenceDescriptors()) {
String unitName = emfRef.getUnitName();
PersistenceUnitDescriptor nextPU = appClient.findReferencedPU(unitName);
if (nextPU == null)
continue;
if ("JTA".equals(nextPU.getTransactionType())) {
result.failed(smh.getLocalString(getClass().getName() + ".puRefName", "Found a reference to a persistence unit by name [ {0} ] in persistence unit root [ {1} ] with JTA transaction type.", new Object[] { nextPU.getName(), nextPU.getPuRoot() }));
}
}
return result;
}
use of com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor in project Payara by payara.
the class EntityManagerFactoryReferenceHandler method getEmfReferenceDescriptors.
/**
* Return EntityManagerFactoryReferenceDescriptors with given name
* if exists or a new one without name being set.
*/
private EntityManagerFactoryReferenceDescriptor[] getEmfReferenceDescriptors(String logicalName, ResourceContainerContext[] rcContexts) {
EntityManagerFactoryReferenceDescriptor[] emfRefs = new EntityManagerFactoryReferenceDescriptor[rcContexts.length];
for (int i = 0; i < rcContexts.length; i++) {
EntityManagerFactoryReferenceDescriptor emfRef = (EntityManagerFactoryReferenceDescriptor) rcContexts[i].getEntityManagerFactoryReference(logicalName);
if (emfRef == null) {
emfRef = new EntityManagerFactoryReferenceDescriptor();
rcContexts[i].addEntityManagerFactoryReferenceDescriptor(emfRef);
}
emfRefs[i] = emfRef;
}
return emfRefs;
}
Aggregations