Search in sources :

Example 91 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, SUBSYSTEM_NAME));
        passByValueWriteAttributeOperation.get(OP_ADDR).set(ejb3SubsystemAddress.toModelNode());
        // setup the parameters for the write attribute operation
        passByValueWriteAttributeOperation.get(NAME).set("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 92 with ModelControllerClient

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

the class EJBManagementUtil method getEJBRemoteConnectorPort.

/**
 * Returns the Jakarta Enterprise Beans remoting connector port that can be used for Jakarta Enterprise Beans remote invocations
 *
 * @param managementServerHostName The hostname of the server
 * @param managementPort           The management port
 * @return
 */
public static int getEJBRemoteConnectorPort(final String managementServerHostName, final int managementPort, final CallbackHandler handler) {
    final ModelControllerClient modelControllerClient = getModelControllerClient(managementServerHostName, managementPort, handler);
    try {
        // first get the remote-connector from the Enterprise Beans 3 subsystem to find the remote connector ref
        // /subsystem=ejb3/service=remote:read-attribute(name=connector-ref)
        final ModelNode readConnectorRefAttribute = new ModelNode();
        readConnectorRefAttribute.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION);
        readConnectorRefAttribute.get(NAME).set(CONNECTOR_REF);
        final PathAddress ejbRemotingServiceAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME), PathElement.pathElement(SERVICE, REMOTE));
        readConnectorRefAttribute.get(OP_ADDR).set(ejbRemotingServiceAddress.toModelNode());
        // execute the read-attribute
        final ModelNode connectorRefResult = execute(modelControllerClient, readConnectorRefAttribute);
        final String connectorRef = connectorRefResult.get(RESULT).asString();
        // now get the socket-binding ref for this connector ref, from the remoting subsystem
        // /subsystem=remoting/connector=<connector-ref>:read-attribute(name=socket-binding)
        final ModelNode readSocketBindingRefAttribute = new ModelNode();
        readSocketBindingRefAttribute.get(OP).set(READ_ATTRIBUTE_OPERATION);
        readSocketBindingRefAttribute.get(NAME).set(SOCKET_BINDING);
        final PathAddress remotingSubsystemAddress = PathAddress.pathAddress(PathElement.pathElement(SUBSYSTEM, RemotingExtension.SUBSYSTEM_NAME), PathElement.pathElement("connector", connectorRef));
        readSocketBindingRefAttribute.get(OP_ADDR).set(remotingSubsystemAddress.toModelNode());
        // execute the read-attribute
        final ModelNode socketBindingRefResult = execute(modelControllerClient, readSocketBindingRefAttribute);
        final String socketBindingRef = socketBindingRefResult.get(RESULT).asString();
        // now get the port value of that socket binding ref
        // /socket-binding-group=standard-sockets/socket-binding=<socket-binding-ref>:read-attribute(name=port)
        final ModelNode readPortAttribute = new ModelNode();
        readPortAttribute.get(OP).set(READ_ATTRIBUTE_OPERATION);
        readPortAttribute.get(NAME).set(PORT);
        // TODO: "standard-sockets" group is hardcoded for now
        final PathAddress socketBindingAddress = PathAddress.pathAddress(PathElement.pathElement(SOCKET_BINDING_GROUP, "standard-sockets"), PathElement.pathElement(SOCKET_BINDING, socketBindingRef));
        readPortAttribute.get(OP_ADDR).set(socketBindingAddress.toModelNode());
        // execute the read-attribute
        final ModelNode portResult = execute(modelControllerClient, readPortAttribute);
        return portResult.get(RESULT).asInt();
    } 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 93 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, SUBSYSTEM_NAME));
        op.get(OP_ADDR).set(ejb3SubsystemAddress.toModelNode());
        // setup the parameters for the write attribute operation
        op.get(NAME).set("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 94 with ModelControllerClient

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

the class AbstractRbacTestCase method getClientForUser.

public ModelControllerClient getClientForUser(String userName) throws UnknownHostException {
    ModelControllerClient result = clients.get(userName);
    if (result == null) {
        result = createClient(userName);
        clients.put(userName, result);
    }
    return result;
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient)

Example 95 with ModelControllerClient

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

the class PermissionsCoverageTestCase method testTheEntireDomainTreeHasPermissionsDefined.

@Test
public void testTheEntireDomainTreeHasPermissionsDefined() throws Exception {
    ModelControllerClient client = managementClient.getControllerClient();
    assertTheEntireDomainTreeHasPermissionsDefined(client);
}
Also used : ModelControllerClient(org.jboss.as.controller.client.ModelControllerClient) Test(org.junit.Test)

Aggregations

ModelControllerClient (org.jboss.as.controller.client.ModelControllerClient)106 ModelNode (org.jboss.dmr.ModelNode)61 Test (org.junit.Test)30 IOException (java.io.IOException)20 ManagementClient (org.jboss.as.arquillian.container.ManagementClient)19 PathAddress (org.jboss.as.controller.PathAddress)10 ArrayList (java.util.ArrayList)9 InSequence (org.jboss.arquillian.junit.InSequence)8 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)7 URL (java.net.URL)6 UnknownHostException (java.net.UnknownHostException)6 JMSOperations (org.jboss.as.test.integration.common.jms.JMSOperations)6 Before (org.junit.Before)6 WildFlyElytronProvider (org.wildfly.security.WildFlyElytronProvider)4 NamingException (javax.naming.NamingException)3 CommandContext (org.jboss.as.cli.CommandContext)3 OperationBuilder (org.jboss.as.controller.client.OperationBuilder)3 After (org.junit.After)3 File (java.io.File)2 InitialContext (javax.naming.InitialContext)2