use of org.jboss.as.naming.ManagedReferenceInjector 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.as.naming.ManagedReferenceInjector in project wildfly by wildfly.
the class ServiceInjectionSource method getResourceValue.
/**
* {@inheritDoc}
*/
public void getResourceValue(final ResolutionContext context, final ServiceBuilder<?> serviceBuilder, final DeploymentPhaseContext phaseContext, final Injector<ManagedReferenceFactory> injector) {
Injector inject = ManagedReferenceFactory.class.isAssignableFrom(serviceValueType) ? injector : new ManagedReferenceInjector(injector);
serviceBuilder.addDependency(serviceName, serviceValueType, inject);
}
use of org.jboss.as.naming.ManagedReferenceInjector in project wildfly by wildfly.
the class BinderServiceConfigurator method build.
@SuppressWarnings("deprecation")
@Override
public ServiceBuilder<?> build(ServiceTarget target) {
if (!this.enabled) {
// If naming is not enabled, just install a dummy service that never starts
return target.addService(this.getServiceName()).setInitialMode(ServiceController.Mode.NEVER);
}
String name = this.binding.getBindName();
BinderService binder = new BinderService(name);
// Until ServiceBasedNamingStore works with new MSC API, we need to use deprecated ServiceBuilder methods
ServiceBuilder<ManagedReferenceFactory> builder = target.addService(this.getServiceName(), binder).addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(name)).addDependency(this.targetServiceName, Object.class, new ManagedReferenceInjector<>(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);
}
Aggregations