use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class AdminObjectAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, final Resource resource) throws OperationFailedException {
final ModelNode address = operation.require(OP_ADDR);
PathAddress path = PathAddress.pathAddress(address);
final String raName = context.getCurrentAddress().getParent().getLastElement().getValue();
final String archiveOrModuleName;
ModelNode raModel = context.readResourceFromRoot(path.subAddress(0, path.size() - 1)).getModel();
final boolean statsEnabled = STATISTICS_ENABLED.resolveModelAttribute(context, raModel).asBoolean();
if (!raModel.hasDefined(ARCHIVE.getName()) && !raModel.hasDefined(MODULE.getName())) {
throw ConnectorLogger.ROOT_LOGGER.archiveOrModuleRequired();
}
if (raModel.get(ARCHIVE.getName()).isDefined()) {
archiveOrModuleName = ARCHIVE.resolveModelAttribute(context, raModel).asString();
} else {
archiveOrModuleName = MODULE.resolveModelAttribute(context, raModel).asString();
}
final String poolName = PathAddress.pathAddress(address).getLastElement().getValue();
final ModifiableAdminObject adminObjectValue;
try {
adminObjectValue = RaOperationUtil.buildAdminObjects(context, operation, poolName);
} catch (ValidateException e) {
throw new OperationFailedException(e, new ModelNode().set(ConnectorLogger.ROOT_LOGGER.failedToCreate("AdminObject", operation, e.getLocalizedMessage())));
}
ServiceName serviceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName, poolName);
ServiceName raServiceName = ServiceName.of(ConnectorServices.RA_SERVICE, raName);
final ServiceTarget serviceTarget = context.getServiceTarget();
final AdminObjectService service = new AdminObjectService(adminObjectValue);
serviceTarget.addService(serviceName, service).setInitialMode(ServiceController.Mode.ACTIVE).addDependency(raServiceName, ModifiableResourceAdapter.class, service.getRaInjector()).install();
ServiceRegistry registry = context.getServiceRegistry(true);
final ServiceController<?> RaxmlController = registry.getService(ServiceName.of(ConnectorServices.RA_SERVICE, raName));
Activation raxml = (Activation) RaxmlController.getValue();
ServiceName deploymentServiceName = ConnectorServices.getDeploymentServiceName(archiveOrModuleName, raName);
String bootStrapCtxName = DEFAULT_NAME;
if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
bootStrapCtxName = raxml.getBootstrapContext();
}
AdminObjectStatisticsService adminObjectStatisticsService = new AdminObjectStatisticsService(context.getResourceRegistrationForUpdate(), poolName, statsEnabled);
ServiceBuilder statsServiceBuilder = serviceTarget.addService(serviceName.append(ConnectorServices.STATISTICS_SUFFIX), adminObjectStatisticsService);
statsServiceBuilder.addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName), adminObjectStatisticsService.getBootstrapContextInjector()).addDependency(deploymentServiceName, adminObjectStatisticsService.getResourceAdapterDeploymentInjector()).setInitialMode(ServiceController.Mode.PASSIVE).install();
PathElement peAO = PathElement.pathElement(Constants.STATISTICS_NAME, "extended");
final Resource aoResource = new IronJacamarResource.IronJacamarRuntimeResource();
resource.registerChild(peAO, aoResource);
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class RaServicesFactory method createDeploymentService.
public static void createDeploymentService(final ManagementResourceRegistration registration, ConnectorXmlDescriptor connectorXmlDescriptor, Module module, ServiceTarget serviceTarget, final String deploymentUnitName, ServiceName deploymentUnitServiceName, String deployment, Activation raxml, final Resource deploymentResource, final ServiceRegistry serviceRegistry) {
// Create the service
ServiceName serviceName = ConnectorServices.getDeploymentServiceName(deploymentUnitName, raxml);
ResourceAdapterXmlDeploymentService service = new ResourceAdapterXmlDeploymentService(connectorXmlDescriptor, raxml, module, deployment, serviceName, deploymentUnitServiceName);
String bootStrapCtxName = DEFAULT_NAME;
if (raxml.getBootstrapContext() != null && !raxml.getBootstrapContext().equals("undefined")) {
bootStrapCtxName = raxml.getBootstrapContext();
}
ServiceBuilder<ResourceAdapterDeployment> builder = Services.addServerExecutorDependency(serviceTarget.addService(serviceName, service), service.getExecutorServiceInjector(), false).addDependency(ConnectorServices.IRONJACAMAR_MDR, AS7MetadataRepository.class, service.getMdrInjector()).addDependency(ConnectorServices.RA_REPOSITORY_SERVICE, ResourceAdapterRepository.class, service.getRaRepositoryInjector()).addDependency(ConnectorServices.MANAGEMENT_REPOSITORY_SERVICE, ManagementRepository.class, service.getManagementRepositoryInjector()).addDependency(ConnectorServices.RESOURCE_ADAPTER_REGISTRY_SERVICE, ResourceAdapterDeploymentRegistry.class, service.getRegistryInjector()).addDependency(ConnectorServices.TRANSACTION_INTEGRATION_SERVICE, TransactionIntegration.class, service.getTxIntegrationInjector()).addDependency(ConnectorServices.CONNECTOR_CONFIG_SERVICE, JcaSubsystemConfiguration.class, service.getConfigInjector()).addDependency(ConnectorServices.CCM_SERVICE, CachedConnectionManager.class, service.getCcmInjector()).addDependency(ConnectorServices.IDLE_REMOVER_SERVICE).addDependency(ConnectorServices.CONNECTION_VALIDATOR_SERVICE).addDependency(NamingService.SERVICE_NAME).addDependency(ConnectorServices.BOOTSTRAP_CONTEXT_SERVICE.append(bootStrapCtxName)).addDependency(ConnectorServices.RESOURCE_ADAPTER_DEPLOYER_SERVICE_PREFIX.append(connectorXmlDescriptor.getDeploymentName()));
if (ActivationSecurityUtil.isLegacySecurityRequired(raxml)) {
builder.addDependency(SubjectFactoryService.SERVICE_NAME, SubjectFactory.class, service.getSubjectFactoryInjector()).addDependency(SimpleSecurityManagerService.SERVICE_NAME, ServerSecurityManager.class, service.getServerSecurityManager());
}
String raName = deployment;
if (raxml.getId() != null) {
raName = raxml.getId();
}
ServiceName parentName = ServiceName.of(ConnectorServices.RA_SERVICE, raName);
for (ServiceName subServiceName : serviceRegistry.getServiceNames()) {
if (parentName.isParentOf(subServiceName) && !subServiceName.getSimpleName().equals(ConnectorServices.STATISTICS_SUFFIX)) {
builder.addDependency(subServiceName);
}
}
if (registration != null && deploymentResource != null) {
if (registration.isAllowsOverride() && registration.getOverrideModel(deploymentUnitName) == null) {
registration.registerOverrideModel(deploymentUnitName, new OverrideDescriptionProvider() {
@Override
public Map<String, ModelNode> getAttributeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
@Override
public Map<String, ModelNode> getChildTypeOverrideDescriptions(Locale locale) {
return Collections.emptyMap();
}
});
}
}
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class ResourceAdaptersSubsystemAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final Resource subsystemResource = context.readResourceFromRoot(PathAddress.pathAddress(ResourceAdaptersExtension.SUBSYSTEM_PATH));
ResourceAdaptersSubsystemService service = new ResourceAdaptersSubsystemService();
CopyOnWriteArrayListMultiMap<String, ServiceName> value = service.getValue();
for (Resource.ResourceEntry re : subsystemResource.getChildren(RESOURCEADAPTER_NAME)) {
value.putIfAbsent(re.getModel().get(ARCHIVE.getName()).asString(), ConnectorServices.RA_SERVICE.append(re.getName()));
}
final ServiceBuilder<?> builder = context.getServiceTarget().addService(ConnectorServices.RESOURCEADAPTERS_SUBSYSTEM_SERVICE, service);
builder.setInitialMode(ServiceController.Mode.ACTIVE).install();
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class ConnectorServices method getDeploymentServiceName.
// resource-adapter DMR resource
public static synchronized ServiceName getDeploymentServiceName(final String raName, final Activation raxml) {
if (raName == null)
throw ConnectorLogger.ROOT_LOGGER.undefinedVar("RaName");
ServiceName serviceName = null;
ModifiableResourceAdapter ra = (ModifiableResourceAdapter) raxml;
if (ra != null && ra.getId() != null) {
serviceName = getDeploymentServiceName(raName, ra.getId());
} else {
serviceName = getDeploymentServiceName(raName, (String) null);
}
ROOT_LOGGER.tracef("ConnectorServices: getDeploymentServiceName(%s,%s) -> %s", raName, raxml, serviceName);
return serviceName;
}
use of org.jboss.msc.service.ServiceName in project wildfly by wildfly.
the class EEJndiViewExtension method execute.
public void execute(final JndiViewExtensionContext context) throws OperationFailedException {
final ModelNode applicationsNode = context.getResult().get("applications");
final ServiceRegistry serviceRegistry = context.getOperationContext().getServiceRegistry(false);
final Set<Resource.ResourceEntry> deploymentResource = context.getOperationContext().readResourceFromRoot(PathAddress.EMPTY_ADDRESS, false).getChildren(DEPLOYMENT);
for (final Resource.ResourceEntry entry : deploymentResource) {
final ServiceController<?> deploymentUnitServiceController = serviceRegistry.getService(ServiceName.JBOSS.append("deployment", "unit", entry.getName()));
if (deploymentUnitServiceController != null) {
final ModelNode deploymentNode = applicationsNode.get(entry.getName());
final DeploymentUnit deploymentUnit = DeploymentUnit.class.cast(deploymentUnitServiceController.getValue());
final String appName = cleanName(deploymentUnit.getName());
final ServiceName appContextName = ContextNames.contextServiceNameOfApplication(appName);
final ServiceController<?> appContextController = serviceRegistry.getService(appContextName);
if (appContextController != null) {
final NamingStore appStore = NamingStore.class.cast(appContextController.getValue());
try {
context.addEntries(deploymentNode.get("java:app"), new NamingContext(appStore, null));
} catch (NamingException e) {
throw new OperationFailedException(e, new ModelNode().set(EeLogger.ROOT_LOGGER.failedToRead("java:app", appName)));
}
}
if (DeploymentTypeMarker.isType(DeploymentType.EAR, deploymentUnit)) {
final List<ResourceRoot> roots = deploymentUnit.getAttachmentList(org.jboss.as.server.deployment.Attachments.RESOURCE_ROOTS);
if (roots != null)
for (ResourceRoot root : roots) {
if (SubDeploymentMarker.isSubDeployment(root)) {
final ResourceRoot parentRoot = deploymentUnit.getAttachment(org.jboss.as.server.deployment.Attachments.DEPLOYMENT_ROOT);
final String relativePath = root.getRoot().getPathNameRelativeTo(parentRoot.getRoot());
final ServiceName subDeploymentServiceName = Services.deploymentUnitName(deploymentUnit.getName(), relativePath);
final ServiceController<?> subDeploymentController = serviceRegistry.getService(subDeploymentServiceName);
if (subDeploymentController != null) {
final DeploymentUnit subDeploymentUnit = DeploymentUnit.class.cast(subDeploymentController.getValue());
handleModule(context, subDeploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
} else {
handleModule(context, deploymentUnit, deploymentNode.get("modules"), serviceRegistry);
}
}
}
}
Aggregations