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<T> build(ServiceTarget target) { return target.addService(this.name, new ValueService<>(this.value)) .addDependency(this.targetName, this.targetClass, this.value) .setInitialMode(ServiceController.Mode.ON_DEMAND); } }
protected void createExtensions() { serviceTarget.addService(LIVEOAK.append("extn-dir"), new ValueService<>(new ImmediateValue<>(new File(configDir, "extensions").getAbsolutePath()))) .install(); ExtensionsBootstrappingService extensions = new ExtensionsBootstrappingService(); serviceTarget.addService(LIVEOAK.append("extensions-bootstrap"), extensions) .addDependency(LIVEOAK.append("extn-dir"), String.class, extensions.extensionsDirectoryInjector()) .install(); }
protected void createVertx() { if (vertx == null) { serviceTarget.addService(LIVEOAK.append("vertx-bootstrap"), new VertxBootstrappingService()) .install(); } else { serviceTarget.addService(VERTX, new ValueService<>(new ImmediateValue<>(vertx))) .install(); } }
protected void prolog() { LiveOakSystem system = new LiveOakSystem(serviceContainer); serviceTarget.addService(LIVEOAK, new ValueService<>(new ImmediateValue<>(system))) .install(); serviceTarget.addService(SERVICE_REGISTRY, new ValueService<>(new ImmediateValue<>(serviceContainer))) .install(); serviceTarget.addService(SERVICE_CONTAINER, new ValueService<>(new ImmediateValue<>(serviceContainer))) .install(); }
@Override public ServiceBuilder<C> build(ServiceTarget target) { return target.addService(this.getServiceName(), new ValueService<>(this)).setInitialMode(ServiceController.Mode.ON_DEMAND); } }
private <T> ServiceController<T> installValueService(final OperationContext context, final ServiceName serviceName, final Class<T> targetClass, final ServiceName dependencyServiceName) { final InjectedValue<T> value = new InjectedValue<T>(); return context.getServiceTarget().addService(serviceName, new ValueService<T>(value)) .addDependency(dependencyServiceName, targetClass, value) .setInitialMode(ServiceController.Mode.ON_DEMAND) .install() ; } }
@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<TransportConfiguration> build(ServiceTarget target) { ServiceBuilder<TransportConfiguration> builder = target.addService(this.getServiceName(), new ValueService<>(this)) .addDependency(ChannelServiceName.CHANNEL.getServiceName(this.name), JChannel.class, this.channel) .addDependency(ChannelServiceName.FACTORY.getServiceName(this.name), ChannelFactory.class, this.factory) ; return builder.setInitialMode(ServiceController.Mode.ON_DEMAND); }
protected ServiceController<ChannelFactory> installDefaultChannelFactoryService(ServiceTarget target, String stack, ServiceVerificationHandler verificationHandler) { final InjectedValue<ChannelFactory> factory = new InjectedValue<ChannelFactory>(); return target.addService(ChannelFactoryService.getServiceName(null), new ValueService<ChannelFactory>(factory)) .addDependency(ChannelFactoryService.getServiceName(stack), ChannelFactory.class, factory) .setInitialMode(ServiceController.Mode.ON_DEMAND) .install() ; }