use of com.sun.enterprise.deployment.EntityManagerReferenceDescriptor in project Payara by payara.
the class EntityManagerInjection method check.
public Result check(WebBundleDescriptor descriptor) {
Result result = getInitializedResult();
addWarningDetails(result, getVerifierContext().getComponentNameConstructor());
// default status is PASSED
result.setStatus(Result.PASSED);
for (EntityManagerReferenceDescriptor emRefDesc : descriptor.getEntityManagerReferenceDescriptors()) {
Set<InjectionTarget> injectionTargets = emRefDesc.getInjectionTargets();
if (injectionTargets != null) {
for (InjectionTarget it : injectionTargets) {
String itClassName = it.getClassName();
String errMsg = smh.getLocalString(className + ".warning", "Found a persistence unit by name [ {0} ] injected into [ {1} ].", new Object[] { emRefDesc.getUnitName(), itClassName });
try {
Class c = Class.forName(itClassName, false, getVerifierContext().getClassLoader());
if (!(Servlet.class.isAssignableFrom(c))) {
result.warning(errMsg);
} else if (!(SingleThreadModel.class.isAssignableFrom(c))) {
result.warning(errMsg);
}
} catch (Exception ex) {
result.warning(errMsg);
}
}
}
}
return result;
}
use of com.sun.enterprise.deployment.EntityManagerReferenceDescriptor in project Payara by payara.
the class EjbDescriptor method addEntityManagerReferenceDescriptor.
@Override
public final void addEntityManagerReferenceDescriptor(EntityManagerReferenceDescriptor reference) {
try {
EntityManagerReferenceDescriptor existing = this.getEntityManagerReferenceByName(reference.getName());
for (InjectionTarget next : reference.getInjectionTargets()) {
existing.addInjectionTarget(next);
}
} catch (IllegalArgumentException e) {
if (getEjbBundleDescriptor() != null) {
reference.setReferringBundleDescriptor(getEjbBundleDescriptor());
}
if (env != null)
env.addEntityManagerReferenceDescriptor(reference);
else
getEntityManagerReferenceDescriptors().add(reference);
}
}
use of com.sun.enterprise.deployment.EntityManagerReferenceDescriptor 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.EntityManagerReferenceDescriptor in project Payara by payara.
the class EntityManagerReferenceHandler method getEmReferenceDescriptors.
/**
* Return EntityManagerReferenceDescriptors with given name
* if exists or a new one without name being set.
*/
private EntityManagerReferenceDescriptor[] getEmReferenceDescriptors(String logicalName, ResourceContainerContext[] rcContexts) {
EntityManagerReferenceDescriptor[] emRefs = new EntityManagerReferenceDescriptor[rcContexts.length];
for (int i = 0; i < rcContexts.length; i++) {
EntityManagerReferenceDescriptor emRef = (EntityManagerReferenceDescriptor) rcContexts[i].getEntityManagerReference(logicalName);
if (emRef == null) {
emRef = new EntityManagerReferenceDescriptor();
rcContexts[i].addEntityManagerReferenceDescriptor(emRef);
}
emRefs[i] = emRef;
}
return emRefs;
}
use of com.sun.enterprise.deployment.EntityManagerReferenceDescriptor 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();
}
Aggregations