Search in sources :

Example 21 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class DomainHostExcludesTest method test002ServerBoot.

@Test
public void test002ServerBoot() throws IOException, MgmtOperationException, InterruptedException {
    ModelControllerClient masterClient = testSupport.getDomainMasterLifecycleUtil().getDomainClient();
    PathAddress serverCfgAddr = PathAddress.pathAddress(HOST, PathElement.pathElement(SERVER_CONFIG, "server-one"));
    ModelNode op = Util.createEmptyOperation("start", serverCfgAddr);
    executeForResult(op, masterClient);
    PathAddress serverAddr = PathAddress.pathAddress(HOST, PathElement.pathElement(RUNNING_SERVER, "server-one"));
    awaitServerLaunch(masterClient, serverAddr);
    checkSockets(masterClient, serverAddr.append(PathElement.pathElement(SOCKET_BINDING_GROUP, "full-ha-sockets")));
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) PathAddress(org.jboss.as.controller.PathAddress) ModelNode(org.jboss.dmr.ModelNode) Test(org.junit.Test)

Example 22 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class EJBManagementUtil method editPassByValueForRemoteInterfaceInvocations.

private static void editPassByValueForRemoteInterfaceInvocations(ManagementClient managementClient, final boolean passByValue) {
    final ModelControllerClient modelControllerClient = managementClient.getControllerClient();
    try {
        // /subsystem=ejb3:write-attribute(name="in-vm-remote-interface-invocation-pass-by-value", value=<passByValue>)
        final ModelNode passByValueWriteAttributeOperation = new ModelNode();
        // set the operation
        passByValueWriteAttributeOperation.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
        // set the address
        final PathAddress ejb3SubsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME));
        passByValueWriteAttributeOperation.get(OP_ADDR).set(ejb3SubsystemAddress.toModelNode());
        // setup the parameters for the write attribute operation
        passByValueWriteAttributeOperation.get(NAME).set(EJB3SubsystemModel.IN_VM_REMOTE_INTERFACE_INVOCATION_PASS_BY_VALUE);
        passByValueWriteAttributeOperation.get(VALUE).set(passByValue);
        // execute the operations
        execute(modelControllerClient, passByValueWriteAttributeOperation);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) PathAddress(org.jboss.as.controller.PathAddress) IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode)

Example 23 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class EJBManagementUtil method createRemoteOutboundSocket.

public static void createRemoteOutboundSocket(final String managementServerHostName, final int managementPort, final String socketGroupName, final String outboundSocketName, final String destinationHost, final int destinationPort, final CallbackHandler callbackHandler) {
    final ModelControllerClient modelControllerClient = getModelControllerClient(managementServerHostName, managementPort, callbackHandler);
    try {
        // /socket-binding-group=<group-name>/remote-destination-outbound-socket-binding=<name>:add(host=<host>, port=<port>)
        final ModelNode outboundSocketAddOperation = new ModelNode();
        outboundSocketAddOperation.get(OP).set(ADD);
        final PathAddress address = PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, socketGroupName), PathElement.pathElement(ModelDescriptionConstants.REMOTE_DESTINATION_OUTBOUND_SOCKET_BINDING, outboundSocketName));
        outboundSocketAddOperation.get(OP_ADDR).set(address.toModelNode());
        // setup the other parameters for the add operation
        outboundSocketAddOperation.get(HOST).set(destinationHost);
        outboundSocketAddOperation.get(PORT).set(destinationPort);
        // execute the add operation
        execute(modelControllerClient, outboundSocketAddOperation);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    } finally {
        // close the controller client connection
        try {
            modelControllerClient.close();
        } catch (IOException e) {
            logger.warn("Error closing model controller client", e);
        }
    }
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) PathAddress(org.jboss.as.controller.PathAddress) IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode)

Example 24 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class EJBManagementUtil method setDefaultDistinctName.

