@Override public String[] apply(PathAddress address) { return new String[] { address.getLastElement().getValue() }; } },
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) { final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR)); final String name = address.getLastElement().getValue(); context.removeService(RemotingProfileService.BASE_SERVICE_NAME.append(name)); }
@SuppressWarnings("deprecation") @Override public ModelNode transformOperation(ModelNode operation) { PathAddress address = Operations.getPathAddress(operation); String protocol = address.getLastElement().getValue(); PathAddress stackAddress = address.getParent(); ModelNode legacyOperation = Util.createOperation("remove-protocol", stackAddress); legacyOperation.get(AbstractProtocolResourceDefinition.DeprecatedAttribute.TYPE.getName()).set(protocol); return legacyOperation; } };
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress address = context.getCurrentAddress(); final PathAddress parent = address.getParent(); final String name = address.getLastElement().getValue(); final String serverName = parent.getLastElement().getValue(); final ServiceName virtualHostServiceName = HostDefinition.HOST_CAPABILITY.getCapabilityServiceName(serverName, name); context.removeService(virtualHostServiceName); final ServiceName consoleRedirectName = UndertowService.consoleRedirectServiceName(serverName, name); context.removeService(consoleRedirectName); final ServiceName commonHostName = WebHost.SERVICE_NAME.append(name); context.removeService(commonHostName); final String defaultWebModule = HostDefinition.DEFAULT_WEB_MODULE.resolveModelAttribute(context, model).asString(); DefaultDeploymentMappingProvider.instance().removeMapping(defaultWebModule); }
PathAddress address = PathAddress.pathAddress(JGroupsSubsystemResourceDefinition.PATH); ModelNode operation = Util.createAddOperation(address); operations.put(address, operation); ModelNode defaultStack = operation.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName()); if (opAddr.getLastElement().getKey().equals(ChannelResourceDefinition.WILDCARD_PATH.getKey())) { ModelNode op = entry.getValue(); if (!op.hasDefined(ChannelResourceDefinition.Attribute.STACK.getName())) { op.get(ChannelResourceDefinition.Attribute.STACK.getName()).set(defaultStack);
public static void checkMapModels(KernelServices services, ModelVersion version, PathAddress address, String... properties) throws Exception { final ModelNode readResource = Util.createEmptyOperation(READ_RESOURCE_OPERATION, address); readResource.get(RECURSIVE).set(true); readResource.get(INCLUDE_DEFAULTS).set(false); ModelNode mainModel = services.executeForResult(readResource.clone()); checkMainMapModel(mainModel, properties); final ModelNode legacyModel; if (address.getLastElement().getKey().equals("transport")) { //TODO get rid of this once the PathAddress transformer works properly //Temporary workaround readResource.get(OP_ADDR).set(address.subAddress(0, address.size() - 1).append("transport", "TRANSPORT").toModelNode()); legacyModel = services.getLegacyServices(version).executeForResult(readResource); } else { legacyModel = ModelTestUtils.checkResultAndGetContents(services.executeOperation(version, services.transformOperation(version, readResource.clone()))); } checkLegacyChildResourceModel(legacyModel, properties); }
private void installManagementModel(final DataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getConnectionProperties() != null) { for (final Map.Entry<String, String> prop : ds.getConnectionProperties().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }
} catch (InstanceNotFoundException e) { final PathAddress address = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)); final PathElement element = address.getLastElement();
@Override public OperationStepHandler apply(OperationStepHandler handler) { return (context, operation) -> { if (this.legacy.test(operation)) { PathElement path = context.getCurrentAddress().getLastElement(); // This is a legacy add operation - process it using the generic handler OperationStepHandler genericHandler = context.getResourceRegistration().getParent().getOperationHandler(PathAddress.pathAddress(ProtocolResourceDefinition.WILDCARD_PATH), ModelDescriptionConstants.ADD); Operations.setPathAddress(operation, context.getCurrentAddress().getParent().append(GenericProtocolResourceDefinition.pathElement(path.getValue()))); // Process this step first to preserve protocol order context.addStep(operation, genericHandler, OperationContext.Stage.MODEL, true); } else { handler.execute(context, operation); } }; } }
ManagementResourceRegistration registration = context.getResourceRegistrationForUpdate(); String protocolName = context.getCurrentAddressValue(); String moduleName = ProtocolResourceDefinition.Attribute.MODULE.resolveModelAttribute(context, resource.getModel()).asString(); Class<? extends Protocol> protocolClass = ChannelRuntimeResourceRegistration.findProtocolClass(context, protocolName, moduleName); if (registration.getPathAddress().getLastElement().isWildcard()) { OverrideDescriptionProvider provider = new OverrideDescriptionProvider() { @Override
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final String name = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.ADDRESS)).getLastElement().getValue(); installRuntimeServices(context, name, model); }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress hostAddress = context.getCurrentAddress().getParent(); final PathAddress serverAddress = hostAddress.getParent(); final String name = context.getCurrentAddressValue(); final String handler = LocationDefinition.HANDLER.resolveModelAttribute(context, model).asString(); final LocationService service = new LocationService(name); final String serverName = serverAddress.getLastElement().getValue(); final String hostName = hostAddress.getLastElement().getValue(); final ServiceName serviceName = UndertowService.locationServiceName(serverName, hostName, name); final ServiceBuilder<LocationService> builder = context.getCapabilityServiceTarget().addCapability(LocationDefinition.LOCATION_CAPABILITY, service) .addCapabilityRequirement(Capabilities.CAPABILITY_HANDLER, HttpHandler.class, service.getHttpHandler(),handler) .addCapabilityRequirement(Capabilities.CAPABILITY_HOST, Host.class, service.getHost(), serverName, hostName); builder.setInitialMode(ServiceController.Mode.ACTIVE) .addAliases(serviceName) .install(); } }
@Override protected ServiceName getParentServiceName(PathAddress parentAddress) { return UndertowService.SERVLET_CONTAINER.append(parentAddress.getLastElement().getValue()); } }
static void buildTransformation(ModelVersion version, ResourceTransformationDescriptionBuilder builder) { if (InfinispanModel.VERSION_6_0_0.requiresTransformation(version)) { Converter converter = (PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) -> { PathAddress storeAddress = address.getParent(); PathElement storePath = storeAddress.getLastElement(); if (storePath.equals(StringKeyedJDBCStoreResourceDefinition.STRING_JDBC_PATH) || storePath.equals(StringKeyedJDBCStoreResourceDefinition.LEGACY_PATH)) { storeAddress = storeAddress.getParent().append(StringKeyedJDBCStoreResourceDefinition.PATH); } else if (storePath.equals(BinaryKeyedJDBCStoreResourceDefinition.LEGACY_PATH)) { storeAddress = storeAddress.getParent().append(BinaryKeyedJDBCStoreResourceDefinition.PATH); } else if (storePath.equals(MixedKeyedJDBCStoreResourceDefinition.LEGACY_PATH)) { storeAddress = storeAddress.getParent().append(MixedKeyedJDBCStoreResourceDefinition.PATH); } ModelNode store = context.readResourceFromRoot(storeAddress).getModel(); value.set(store.hasDefined(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getName()) ? store.get(StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getName()) : StoreResourceDefinition.Attribute.MAX_BATCH_SIZE.getDefinition().getDefaultValue()); }; builder.getAttributeBuilder().setValueConverter(new SimpleAttributeConverter(converter), DeprecatedAttribute.BATCH_SIZE.getDefinition()); } }
private void installManagementModel(final XaDataSource ds, final DeploymentUnit deploymentUnit, final PathAddress addr) { XMLXaDataSourceRuntimeHandler.INSTANCE.registerDataSource(addr, ds); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, addr.getLastElement()); if (ds.getXaDataSourceProperty() != null) { for (final Map.Entry<String, String> prop : ds.getXaDataSourceProperty().entrySet()) { PathAddress registration = PathAddress.pathAddress(addr.getLastElement(), PathElement.pathElement(XA_CONNECTION_PROPERTIES, prop.getKey())); deploymentResourceSupport.getDeploymentSubModel(DataSourcesExtension.SUBSYSTEM_NAME, registration); } } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, final ModelNode model) { PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR)); final String securityDomain = address.getLastElement().getValue(); // This needs to run after all child resources so that they can detect a fresh state context.addStep(new OperationStepHandler() { @Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final Resource resource = context.readResource(PathAddress.EMPTY_ADDRESS); launchServices(context, securityDomain, Resource.Tools.readModel(resource)); // Rollback handled by the parent step context.completeStep(OperationContext.RollbackHandler.NOOP_ROLLBACK_HANDLER); } }, OperationContext.Stage.RUNTIME); }
@Override public void installServices(OperationContext context, ModelNode model) throws OperationFailedException { PathAddress address = context.getCurrentAddress(); PathAddress hostAddress = address.getParent(); PathAddress serverAddress = hostAddress.getParent(); String hostName = hostAddress.getLastElement().getValue(); String serverName = serverAddress.getLastElement().getValue(); String domain = ModelNodes.optionalString(DOMAIN.resolveModelAttribute(context, model)).orElse(null); String path = PATH.resolveModelAttribute(context, model).asString(); boolean secure = SECURE.resolveModelAttribute(context, model).asBoolean(); boolean httpOnly = HTTP_ONLY.resolveModelAttribute(context, model).asBoolean(); String cookieName = COOKIE_NAME.resolveModelAttribute(context, model).asString(); ServiceName serviceName = UndertowService.ssoServiceName(serverName, hostName); ServiceName virtualHostServiceName = HostDefinition.HOST_CAPABILITY.getCapabilityServiceName(serverName,hostName); CapabilityServiceTarget target = context.getCapabilityServiceTarget(); ServiceName managerServiceName = serviceName.append("manager"); DistributableHostSingleSignOnManagerServiceConfiguratorProvider.INSTANCE.map(provider -> provider.getServiceConfigurator(managerServiceName, serverName, hostName)) .orElse(new SimpleCapabilityServiceConfigurator<>(managerServiceName, new InMemorySingleSignOnManager())) .configure(context).build(target).setInitialMode(ServiceController.Mode.ON_DEMAND).install(); SingleSignOnService service = new SingleSignOnService(domain, path, httpOnly, secure, cookieName); target.addCapability(HostSingleSignOnDefinition.HOST_SSO_CAPABILITY, service) .addAliases(serviceName) .addDependency(virtualHostServiceName, Host.class, service.getHost()) .addDependency(managerServiceName, SingleSignOnManager.class, service.getSingleSignOnSessionManager()) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
@Override protected ServiceName getParentServiceName(PathAddress parentAddress) { return UndertowService.SERVLET_CONTAINER.append(parentAddress.getLastElement().getValue()); } }
private void installManagementResource(ComponentConfiguration configuration, DeploymentUnit deploymentUnit) { final EJBComponentType type = EJBComponentType.getComponentType(configuration); PathAddress addr = getComponentAddress(type, configuration, deploymentUnit); final AbstractEJBComponentRuntimeHandler<?> handler = type.getRuntimeHandler(); handler.registerComponent(addr, configuration.getComponentDescription().getStartServiceName()); deploymentUnit.addToAttachmentList(EjbDeploymentAttachmentKeys.MANAGED_COMPONENTS, new InstalledComponent(type, addr)); final DeploymentResourceSupport deploymentResourceSupport = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_RESOURCE_SUPPORT); deploymentResourceSupport.getDeploymentSubModel(EJB3Extension.SUBSYSTEM_NAME, addr.getLastElement()); final EJBComponentDescription description = (EJBComponentDescription) configuration.getComponentDescription(); if (description.isTimerServiceRequired()) { final PathAddress timerServiceAddress = PathAddress.pathAddress(addr.getLastElement(), EJB3SubsystemModel.TIMER_SERVICE_PATH); final TimerServiceResource timerServiceResource = ((TimerServiceImpl) description.getTimerService()).getResource(); deploymentResourceSupport.registerDeploymentSubResource(EJB3Extension.SUBSYSTEM_NAME, timerServiceAddress, timerServiceResource); } }
protected void populateModel(ModelNode operation, ModelNode model) throws OperationFailedException { final ModelNode address = operation.require(OP_ADDR); final String driverName = PathAddress.pathAddress(address).getLastElement().getValue(); for (AttributeDefinition attribute : Constants.JDBC_DRIVER_ATTRIBUTES) { // https://issues.jboss.org/browse/WFLY-9324 skip validation on driver-name if (!attribute.getName().equals(DRIVER_NAME_NAME)) { attribute.validateAndSet(operation, model); } } model.get(DRIVER_NAME.getName()).set(driverName);//this shouldn't be here anymore }