public SimpleBuilder(ServiceName name, Value<T> value) { this(name, new ValueService<>(value)); }
@Override public ServiceBuilder<T> build(ServiceTarget target) { return target.addService(this.name, new ValueService<>(this.value)) .addDependency(this.targetName, this.targetClass, this.value) .setInitialMode(ServiceController.Mode.PASSIVE); } }
@Override public ServiceBuilder<?> build(ServiceTarget target) { ServiceBuilder<?> builder = target.addService(this.getServiceName(), new ValueService<>(this.requirement)); return this.requirement.register(builder).setInitialMode(ServiceController.Mode.PASSIVE); } }
void updateOrCreateDefaultExceptionLoggingEnabledService(final OperationContext context, final ModelNode model) throws OperationFailedException { final boolean enabled = EJB3SubsystemRootResourceDefinition.LOG_EJB_EXCEPTIONS.resolveModelAttribute(context, model).asBoolean(); final ServiceName serviceName = LoggingInterceptor.LOGGING_ENABLED_SERVICE_NAME; final ServiceRegistry registry = context.getServiceRegistry(true); final ServiceController sc = registry.getService(serviceName); if (sc != null) { final AtomicBoolean value = (AtomicBoolean) sc.getValue(); value.set(enabled); } else { // create and install the service final ValueService<AtomicBoolean> service = new ValueService<>(new ImmediateValue<>(new AtomicBoolean(enabled))); context.getServiceTarget().addService(serviceName, service) .install(); } } }
void updateOptimisticLocking(final OperationContext context, final ModelNode model) throws OperationFailedException { final ModelNode enabled = EJB3SubsystemRootResourceDefinition.DEFAULT_ENTITY_BEAN_OPTIMISTIC_LOCKING.resolveModelAttribute(context, model); final ServiceRegistry serviceRegistry = context.getServiceRegistry(true); ServiceController<?> existingService = serviceRegistry.getService(SERVICE_NAME); // if a default optimistic locking config is installed, remove it if (existingService != null) { context.removeService(existingService); } if (enabled.isDefined()) { final Service<Boolean> newDefaultPoolConfigService = new ValueService<Boolean>(new ImmediateValue<Boolean>(enabled.asBoolean())); ServiceController<?> newController = context.getServiceTarget().addService(SERVICE_NAME, newDefaultPoolConfigService) .install(); } } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { String driverName = context.getCurrentAddressValue(); String moduleName = DriverDefinition.MODULE_ATTRIBUTE.resolveModelAttribute(context, model).asString(); boolean classDefined = DriverDefinition.CLASS_ATTRIBUTE.resolveModelAttribute(context, model).isDefined(); String className = classDefined ? DriverDefinition.CLASS_ATTRIBUTE.resolveModelAttribute(context, model).asString() : null; Service<?> driverService = new ValueService<>(new Value<Class<?>>() { @Override public Class<?> getValue() throws IllegalStateException, IllegalArgumentException { if (className != null) { return loadClass(driverName, moduleName, className); } else { return loadDriver(driverName, moduleName); } } }); context.getCapabilityServiceTarget().addCapability(DriverDefinition.AGROAL_DRIVER_CAPABILITY.fromBaseCapability(driverName), driverService).install(); } }
@Override protected void preStart(final StartContext context) { //adds the HTTP upgrade service //TODO: have a bit more of a think about how we handle this context.getChildTarget().addService(HTTP_UPGRADE_REGISTRY.append(getName()), new ValueService<Object>(new ImmediateValue<Object>(httpUpgradeHandler))) .install(); ListenerRegistry.Listener listener = new ListenerRegistry.Listener(getProtocol(), getName(), serverName, getBinding().getValue().getSocketAddress()); listener.setContextInformation("socket-binding", getBinding().getValue()); httpListenerRegistry.getValue().addListener(listener); }
phaseContext.getServiceTarget().addService(ComponentRegistry.serviceName(deploymentUnit), new ValueService<>(new ImmediateValue<Object>(componentRegistry))) .addDependency(moduleDescription.getDefaultClassIntrospectorServiceName(), EEClassIntrospector.class, componentRegistry.getClassIntrospectorInjectedValue()) .install();
@Override public ServiceBuilder<T> build(ServiceTarget target) { return target.addService(this.name, new ValueService<>(this.value)) .addDependency(this.targetName, this.targetClass, this.value) .setInitialMode(ServiceController.Mode.PASSIVE); } }
@Override public ServiceBuilder<RemoteSiteConfiguration> build(ServiceTarget target) { return target.addService(this.getServiceName(), new ValueService<>(this)) .addDependency(ChannelServiceName.CHANNEL.getServiceName(this.channelName), JChannel.class, this.channel) .setInitialMode(ServiceController.Mode.ON_DEMAND) ; }
public static void installModuleResolvedService(ServiceTarget serviceTarget, ModuleIdentifier identifier) { final ValueService<ModuleIdentifier> resolvedService = new ValueService<ModuleIdentifier>(new ImmediateValue<ModuleIdentifier>(identifier)); serviceTarget.addService(ServiceModuleLoader.moduleResolvedServiceName(identifier), resolvedService) .addDependency(moduleSpecServiceName(identifier)) .install(); }
@Override public ServiceBuilder<ChannelFactory> build(ServiceTarget target) { return target.addService(this.getServiceName(), new ValueService<>(this)) .addDependency(ChannelServiceName.CONNECTOR.getServiceName(this.channelName), JChannel.class, this.parentChannel) .addDependency(ChannelServiceName.FACTORY.getServiceName(this.channelName), ChannelFactory.class, this.parentFactory) .setInitialMode(ServiceController.Mode.ON_DEMAND) ; }
@Override public ServiceBuilder<P> build(ServiceTarget target) { ServiceBuilder<P> builder = target.addService(this.getServiceName(), new ValueService<>(this)); if (this.socketBinding != null) { this.socketBinding.register(builder); } return builder.setInitialMode(ServiceController.Mode.ON_DEMAND); }
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { SwarmMessages.MESSAGES.argsInstalled(Arrays.asList(this.args)); context.getServiceTarget().addService(ServiceName.of("wildfly", "swarm", "main-args"), new ValueService<>(new ImmediateValue<>(this.args))) .install(); } }
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { SwarmMessages.MESSAGES.argsInstalled(Arrays.asList(this.args)); context.getServiceTarget().addService(ServiceName.of("wildfly", "swarm", "main-args"), new ValueService<>(new ImmediateValue<>(this.args))) .install(); } }
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { SwarmMessages.MESSAGES.argsInstalled(Arrays.asList(this.args)); context.getServiceTarget().addService(ServiceName.of("wildfly", "swarm", "main-args"), new ValueService<>(new ImmediateValue<>(this.args))) .install(); } }
public static void installModuleResolvedService(ServiceTarget serviceTarget, ModuleIdentifier identifier) { final ValueService<ModuleIdentifier> resolvedService = new ValueService<ModuleIdentifier>(new ImmediateValue<ModuleIdentifier>(identifier)); final ServiceBuilder sb = serviceTarget.addService(ServiceModuleLoader.moduleResolvedServiceName(identifier), resolvedService); sb.requires(moduleSpecServiceName(identifier)); sb.install(); }
/** * Add a {@link ModuleSpec} for and OSGi module as a service that can later be looked up by the {@link ServiceModuleLoader} */ @Override public void addModuleSpec(XBundleRevision brev, final ModuleSpec moduleSpec) { ModuleIdentifier identifier = moduleSpec.getModuleIdentifier(); LOGGER.tracef("Add module spec to loader: %s", identifier); ServiceName moduleSpecName = ServiceModuleLoader.moduleSpecServiceName(identifier); ImmediateValue<ModuleDefinition> value = new ImmediateValue<>(new ModuleDefinition(identifier, Collections.<ModuleDependency>emptySet(), moduleSpec)); serviceTarget.addService(moduleSpecName, new ValueService<>(value)).install(); ServiceModuleLoader.installModuleResolvedService(serviceTarget, identifier); }
private void installAliases(final ModuleSpecification moduleSpecification, final ModuleIdentifier moduleIdentifier, final DeploymentUnit deploymentUnit, final DeploymentPhaseContext phaseContext) { for (final ModuleIdentifier alias : moduleSpecification.getAliases()) { final ServiceName moduleSpecServiceName = ServiceModuleLoader.moduleSpecServiceName(alias); final ModuleSpec spec = ModuleSpec.buildAlias(alias, moduleIdentifier).create(); final ValueService<ModuleSpec> moduleSpecService = new ValueService<ModuleSpec>(new ImmediateValue<ModuleSpec>(spec)); phaseContext.getServiceTarget().addService(moduleSpecServiceName, moduleSpecService).addDependencies( deploymentUnit.getServiceName()).addDependencies(phaseContext.getPhaseServiceName()).setInitialMode( Mode.ON_DEMAND).install(); ModuleLoadService.installService(phaseContext.getServiceTarget(), alias, Collections.singletonList(moduleIdentifier)); } }
@Override protected void preStart(final StartContext context) { //adds the HTTP upgrade service //TODO: have a bit more of a think about how we handle this context.getChildTarget().addService(HTTP_UPGRADE_REGISTRY.append(getName()), new ValueService<Object>(new ImmediateValue<Object>(httpUpgradeHandler))) .install(); ListenerRegistry.Listener listener = new ListenerRegistry.Listener(getProtocol(), getName(), serverName, getBinding().getValue().getSocketAddress()); listener.setContextInformation("socket-binding", getBinding().getValue()); httpListenerRegistry.getValue().addListener(listener); }