public static void setDefaultDistinctName(ManagementClient managementClient, final String distinctName) {
    final ModelControllerClient modelControllerClient = managementClient.getControllerClient();
    try {
        final ModelNode op = new ModelNode();
        if (distinctName != null) {
            op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
            op.get(VALUE).set(distinctName);
        } else {
            op.get(OP).set(UNDEFINE_ATTRIBUTE_OPERATION);
        }
        // set the address
        final PathAddress ejb3SubsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, EJB3Extension.SUBSYSTEM_NAME));
        op.get(OP_ADDR).set(ejb3SubsystemAddress.toModelNode());
        // setup the parameters for the write attribute operation
        op.get(NAME).set(EJB3SubsystemModel.DEFAULT_DISTINCT_NAME);
        // execute the operations
        execute(modelControllerClient, op);
    } catch (IOException ioe) {
        throw new RuntimeException(ioe);
    }
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) PathAddress(org.jboss.as.controller.PathAddress) IOException(java.io.IOException) ModelNode(org.jboss.dmr.ModelNode)

Example 25 with ModelControllerClient

use of org.jboss.as.controller.client.ModelControllerClient in project wildfly by wildfly.

the class ClientCompatibilityUnitTestCase method createClient.

protected static ModelControllerClient createClient(final String artifact, final String version, final String host, final int port) throws Exception {
    final ChildFirstClassLoaderBuilder classLoaderBuilder = new ChildFirstClassLoaderBuilder(false);
    classLoaderBuilder.addRecursiveMavenResourceURL(artifact + ":" + version, excludes);
    classLoaderBuilder.addParentFirstClassPattern("org.jboss.as.controller.client.ModelControllerClientConfiguration");
    classLoaderBuilder.addParentFirstClassPattern("org.jboss.as.controller.client.ModelControllerClient");
    classLoaderBuilder.addParentFirstClassPattern("org.jboss.as.controller.client.OperationMessageHandler");
    classLoaderBuilder.addParentFirstClassPattern("org.jboss.as.controller.client.Operation");
    classLoaderBuilder.addParentFirstClassPattern("org.jboss.as.controller.client.OperationResponse*");
    final ClassLoader classLoader = classLoaderBuilder.build();
    final Class<?> factoryClass = classLoader.loadClass("org.jboss.as.controller.client.ModelControllerClient$Factory");
    final Method factory = factoryClass.getMethod("create", String.class, int.class);
    try {
        final Object client = factory.invoke(null, host, port);
        final InvocationHandler invocationHandler = new InvocationHandler() {

            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                return method.invoke(client, args);
            }
        };
        final Class<?>[] interfaces = new Class<?>[] { ModelControllerClient.class };
        return (ModelControllerClient) Proxy.newProxyInstance(classLoader, interfaces, invocationHandler);
    } catch (InvocationTargetException e) {
        Throwable t = e.getCause();
        if (t == null) {
            throw e;
        }
        throw t instanceof Exception ? (Exception) t : new RuntimeException(t);
    }
}
Also used : ChildFirstClassLoaderBuilder(org.jboss.as.model.test.ChildFirstClassLoaderBuilder) Method(java.lang.reflect.Method) InvocationHandler(java.lang.reflect.InvocationHandler) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) BeforeClass(org.junit.BeforeClass)

Aggregations

ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)58 ModelNode (org.jboss.dmr.ModelNode)27 Test (org.junit.Test)21 ManagementClient (org.jboss.as.arquillian.container.ManagementClient)17 IOException (java.io.IOException)11 InSequence (org.jboss.arquillian.junit.InSequence)8 URL (java.net.URL)5 PathAddress (org.jboss.as.controller.PathAddress)5 Before (org.junit.Before)5 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)4 UnknownHostException (java.net.UnknownHostException)3 InitialContext (javax.naming.InitialContext)2 NamingException (javax.naming.NamingException)2 OperateOnDeployment (org.jboss.arquillian.container.test.api.OperateOnDeployment)2 CommandContext (org.jboss.as.cli.CommandContext)2 CommandFormatException (org.jboss.as.cli.CommandFormatException)2 OperationFormatException (org.jboss.as.cli.operation.OperationFormatException)2 DefaultOperationRequestBuilder (org.jboss.as.cli.operation.impl.DefaultOperationRequestBuilder)2 After (org.junit.After)2 BeforeClass (org.junit.BeforeClass)2