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);
}
}
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);
}
}
}
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);
}
}
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;
}
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);
}
Aggregations