Search in sources :

Example 1 with PersistenceCompleteInstallProcessor

use of org.jboss.as.jpa.processor.PersistenceCompleteInstallProcessor in project wildfly by wildfly.

the class JPASubSystemAdd method performBoottime.

protected void performBoottime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
    runtimeValidator.validate(operation.resolve());
    context.addStep(new AbstractDeploymentChainStep() {

        protected void execute(DeploymentProcessorTarget processorTarget) {
            // set Hibernate persistence provider as the default provider
            javax.persistence.spi.PersistenceProviderResolverHolder.setPersistenceProviderResolver(PersistenceProviderResolverImpl.getInstance());
            final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
            PlatformImpl platform;
            if (appclient) {
                // we do not yet support a second level cache in the client container
                platform = new PlatformImpl(Classification.NONE);
            } else {
                // Infinispan can be used in server container
                platform = new PlatformImpl(Classification.INFINISPAN, Classification.INFINISPAN);
            }
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.STRUCTURE, Phase.STRUCTURE_REGISTER_JBOSS_ALL_JPA, new JBossAllXmlParserRegisteringProcessor<>(JPAJarJBossAllParser.ROOT_ELEMENT, JpaAttachments.DEPLOYMENT_SETTINGS_KEY, new JPAJarJBossAllParser()));
            // handles parsing of persistence.xml
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_PERSISTENCE_UNIT, new PersistenceUnitParseProcessor(appclient));
            // handles persistence unit / context annotations in components
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_PERSISTENCE_ANNOTATION, new JPAAnnotationProcessor());
            // injects JPA dependencies into an application
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_JPA, new JPADependencyProcessor());
            // Inject Hibernate Search dependencies into an application
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_HIBERNATE_SEARCH, new HibernateSearchProcessor());
            // handle ClassFileTransformer
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.FIRST_MODULE_USE, Phase.FIRST_MODULE_USE_PERSISTENCE_CLASS_FILE_TRANSFORMER, new JPAClassFileTransformerProcessor());
            // registers listeners/interceptors on session beans
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.FIRST_MODULE_USE, Phase.FIRST_MODULE_USE_INTERCEPTORS, new JPAInterceptorProcessor());
            // begin pu service install and deploying a persistence provider
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.FIRST_MODULE_USE, Phase.FIRST_MODULE_USE_PERSISTENCE_PREPARE, new PersistenceBeginInstallProcessor(platform));
            // handles persistence unit / context references from deployment descriptors
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_PERSISTENCE_REF, new PersistenceRefProcessor());
            // handles pu deployment (completes pu service installation)
            processorTarget.addDeploymentProcessor(JPAExtension.SUBSYSTEM_NAME, Phase.INSTALL, Phase.INSTALL_PERSISTENTUNIT, new PersistenceCompleteInstallProcessor(platform));
        }
    }, OperationContext.Stage.RUNTIME);
    final ModelNode defaultDSNode = operation.require(CommonAttributes.DEFAULT_DATASOURCE);
    final String dataSourceName = defaultDSNode.resolve().asString();
    ExtendedPersistenceInheritance defaultExtendedPersistenceInheritance = ExtendedPersistenceInheritance.DEEP;
    if (operation.hasDefined(CommonAttributes.DEFAULT_EXTENDEDPERSISTENCE_INHERITANCE)) {
        final ModelNode defaultExtendedPersistenceInheritanceNode = operation.get(CommonAttributes.DEFAULT_EXTENDEDPERSISTENCE_INHERITANCE);
        defaultExtendedPersistenceInheritance = ExtendedPersistenceInheritance.valueOf(defaultExtendedPersistenceInheritanceNode.resolve().asString());
    }
    final ServiceTarget target = context.getServiceTarget();
    JPAService.addService(target, dataSourceName, defaultExtendedPersistenceInheritance);
    JPAUserTransactionListenerService.addService(target);
}
Also used : JBossAllXmlParserRegisteringProcessor(org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor) ServiceTarget(org.jboss.msc.service.ServiceTarget) PersistenceRefProcessor(org.jboss.as.jpa.processor.PersistenceRefProcessor) JPAInterceptorProcessor(org.jboss.as.jpa.processor.JPAInterceptorProcessor) PersistenceCompleteInstallProcessor(org.jboss.as.jpa.processor.PersistenceCompleteInstallProcessor) JPADependencyProcessor(org.jboss.as.jpa.processor.JPADependencyProcessor) ExtendedPersistenceInheritance(org.jboss.as.jpa.config.ExtendedPersistenceInheritance) JPAJarJBossAllParser(org.jboss.as.jpa.processor.JPAJarJBossAllParser) DeploymentProcessorTarget(org.jboss.as.server.DeploymentProcessorTarget) PersistenceUnitParseProcessor(org.jboss.as.jpa.processor.PersistenceUnitParseProcessor) JPAClassFileTransformerProcessor(org.jboss.as.jpa.processor.JPAClassFileTransformerProcessor) AbstractDeploymentChainStep(org.jboss.as.server.AbstractDeploymentChainStep) HibernateSearchProcessor(org.jboss.as.jpa.processor.HibernateSearchProcessor) ModelNode(org.jboss.dmr.ModelNode) JPAAnnotationProcessor(org.jboss.as.jpa.processor.JPAAnnotationProcessor) PersistenceBeginInstallProcessor(org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor) PlatformImpl(org.jboss.as.jpa.platform.PlatformImpl)

Aggregations

ExtendedPersistenceInheritance (org.jboss.as.jpa.config.ExtendedPersistenceInheritance)1 PlatformImpl (org.jboss.as.jpa.platform.PlatformImpl)1 HibernateSearchProcessor (org.jboss.as.jpa.processor.HibernateSearchProcessor)1 JPAAnnotationProcessor (org.jboss.as.jpa.processor.JPAAnnotationProcessor)1 JPAClassFileTransformerProcessor (org.jboss.as.jpa.processor.JPAClassFileTransformerProcessor)1 JPADependencyProcessor (org.jboss.as.jpa.processor.JPADependencyProcessor)1 JPAInterceptorProcessor (org.jboss.as.jpa.processor.JPAInterceptorProcessor)1 JPAJarJBossAllParser (org.jboss.as.jpa.processor.JPAJarJBossAllParser)1 PersistenceBeginInstallProcessor (org.jboss.as.jpa.processor.PersistenceBeginInstallProcessor)1 PersistenceCompleteInstallProcessor (org.jboss.as.jpa.processor.PersistenceCompleteInstallProcessor)1 PersistenceRefProcessor (org.jboss.as.jpa.processor.PersistenceRefProcessor)1 PersistenceUnitParseProcessor (org.jboss.as.jpa.processor.PersistenceUnitParseProcessor)1 AbstractDeploymentChainStep (org.jboss.as.server.AbstractDeploymentChainStep)1 DeploymentProcessorTarget (org.jboss.as.server.DeploymentProcessorTarget)1 JBossAllXmlParserRegisteringProcessor (org.jboss.as.server.deployment.jbossallxml.JBossAllXmlParserRegisteringProcessor)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceTarget (org.jboss.msc.service.ServiceTarget)1