use of org.jboss.msc.service.ServiceController in project wildfly by wildfly.
the class DefaultSessionBeanAccessTimeoutWriteHandler method applyModelToRuntime.
private void applyModelToRuntime(OperationContext context, final ModelNode model) throws OperationFailedException {
long timeout = attribute.resolveModelAttribute(context, model).asLong();
final ServiceRegistry serviceRegistry = context.getServiceRegistry(true);
ServiceController<DefaultAccessTimeoutService> controller = (ServiceController<DefaultAccessTimeoutService>) serviceRegistry.getService(serviceName);
if (controller != null) {
DefaultAccessTimeoutService service = controller.getValue();
if (service != null) {
service.setDefaultAccessTimeout(timeout);
}
}
}
use of org.jboss.msc.service.ServiceController in project wildfly by wildfly.
the class ModuleJndiBindingProcessor method addJndiBinding.
protected void addJndiBinding(final EEModuleConfiguration module, final BindingConfiguration bindingConfiguration, final DeploymentPhaseContext phaseContext, final List<ServiceName> dependencies) throws DeploymentUnitProcessingException {
// Gather information about the dependency
final String bindingName = bindingConfiguration.getName().startsWith("java:") ? bindingConfiguration.getName() : "java:module/env/" + bindingConfiguration.getName();
InjectionSource.ResolutionContext resolutionContext = new InjectionSource.ResolutionContext(true, module.getModuleName(), module.getModuleName(), module.getApplicationName());
// Check to see if this entry should actually be bound into JNDI.
if (bindingName != null) {
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(module.getApplicationName(), module.getModuleName(), module.getModuleName(), false, bindingName);
dependencies.add(bindInfo.getBinderServiceName());
if (bindingName.startsWith("java:comp") || bindingName.startsWith("java:module") || bindingName.startsWith("java:app")) {
//this is a binding that does not need to be shared.
try {
final BinderService service = new BinderService(bindInfo.getBindName(), bindingConfiguration.getSource());
ServiceBuilder<ManagedReferenceFactory> serviceBuilder = phaseContext.getServiceTarget().addService(bindInfo.getBinderServiceName(), service);
bindingConfiguration.getSource().getResourceValue(resolutionContext, serviceBuilder, phaseContext, service.getManagedObjectInjector());
serviceBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector());
serviceBuilder.install();
} catch (DuplicateServiceException e) {
ServiceController<ManagedReferenceFactory> registered = (ServiceController<ManagedReferenceFactory>) CurrentServiceContainer.getServiceContainer().getService(bindInfo.getBinderServiceName());
if (registered == null)
throw e;
BinderService service = (BinderService) registered.getService();
if (!service.getSource().equals(bindingConfiguration.getSource()))
throw EeLogger.ROOT_LOGGER.conflictingBinding(bindingName, bindingConfiguration.getSource());
} catch (CircularDependencyException e) {
throw EeLogger.ROOT_LOGGER.circularDependency(bindingName);
}
} else {
BinderService service;
try {
service = new BinderService(bindInfo.getBindName(), bindingConfiguration.getSource(), true);
ServiceBuilder<ManagedReferenceFactory> serviceBuilder = CurrentServiceContainer.getServiceContainer().addService(bindInfo.getBinderServiceName(), service);
bindingConfiguration.getSource().getResourceValue(resolutionContext, serviceBuilder, phaseContext, service.getManagedObjectInjector());
serviceBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector());
serviceBuilder.install();
} catch (DuplicateServiceException e) {
final ServiceController<ManagedReferenceFactory> controller = (ServiceController<ManagedReferenceFactory>) CurrentServiceContainer.getServiceContainer().getService(bindInfo.getBinderServiceName());
if (controller == null)
throw e;
service = (BinderService) controller.getService();
if (!equals(service.getSource(), bindingConfiguration.getSource())) {
throw EeLogger.ROOT_LOGGER.conflictingBinding(bindingName, bindingConfiguration.getSource());
}
}
//as these bindings are not child services
//we need to add a listener that released the service when the deployment stops
service.acquire();
ServiceController<?> unitService = CurrentServiceContainer.getServiceContainer().getService(phaseContext.getDeploymentUnit().getServiceName());
unitService.addListener(new BinderReleaseListener(service));
}
} else {
throw EeLogger.ROOT_LOGGER.nullBindingName(bindingConfiguration);
}
}
use of org.jboss.msc.service.ServiceController in project wildfly by wildfly.
the class ComponentInstallProcessor method processBindings.
@SuppressWarnings("unchecked")
private void processBindings(DeploymentPhaseContext phaseContext, ComponentConfiguration configuration, ServiceTarget serviceTarget, InjectionSource.ResolutionContext resolutionContext, List<BindingConfiguration> bindings, final ServiceBuilder<?> jndiDepServiceBuilder, final Set<ServiceName> bound) throws DeploymentUnitProcessingException {
//we only handle java:comp bindings for components that have their own namespace here, the rest are processed by ModuleJndiBindingProcessor
for (BindingConfiguration bindingConfiguration : bindings) {
if (bindingConfiguration.getName().startsWith("java:comp") || !bindingConfiguration.getName().startsWith("java:")) {
final String bindingName = bindingConfiguration.getName().startsWith("java:comp") ? bindingConfiguration.getName() : "java:comp/env/" + bindingConfiguration.getName();
final ContextNames.BindInfo bindInfo = ContextNames.bindInfoForEnvEntry(configuration.getApplicationName(), configuration.getModuleName(), configuration.getComponentName(), configuration.getComponentDescription().getNamingMode() == ComponentNamingMode.CREATE, bindingName);
if (bound.contains(bindInfo.getBinderServiceName())) {
continue;
}
bound.add(bindInfo.getBinderServiceName());
try {
final BinderService service = new BinderService(bindInfo.getBindName(), bindingConfiguration.getSource());
jndiDepServiceBuilder.addDependency(bindInfo.getBinderServiceName());
ServiceBuilder<ManagedReferenceFactory> serviceBuilder = serviceTarget.addService(bindInfo.getBinderServiceName(), service);
bindingConfiguration.getSource().getResourceValue(resolutionContext, serviceBuilder, phaseContext, service.getManagedObjectInjector());
serviceBuilder.addDependency(bindInfo.getParentContextServiceName(), ServiceBasedNamingStore.class, service.getNamingStoreInjector());
serviceBuilder.install();
} catch (DuplicateServiceException e) {
ServiceController<ManagedReferenceFactory> registered = (ServiceController<ManagedReferenceFactory>) CurrentServiceContainer.getServiceContainer().getService(bindInfo.getBinderServiceName());
if (registered == null)
throw e;
BinderService service = (BinderService) registered.getService();
if (!service.getSource().equals(bindingConfiguration.getSource()))
throw EeLogger.ROOT_LOGGER.conflictingBinding(bindingName, bindingConfiguration.getSource());
} catch (CircularDependencyException e) {
throw EeLogger.ROOT_LOGGER.circularDependency(bindingName);
}
}
}
}
use of org.jboss.msc.service.ServiceController in project wildfly by wildfly.
the class RaAdd method performRuntime.
@Override
public void performRuntime(final OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException {
final ModelNode model = resource.getModel();
// domains/application attributes should only be defined when Elytron enabled is undefined or false (default value)
if (ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean()) {
if (model.hasDefined(SECURITY_DOMAIN.getName()))
throw SUBSYSTEM_RA_LOGGER.attributeRequiresFalseOrUndefinedAttribute(SECURITY_DOMAIN.getName(), ELYTRON_ENABLED.getName());
else if (model.hasDefined(SECURITY_DOMAIN_AND_APPLICATION.getName()))
throw SUBSYSTEM_RA_LOGGER.attributeRequiresFalseOrUndefinedAttribute(SECURITY_DOMAIN_AND_APPLICATION.getName(), ELYTRON_ENABLED.getName());
else if (model.hasDefined(APPLICATION.getName()))
throw SUBSYSTEM_RA_LOGGER.attributeRequiresFalseOrUndefinedAttribute(APPLICATION.getName(), ELYTRON_ENABLED.getName());
} else {
if (model.hasDefined(AUTHENTICATION_CONTEXT.getName()))
throw SUBSYSTEM_RA_LOGGER.attributeRequiresTrueAttribute(AUTHENTICATION_CONTEXT.getName(), ELYTRON_ENABLED.getName());
else if (model.hasDefined(AUTHENTICATION_CONTEXT_AND_APPLICATION.getName()))
throw SUBSYSTEM_RA_LOGGER.attributeRequiresTrueAttribute(AUTHENTICATION_CONTEXT_AND_APPLICATION.getName(), ELYTRON_ENABLED.getName());
}
// do the same for recovery security attributes
if (RECOVERY_ELYTRON_ENABLED.resolveModelAttribute(context, model).asBoolean()) {
if (model.hasDefined(RECOVERY_SECURITY_DOMAIN.getName()))
throw SUBSYSTEM_RA_LOGGER.attributeRequiresFalseOrUndefinedAttribute(RECOVERY_SECURITY_DOMAIN.getName(), RECOVERY_ELYTRON_ENABLED.getName());
} else {
if (model.hasDefined(RECOVERY_AUTHENTICATION_CONTEXT.getName()))
throw SUBSYSTEM_RA_LOGGER.attributeRequiresTrueAttribute(RECOVERY_AUTHENTICATION_CONTEXT.getName(), RECOVERY_ELYTRON_ENABLED.getName());
}
// Compensating is remove
final String name = context.getCurrentAddressValue();
final String archiveOrModuleName;
final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean();
if (!model.hasDefined(ARCHIVE.getName()) && !model.hasDefined(MODULE.getName())) {
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
}
if (model.get(ARCHIVE.getName()).isDefined()) {
archiveOrModuleName = model.get(ARCHIVE.getName()).asString();
} else {
archiveOrModuleName = model.get(MODULE.getName()).asString();
}
ModifiableResourceAdapter resourceAdapter = RaOperationUtil.buildResourceAdaptersObject(name, context, operation, archiveOrModuleName);
List<ServiceController<?>> newControllers = new ArrayList<ServiceController<?>>();
if (model.get(ARCHIVE.getName()).isDefined()) {
RaOperationUtil.installRaServices(context, name, resourceAdapter, newControllers);
} else {
RaOperationUtil.installRaServicesAndDeployFromModule(context, name, resourceAdapter, archiveOrModuleName, newControllers);
if (context.isBooting()) {
context.addStep(new OperationStepHandler() {
public void execute(final OperationContext context, ModelNode operation) throws OperationFailedException {
//Next lines activate configuration on module deployed rar
//in case there is 2 different resource-adapter config using same module deployed rar
// a Deployment sercivice could be already present and need a restart to consider also this
//newly added configuration
ServiceName restartedServiceName = RaOperationUtil.restartIfPresent(context, archiveOrModuleName, name);
if (restartedServiceName == null) {
RaOperationUtil.activate(context, name, archiveOrModuleName);
}
context.completeStep(new OperationContext.RollbackHandler() {
@Override
public void handleRollback(OperationContext context, ModelNode operation) {
try {
RaOperationUtil.removeIfActive(context, archiveOrModuleName, name);
} catch (OperationFailedException e) {
}
}
});
}
}, OperationContext.Stage.RUNTIME);
}
}
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, name));
Activation raxml = (Activation) RaxmlController.getValue();
ServiceName serviceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, name);
String bootStrapCtxName = DEFAULT_NAME;
if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
bootStrapCtxName = raxml.getBootstrapContext();
}
ResourceAdapterStatisticsService raStatsService = new ResourceAdapterStatisticsService(context.getResourceRegistrationForUpdate(), name, statsEnabled);
ServiceBuilder statsServiceBuilder = context.getServiceTarget().addService(ServiceName.of(ConnectorServices.RA_SERVICE, name).append(ConnectorServices.STATISTICS_SUFFIX), raStatsService);
statsServiceBuilder.addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName), raStatsService.getBootstrapContextInjector()).addDependency(serviceName, raStatsService.getResourceAdapterDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
PathElement peStats = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
final Resource statsResource = new IronJacamarResource.IronJacamarRuntimeResource();
resource.registerChild(peStats, statsResource);
}
use of org.jboss.msc.service.ServiceController in project wildfly by wildfly.
the class EJBComponentCreateService method getEJBUtilities.
/**
* @return
* @deprecated {@link EJBUtilities} is deprecated post 7.2.0.Final version.
*/
@Deprecated
protected EJBUtilities getEJBUtilities() {
// constructs
final DeploymentUnit deploymentUnit = getDeploymentUnitInjector().getValue();
final ServiceController<EJBUtilities> serviceController = (ServiceController<EJBUtilities>) deploymentUnit.getServiceRegistry().getRequiredService(EJBUtilities.SERVICE_NAME);
return serviceController.getValue();
}
Aggregations