use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class HandlerAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
// modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
if (context.isBooting()) {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final PathElement confElem = address.getElement(address.size() - 3);
final String configType = confElem.getKey();
final String configName = confElem.getValue();
final String handlerChainType = address.getElement(address.size() - 2).getKey();
final String handlerChainId = address.getElement(address.size() - 2).getValue();
final String handlerName = address.getElement(address.size() - 1).getValue();
final String handlerClass = operation.require(CLASS).asString();
final HandlerService service = new HandlerService(handlerName, handlerClass, counter.incrementAndGet());
final ServiceTarget target = context.getServiceTarget();
final ServiceName configServiceName = getConfigServiceName(configType, configName);
final ServiceRegistry registry = context.getServiceRegistry(false);
if (registry.getService(configServiceName) == null) {
throw WSLogger.ROOT_LOGGER.missingConfig(configName);
}
final ServiceName handlerChainServiceName = getHandlerChainServiceName(configServiceName, handlerChainType, handlerChainId);
if (registry.getService(handlerChainServiceName) == null) {
throw WSLogger.ROOT_LOGGER.missingHandlerChain(configName, handlerChainType, handlerChainId);
}
final ServiceName handlerServiceName = getHandlerServiceName(handlerChainServiceName, handlerName);
final ServiceBuilder<?> handlerServiceBuilder = target.addService(handlerServiceName, service);
ServiceController<?> controller = handlerServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
} else {
context.reloadRequired();
}
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class HandlerChainAdd method performRuntime.
@Override
protected void performRuntime(final OperationContext context, final ModelNode operation, final ModelNode model) throws OperationFailedException {
//modify the runtime if we're booting, otherwise set reload required and leave the runtime unchanged
if (context.isBooting()) {
final String protocolBindings = getAttributeValue(operation, PROTOCOL_BINDINGS);
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final PathElement confElem = address.getElement(address.size() - 2);
final String configType = confElem.getKey();
final String configName = confElem.getValue();
final String handlerChainType = address.getElement(address.size() - 1).getKey();
final String handlerChainId = address.getElement(address.size() - 1).getValue();
final ServiceName configServiceName = getConfigServiceName(configType, configName);
if (context.getServiceRegistry(false).getService(configServiceName) == null) {
throw WSLogger.ROOT_LOGGER.missingConfig(configName);
}
final ServiceName handlerChainServiceName = getHandlerChainServiceName(configServiceName, handlerChainType, handlerChainId);
final HandlerChainService service = new HandlerChainService(handlerChainType, handlerChainId, protocolBindings);
final ServiceTarget target = context.getServiceTarget();
final ServiceBuilder<?> handlerChainServiceBuilder = target.addService(handlerChainServiceName, service);
for (ServiceName sn : PackageUtils.getServiceNameDependencies(context, handlerChainServiceName, address, HANDLER)) {
//get a new injector instance each time
handlerChainServiceBuilder.addDependency(sn, UnifiedHandlerMetaData.class, service.getHandlersInjector());
}
handlerChainServiceBuilder.setInitialMode(ServiceController.Mode.ACTIVE).install();
} else {
context.reloadRequired();
}
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class WSEndpointMetrics method getEndpointMetricsFragment.
@SuppressWarnings("unchecked")
private ModelNode getEndpointMetricsFragment(final ModelNode operation, final ServiceRegistry registry) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
String endpointId;
try {
endpointId = URLDecoder.decode(address.getLastElement().getValue(), "UTF-8");
} catch (final UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
final String metricName = operation.require(NAME).asString();
final String webContext = endpointId.substring(0, endpointId.indexOf(":"));
final String endpointName = endpointId.substring(endpointId.indexOf(":") + 1);
ServiceName endpointServiceName = WSServices.ENDPOINT_SERVICE.append("context=" + webContext).append(endpointName);
ServiceController<Endpoint> service = (ServiceController<Endpoint>) currentServiceContainer().getService(endpointServiceName);
Endpoint endpoint = service.getValue();
if (endpoint == null) {
throw new OperationFailedException(WSLogger.ROOT_LOGGER.noMetricsAvailable());
}
final ModelNode result = new ModelNode();
final EndpointMetrics endpointMetrics = endpoint.getEndpointMetrics();
if (MIN_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getMinProcessingTime());
} else if (MAX_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getMaxProcessingTime());
} else if (AVERAGE_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getAverageProcessingTime());
} else if (TOTAL_PROCESSING_TIME.getName().equals(metricName)) {
result.set(endpointMetrics.getTotalProcessingTime());
} else if (REQUEST_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getRequestCount());
} else if (RESPONSE_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getResponseCount());
} else if (FAULT_COUNT.getName().equals(metricName)) {
result.set(endpointMetrics.getFaultCount());
}
return result;
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class WSSubsystem11Reader method readElement.
@Override
public void readElement(final XMLExtendedStreamReader reader, final List<ModelNode> list) throws XMLStreamException {
final PathAddress address = PathAddress.pathAddress(WSExtension.SUBSYSTEM_PATH);
final ModelNode subsystem = Util.createAddOperation(address);
list.add(subsystem);
readAttributes(reader, subsystem);
// elements
final EnumSet<Element> encountered = EnumSet.noneOf(Element.class);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case MODIFY_WSDL_ADDRESS:
{
if (!encountered.add(element)) {
throw unexpectedElement(reader);
}
final String value = parseElementNoAttributes(reader);
Attributes.MODIFY_WSDL_ADDRESS.parseAndSetParameter(value, subsystem, reader);
break;
}
case WSDL_HOST:
{
if (!encountered.add(element)) {
throw unexpectedElement(reader);
}
final String value = parseElementNoAttributes(reader);
Attributes.WSDL_HOST.parseAndSetParameter(value, subsystem, reader);
break;
}
case WSDL_PORT:
{
if (!encountered.add(element)) {
throw unexpectedElement(reader);
}
final String value = parseElementNoAttributes(reader);
Attributes.WSDL_PORT.parseAndSetParameter(value, subsystem, reader);
break;
}
case WSDL_SECURE_PORT:
{
if (!encountered.add(element)) {
throw unexpectedElement(reader);
}
final String value = parseElementNoAttributes(reader);
Attributes.WSDL_SECURE_PORT.parseAndSetParameter(value, subsystem, reader);
break;
}
case ENDPOINT_CONFIG:
{
List<ModelNode> configs = readConfig(reader, address, false);
list.addAll(configs);
break;
}
default:
{
handleUnknownElement(reader, address, element, list, encountered);
}
}
}
//TODOļ¼check required element
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class XTSExtension method registerTransformers1x.
private void registerTransformers1x(SubsystemRegistration subsystem) {
ResourceTransformationDescriptionBuilder builder = TransformationDescriptionBuilder.Factory.createSubsystemInstance();
builder.getAttributeBuilder().setDiscard(new DiscardAttributeChecker.DefaultDiscardAttributeChecker() {
@Override
protected boolean isValueDiscardable(PathAddress address, String attributeName, ModelNode attributeValue, TransformationContext context) {
return attributeValue.isDefined() && attributeValue.equals(XTSSubsystemDefinition.HOST_NAME.getDefaultValue());
}
}, XTSSubsystemDefinition.HOST_NAME).setDiscard(new DiscardAttributeChecker.DiscardAttributeValueChecker(new ModelNode(false)), XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION).addRejectCheck(RejectAttributeChecker.DEFINED, XTSSubsystemDefinition.HOST_NAME, XTSSubsystemDefinition.DEFAULT_CONTEXT_PROPAGATION).end();
TransformationDescription.Tools.register(builder.build(), subsystem, ModelVersion.create(1, 1, 0));
}
Aggregations