Refine search
static PathAddress cacheAddress(PathAddress transactionAddress) { return transactionAddress.subAddress(0, transactionAddress.size() - 1); }
@Override public PathAddress transform(PathAddress address) { return address.subAddress(0, address.size() - 1).append(LEGACY_PATH); } };
@Override protected PathAddress getParentAddress(PathAddress address) { for (int i = address.size() - 1; i >= 0; i--) { PathElement pe = address.getElement(i); if (pe.getKey().equals("service") && pe.getValue().equals("remote")) { return address.subAddress(0, i + 1); } } return null; }
@Override public Resource navigate(final PathAddress address) { if (address.size() > 0 && BALANCER.equals(address.getElement(0).getKey())) { final Resource modClusterBalancerResource = requireChild(address.getElement(0)); if(address.size() == 1) { return modClusterBalancerResource; } else { return modClusterBalancerResource.navigate(address.subAddress(1)); } } return delegate.navigate(address); }
@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); } });
@Override public Resource navigate(final PathAddress address) { final String element = address.getElement(0).getKey(); if (address.size() > 0 && (NODE.equals(element) || LOAD_BALANCING_GROUP.equals(element))) { final Resource subResource = requireChild(address.getElement(0)); if(address.size() == 1) { return subResource; } else { return subResource.navigate(address.subAddress(1)); } } throw new NoSuchResourceException(address.getElement(0)); }
@Override public PathAddress transform(PathAddress address) { PathAddress parentAddress = address.subAddress(0, address.size() - 1); return parentAddress.getLastElement().getKey().equals(TransportResourceDefinition.WILDCARD_PATH.getKey()) ? TransportResourceDefinition.LEGACY_ADDRESS_TRANSFORMER.transform(parentAddress).append(address.getLastElement()) : address; } };
private T getDataSourceConfig(final PathAddress operationAddress) throws OperationFailedException { final List<PathElement> relativeAddress = new ArrayList<PathElement>(); for (int i = operationAddress.size() - 1; i >= 0; i--) { PathElement pe = operationAddress.getElement(i); relativeAddress.add(0, pe); if (ModelDescriptionConstants.DEPLOYMENT.equals(pe.getKey())) { break; } } final PathAddress pa = PathAddress.pathAddress(relativeAddress); final T config; if(operationAddress.getLastElement().getKey().equals(CONNECTION_PROPERTIES) || operationAddress.getLastElement().getKey().equals(XA_DATASOURCE_PROPERTIES)) { config = dataSourceConfigs.get(pa.subAddress(0, pa.size() - 1)); } else { config = dataSourceConfigs.get(pa); } if (config == null) { String exceptionMessage = ConnectorLogger.ROOT_LOGGER.noDataSourceRegisteredForAddress(operationAddress); throw new OperationFailedException(exceptionMessage); } return config; }
@Override public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) { if (value.isDefined()) { PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); String poolName = value.asString(); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { if (entry.getName().equals(poolName)) { value.set(entry.getModel().get("jndi-name")); return; } } } } } } };
@Override public AttributeValueTranslator getWriteTranslator() { return (context, value) -> { String jndiName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { if (subsystem.hasChildren(type)) { for (Resource.ResourceEntry entry : subsystem.getChildren(type)) { ModelNode model = entry.getModel(); if (model.get("jndi-name").asString().equals(jndiName)) { return new ModelNode(entry.getName()); } } } } throw InfinispanLogger.ROOT_LOGGER.dataSourceJndiNameNotFound(jndiName); }; } };
@Override public void convertResourceAttribute(PathAddress address, String name, ModelNode value, TransformationContext context) { ModelNode remoteSite = context.readResourceFromRoot(address).getModel(); String channelName = remoteSite.get(Attribute.CHANNEL.getName()).asString(); if (DeprecatedAttribute.STACK.getName().equals(name)) { PathAddress subsystemAddress = address.subAddress(0, address.size() - 3); PathAddress channelAddress = subsystemAddress.append(ChannelResourceDefinition.pathElement(channelName)); ModelNode channel = context.readResourceFromRoot(channelAddress).getModel(); if (channel.hasDefined(ChannelResourceDefinition.Attribute.STACK.getName())) { value.set(channel.get(ChannelResourceDefinition.Attribute.STACK.getName()).asString()); } else { ModelNode subsystem = context.readResourceFromRoot(subsystemAddress).getModel(); value.set(subsystem.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_STACK.getName()).asString()); } } else if (DeprecatedAttribute.CLUSTER.getName().equals(name)) { value.set(channelName); } else { throw new IllegalStateException(); } } };
@Override public void execute(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size() - 1), false); final ModelNode subModel = web.getModel(); final String host = DeploymentDefinition.VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString(); final String path = DeploymentDefinition.CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString(); final String server = DeploymentDefinition.SERVER.resolveModelAttribute(context, subModel).asString(); context.addStep(new OperationStepHandler() { @Override public void execute(final OperationContext context, final ModelNode operation) { final ServiceController<?> deploymentServiceController = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (deploymentServiceController == null) { return; } final UndertowDeploymentService deploymentService = (UndertowDeploymentService) deploymentServiceController.getService(); final DeploymentInfo deploymentInfo = deploymentService.getDeploymentInfoInjectedValue().getValue(); final ServletInfo servlet = deploymentInfo.getServlets().get(context.getCurrentAddressValue()); ModelNode response = new ModelNode(); response.setEmptyList(); for (String mapping : servlet.getMappings()) { response.add(mapping); } } }, OperationContext.Stage.RUNTIME); } });
@Override public AttributeValueTranslator getReadTranslator() { return (context, value) -> { String poolName = value.asString(); PathAddress address = context.getCurrentAddress(); PathAddress rootAddress = address.subAddress(0, address.size() - 4); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "datasources")); Resource subsystem = context.readResourceFromRoot(subsystemAddress); for (String type : Arrays.asList("data-source", "xa-data-source")) { Resource resource = subsystem.getChild(PathElement.pathElement(type, poolName)); if (resource != null) { return resource.getModel().get("jndi-name"); } } throw InfinispanLogger.ROOT_LOGGER.dataSourceNotFound(poolName); }; }
@Override public void execute(final OperationContext context, final ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size() - 1), false); final ModelNode subModel = web.getModel(); final String host = DeploymentDefinition.VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString(); final String path = DeploymentDefinition.CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString(); final String server = DeploymentDefinition.SERVER.resolveModelAttribute(context, subModel).asString(); context.addStep(new OperationStepHandler() { @Override public void execute(final OperationContext context, final ModelNode operation) { final ServiceController<?> deploymentServiceController = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (deploymentServiceController == null) { return; } final UndertowDeploymentService deploymentService = (UndertowDeploymentService) deploymentServiceController.getService(); final DeploymentInfo deploymentInfo = deploymentService.getDeploymentInfoInjectedValue().getValue(); final UndertowMetricsCollector collector = (UndertowMetricsCollector)deploymentInfo.getMetricsCollector(); MetricsHandler.MetricResult result = collector != null ? collector.getMetrics(context.getCurrentAddressValue()) : null; if (result != null) { final ModelNode response = new ModelNode(); handle(response, result); context.getResult().set(response); } } }, OperationContext.Stage.RUNTIME); } }
PathAddress rootAddress = address.subAddress(0, address.size() - 2); PathAddress subsystemAddress = rootAddress.append(PathElement.pathElement(ModelDescriptionConstants.SUBSYSTEM, "infinispan")); ModelNode subsystem = context.readResourceFromRoot(address.subAddress(0, address.size() - 1)).getModel(); if (subsystem.hasDefined(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName())) { if (subsystem.get(JGroupsSubsystemResourceDefinition.Attribute.DEFAULT_CHANNEL.getName()).asString().equals(channelName)) {
final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size()), false); final ModelNode subModel = web.getModel();
private static SessionManager getSessionManager(OperationContext context, ModelNode operation) throws OperationFailedException { final PathAddress address = PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)); final Resource web = context.readResourceFromRoot(address.subAddress(0, address.size()), false); final ModelNode subModel = web.getModel(); final String host = VIRTUAL_HOST.resolveModelAttribute(context, subModel).asString(); final String path = CONTEXT_ROOT.resolveModelAttribute(context, subModel).asString(); final String server = SERVER.resolveModelAttribute(context, subModel).asString(); final UndertowDeploymentService deploymentService; final ServiceController<?> controller = context.getServiceRegistry(false).getService(UndertowService.deploymentServiceName(server, host, path)); if (controller != null && controller.getState() != ServiceController.State.UP) {//check if deployment is active at all throw UndertowLogger.ROOT_LOGGER.sessionManagerNotAvailable(); } else { deploymentService = (UndertowDeploymentService) controller.getService(); if (deploymentService == null || deploymentService.getDeployment() == null) { //we might be in shutdown and it is possible throw UndertowLogger.ROOT_LOGGER.sessionManagerNotAvailable(); } } Deployment deployment = deploymentService.getDeployment(); return deployment.getSessionManager(); }
@Override public void convert(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) { if (!value.isDefined()) { PathAddress rootAddress = address.subAddress(0, address.size() - 3); PathAddress subsystemAddress = rootAddress.append(JGroupsSubsystemResourceDefinition.PATH); ModelNode subsystemModel = context.readResourceFromRoot(subsystemAddress).getModel();
public static ServiceName getFilterRefServiceName(final PathAddress address, String name) { final PathAddress oneUp = address.subAddress(0, address.size() - 1); final PathAddress twoUp = oneUp.subAddress(0, oneUp.size() - 1); final PathAddress threeUp = twoUp.subAddress(0, twoUp.size() - 1); ServiceName serviceName; if (address.getLastElement().getKey().equals(Constants.FILTER_REF)) { if (oneUp.getLastElement().getKey().equals(Constants.HOST)) { //adding reference String host = oneUp.getLastElement().getValue(); String server = twoUp.getLastElement().getValue(); serviceName = UndertowService.filterRefName(server, host, name); } else { String location = oneUp.getLastElement().getValue(); String host = twoUp.getLastElement().getValue(); String server = threeUp.getLastElement().getValue(); serviceName = UndertowService.filterRefName(server, host, location, name); } } else if (address.getLastElement().getKey().equals(Constants.HOST)) { String host = address.getLastElement().getValue(); String server = oneUp.getLastElement().getValue(); serviceName = UndertowService.filterRefName(server, host, name); } else { String location = address.getLastElement().getValue(); String host = oneUp.getLastElement().getValue(); String server = twoUp.getLastElement().getValue(); serviceName = UndertowService.filterRefName(server, host, location, name); } return serviceName; }
@Override public boolean reject(PathAddress address, String name, ModelNode value, ModelNode model, TransformationContext context) { if (value.isDefined()) return false; PathAddress rootAddress = address.subAddress(0, address.size() - 3); PathAddress subsystemAddress = rootAddress.append(JGroupsSubsystemResourceDefinition.PATH); ModelNode subsystemModel = context.readResourceFromRoot(subsystemAddress).getModel();