use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class WebSubsystemParser method readElement.
/**
* {@inheritDoc}
*/
@Override
public void readElement(XMLExtendedStreamReader reader, List<ModelNode> list) throws XMLStreamException {
PathAddress address = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, WebExtension.SUBSYSTEM_NAME));
final ModelNode subsystem = new ModelNode();
subsystem.get(OP).set(ADD);
subsystem.get(OP_ADDR).set(address.toModelNode());
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));
switch(attribute) {
case NATIVE:
WebDefinition.NATIVE.parseAndSetParameter(value, subsystem, reader);
break;
case DEFAULT_VIRTUAL_SERVER:
WebDefinition.DEFAULT_VIRTUAL_SERVER.parseAndSetParameter(value, subsystem, reader);
break;
case INSTANCE_ID:
WebDefinition.INSTANCE_ID.parseAndSetParameter(value, subsystem, reader);
break;
case DEFAULT_SESSION_TIMEOUT:
attributeSupportedSince(Namespace.WEB_2_2, reader, i);
WebDefinition.DEFAULT_SESSION_TIMEOUT.parseAndSetParameter(value, subsystem, reader);
break;
default:
throw unexpectedAttribute(reader, i);
}
}
list.add(subsystem);
boolean containerConfigDefined = false;
final Namespace namespace = Namespace.forUri(reader.getNamespaceURI());
// elements
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
switch(namespace) {
case WEB_1_0:
case WEB_1_1:
case WEB_1_2:
case WEB_1_3:
{
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case CONTAINER_CONFIG:
{
parseContainerConfig(reader, address, list);
containerConfigDefined = true;
break;
}
case CONNECTOR:
{
parseConnector(reader, address, list);
break;
}
case VIRTUAL_SERVER:
{
parseHost(reader, address, list);
break;
}
default:
{
throw unexpectedElement(reader);
}
}
break;
}
case WEB_1_4:
case WEB_1_5:
case WEB_2_0:
case WEB_2_1:
case WEB_2_2:
{
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case CONTAINER_CONFIG:
{
parseContainerConfig(reader, address, list);
containerConfigDefined = true;
break;
}
case CONNECTOR:
{
parseConnector(reader, address, list);
break;
}
case VIRTUAL_SERVER:
{
parseHost(reader, address, list);
break;
}
case VALVE:
{
parseValve(reader, address, list);
break;
}
default:
{
throw unexpectedElement(reader);
}
}
break;
}
default:
{
throw unexpectedElement(reader);
}
}
}
if (!containerConfigDefined) {
addDefaultContainerConfig(address, list);
}
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class WebSubsystemParser method parseValve.
private static void parseValve(XMLExtendedStreamReader reader, PathAddress parent, List<ModelNode> list) throws XMLStreamException {
String name = null;
final ModelNode valve = new ModelNode();
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));
switch(attribute) {
case NAME:
name = value;
break;
case MODULE:
WebValveDefinition.MODULE.parseAndSetParameter(value, valve, reader);
break;
case CLASS_NAME:
WebValveDefinition.CLASS_NAME.parseAndSetParameter(value, valve, reader);
break;
case ENABLED:
WebValveDefinition.ENABLED.parseAndSetParameter(value, valve, reader);
break;
default:
throw unexpectedAttribute(reader, i);
}
}
if (name == null) {
throw missingRequired(reader, Collections.singleton(Attribute.NAME));
}
valve.get(OP).set(ADD);
PathAddress address = PathAddress.pathAddress(parent, PathElement.pathElement(VALVE, name));
valve.get(OP_ADDR).set(address.toModelNode());
list.add(valve);
while (reader.hasNext() && reader.nextTag() != END_ELEMENT) {
final Element element = Element.forName(reader.getLocalName());
switch(element) {
case PARAM:
final String[] array = requireAttributes(reader, Attribute.PARAM_NAME.getLocalName(), Attribute.PARAM_VALUE.getLocalName());
valve.get(PARAM).get(array[0]).set(array[1]);
requireNoContent(reader);
break;
default:
throw unexpectedElement(reader);
}
}
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class WebSubsystemTestCase method checkUndefinedCipherSuite.
private void checkUndefinedCipherSuite(KernelServices services, ModelVersion version) throws Exception {
final ModelNode success = new ModelNode();
success.get(ModelDescriptionConstants.OUTCOME).set(ModelDescriptionConstants.SUCCESS);
success.get(ModelDescriptionConstants.RESULT);
success.protect();
PathAddress addr = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, getMainSubsystemName()), PathElement.pathElement("connector", "https"), PathElement.pathElement("configuration", "ssl"));
ModelNode op = Util.createOperation(WRITE_ATTRIBUTE_OPERATION, addr);
op.get(NAME).set("cipher-suite");
op.get(VALUE).set(new ModelNode());
TransformedOperation transOp = services.transformOperation(version, op);
Assert.assertTrue(transOp.rejectOperation(success));
op.get(VALUE).set("SSL_RSA_WITH_3DES_EDE_CBC_SHA");
transOp = services.transformOperation(version, op);
Assert.assertFalse(transOp.rejectOperation(success));
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class BroadcastGroupAdd method performRuntime.
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
ServiceRegistry registry = context.getServiceRegistry(false);
final ServiceName serviceName = MessagingServices.getActiveMQServiceName(PathAddress.pathAddress(operation.get(ModelDescriptionConstants.OP_ADDR)));
ServiceController<?> service = registry.getService(serviceName);
if (service != null) {
context.reloadRequired();
} else {
final PathAddress address = PathAddress.pathAddress(operation.require(OP_ADDR));
final String name = address.getLastElement().getValue();
final ServiceTarget target = context.getServiceTarget();
if (model.hasDefined(JGROUPS_CHANNEL.getName())) {
// nothing to do, in that case, the clustering.jgroups subsystem will have setup the stack
} else if (model.hasDefined(RemoteTransportDefinition.SOCKET_BINDING.getName())) {
final GroupBindingService bindingService = new GroupBindingService();
target.addService(GroupBindingService.getBroadcastBaseServiceName(serviceName).append(name), bindingService).addDependency(SocketBinding.JBOSS_BINDING_NAME.append(model.get(SOCKET_BINDING).asString()), SocketBinding.class, bindingService.getBindingRef()).install();
}
}
}
use of org.jboss.as.controller.PathAddress in project wildfly by wildfly.
the class MailSessionAdd method performRuntime.
/**
* Make any runtime changes necessary to effect the changes indicated by the given {@code operation}. E
* <p>
* It constructs a MailSessionService that provides mail session and registers it to Naming service.
* </p>
*
* @param context the operation context
* @param operation the operation being executed
* @param model persistent configuration model node that corresponds to the address of {@code operation}
* @throws org.jboss.as.controller.OperationFailedException
* if {@code operation} is invalid or updating the runtime otherwise fails
*/
@Override
protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final PathAddress address = PathAddress.pathAddress(operation.get(OP_ADDR));
ModelNode fullTree = Resource.Tools.readModel(context.readResource(PathAddress.EMPTY_ADDRESS));
installRuntimeServices(context, address, fullTree);
}
Aggregations