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();
}
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);
}
Aggregations