use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class NamingBindingAdd method installSimpleBinding.
void installSimpleBinding(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
Object bindValue = createSimpleBinding(context, model);
ValueManagedReferenceFactory referenceFactory = new ValueManagedReferenceFactory(new ImmediateValue<Object>(bindValue));
final BinderService binderService = new BinderService(name, bindValue);
binderService.getManagedObjectInjector().inject(new MutableManagedReferenceFactory(referenceFactory));
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
final ServiceTarget serviceTarget = context.getServiceTarget();
ServiceBuilder<ManagedReferenceFactory> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
builder.install();
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class NamingBindingAdd method installLookup.
void installLookup(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
final String lookup = NamingBindingResourceDefinition.LOOKUP.resolveModelAttribute(context, model).asString();
final ServiceTarget serviceTarget = context.getServiceTarget();
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name);
final BinderService binderService = new BinderService(name);
binderService.getManagedObjectInjector().inject(new MutableManagedReferenceFactory(new LookupManagedReferenceFactory(lookup)));
serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).install();
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class PartitionManagerService method publishPartitionManager.
private void publishPartitionManager(StartContext context) {
BindInfo bindInfo = createPartitionManagerBindInfo();
ServiceName serviceName = bindInfo.getBinderServiceName();
final BinderService binderService = new BinderService(serviceName.getCanonicalName());
final ServiceBuilder<ManagedReferenceFactory> builder = context.getController().getServiceContainer().addService(serviceName, binderService).addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(this.jndiName));
builder.addDependency(ContextNames.JAVA_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector());
builder.addDependency(createServiceName(this.alias), PartitionManager.class, new Injector<PartitionManager>() {
@Override
public void inject(final PartitionManager value) throws InjectionException {
binderService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue<Object>(value)));
}
@Override
public void uninject() {
binderService.getManagedObjectInjector().uninject();
}
});
builder.setInitialMode(Mode.PASSIVE).install();
ROOT_LOGGER.boundToJndi("PartitionManager " + this.alias, bindInfo.getAbsoluteJndiName());
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class MailSessionDefinitionInjectionSource method startMailSession.
private void startMailSession(final MailSessionService mailSessionService, final String jndiName, final EEModuleDescription moduleDescription, final ResolutionContext context, final ServiceTarget serviceTarget, final ServiceBuilder<?> valueSourceServiceBuilder, final Injector<ManagedReferenceFactory> injector) {
final ServiceName mailSessionServiceName = MailSessionAdd.MAIL_SESSION_SERVICE_NAME.append("MailSessionDefinition", moduleDescription.getApplicationName(), moduleDescription.getModuleName(), jndiName);
final ServiceBuilder<?> mailSessionServiceBuilder = serviceTarget.addService(mailSessionServiceName, mailSessionService);
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(context.getApplicationName(), context.getModuleName(), context.getComponentName(), !context.isCompUsesModule(), jndiName);
final MailSessionManagedReferenceFactory referenceFactoryService = new MailSessionManagedReferenceFactory(mailSessionService);
final BinderService binderService = new BinderService(bindInfo.getBindName(), this);
final ServiceBuilder<?> binderBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addInjection(binderService.getManagedObjectInjector(), referenceFactoryService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<? extends Object> controller, final ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
MailLogger.ROOT_LOGGER.boundMailSession(jndiName);
break;
}
case START_REQUESTED_to_DOWN:
{
MailLogger.ROOT_LOGGER.unboundMailSession(jndiName);
break;
}
case REMOVING_to_REMOVED:
{
MailLogger.ROOT_LOGGER.debugf("Removed Mail Session [%s]", jndiName);
break;
}
}
}
});
mailSessionServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
valueSourceServiceBuilder.addDependency(bindInfo.getBinderServiceName(), ManagedReferenceFactory.class, injector);
}
use of org.jboss.as.naming.service.BinderService in project wildfly by wildfly.
the class BinderServiceUtil method installBinderService.
/**
* Install a binder service to bind the {@code obj} using the binding {@code name}.
* @param serviceTarget
* @param name the binding name
* @param obj the object that must be bound
*/
public static void installBinderService(final ServiceTarget serviceTarget, final String name, final Object obj) {
final BindInfo bindInfo = ContextNames.bindInfoFor(name);
final BinderService binderService = new BinderService(bindInfo.getBindName());
serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addInjection(binderService.getManagedObjectInjector(), new ValueManagedReferenceFactory(Values.immediateValue(obj))).setInitialMode(ServiceController.Mode.ACTIVE).install();
}
Aggregations