Search in sources :

Example 6 with PersistenceUnitDescriptor

use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.

the class AppClientContainer method completePreparation.

/**
 * Gets the ACC ready so the main class can run.
 * This can be followed, immediately or after some time, by either an
 * invocation of {@link #launch(java.lang.String[])  or
 * by the JVM invoking the client's main method (as would happen during
 * a <code>java -jar theClient.jar</code> launch.
 *
 * @throws java.lang.Exception
 */
private void completePreparation(final Instrumentation inst) throws NamingException, IOException, InstantiationException, IllegalAccessException, InjectionException, ClassNotFoundException, SAXParseException, NoSuchMethodException, UserError {
    if (state != State.INSTANTIATED) {
        throw new IllegalStateException();
    }
    /*
         * Attach any names defined in the app client.  Validate the descriptor
         * first, then use it to bind names in the app client.  This order is
         * important - for example, to set up message destination refs correctly.
         */
    client.validateDescriptor();
    final ApplicationClientDescriptor desc = client.getDescriptor(classLoader);
    componentId = componentEnvManager.bindToComponentNamespace(desc);
    /*
         * Arrange for cleanup now instead of during launch() because in some use cases
         * the JVM will invoke the client's main method itself and launch will
         * be skipped.
         */
    cleanup = Cleanup.arrangeForShutdownCleanup(logger, habitat, desc);
    /*
         * Allow pre-destroy handling to work on the main class during clean-up.
         */
    cleanup.setInjectionManager(injectionManager, clientMainClassSetting.clientMainClass);
    /*
         * If this app client contains persistence unit refs, then initialize
         * the PU handling.  
         */
    Collection<? extends PersistenceUnitDescriptor> referencedPUs = desc.findReferencedPUs();
    if (referencedPUs != null && !referencedPUs.isEmpty()) {
        ProviderContainerContractInfoImpl pcci = new ProviderContainerContractInfoImpl((ACCClassLoader) getClassLoader(), inst, client.getAnchorDir(), connectorRuntime);
        for (PersistenceUnitDescriptor puDesc : referencedPUs) {
            PersistenceUnitLoader pul = new PersistenceUnitLoader(puDesc, pcci);
            desc.addEntityManagerFactory(puDesc.getName(), pul.getEMF());
        }
        cleanup.setEMFs(pcci.emfs());
    }
    cleanup.setConnectorRuntime(connectorRuntime);
    prepareURLStreamHandling();
    // This is required for us to enable interrupt jaxws service
    // creation calls
    System.setProperty("javax.xml.ws.spi.Provider", "com.sun.enterprise.webservice.spi.ProviderImpl");
    // InjectionManager's injectClass will be called from getMainMethod
    // Load any managed beans
    ManagedBeanManager managedBeanManager = habitat.getService(ManagedBeanManager.class);
    managedBeanManager.loadManagedBeans(desc.getApplication());
    cleanup.setManagedBeanManager(managedBeanManager);
    /**
     * We don't really need the main method here but we do need the side-effects.
     */
    getMainMethod();
    state = State.PREPARED;
}
Also used : ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) PersistenceUnitLoader(org.glassfish.persistence.jpa.PersistenceUnitLoader) PersistenceUnitDescriptor(com.sun.enterprise.deployment.PersistenceUnitDescriptor) ManagedBeanManager(com.sun.enterprise.container.common.spi.ManagedBeanManager)

Example 7 with PersistenceUnitDescriptor

use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.

the class PersistenceUnitNode method startElement.

