/** * {@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); }
/** * Binds the java:comp/UserTransaction service and the java:comp/TransactionSynchronizationRegistry * * @param deploymentUnit The deployment unit * @param serviceTarget The service target * @param contextServiceName The service name of the context to bind to */ private void bindServices(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName contextServiceName) { final ServiceName userTransactionServiceName = contextServiceName.append("UserTransaction"); final UserTransactionBindingService userTransactionBindingService = new UserTransactionBindingService("UserTransaction"); serviceTarget.addService(userTransactionServiceName, userTransactionBindingService) .addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class,userTransactionBindingService.getUserTransactionAccessControlServiceInjector()) .addDependency(UserTransactionService.INTERNAL_SERVICE_NAME, UserTransaction.class, new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, userTransactionBindingService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,userTransactionServiceName); final ServiceName transactionSynchronizationRegistryName = contextServiceName.append("TransactionSynchronizationRegistry"); BinderService transactionSyncBinderService = new BinderService("TransactionSynchronizationRegistry"); serviceTarget.addService(transactionSynchronizationRegistryName, transactionSyncBinderService) .addDependency(TransactionSynchronizationRegistryService.INTERNAL_SERVICE_NAME, TransactionSynchronizationRegistry.class, new ManagedReferenceInjector<TransactionSynchronizationRegistry>(transactionSyncBinderService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, transactionSyncBinderService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,transactionSynchronizationRegistryName); }
/** * Binds java:comp/ORB * * @param serviceTarget The service target * @param contextServiceName The service name of the context to bind to */ private void bindService(final ServiceTarget serviceTarget, final ServiceName contextServiceName, final Module module) { final ServiceName orbServiceName = contextServiceName.append("ORB"); final BinderService orbService = new BinderService("ORB"); serviceTarget.addService(orbServiceName, orbService) .addDependency(CorbaORBService.SERVICE_NAME, ORB.class, new ManagedReferenceInjector<ORB>(orbService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, orbService.getNamingStoreInjector()) .install(); final ServiceName handleDelegateServiceName = contextServiceName.append("HandleDelegate"); final BinderService handleDelegateBindingService = new BinderService("HandleDelegate"); handleDelegateBindingService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue(new HandleDelegateImpl(module.getClassLoader())))); serviceTarget.addService(handleDelegateServiceName, handleDelegateBindingService) .addDependency(contextServiceName, ServiceBasedNamingStore.class, handleDelegateBindingService.getNamingStoreInjector()) .install(); }
@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); } }
.addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class, userTransactionBindingService.getUserTransactionAccessControlServiceInjector()) .addDependency(UserTransactionService.INTERNAL_SERVICE_NAME, UserTransaction.class, new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector())); utBuilder.install();
/** * {@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); }
/** * {@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); }
/** * Binds the java:comp/UserTransaction service and the java:comp/TransactionSynchronizationRegistry * * @param deploymentUnit The deployment unit * @param serviceTarget The service target * @param contextServiceName The service name of the context to bind to */ private void bindServices(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName contextServiceName) { final ServiceName userTransactionServiceName = contextServiceName.append("UserTransaction"); final UserTransactionBindingService userTransactionBindingService = new UserTransactionBindingService("UserTransaction"); serviceTarget.addService(userTransactionServiceName, userTransactionBindingService) .addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class,userTransactionBindingService.getUserTransactionAccessControlServiceInjector()) .addDependency(UserTransactionService.INTERNAL_SERVICE_NAME, UserTransaction.class, new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, userTransactionBindingService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,userTransactionServiceName); final ServiceName transactionSynchronizationRegistryName = contextServiceName.append("TransactionSynchronizationRegistry"); BinderService transactionSyncBinderService = new BinderService("TransactionSynchronizationRegistry"); serviceTarget.addService(transactionSynchronizationRegistryName, transactionSyncBinderService) .addDependency(TransactionSynchronizationRegistryService.INTERNAL_SERVICE_NAME, TransactionSynchronizationRegistry.class, new ManagedReferenceInjector<TransactionSynchronizationRegistry>(transactionSyncBinderService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, transactionSyncBinderService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,transactionSynchronizationRegistryName); }
/** * Binds the java:comp/UserTransaction service and the java:comp/TransactionSynchronizationRegistry * * @param deploymentUnit The deployment unit * @param serviceTarget The service target * @param contextServiceName The service name of the context to bind to */ private void bindServices(DeploymentUnit deploymentUnit, ServiceTarget serviceTarget, ServiceName contextServiceName) { final ServiceName userTransactionServiceName = contextServiceName.append("UserTransaction"); final UserTransactionBindingService userTransactionBindingService = new UserTransactionBindingService("UserTransaction"); serviceTarget.addService(userTransactionServiceName, userTransactionBindingService) .addDependency(UserTransactionAccessControlService.SERVICE_NAME, UserTransactionAccessControlService.class,userTransactionBindingService.getUserTransactionAccessControlServiceInjector()) .addDependency(UserTransactionService.SERVICE_NAME, UserTransaction.class, new ManagedReferenceInjector<UserTransaction>(userTransactionBindingService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, userTransactionBindingService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,userTransactionServiceName); final ServiceName transactionSynchronizationRegistryName = contextServiceName.append("TransactionSynchronizationRegistry"); BinderService transactionSyncBinderService = new BinderService("TransactionSynchronizationRegistry"); serviceTarget.addService(transactionSynchronizationRegistryName, transactionSyncBinderService) .addDependency(TransactionSynchronizationRegistryService.SERVICE_NAME, TransactionSynchronizationRegistry.class, new ManagedReferenceInjector<TransactionSynchronizationRegistry>(transactionSyncBinderService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, transactionSyncBinderService.getNamingStoreInjector()) .install(); deploymentUnit.addToAttachmentList(org.jboss.as.server.deployment.Attachments.JNDI_DEPENDENCIES,transactionSynchronizationRegistryName); }
public static ServiceController<?> addService(final ServiceTarget serviceTarget) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_FACTORY_BINDING_NAME); BinderService binderService = new BinderService(bindInfo.getBindName()) { @Override public synchronized void start(StartContext context) throws StartException { super.start(context); LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName()); } @Override public synchronized void stop(StopContext context) { LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName()); super.stop(context); } }; Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector(); ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService); builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()); builder.addDependency(CamelConstants.CAMEL_CONTEXT_FACTORY_SERVICE_NAME, CamelContextFactory.class, new ManagedReferenceInjector<CamelContextFactory>(injector)); return builder.install(); } }
public static ServiceController<?> addService(ServiceTarget serviceTarget) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_REGISTRY_BINDING_NAME); BinderService binderService = new BinderService(bindInfo.getBindName()) { @Override public synchronized void start(StartContext context) throws StartException { super.start(context); LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName()); } @Override public synchronized void stop(StopContext context) { LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName()); super.stop(context); } }; Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector(); ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService); builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()); builder.addDependency(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, CamelContextRegistry.class, new ManagedReferenceInjector<CamelContextRegistry>(injector)); return builder.install(); } }
public static ServiceController<?> addService(final ServiceTarget serviceTarget) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_FACTORY_BINDING_NAME); BinderService binderService = new BinderService(bindInfo.getBindName()) { @Override public synchronized void start(StartContext context) throws StartException { super.start(context); LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName()); } @Override public synchronized void stop(StopContext context) { LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName()); super.stop(context); } }; Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector(); ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService); builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()); builder.addDependency(CamelConstants.CAMEL_CONTEXT_FACTORY_SERVICE_NAME, CamelContextFactory.class, new ManagedReferenceInjector<CamelContextFactory>(injector)); return builder.install(); } }
public static ServiceController<?> addService(ServiceTarget serviceTarget) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(CamelConstants.CAMEL_CONTEXT_REGISTRY_BINDING_NAME); BinderService binderService = new BinderService(bindInfo.getBindName()) { @Override public synchronized void start(StartContext context) throws StartException { super.start(context); LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName()); } @Override public synchronized void stop(StopContext context) { LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName()); super.stop(context); } }; Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector(); ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService); builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()); builder.addDependency(CamelConstants.CAMEL_CONTEXT_REGISTRY_SERVICE_NAME, CamelContextRegistry.class, new ManagedReferenceInjector<CamelContextRegistry>(injector)); return builder.install(); } }
@SuppressWarnings("rawtypes") ServiceController<?> installJndiService(ServiceTarget target, String containerName, String cacheName, String jndiName) { final ServiceName cacheServiceName = CacheServiceName.CACHE.getServiceName(containerName, cacheName); final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName); final BinderService binder = new BinderService(bindInfo.getBindName()); return target.addService(bindInfo.getBinderServiceName(), binder) .addAliases(ContextNames.JAVA_CONTEXT_SERVICE_NAME.append(jndiName)) .addDependency(cacheServiceName, Cache.class, new ManagedReferenceInjector<>(binder.getManagedObjectInjector())) .addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binder.getNamingStoreInjector()) .setInitialMode(ServiceController.Mode.PASSIVE) .install() ; }
@Override public ServiceBuilder<ManagedReferenceFactory> build(ServiceTarget target) { 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); } }
/** * Binds java:comp/ORB * * @param serviceTarget The service target * @param contextServiceName The service name of the context to bind to */ private void bindService(final ServiceTarget serviceTarget, final ServiceName contextServiceName, final Module module) { final ServiceName orbServiceName = contextServiceName.append("ORB"); final BinderService orbService = new BinderService("ORB"); serviceTarget.addService(orbServiceName, orbService) .addDependency(CorbaORBService.SERVICE_NAME, ORB.class, new ManagedReferenceInjector<ORB>(orbService.getManagedObjectInjector())) .addDependency(contextServiceName, ServiceBasedNamingStore.class, orbService.getNamingStoreInjector()) .install(); final ServiceName handleDelegateServiceName = contextServiceName.append("HandleDelegate"); final BinderService handleDelegateBindingService = new BinderService("HandleDelegate"); handleDelegateBindingService.getManagedObjectInjector().inject(new ValueManagedReferenceFactory(new ImmediateValue(new HandleDelegateImpl(module.getClassLoader())))); serviceTarget.addService(handleDelegateServiceName, handleDelegateBindingService) .addDependency(contextServiceName, ServiceBasedNamingStore.class, handleDelegateBindingService.getNamingStoreInjector()) .install(); }
private ServiceController<?> addBinderService(String name, Object obj) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name); BinderService binderService = new BinderService(bindInfo.getBindName()) { @Override public synchronized void start(StartContext context) throws StartException { super.start(context); LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName()); } @Override public synchronized void stop(StopContext context) { LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName()); super.stop(context); } }; Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector(); new ManagedReferenceInjector<Object>(injector).inject(obj); ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService); builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()); return builder.install(); }
private ServiceController<?> addBinderService(String name, Object obj) { final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(name); BinderService binderService = new BinderService(bindInfo.getBindName()) { @Override public synchronized void start(StartContext context) throws StartException { super.start(context); LOGGER.info("Bound camel naming object: {}", bindInfo.getAbsoluteJndiName()); } @Override public synchronized void stop(StopContext context) { LOGGER.debug("Unbind camel naming object: {}", bindInfo.getAbsoluteJndiName()); super.stop(context); } }; Injector<ManagedReferenceFactory> injector = binderService.getManagedObjectInjector(); new ManagedReferenceInjector<Object>(injector).inject(obj); ServiceBuilder<?> builder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService); builder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()); return builder.install(); }
@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); } }
binderBuilder.addDependency(ModeShapeServiceNames.ENGINE, ModeShapeEngine.class, new ManagedReferenceInjector<ModeShapeEngine>(binderService.getManagedObjectInjector())); binderBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class,