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