Search in sources :

Example 1 with BindInfo

use of org.jboss.as.naming.deployment.ContextNames.BindInfo 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());
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) InjectionException(org.jboss.msc.inject.InjectionException) DefaultPartitionManager(org.picketlink.idm.internal.DefaultPartitionManager) PartitionManager(org.picketlink.idm.PartitionManager) ServiceName(org.jboss.msc.service.ServiceName) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) BindInfo(org.jboss.as.naming.deployment.ContextNames.BindInfo)

Example 2 with BindInfo

use of org.jboss.as.naming.deployment.ContextNames.BindInfo 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();
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) BindInfo(org.jboss.as.naming.deployment.ContextNames.BindInfo)

Example 3 with BindInfo

use of org.jboss.as.naming.deployment.ContextNames.BindInfo in project wildfly by wildfly.

the class BinderServiceUtil method installAliasBinderService.

public static void installAliasBinderService(final ServiceTarget serviceTarget, final BindInfo bindInfo, final String alias) {
    final BindInfo aliasBindInfo = ContextNames.bindInfoFor(alias);
    final BinderService aliasBinderService = new BinderService(alias);
    aliasBinderService.getManagedObjectInjector().inject(new AliasManagedReferenceFactory(bindInfo.getAbsoluteJndiName()));
    serviceTarget.addService(aliasBindInfo.getBinderServiceName(), aliasBinderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, aliasBinderService.getNamingStoreInjector()).addDependency(bindInfo.getBinderServiceName()).addListener(new AbstractServiceListener<ManagedReferenceFactory>() {

        @Override
        public void transition(ServiceController<? extends ManagedReferenceFactory> controller, ServiceController.Transition transition) {
            switch(transition) {
                case STARTING_to_UP:
                    {
                        ROOT_LOGGER.boundJndiName(alias);
                        break;
                    }
                case STOPPING_to_DOWN:
                    {
                        ROOT_LOGGER.unboundJndiName(alias);
                        break;
                    }
                case REMOVING_to_REMOVED:
                    {
                        ROOT_LOGGER.debugf("Removed messaging object [%s]", alias);
                        break;
                    }
            }
        }
    }).install();
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) ServiceBasedNamingStore(org.jboss.as.naming.ServiceBasedNamingStore) ContextListAndJndiViewManagedReferenceFactory(org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory) ContextListManagedReferenceFactory(org.jboss.as.naming.ContextListManagedReferenceFactory) ManagedReferenceFactory(org.jboss.as.naming.ManagedReferenceFactory) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) AbstractServiceListener(org.jboss.msc.service.AbstractServiceListener) ServiceController(org.jboss.msc.service.ServiceController) BindInfo(org.jboss.as.naming.deployment.ContextNames.BindInfo)

Example 4 with BindInfo

use of org.jboss.as.naming.deployment.ContextNames.BindInfo in project wildfly by wildfly.

the class BinderServiceUtil method installBinderService.

/**
     * Install a binder service to bind the value of the {@code service} using the binding {@code name}.

     * @param serviceTarget
     * @param name the binding name
     * @param service the service whose value must be bound
     */
public static void installBinderService(final ServiceTarget serviceTarget, final String name, final Service<?> service, final ServiceName... dependencies) {
    final BindInfo bindInfo = ContextNames.bindInfoFor(name);
    final BinderService binderService = new BinderService(bindInfo.getBindName());
    final ServiceBuilder serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addInjection(binderService.getManagedObjectInjector(), new ValueManagedReferenceFactory(service)).setInitialMode(ServiceController.Mode.PASSIVE);
    if (dependencies != null && dependencies.length > 0) {
        serviceBuilder.addDependencies(dependencies);
    }
    serviceBuilder.install();
}
Also used : BinderService(org.jboss.as.naming.service.BinderService) ValueManagedReferenceFactory(org.jboss.as.naming.ValueManagedReferenceFactory) BindInfo(org.jboss.as.naming.deployment.ContextNames.BindInfo) ServiceBuilder(org.jboss.msc.service.ServiceBuilder)

Aggregations

ValueManagedReferenceFactory (org.jboss.as.naming.ValueManagedReferenceFactory)4 BindInfo (org.jboss.as.naming.deployment.ContextNames.BindInfo)4 BinderService (org.jboss.as.naming.service.BinderService)4 ManagedReferenceFactory (org.jboss.as.naming.ManagedReferenceFactory)2 ServiceBasedNamingStore (org.jboss.as.naming.ServiceBasedNamingStore)2 ContextListAndJndiViewManagedReferenceFactory (org.jboss.as.naming.ContextListAndJndiViewManagedReferenceFactory)1 ContextListManagedReferenceFactory (org.jboss.as.naming.ContextListManagedReferenceFactory)1 InjectionException (org.jboss.msc.inject.InjectionException)1 AbstractServiceListener (org.jboss.msc.service.AbstractServiceListener)1 ServiceBuilder (org.jboss.msc.service.ServiceBuilder)1 ServiceController (org.jboss.msc.service.ServiceController)1 ServiceName (org.jboss.msc.service.ServiceName)1 PartitionManager (org.picketlink.idm.PartitionManager)1 DefaultPartitionManager (org.picketlink.idm.internal.DefaultPartitionManager)1