Search in sources :

Example 11 with RootDeploymentDescriptor

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);
            }
        }
    }
}
Also used : BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) ManagedBeanDescriptor(com.sun.enterprise.deployment.ManagedBeanDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) EjbDescriptor(com.sun.enterprise.deployment.EjbDescriptor) DataSourceDefinitionDescriptor(com.sun.enterprise.deployment.DataSourceDefinitionDescriptor) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) Descriptor(org.glassfish.deployment.common.Descriptor)

Example 12 with RootDeploymentDescriptor

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);
}
Also used : EjbBundleContext(com.sun.enterprise.deployment.annotation.context.EjbBundleContext) ResourceContainerContext(com.sun.enterprise.deployment.annotation.context.ResourceContainerContext) WebComponentsContext(com.sun.enterprise.deployment.annotation.context.WebComponentsContext) EjbBundleDescriptor(com.sun.enterprise.deployment.EjbBundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) AnnotatedElementHandler(org.glassfish.apf.AnnotatedElementHandler) EjbsContext(com.sun.enterprise.deployment.annotation.context.EjbsContext)

Example 13 with RootDeploymentDescriptor

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;
}
Also used : HashMap(java.util.HashMap) PersistenceProvider(javax.persistence.spi.PersistenceProvider) ValidationMode(javax.persistence.ValidationMode) PersistenceUnitInfo(javax.persistence.spi.PersistenceUnitInfo) PersistenceUnitsDescriptor(com.sun.enterprise.deployment.PersistenceUnitsDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) EntityManagerFactory(javax.persistence.EntityManagerFactory)

Example 14 with RootDeploymentDescriptor

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;
        }
    }
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor)

Example 15 with RootDeploymentDescriptor

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);
}
Also used : ModuleDescriptor(org.glassfish.deployment.common.ModuleDescriptor) BundleDescriptor(com.sun.enterprise.deployment.BundleDescriptor) ArchiveType(org.glassfish.api.deployment.archive.ArchiveType) RootDeploymentDescriptor(org.glassfish.deployment.common.RootDeploymentDescriptor) PersistenceUnitDescriptor(com.sun.enterprise.deployment.PersistenceUnitDescriptor)

Aggregations

RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)24 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)9 EjbBundleDescriptor (com.sun.enterprise.deployment.EjbBundleDescriptor)6 ModuleDescriptor (org.glassfish.deployment.common.ModuleDescriptor)6 HashMap (java.util.HashMap)3 Application (com.sun.enterprise.deployment.Application)2 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)2 EjbDescriptor (com.sun.enterprise.deployment.EjbDescriptor)2 PersistenceUnitDescriptor (com.sun.enterprise.deployment.PersistenceUnitDescriptor)2 WebBundleDescriptor (com.sun.enterprise.deployment.WebBundleDescriptor)2 PrincipalNameDescriptor (com.sun.enterprise.deployment.runtime.common.PrincipalNameDescriptor)2 StringTokenizer (java.util.StringTokenizer)2 ArchiveType (org.glassfish.api.deployment.archive.ArchiveType)2 ReadableArchive (org.glassfish.api.deployment.archive.ReadableArchive)2 ArchiveFactory (com.sun.enterprise.deploy.shared.ArchiveFactory)1 DataSourceDefinitionDescriptor (com.sun.enterprise.deployment.DataSourceDefinitionDescriptor)1 ManagedBeanDescriptor (com.sun.enterprise.deployment.ManagedBeanDescriptor)1 PersistenceUnitsDescriptor (com.sun.enterprise.deployment.PersistenceUnitsDescriptor)1 WebComponentDescriptor (com.sun.enterprise.deployment.WebComponentDescriptor)1 EjbBundleContext (com.sun.enterprise.deployment.annotation.context.EjbBundleContext)1