Search in sources :

Example 1 with ManagedReferenceInjector

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);
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) ManagedReferenceInjector(org.jboss.as.naming.ManagedReferenceInjector) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ValueService(org.jboss.msc.service.ValueService) ImmediateValue(org.jboss.msc.value.ImmediateValue) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Example 2 with ManagedReferenceInjector

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);
}
Also used : ManagedReferenceInjector(org.jboss.as.naming.ManagedReferenceInjector) ManagedReferenceInjector(org.jboss.as.naming.ManagedReferenceInjector) Injector(org.jboss.msc.inject.Injector) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory)

Example 3 with ManagedReferenceInjector

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);
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) ManagedReferenceInjector(org.jboss.as.naming.ManagedReferenceInjector) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ContextNames(org.jboss.as.naming.deployment.ContextNames)

Aggregations

ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)3 ManagedReferenceInjector (org.jboss.as.naming.ManagedReferenceInjector)3 ContextNames (org.jboss.as.naming.deployment.ContextNames)2 BinderService (org.jboss.as.naming.service.BinderService)2 Injector (org.jboss.msc.inject.Injector)1 ValueService (org.jboss.msc.service.ValueService)1 ImmediateValue (org.jboss.msc.value.ImmediateValue)1