Search in sources :

Example 1 with CurrentServiceContainer

use of org.jboss.as.server.CurrentServiceContainer in project wildfly by wildfly.

the class ServiceTransactionSetupProvider method readObject.

private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
    in.defaultReadObject();
    // resolve from msc
    final ServiceContainer currentServiceContainer = System.getSecurityManager() == null ? CurrentServiceContainer.getServiceContainer() : AccessController.doPrivileged(CurrentServiceContainer.GET_ACTION);
    final ServiceController<?> serviceController = currentServiceContainer.getService(serviceName);
    if (serviceController == null) {
        throw EeLogger.ROOT_LOGGER.transactionSetupProviderServiceNotInstalled();
    }
    transactionSetupProvider = (TransactionSetupProvider) serviceController.getValue();
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) CurrentServiceContainer(org.jboss.as.server.CurrentServiceContainer)

Example 2 with CurrentServiceContainer

use of org.jboss.as.server.CurrentServiceContainer in project wildfly by wildfly.

the class InfinispanCacheDeploymentListener method startCache.

@Override
public Wrapper startCache(Classification classification, Properties properties) throws Exception {
    String cache_type = properties.getProperty(CACHE_TYPE);
    String container = properties.getProperty(CONTAINER);
    // TODO Figure out how to access CapabilityServiceSupport from here
    ServiceName containerServiceName = ServiceName.parse(InfinispanRequirement.CONTAINER.resolve(container));
    EmbeddedCacheManager embeddedCacheManager;
    ServiceName serviceName;
    if (CACHE_PRIVATE.equals(cache_type)) {
        // need a private cache for non-jpa application use
        String name = properties.getProperty(NAME);
        serviceName = ServiceName.JBOSS.append(DEFAULT_CACHE_CONTAINER, (name != null) ? name : UUID.randomUUID().toString());
        ServiceContainer target = currentServiceContainer();
        // Create a mock service that represents this session factory instance
        ServiceBuilder<EmbeddedCacheManager> builder = new AliasServiceBuilder<>(serviceName, containerServiceName, EmbeddedCacheManager.class).build(target).setInitialMode(ServiceController.Mode.ACTIVE);
        embeddedCacheManager = ServiceContainerHelper.getValue(builder.install());
    } else {
        // need a shared cache for jpa applications
        serviceName = containerServiceName;
        ServiceRegistry registry = currentServiceContainer();
        embeddedCacheManager = (EmbeddedCacheManager) registry.getRequiredService(serviceName).getValue();
    }
    return new CacheWrapper(embeddedCacheManager, serviceName);
}
Also used : ServiceContainer(org.jboss.msc.service.ServiceContainer) CurrentServiceContainer(org.jboss.as.server.CurrentServiceContainer) ServiceName(org.jboss.msc.service.ServiceName) ServiceRegistry(org.jboss.msc.service.ServiceRegistry) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) AliasServiceBuilder(org.wildfly.clustering.service.AliasServiceBuilder)

Aggregations

CurrentServiceContainer (org.jboss.as.server.CurrentServiceContainer)2 ServiceContainer (org.jboss.msc.service.ServiceContainer)2 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 ServiceName (org.jboss.msc.service.ServiceName)1 ServiceRegistry (org.jboss.msc.service.ServiceRegistry)1 AliasServiceBuilder (org.wildfly.clustering.service.AliasServiceBuilder)1