use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.
the class PersistenceUnitServiceHandler method entityManagerFactoryBind.
private static void entityManagerFactoryBind(EEModuleDescription eeModuleDescription, ServiceTarget serviceTarget, PersistenceUnitMetadata pu, ServiceName puServiceName) {
if (pu.getProperties().containsKey(ENTITYMANAGERFACTORY_JNDI_PROPERTY)) {
String jndiName = pu.getProperties().get(ENTITYMANAGERFACTORY_JNDI_PROPERTY).toString();
final ContextNames.BindInfo bindingInfo;
if (jndiName.startsWith("java:")) {
bindingInfo = ContextNames.bindInfoForEnvEntry(eeModuleDescription.getApplicationName(), eeModuleDescription.getModuleName(), eeModuleDescription.getModuleName(), false, jndiName);
} else {
bindingInfo = ContextNames.bindInfoFor(jndiName);
}
ROOT_LOGGER.tracef("binding the entity manager factory to jndi name '%s'", bindingInfo.getAbsoluteJndiName());
final BinderService binderService = new BinderService(bindingInfo.getBindName());
serviceTarget.addService(bindingInfo.getBinderServiceName(), binderService).addDependency(bindingInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addDependency(puServiceName, PersistenceUnitServiceImpl.class, new Injector<PersistenceUnitServiceImpl>() {
@Override
public void inject(final PersistenceUnitServiceImpl value) throws InjectionException {
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value.getEntityManagerFactory())));
}
@Override
public void uninject() {
binderService.getNamingStoreInjector().uninject();
}
}).install();
}
}
use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.
the class UndertowDeploymentProcessor method installSessionManagerFactory.
private static ServiceName installSessionManagerFactory(CapabilityServiceSupport support, ServiceTarget target, ServiceName deploymentServiceName, String deploymentName, Module module, JBossWebMetaData metaData, ServletContainerService servletContainerService) {
Integer maxActiveSessions = metaData.getMaxActiveSessions();
if (maxActiveSessions == null && servletContainerService != null) {
maxActiveSessions = servletContainerService.getMaxSessions();
}
ServiceName name = deploymentServiceName.append("session");
if (metaData.getDistributable() != null) {
DistributableSessionManagerFactoryBuilder sessionManagerFactoryBuilder = new DistributableSessionManagerFactoryBuilderValue().getValue();
if (sessionManagerFactoryBuilder != null) {
sessionManagerFactoryBuilder.build(support, target, name, new SimpleDistributableSessionManagerConfiguration(maxActiveSessions, metaData.getReplicationConfig(), deploymentName, module)).setInitialMode(Mode.ON_DEMAND).install();
return name;
}
// Fallback to local session manager if server does not support clustering
UndertowLogger.ROOT_LOGGER.clusteringNotSupported();
}
InMemorySessionManagerFactory factory = (maxActiveSessions != null) ? new InMemorySessionManagerFactory(maxActiveSessions) : new InMemorySessionManagerFactory();
target.addService(name, new ValueService<>(new ImmediateValue<>(factory))).setInitialMode(Mode.ON_DEMAND).install();
return name;
}
use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.
the class BinderServiceBuilder method build.
@Override
public ServiceBuilder<ManagedReferenceFactory> build(ServiceTarget target) {
if (!this.enabled) {
// If naming is not enabled, just install a dummy service that never starts
Value<ManagedReferenceFactory> value = new ImmediateValue<>(null);
return target.addService(this.getServiceName(), new ValueService<>(value)).setInitialMode(ServiceController.Mode.NEVER);
}
String name = this.binding.getBindName();
BinderService binder = new BinderService(name);
ServiceBuilder<ManagedReferenceFactory> builder = target.addService(this.getServiceName(), binder).addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(name)).addDependency(this.targetServiceName, this.targetClass, new ManagedReferenceInjector<T>(binder.getManagedObjectInjector())).addDependency(this.binding.getParentContextServiceName(), ServiceBasedNamingStore.class, binder.getNamingStoreInjector());
for (ContextNames.BindInfo alias : this.aliases) {
builder.addAliases(alias.getBinderServiceName(), ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(alias.getBindName()));
}
return builder.setInitialMode(ServiceController.Mode.PASSIVE);
}
use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.
the class ThreadPoolFactoryBuilder method build.
@Override
public ServiceBuilder<ThreadPoolFactory> build(ServiceTarget target) {
int queueLength = this.getQueueLength();
BlockingQueue<Runnable> queue = (queueLength > 0) ? new ArrayBlockingQueue<>(queueLength) : new SynchronousQueue<>();
ClassLoader loader = JChannelFactory.class.getClassLoader();
ThreadFactory threadFactory = new ClassLoaderThreadFactory(new DefaultThreadFactory(this.getThreadGroupPrefix(), false, true), loader);
RejectedExecutionHandler handler = new ShutdownRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
ThreadPoolFactory factory = () -> new ThreadPoolExecutor(this.getMinThreads(), this.getMaxThreads(), this.getKeepAliveTime(), TimeUnit.MILLISECONDS, queue, threadFactory, handler);
return target.addService(this.getServiceName(), new ValueService<>(new ImmediateValue<>(factory)));
}
use of org.jboss.msc.value.ImmediateValue in project wildfly by wildfly.
the class TimerFactoryBuilder method build.
@Override
public ServiceBuilder<TimerFactory> build(ServiceTarget target) {
ThreadFactory threadFactory = new ClassLoaderThreadFactory(new LazyThreadFactory(this.getThreadGroupPrefix(), true, true), JChannelFactory.class.getClassLoader());
TimerFactory factory = () -> new TimeScheduler3(threadFactory, this.getMinThreads(), this.getMaxThreads(), this.getKeepAliveTime(), this.getQueueLength(), "abort");
return target.addService(this.getServiceName(), new ValueService<>(new ImmediateValue<>(factory)));
}
Aggregations