本文整理汇总了Java中org.jboss.as.cli.CommandContextFactory类的典型用法代码示例。如果您正苦于以下问题:Java CommandContextFactory类的具体用法?Java CommandContextFactory怎么用?Java CommandContextFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandContextFactory类属于org.jboss.as.cli包,在下文中一共展示了CommandContextFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupNativeInterface
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
private static void setupNativeInterface() throws Exception {
ctx.handle("/socket-binding-group=standard-sockets/socket-binding=management-native:"
+ "add(port=" + MANAGEMENT_NATIVE_PORT + ",interface=management");
ctx.handle("/core-service=management/security-realm=native-realm:add()");
ctx.handle("/core-service=management/security-realm=native-realm/authentication=local:"
+ "add(default-user=\"$local\"");
ctx.handle("/core-service=management/management-interface=native-interface:"
+ "add(security-realm=native-realm,socket-binding=management-native");
ctx.handle("reload");
// Build the cleaner
CommandContextConfiguration.Builder configBuilder = new CommandContextConfiguration.Builder();
configBuilder.setConsoleOutput(System.out).
setController("remote://" + TestSuiteEnvironment.getServerAddress()
+ ":" + MANAGEMENT_NATIVE_PORT);
cleaner = CommandContextFactory.getInstance().newCommandContext(configBuilder.build());
cleaner.connectController();
}
示例2: beforeTest
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Before
public void beforeTest() throws CliInitializationException, IOException, CommandLineException {
container.start();
consoleOutput.reset();
ExtensionUtils.createExtensionModule("org.wildfly.extension.blocker-test", BlockerExtension.class,
EmptySubsystemParser.class.getPackage());
CommandContextConfiguration config = new CommandContextConfiguration.Builder().
setInitConsole(true).setConsoleOutput(consoleOutput).
setController("remote+http://"
+ TestSuiteEnvironment.getServerAddress() + ":"
+ TestSuiteEnvironment.getServerPort()).
setCommandTimeout(CONFIG_TIMEOUT).build();
ctx = CommandContextFactory.getInstance().newCommandContext(config);
ctx.handle("command-timeout reset default");
ctx.handle("connect");
ctx.handle("/extension=org.wildfly.extension.blocker-test:add");
ctx.handle("command-timeout reset config");
}
示例3: connect
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
/**
* Connect to the server using a specified host and port.
* @param protocol The protocol
* @param controllerHost The host name.
* @param controllerPort The port.
* @param username The user name for logging in.
* @param password The password for logging in.
*/
public void connect(String protocol, String controllerHost, int controllerPort,
String username, char[] password, String clientBindAddress) {
doConnect(() -> {
return CommandContextFactory.getInstance().newCommandContext(
new CommandContextConfiguration.Builder().
setController(constructUri(protocol,
controllerHost,
controllerPort))
.setUsername(username)
.setPassword(password)
.setErrorOnInteract(false)
.setClientBindAddress(clientBindAddress)
.build());
});
}
示例4: create
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
/**
* Creates the command context and connects the context.
*
* @param configuration the configuration to use when connecting the {@link CommandContext}
*
* @return the command line context
*
* @throws IllegalStateException if the context fails to initialize
*/
@SuppressWarnings("UseOfSystemOutOrSystemErr")
private CommandContext create(final MavenModelControllerClientConfiguration configuration) {
CommandContext commandContext = null;
try {
// Use System.in and System.out to allow prompting for a username and password if required
commandContext = CommandContextFactory.getInstance().newCommandContext(configuration.getController(),
configuration.getUsername(), configuration.getPassword(), new UncloseableInputStream(System.in),
new UncloseableOutputStream(System.out));
// Connect the controller
commandContext.connectController();
} catch (CommandLineException e) {
// Terminate the session if we've encountered an error
if (commandContext != null) {
commandContext.terminateSession();
}
throw new IllegalStateException("Failed to initialize CLI context", e);
}
return commandContext;
}
示例5: setup
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
CommandContext commandContext = CommandContextFactory.getInstance().newCommandContext();
commandContext.bindClient(managementClient.getControllerClient());
commandContext
.handle("/subsystem=logging/custom-formatter=JsonFormatter/:add(module=biz.paluch.logging,class=biz.paluch.logging.gelf.wildfly.WildFlyJsonFormatter,properties={ \\\n"
+ "\t\t version=\"1.0\", \\\n" + "\t\t facility=\"java-test\", \\\n"
+ "\t\t extractStackTrace=true, \\\n" + "\t\t filterStackTrace=true, \\\n"
+ "\t\t mdcProfiling=true, \\\n"
+ "\t\t additionalFields=\"fieldName1=fieldValue1,fieldName2=fieldValue2\", \\\n"
+ "\t\t mdcFields=\"mdcField1,mdcField2\"})");
commandContext
.handle("/subsystem=logging/file-handler=JsonLog/:add(file={\"relative-to\"=>\"jboss.server.log.dir\" ,path=server.json}, \\\n"
+ " level=ALL,named-formatter=JsonFormatter)");
commandContext.handle(
"/subsystem=logging/root-logger=ROOT/:write-attribute(name=handlers,value=[\"FILE\",\"CONSOLE\",\"JsonLog\"])");
}
示例6: setup
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
CommandContext commandContext = CommandContextFactory.getInstance().newCommandContext();
commandContext.bindClient(managementClient.getControllerClient());
commandContext
.handle("/subsystem=logging/custom-handler=GelfLogger/:add(module=biz.paluch.logging,class=biz.paluch.logging.gelf.wildfly.WildFlyGelfLogHandler,properties={ \\\n"
+ " host=\"udp:localhost\", \\\n" + " port=\"19392\", \\\n"
+ " version=\"1.0\", \\\n" + "\t\t facility=\"java-test\", \\\n"
+ "\t\t extractStackTrace=true, \\\n" + "\t\t filterStackTrace=true, \\\n"
+ "\t\t mdcProfiling=true, \\\n" + "\t\t timestampPattern=\"yyyy-MM-dd HH:mm:ss,SSSS\", \\\n"
+ "\t\t maximumMessageSize=8192, \\\n"
+ "\t\t additionalFields=\"fieldName1=fieldValue1,fieldName2=fieldValue2\", \\\n"
+ "\t\t mdcFields=\"mdcField1,mdcField2\" \\\n"
+ "\t\t dynamicMdcFields=\"mdc.*,(mdc|MDC)fields\" \\\n" + "\t\t includeFullMdc=true \\\n"
+ " })");
commandContext.handle(
"/subsystem=logging/root-logger=ROOT/:write-attribute(name=handlers,value=[\"FILE\",\"CONSOLE\",\"GelfLogger\"])");
}
示例7: main
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
String controllerHost = null;
int controllerPort = -1;
String username = null;
char[] password = null;
boolean disableLocalAuth = false;
boolean initConsole = false;
int connectionTimeout = -1;
//noinspection ConstantConditions
CommandContext commandContext = CommandContextFactory.getInstance().newCommandContext(
controllerHost, controllerPort, username, password, disableLocalAuth, initConsole, connectionTimeout);
try {
commandContext.connectController();
}
catch(CommandLineException e) {
System.out.println("failed to connect controller");
e.printStackTrace();
return;
}
String command = "/:read-attribute(name=release-version";
//
// two alternative ways of executing the command, see below for advantages and disadvantages:
//
executeCommandWithContextHandle(commandContext, command);
executeCommandLowLevel(commandContext, command);
}
示例8: getCommandContext
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
public static CommandContext getCommandContext(WildFlyManagedConfiguration config) throws CliInitializationException {
setJBossCliConfig();
return CommandContextFactory.getInstance().newCommandContext(
constructUri(config.getHostControllerManagementProtocol(),
config.getHostControllerManagementAddress(),
config.getHostControllerManagementPort()), isRemote ? username : null, isRemote ? password.toCharArray() : null);
}
示例9: testInvalidName
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Test
public void testInvalidName() throws Exception {
CommandContext ctx = CommandContextFactory.getInstance().newCommandContext();
ctx.connectController("remote+http://" + TestSuiteEnvironment.getServerAddress()
+ ":" + TestSuiteEnvironment.getServerPort());
try {
expectException(ctx, "deployment-overlay remove --name=toto");
expectException(ctx, "deployment-overlay list-content --name=toto");
expectException(ctx, "deployment-overlay list-links --name=toto");
expectException(ctx, "deployment-overlay redeploy-affected --name=toto");
expectException(ctx, "deployment-overlay link --name=toto");
expectException(ctx, "deployment-overlay upload --name=toto");
ctx.handle("batch");
expectException(ctx, "deployment-overlay list-content --name=toto");
expectException(ctx, "deployment-overlay list-links --name=toto");
File f = File.createTempFile("deploymentOverlay", null);
f.createNewFile();
f.deleteOnExit();
ctx.handle("deployment-overlay link --name=toto --deployments=tutu");
ctx.handle("deployment-overlay upload --name=toto --content=tutu="
+ f.getAbsolutePath());
} finally {
ctx.terminateSession();
}
}
示例10: before
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@BeforeClass
public static void before() throws Exception {
CommandContextConfiguration.Builder configBuilder = new CommandContextConfiguration.Builder();
configBuilder.setInitConsole(true).setConsoleInput(System.in).setConsoleOutput(System.out).
setController("remote+http://" + TestSuiteEnvironment.getServerAddress()
+ ":" + TestSuiteEnvironment.getServerPort());
ctx = CommandContextFactory.getInstance().newCommandContext(configBuilder.build());
ctx.connectController();
String tempDir = System.getProperty("java.io.tmpdir");
// deployment1
WebArchive war = ShrinkWrap.create(WebArchive.class, "cli-test-app1-deploy.war");
war.addAsWebResource(new StringAsset("Version0"), "page.html");
cliTestApp1War = new File(tempDir + File.separator + war.getName());
new ZipExporterImpl(war).exportTo(cliTestApp1War, true);
// deployment2
war = ShrinkWrap.create(WebArchive.class, "cli-test-app2-deploy.war");
war.addAsWebResource(new StringAsset("Version1"), "page.html");
cliTestApp2War = new File(tempDir + File.separator + war.getName());
new ZipExporterImpl(war).exportTo(cliTestApp2War, true);
// deployment3
war = ShrinkWrap.create(WebArchive.class, "cli-test-another-deploy.war");
war.addAsWebResource(new StringAsset("Version2"), "page.html");
cliTestAnotherWar = new File(tempDir + File.separator + war.getName());
new ZipExporterImpl(war).exportTo(cliTestAnotherWar, true);
ctx.handle("deploy --disabled " + cliTestApp1War.getAbsolutePath());
ctx.handle("deploy --disabled " + cliTestAnotherWar.getAbsolutePath());
ctx.handle("deploy --disabled " + cliTestApp2War.getAbsolutePath());
}
示例11: testAPI
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Test
public void testAPI() throws Exception {
CommandContext ctx = null;
try {
ctx = CommandContextFactory.getInstance().newCommandContext();
assertEquals(VAR_VALUE, ctx.getVariable(VAR_NAME));
} finally {
if(ctx != null) {
ctx.terminateSession();
}
}
}
示例12: test
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Test
public void test() throws Exception {
serverController.start();
CommandContextConfiguration config = new CommandContextConfiguration.Builder().
setController("remote+http://"
+ TestSuiteEnvironment.getServerAddress() + ":"
+ TestSuiteEnvironment.getServerPort()).build();
CommandContext ctx = CommandContextFactory.getInstance().newCommandContext(config);
ctx.handle("command-timeout set 60");
ctx.handle("connect");
ctx.handle("shutdown");
}
示例13: readPatchInfo
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
private void readPatchInfo(boolean verbose, boolean offline) throws Exception {
String line = "patch info";
if(verbose) {
line += " --verbose";
}
final CommandContext ctx = CommandContextFactory.getInstance().newCommandContext(null, null, null, System.in, bytesOs);
if(!offline) {
controller.start();
final ModelControllerClient client = ModelControllerClient.Factory.create(TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort());
ctx.bindClient(client);
} else {
line += " --distribution=" + PatchingTestUtil.AS_DISTRIBUTION;
}
bytesOs.reset();
try {
ctx.handle(line);
} finally {
ctx.terminateSession();
if(!offline) {
controller.stop();
}
}
reader.refresh();
}
示例14: setup
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
bytesOs = new ByteArrayOutputStream();
moduleADir = createModule("layerA");
moduleBDir = createModule("layerB");
moduleCDir = createModule("layerC");
cli = CommandContextFactory.getInstance().newCommandContext(null, null, null, System.in, bytesOs);
final ModelControllerClient client = ModelControllerClient.Factory.create(TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort());
cli.bindClient(client);
}
示例15: before
import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Before
public void before() throws Exception {
bytesOs = new ByteArrayOutputStream();
String controller = "remote+http://" + TestSuiteEnvironment.getHttpAddress() + ":9990";
ctx = CommandContextFactory.getInstance().newCommandContext(controller, null, null, System.in, bytesOs);
}