use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class MailSessionAdd method installRuntimeServices.
static void installRuntimeServices(OperationContext context, PathAddress address, ModelNode fullModel) throws OperationFailedException {
String name = address.getLastElement().getValue();
final String jndiName = getJndiName(fullModel, context);
final ServiceTarget serviceTarget = context.getServiceTarget();
final MailSessionConfig config = from(context, fullModel);
final MailSessionService service = new MailSessionService(config);
final ServiceName serviceName = MAIL_SESSION_SERVICE_NAME.append(name);
final ServiceBuilder<?> mailSessionBuilder = serviceTarget.addService(serviceName, service);
addOutboundSocketDependency(service, mailSessionBuilder, config.getImapServer());
addCredentialStoreReference(config.getImapServer(), context, fullModel, mailSessionBuilder, MailSubsystemModel.IMAP_SERVER_PATH.getKey(), MailSubsystemModel.IMAP_SERVER_PATH.getValue());
addOutboundSocketDependency(service, mailSessionBuilder, config.getPop3Server());
addCredentialStoreReference(config.getPop3Server(), context, fullModel, mailSessionBuilder, MailSubsystemModel.POP3_SERVER_PATH.getKey(), MailSubsystemModel.POP3_SERVER_PATH.getValue());
addOutboundSocketDependency(service, mailSessionBuilder, config.getSmtpServer());
addCredentialStoreReference(config.getSmtpServer(), context, fullModel, mailSessionBuilder, MailSubsystemModel.SMTP_SERVER_PATH.getKey(), MailSubsystemModel.SMTP_SERVER_PATH.getValue());
for (CustomServerConfig server : config.getCustomServers()) {
if (server.getOutgoingSocketBinding() != null) {
addOutboundSocketDependency(service, mailSessionBuilder, server);
}
addCredentialStoreReference(server, context, fullModel, mailSessionBuilder, MailSubsystemModel.CUSTOM_SERVER_PATH.getKey(), server.getProtocol());
}
final ManagedReferenceFactory valueManagedReferenceFactory = new MailSessionManagedReferenceFactory(service);
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoFor(jndiName);
final BinderService binderService = new BinderService(bindInfo.getBindName());
final ServiceBuilder<?> binderBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), binderService).addInjection(binderService.getManagedObjectInjector(), valueManagedReferenceFactory).addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()).addListener(new AbstractServiceListener<Object>() {
public void transition(final ServiceController<? extends Object> controller, final ServiceController.Transition transition) {
switch(transition) {
case STARTING_to_UP:
{
MailLogger.ROOT_LOGGER.boundMailSession(jndiName);
break;
}
case START_REQUESTED_to_DOWN:
{
MailLogger.ROOT_LOGGER.unboundMailSession(jndiName);
break;
}
case REMOVING_to_REMOVED:
{
MailLogger.ROOT_LOGGER.removedMailSession(jndiName);
break;
}
}
}
});
mailSessionBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
binderBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class PropertyAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
//modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
if (context.isBooting()) {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String propertyName = address.getElement(address.size() - 1).getValue();
final PathElement confElem = address.getElement(address.size() - 2);
final String configType = confElem.getKey();
final String configName = confElem.getValue();
final String propertyValue = operation.has(VALUE) ? Attributes.VALUE.resolveModelAttribute(context, operation).asString() : null;
final PropertyService service = new PropertyService(propertyName, propertyValue);
final ServiceTarget target = context.getServiceTarget();
final ServiceName configServiceName = getConfigServiceName(configType, configName);
if (context.getServiceRegistry(false).getService(configServiceName) == null) {
throw WSLogger.ROOT_LOGGER.missingConfig(configName);
}
final ServiceName propertyServiceName = getPropertyServiceName(configServiceName, propertyName);
final ServiceBuilder<?> propertyServiceBuilder = target.addService(propertyServiceName, service);
ServiceController<?> controller = propertyServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
} else {
context.reloadRequired();
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class WSSubsystemAdd method performBoottime.
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
WSLogger.ROOT_LOGGER.activatingWebservicesExtension();
ModuleClassLoaderProvider.register();
final boolean appclient = context.getProcessType() == ProcessType.APPLICATION_CLIENT;
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
// add the DUP for dealing with WS deployments
WSDeploymentActivator.activate(processorTarget, appclient);
}
}, OperationContext.Stage.RUNTIME);
ServiceTarget serviceTarget = context.getServiceTarget();
final boolean jmxAvailable = isJMXSubsystemAvailable(context);
if (appclient && model.hasDefined(WSDL_HOST)) {
ServerConfigImpl serverConfig = createServerConfig(model, true, context);
ServerConfigService.install(serviceTarget, serverConfig, getServerConfigDependencies(context, appclient), jmxAvailable, false);
}
if (!appclient) {
ServerConfigImpl serverConfig = createServerConfig(model, false, context);
ServerConfigService.install(serviceTarget, serverConfig, getServerConfigDependencies(context, appclient), jmxAvailable, true);
}
XTSClientIntegrationService.install(serviceTarget);
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class ClientConfigAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
//modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
if (context.isBooting()) {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
//get the server config object from the ServerConfigService (service installed and not started yet, but the object is fine for our needs here)
final ServerConfig serverConfig = ASHelper.getMSCService(WSServices.CONFIG_SERVICE, ServerConfig.class, context);
if (serverConfig == null) {
throw WSLogger.ROOT_LOGGER.serviceNotAvailable(WSServices.CONFIG_SERVICE.getCanonicalName());
}
final ServiceName serviceName = getClientConfigServiceName(name);
final ConfigService clientConfigService = new ConfigService(serverConfig, name, true);
final ServiceTarget target = context.getServiceTarget();
final ServiceBuilder<?> clientServiceBuilder = target.addService(serviceName, clientConfigService);
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PROPERTY)) {
//get a new injector instance each time
clientServiceBuilder.addDependency(sn, PropertyService.class, clientConfigService.getPropertiesInjector());
}
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.PRE_HANDLER_CHAIN)) {
//get a new injector instance each time
clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPreHandlerChainsInjector());
}
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, serviceName, address, Constants.POST_HANDLER_CHAIN)) {
//get a new injector instance each time
clientServiceBuilder.addDependency(sn, UnifiedHandlerChainMetaData.class, clientConfigService.getPostHandlerChainsInjector());
}
clientServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
} else {
context.reloadRequired();
}
}
use of org.jboss.msc.service.ServiceTarget in project wildfly by wildfly.
the class EndpointServiceDeploymentAspect method start.
@Override
public void start(final Deployment dep) {
final ServiceTarget target = getOptionalAttachment(dep, ServiceTarget.class);
final DeploymentUnit unit = getRequiredAttachment(dep, DeploymentUnit.class);
for (final Endpoint ep : dep.getService().getEndpoints()) {
EndpointService.install(target, ep, unit);
}
}
Aggregations