Search in sources :

Example 1 with JPAStoreSubsystemConfigurationBuilder

use of org.wildfly.extension.picketlink.idm.config.JPAStoreSubsystemConfigurationBuilder in project wildfly by wildfly.

the class PartitionManagerAddHandler method configureJPAIdentityStore.

private JPAStoreSubsystemConfigurationBuilder configureJPAIdentityStore(OperationContext context, ServiceBuilder<PartitionManager> serviceBuilder, PartitionManagerService partitionManagerService, final ModelNode identityStore, String configurationName, final NamedIdentityConfigurationBuilder builder) throws OperationFailedException {
    JPAStoreSubsystemConfigurationBuilder storeConfig = builder.stores().add(JPAStoreSubsystemConfiguration.class, JPAStoreSubsystemConfigurationBuilder.class);
    ModelNode jpaDataSourceNode = JPAStoreResourceDefinition.DATA_SOURCE.resolveModelAttribute(context, identityStore);
    ModelNode jpaEntityModule = JPAStoreResourceDefinition.ENTITY_MODULE.resolveModelAttribute(context, identityStore);
    ModelNode jpaEntityModuleUnitName = JPAStoreResourceDefinition.ENTITY_MODULE_UNIT_NAME.resolveModelAttribute(context, identityStore);
    ModelNode jpaEntityManagerFactoryNode = JPAStoreResourceDefinition.ENTITY_MANAGER_FACTORY.resolveModelAttribute(context, identityStore);
    if (jpaEntityModule.isDefined()) {
        storeConfig.entityModule(jpaEntityModule.asString());
    }
    storeConfig.entityModuleUnitName(jpaEntityModuleUnitName.asString());
    if (serviceBuilder != null) {
        JPAIdentityStoreService storeService = new JPAIdentityStoreService(storeConfig);
        ServiceName storeServiceName = PartitionManagerService.createIdentityStoreServiceName(partitionManagerService.getName(), configurationName, ModelElement.JPA_STORE.getName());
        ServiceBuilder<JPAIdentityStoreService> storeServiceBuilder = context.getServiceTarget().addService(storeServiceName, storeService);
        storeServiceBuilder.addDependency(TxnServices.JBOSS_TXN_TRANSACTION_MANAGER, TransactionManager.class, storeService.getTransactionManager());
        storeServiceBuilder.addDependency(TxnServices.JBOSS_TXN_SYNCHRONIZATION_REGISTRY, TransactionSynchronizationRegistry.class, storeService.getTransactionSynchronizationRegistry());
        if (jpaDataSourceNode.isDefined()) {
            storeConfig.dataSourceJndiUrl(toJndiName(jpaDataSourceNode.asString()));
            storeServiceBuilder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(toJndiName(jpaDataSourceNode.asString()).split("/")));
        }
        if (jpaEntityManagerFactoryNode.isDefined()) {
            storeConfig.entityManagerFactoryJndiName(jpaEntityManagerFactoryNode.asString());
            storeServiceBuilder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(jpaEntityManagerFactoryNode.asString().split("/")), ValueManagedReferenceFactory.class, new InjectedValue<ValueManagedReferenceFactory>());
        }
        serviceBuilder.addDependency(storeServiceName);
        ServiceController<JPAIdentityStoreService> controller = storeServiceBuilder.setInitialMode(Mode.PASSIVE).install();
    }
    return storeConfig;
}
Also used : JPAIdentityStoreService(org.wildfly.extension.picketlink.idm.service.JPAIdentityStoreService) ServiceName(org.jboss.msc.service.ServiceName) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ModelNode(org.jboss.dmr.ModelNode) JPAStoreSubsystemConfigurationBuilder(org.wildfly.extension.picketlink.idm.config.JPAStoreSubsystemConfigurationBuilder)

Aggregations

ValueManagedReferenceFactory (org.jboss.as.naming.ValueManagedReferenceFactory)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceName (org.jboss.msc.service.ServiceName)1 JPAStoreSubsystemConfigurationBuilder (org.wildfly.extension.picketlink.idm.config.JPAStoreSubsystemConfigurationBuilder)1 JPAIdentityStoreService (org.wildfly.extension.picketlink.idm.service.JPAIdentityStoreService)1