use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class AddStepHandler method execute.
@Override
public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {
PathAddress address = context.getCurrentAddress();
PathAddress parentAddress = address.getParent();
PathElement path = address.getLastElement();
OperationStepHandler parentHandler = context.getRootResourceRegistration().getOperationHandler(parentAddress, ModelDescriptionConstants.ADD);
if (parentHandler instanceof DescribedAddStepHandler) {
AddStepHandlerDescriptor parentDescriptor = ((DescribedAddStepHandler) parentHandler).getDescriptor();
if (parentDescriptor.getRequiredChildren().contains(path)) {
if (context.readResourceFromRoot(parentAddress, false).hasChild(path)) {
// If we are a required child resource of our parent, we need to remove the auto-created resource first
context.addStep(Util.createRemoveOperation(address), context.getRootResourceRegistration().getOperationHandler(address, ModelDescriptionConstants.REMOVE), OperationContext.Stage.MODEL);
context.addStep(operation, this, OperationContext.Stage.MODEL);
return;
}
} else {
Optional<PathElement> singletonPathResult = parentDescriptor.getRequiredSingletonChildren().stream().filter((PathElement requiredPath) -> requiredPath.getKey().equals(path.getKey()) && !requiredPath.getValue().equals(path.getValue())).findFirst();
if (singletonPathResult.isPresent()) {
PathElement singletonPath = singletonPathResult.get();
if (context.readResourceFromRoot(parentAddress, false).hasChild(singletonPath)) {
// If there is a required singleton sibling resource, we need to remove it first
PathAddress singletonAddress = parentAddress.append(singletonPath);
context.addStep(Util.createRemoveOperation(singletonAddress), context.getRootResourceRegistration().getOperationHandler(singletonAddress, ModelDescriptionConstants.REMOVE), OperationContext.Stage.MODEL);
context.addStep(operation, this, OperationContext.Stage.MODEL);
return;
}
}
}
}
super.execute(context, operation);
if (this.requiresRuntime(context)) {
this.descriptor.getRuntimeResourceRegistrations().forEach(registration -> context.addStep(registration, OperationContext.Stage.MODEL));
}
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class SimpleAliasEntry method convertToTargetAddress.
@Override
public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) {
PathAddress target = this.getTargetAddress();
List<PathElement> result = new ArrayList<>(address.size());
for (int i = 0; i < address.size(); ++i) {
PathElement element = address.getElement(i);
if (i < target.size()) {
PathElement targetElement = target.getElement(i);
result.add(targetElement.isWildcard() ? PathElement.pathElement(targetElement.getKey(), element.getValue()) : targetElement);
} else {
result.add(element);
}
}
return PathAddress.pathAddress(result);
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class EJB3RemoteServiceAdd method installRuntimeServices.
void installRuntimeServices(final OperationContext context, final ModelNode model) throws OperationFailedException {
final String clientMappingsClusterName = EJB3RemoteResourceDefinition.CLIENT_MAPPINGS_CLUSTER_NAME.resolveModelAttribute(context, model).asString();
final String connectorName = EJB3RemoteResourceDefinition.CONNECTOR_REF.resolveModelAttribute(context, model).asString();
final ServiceName remotingServerInfoServiceName = RemotingConnectorBindingInfoService.serviceName(connectorName);
final String threadPoolName = EJB3RemoteResourceDefinition.THREAD_POOL_NAME.resolveModelAttribute(context, model).asString();
final boolean executeInWorker = EJB3RemoteResourceDefinition.EXECUTE_IN_WORKER.resolveModelAttribute(context, model).asBoolean();
final ServiceTarget target = context.getServiceTarget();
// Install the client-mapping service for the remoting connector
new EJBRemotingConnectorClientMappingsEntryProviderService(clientMappingsClusterName, remotingServerInfoServiceName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
new RegistryInstallerService(clientMappingsClusterName).configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install();
// Handle case where no infinispan subsystem exists or does not define an ejb cache-container
Resource rootResource = context.readResourceFromRoot(PathAddress.EMPTY_ADDRESS);
PathElement infinispanPath = PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan");
if (!rootResource.hasChild(infinispanPath) || !rootResource.getChild(infinispanPath).hasChild(PathElement.pathElement("cache-container", clientMappingsClusterName))) {
// Install services that would normally be installed by this container/cache
CapabilityServiceSupport support = context.getCapabilityServiceSupport();
for (GroupBuilderProvider provider : ServiceLoader.load(LocalGroupBuilderProvider.class, LocalGroupBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName), clientMappingsClusterName)) {
builder.configure(support).build(target).install();
}
}
for (CacheBuilderProvider provider : ServiceLoader.load(LocalCacheBuilderProvider.class, LocalCacheBuilderProvider.class.getClassLoader())) {
for (CapabilityServiceBuilder<?> builder : provider.getBuilders(requirement -> requirement.getServiceName(support, clientMappingsClusterName, null), clientMappingsClusterName, null)) {
builder.configure(support).build(target).install();
}
}
}
final OptionMap channelCreationOptions = this.getChannelCreationOptions(context);
// Install the EJB remoting connector service which will listen for client connections on the remoting channel
// TODO: Externalize (expose via management API if needed) the version and the marshalling strategy
final EJBRemoteConnectorService ejbRemoteConnectorService = new EJBRemoteConnectorService(channelCreationOptions);
ServiceBuilder<EJBRemoteConnectorService> builder = target.addService(EJBRemoteConnectorService.SERVICE_NAME, ejbRemoteConnectorService);
builder.addDependency(RemotingServices.SUBSYSTEM_ENDPOINT, Endpoint.class, ejbRemoteConnectorService.getEndpointInjector()).addDependency(remotingServerInfoServiceName, RemotingConnectorBindingInfoService.RemotingConnectorInfo.class, ejbRemoteConnectorService.getRemotingConnectorInfoInjectedValue()).addDependency(AssociationService.SERVICE_NAME, AssociationService.class, ejbRemoteConnectorService.getAssociationServiceInjector()).addDependency(TxnServices.JBOSS_TXN_REMOTE_TRANSACTION_SERVICE, RemotingTransactionService.class, ejbRemoteConnectorService.getRemotingTransactionServiceInjector()).addDependency(ControlledProcessStateService.SERVICE_NAME, ControlledProcessStateService.class, ejbRemoteConnectorService.getControlledProcessStateServiceInjector()).setInitialMode(ServiceController.Mode.ACTIVE);
if (!executeInWorker) {
builder.addDependency(EJB3SubsystemModel.BASE_THREAD_POOL_SERVICE_NAME.append(threadPoolName), ExecutorService.class, ejbRemoteConnectorService.getExecutorService());
}
builder.install();
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class ACLResourceDefinition method registerChildren.
@Override
public void registerChildren(ManagementResourceRegistration resourceRegistration) {
super.registerChildren(resourceRegistration);
ManagementResourceRegistration moduleReg = resourceRegistration.registerSubModel(new LoginModuleResourceDefinition(Constants.ACL_MODULE));
//https://issues.jboss.org/browse/WFLY-2474 acl-module was wrongly called login-module in 7.2.0
resourceRegistration.registerAlias(PathElement.pathElement(Constants.LOGIN_MODULE), new AliasEntry(moduleReg) {
@Override
public PathAddress convertToTargetAddress(PathAddress address, AliasContext aliasContext) {
PathElement element = address.getLastElement();
element = PathElement.pathElement(Constants.ACL_MODULE, element.getValue());
return address.subAddress(0, address.size() - 1).append(element);
}
});
}
use of org.jboss.as.controller.PathElement in project wildfly by wildfly.
the class SecuritySubsystemParser method parseSecurityDomain.
private void parseSecurityDomain(List<ModelNode> list, XMLExtendedStreamReader reader, PathAddress parentAddress) throws XMLStreamException {
ModelNode op = Util.createAddOperation();
list.add(op);
PathElement secDomainPath = null;
EnumSet<Attribute> required = EnumSet.of(Attribute.NAME);
final int count = reader.getAttributeCount();
for (int i = 0; i < count; i++) {
requireNoNamespaceAttribute(reader, i);
final String value = reader.getAttributeValue(i);
final Attribute attribute = Attribute.forName(reader.getAttributeLocalName(i));
required.remove(attribute);
switch(attribute) {
case NAME:
{
if (value == null || value.length() == 0) {
throw invalidAttributeValue(reader, i);
}
secDomainPath = PathElement.pathElement(SECURITY_DOMAIN, value);
break;
}
case CACHE_TYPE:
{
SecurityDomainResourceDefinition.CACHE_TYPE.parseAndSetParameter(value, op, reader);
break;
}
default:
throw unexpectedAttribute(reader, i);
}
}
if (required.size() > 0) {
throw missingRequired(reader, required);
}
final PathAddress address = parentAddress.append(secDomainPath);
op.get(OP_ADDR).set(address.toModelNode());
final EnumSet<Element> visited = EnumSet.noneOf(Element.class);
moduleNames = new HashMap<String, Integer>();
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
if (!visited.add(element)) {
throw unexpectedElement(reader);
}
switch(element) {
case AUTHENTICATION:
{
if (visited.contains(Element.AUTHENTICATION_JASPI)) {
throw SecurityLogger.ROOT_LOGGER.xmlStreamExceptionAuth(reader.getLocation());
}
parseAuthentication(list, address, reader);
break;
}
case AUTHORIZATION:
{
parseAuthorization(list, address, reader);
break;
}
case ACL:
{
parseACL(list, address, reader);
break;
}
case AUDIT:
{
parseAudit(list, address, reader);
break;
}
case IDENTITY_TRUST:
{
parseIdentityTrust(list, address, reader);
break;
}
case MAPPING:
{
parseMapping(list, address, reader);
break;
}
case AUTHENTICATION_JASPI:
{
if (visited.contains(Element.AUTHENTICATION)) {
throw SecurityLogger.ROOT_LOGGER.xmlStreamExceptionAuth(reader.getLocation());
}
parseAuthenticationJaspi(list, address, reader);
break;
}
case JSSE:
{
parseJSSE(list, address, reader);
break;
}
default:
{
throw unexpectedElement(reader);
}
}
}
moduleNames.clear();
}
Aggregations