@Override
public void startElement(XMLElement element, Attributes attributes) {
    if (PersistenceTagNames.PROPERTY.equals(element.getQName())) {
        assert (attributes.getLength() == 2);
        assert (attributes.getIndex(PersistenceTagNames.PROPERTY_NAME) != -1);
        assert (attributes.getIndex(PersistenceTagNames.PROPERTY_VALUE) != -1);
        PersistenceUnitDescriptor persistenceUnitDescriptor = (PersistenceUnitDescriptor) getDescriptor();
        String propName = attributes.getValue(PersistenceTagNames.PROPERTY_NAME);
        String propValue = (String) TranslatedConfigView.getTranslatedValue(attributes.getValue(PersistenceTagNames.PROPERTY_VALUE));
        persistenceUnitDescriptor.addProperty(propName, propValue);
        return;
    }
    super.startElement(element, attributes);
}
Also used : PersistenceUnitDescriptor(com.sun.enterprise.deployment.PersistenceUnitDescriptor)

Example 8 with PersistenceUnitDescriptor

use of com.sun.enterprise.deployment.PersistenceUnitDescriptor 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;
}
Also used : ApplicationClientDescriptor(com.sun.enterprise.deployment.ApplicationClientDescriptor) PersistenceUnitsDescriptor(com.sun.enterprise.deployment.PersistenceUnitsDescriptor) EntityManagerFactoryReferenceDescriptor(com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor) Result(com.sun.enterprise.tools.verifier.Result) PersistenceUnitDescriptor(com.sun.enterprise.deployment.PersistenceUnitDescriptor)

Example 9 with PersistenceUnitDescriptor

use of com.sun.enterprise.deployment.PersistenceUnitDescriptor in project Payara by payara.

the class MappingFileNotFound method check.

public Result check(Descriptor descriptor) {
    Result result = getInitializedResult();
    result.setStatus(Result.PASSED);
    addErrorDetails(result, getVerifierContext().getComponentNameConstructor());
    PersistenceUnitDescriptor pu = PersistenceUnitDescriptor.class.cast(descriptor);
    List<String> mappingFileNames = new ArrayList<String>(pu.getMappingFiles());
    for (String mappingFileName : mappingFileNames) {
        if (getVerifierContext().getClassLoader().getResource(mappingFileName) == null) {
            result.failed(smh.getLocalString(getClass().getName() + "failed", "Mapping file [ {0} ] specified in persistence.xml does not exist in the application.", new Object[] { mappingFileName }));
        }
    }
    return result;
}
Also used : ArrayList(java.util.ArrayList) Result(com.sun.enterprise.tools.verifier.Result) PersistenceUnitDescriptor(com.sun.enterprise.deployment.PersistenceUnitDescriptor)

Example 10 with PersistenceUnitDescriptor

use of com.sun.enterprise.deployment.PersistenceUnitDescriptor 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

PersistenceUnitDescriptor (com.sun.enterprise.deployment.PersistenceUnitDescriptor)12 Result (com.sun.enterprise.tools.verifier.Result)6 ApplicationClientDescriptor (com.sun.enterprise.deployment.ApplicationClientDescriptor)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 RootDeploymentDescriptor (org.glassfish.deployment.common.RootDeploymentDescriptor)2 ManagedBeanManager (com.sun.enterprise.container.common.spi.ManagedBeanManager)1 BundleDescriptor (com.sun.enterprise.deployment.BundleDescriptor)1 EntityManagerFactoryReferenceDescriptor (com.sun.enterprise.deployment.EntityManagerFactoryReferenceDescriptor)1 PersistenceUnitsDescriptor (com.sun.enterprise.deployment.PersistenceUnitsDescriptor)1 EntityManagerFactoryReference (com.sun.enterprise.deployment.types.EntityManagerFactoryReference)1 EntityManagerReference (com.sun.enterprise.deployment.types.EntityManagerReference)1 AVKPersistenceUnitInfoImpl (com.sun.enterprise.tools.verifier.persistence.AVKPersistenceUnitInfoImpl)1 File (java.io.File)1 Properties (java.util.Properties)1 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 PersistenceException (javax.persistence.PersistenceException)1 PersistenceProvider (javax.persistence.spi.PersistenceProvider)1 PersistenceUnitInfo (javax.persistence.spi.PersistenceUnitInfo)1 PersistenceUnitProperties (org.eclipse.persistence.config.PersistenceUnitProperties)1