use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.
the class DataSourceDefinitionDeployer method registerDataSourceDefinitions.
public void registerDataSourceDefinitions(com.sun.enterprise.deployment.Application application) {
String appName = application.getAppName();
// Register data source definitions defined in application.xml
registerDataSourceDefinitions(appName, application);
// Register data source definition defined in web.xml and ejb-jar.xml
for (BundleDescriptor bundle : application.getBundleDescriptors()) {
registerDataSourceDefinitions(appName, bundle);
Collection<RootDeploymentDescriptor> descriptors = bundle.getExtensionsDescriptors();
if (descriptors != null) {
for (Descriptor descriptor : descriptors) {
registerDataSourceDefinitions(appName, descriptor);
}
}
}
}
use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.
the class AbstractResourceHandler method processAnnotation.
/**
* 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.
*
* @param ainfo the annotation information
* @return
* @throws AnnotationProcessorException
*/
@Override
public HandlerProcessingResult processAnnotation(AnnotationInfo ainfo) throws AnnotationProcessorException {
AnnotatedElementHandler aeHandler = ainfo.getProcessingContext().getHandler();
if (aeHandler instanceof EjbBundleContext) {
EjbBundleContext ejbBundleContext = (EjbBundleContext) aeHandler;
aeHandler = ejbBundleContext.createContextForEjb();
if (aeHandler == null) {
aeHandler = ejbBundleContext.createContextForEjbInterceptor();
}
// If it's still null and we're in an ejb-jar, use the EjbBundleContext.
// This way we process dependencies on any classes (other than ejbs ,
// interceptors , and their super-classes) that have annotations in case
// we need the info for managed classes we wouldn't normally know about
// (e.g. 299 classes). In a .war, those are already processed during the
// .war annotation scanning.
EjbBundleDescriptor bundleDesc = ejbBundleContext.getDescriptor();
RootDeploymentDescriptor enclosingBundle = bundleDesc.getModuleDescriptor().getDescriptor();
boolean ejbJar = enclosingBundle instanceof EjbBundleDescriptor;
if ((aeHandler == null) && ejbJar) {
aeHandler = ejbBundleContext;
}
}
if (aeHandler == null) {
// not an ejb, interceptor in ejbBundle
return getInvalidAnnotatedElementHandlerResult(ainfo.getProcessingContext().getHandler(), ainfo);
}
ResourceContainerContext[] rcContexts = null;
if (aeHandler instanceof EjbsContext) {
EjbsContext ejbsContext = (EjbsContext) aeHandler;
rcContexts = (ResourceContainerContext[]) ejbsContext.getEjbContexts();
} else if (aeHandler instanceof WebComponentsContext) {
WebComponentsContext webCompsContext = (WebComponentsContext) aeHandler;
rcContexts = (ResourceContainerContext[]) webCompsContext.getWebComponentContexts();
} else if (aeHandler instanceof ResourceContainerContext) {
rcContexts = new ResourceContainerContext[] { (ResourceContainerContext) aeHandler };
} else {
return getInvalidAnnotatedElementHandlerResult(aeHandler, ainfo);
}
return processAnnotation(ainfo, rcContexts);
}
use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.
the class PersistenceUnitLoader method loadPU.
/**
* Loads an individual PersistenceUnitDescriptor and registers the
* EntityManagerFactory in appropriate DOL structure.
*
* @param pud PersistenceUnitDescriptor to be loaded.
*/
private EntityManagerFactory loadPU(PersistenceUnitDescriptor pud) {
checkForUpgradeFromTopLinkEssentials(pud);
checkForDataSourceOverride(pud);
calculateDefaultDataSource(pud);
PersistenceUnitInfo pInfo = new PersistenceUnitInfoImpl(pud, providerContainerContractInfo);
String applicationLocation = providerContainerContractInfo.getApplicationLocation();
final boolean fineMsgLoggable = logger.isLoggable(Level.FINE);
if (fineMsgLoggable) {
logger.fine("Loading persistence unit for application: \"" + applicationLocation + "\"pu Root is: " + pud.getPuRoot());
// NOI18N
logger.fine("PersistenceInfo for this pud is :\n" + pInfo);
}
PersistenceProvider provider;
try {
// See we use application CL as opposed to system CL to loadPU
// provider. This allows user to get hold of provider specific
// implementation classes in their code. But this also means
// provider must not use appserver implementation classes directly
// because once we implement isolation in our class loader hierarchy
// the only classes available to application class loader would be
// our appserver interface classes. By Sahoo
provider = PersistenceProvider.class.cast(providerContainerContractInfo.getClassLoader().loadClass(pInfo.getPersistenceProviderClassName()).newInstance());
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
throw new RuntimeException(e);
}
Map<String, Object> schemaGenerationOverrides;
schemaGenerationProcessor = SchemaGenerationProcessorFactory.createSchemaGenerationProcessor(pud);
if (providerContainerContractInfo.isJava2DBRequired()) {
schemaGenerationProcessor.init(pud, providerContainerContractInfo.getDeploymentContext());
schemaGenerationOverrides = schemaGenerationProcessor.getOverridesForSchemaGeneration();
} else {
// schema generation is not required if this EMF is being created for
// -appserver restarting or,
// -on an instance or,
// -appclient
// Suppress schema generation in this case
schemaGenerationOverrides = schemaGenerationProcessor.getOverridesForSuppressingSchemaGeneration();
}
Map<String, Object> overRides = new HashMap<String, Object>(integrationProperties);
if (schemaGenerationOverrides != null) {
overRides.putAll(schemaGenerationOverrides);
}
// Check if the persistence unit requires Bean Validation
ValidationMode validationMode = getValidationMode(pud);
if (validationMode == ValidationMode.AUTO || validationMode == ValidationMode.CALLBACK) {
overRides.put(VALIDATOR_FACTORY, providerContainerContractInfo.getValidatorFactory());
}
if (!providerContainerContractInfo.isWeavingEnabled()) {
// NOI18N
overRides.put(ECLIPSELINK_WEAVING_PROPERTY, System.getProperty(ECLIPSELINK_WEAVING_PROPERTY, "false"));
}
EntityManagerFactory emf = provider.createContainerEntityManagerFactory(pInfo, overRides);
if (fineMsgLoggable) {
// NOI18N
logger.logp(// NOI18N
Level.FINE, // NOI18N
"PersistenceUnitLoader", // NOI18N
"loadPU", "emf = {0}", // NOI18N
emf);
}
PersistenceUnitsDescriptor parent = pud.getParent();
RootDeploymentDescriptor containingBundle = parent.getParent();
providerContainerContractInfo.registerEMF(pInfo.getPersistenceUnitName(), pud.getPuRoot(), containingBundle, emf);
if (fineMsgLoggable) {
logger.fine(// NOI18N
"Finished loading persistence unit for application: " + applicationLocation);
}
return emf;
}
use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.
the class JarNotFound method getAbsolutePuRoot.
/**
* This method calculates the absolute path of the root of a PU.
* Absolute path is not the path with regards to root of file system.
* It is the path from the root of the Java EE application this
* persistence unit belongs to.
* Returned path always uses '/' as path separator.
* @param applicationLocation absolute path of application root
* @param persistenceUnitDescriptor
* @return the absolute path of the root of this persistence unit
*/
private String getAbsolutePuRoot(String applicationLocation, PersistenceUnitDescriptor persistenceUnitDescriptor) {
RootDeploymentDescriptor rootDD = persistenceUnitDescriptor.getParent().getParent();
String puRoot = persistenceUnitDescriptor.getPuRoot();
if (rootDD.isApplication()) {
return puRoot;
} else {
ModuleDescriptor module = BundleDescriptor.class.cast(rootDD).getModuleDescriptor();
if (module.isStandalone()) {
return puRoot;
} else {
final String moduleLocation = DeploymentUtils.getRelativeEmbeddedModulePath(applicationLocation, module.getArchiveUri());
// see we always '/'
return moduleLocation + '/' + puRoot;
}
}
}
use of org.glassfish.deployment.common.RootDeploymentDescriptor in project Payara by payara.
the class PersistenceUnitCheckMgrImpl method check.
@Override
protected void check(Descriptor descriptor) throws Exception {
PersistenceUnitDescriptor pu = PersistenceUnitDescriptor.class.cast(descriptor);
RootDeploymentDescriptor rootDD = pu.getParent().getParent();
if (rootDD.isApplication()) {
moduleName = Result.APP;
} else {
ModuleDescriptor mdesc = BundleDescriptor.class.cast(rootDD).getModuleDescriptor();
final ArchiveType moduleType = mdesc.getModuleType();
if (moduleType != null && moduleType.equals(DOLUtils.ejbType())) {
moduleName = Result.EJB;
} else if (moduleType != null && moduleType.equals(DOLUtils.warType())) {
moduleName = Result.WEB;
} else if (moduleType != null && moduleType.equals(DOLUtils.carType())) {
moduleName = Result.APPCLIENT;
} else {
throw new RuntimeException(// NOI18N
smh.getLocalString(// NOI18N
getClass().getName() + ".exception", // NOI18N
"Unknown module type : {0}", new Object[] { moduleType }));
}
}
super.check(descriptor);
}
Aggregations