• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CommandContextFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jboss.as.cli.CommandContextFactory的典型用法代码示例。如果您正苦于以下问题:Java CommandContextFactory类的具体用法?Java CommandContextFactory怎么用?Java CommandContextFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommandContextFactory类属于org.jboss.as.cli包,在下文中一共展示了CommandContextFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:ReloadSASLFactoryTestCase.java


示例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");
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:19,代码来源:CommandTimeoutHandlerTestCase.java


示例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());
    });
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:24,代码来源:CLI.java


示例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;
}
 
开发者ID:wildfly,项目名称:wildfly-maven-plugin,代码行数:29,代码来源:CommandExecutor.java


示例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\"])");
}
 
开发者ID:mp911de,项目名称:logstash-gelf,代码行数:21,代码来源:WildFlyFormatterIntegrationTests.java


示例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\"])");
}
 
开发者ID:mp911de,项目名称:logstash-gelf,代码行数:21,代码来源:WildFlyHandlerIntegrationTests.java


示例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);

    }
 
开发者ID:NovaOrdis,项目名称:playground,代码行数:36,代码来源:Main.java


示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:CLITestUtil.java


示例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();
    }

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:29,代码来源:DeploymentOverlayTestCase.java


示例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());

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:35,代码来源:DeployTestCase.java


示例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();
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:RcFileTestCase.java


示例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");
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:ShutdownTestCase.java


示例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();
    }
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:29,代码来源:PatchInfoTestCase.java


示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:13,代码来源:PatchStreamsUnitTestCase.java


示例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);
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:8,代码来源:RemotePatchInfoPatchIdUnitTestCase.java


示例16: applyPatch

import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
/**
 * Applies a patch using a client provided ModelControllerClient.
 * Test for WFCORE-526
 * @param path  the path to patch archive
 * @return returns true or throws an exception
 * @throws Exception  if the patch command failed
 */
protected boolean applyPatch(String path) throws Exception {
    final CommandContext ctx = CommandContextFactory.getInstance().newCommandContext();
    final ModelControllerClient client = ModelControllerClient.Factory.create(TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort());
    ctx.bindClient(client);
    try {
        ctx.handle("patch apply " + path);
    } finally {
        // terminating the session closes the client too
        ctx.terminateSession();
    }
    return true;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:20,代码来源:BasicOneOffPatchingScenariosTestCase.java


示例17: initOfflineContext

import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
private void initOfflineContext() {
    try {
        ctx = CommandContextFactory.getInstance().newCommandContext();
    } catch (CliInitializationException e) {
        throw new IllegalStateException("Unable to initialize "
                + "command context.", e);
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:9,代码来源:CLI.java


示例18: initCommandContext

import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
private static CommandContext initCommandContext(CommandContextConfiguration ctxConfig, boolean connect) throws CliInitializationException {
    final CommandContext cmdCtx = CommandContextFactory.getInstance().newCommandContext(ctxConfig);
    if(connect) {
        try {
            cmdCtx.connectController();
        } catch (CommandLineException e) {
            throw new CliInitializationException("Failed to connect to the controller", e);
        }
    }
    return cmdCtx;
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:12,代码来源:CliLauncher.java


示例19: testCLICommands

import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Test
public void testCLICommands() throws Exception {
    CommandContextImpl ctx = (CommandContextImpl) CommandContextFactory.getInstance().newCommandContext();
    AeshCommands commands = ctx.getAeshCommands();
    for (String name : commands.getRegistry().getAllCommandNames()) {
        CLICommandContainer container = (CLICommandContainer) commands.getRegistry().getCommand(name, name);
        if (!(container.getWrappedContainer() instanceof LegacyCommandContainer)
                && !isAeshExtension(container.getParser().getCommand())) {
            HelpSupport.checkCommand(null, container.getParser());
            for (CommandLineParser<Command<CLICommandInvocation>> child : container.getParser().getAllChildParsers()) {
                HelpSupport.checkCommand(container.getParser(), child);
            }
        }
    }
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:16,代码来源:HelpSupportTestCase.java


示例20: setup

import org.jboss.as.cli.CommandContextFactory; //导入依赖的package包/类
@Before
public void setup() throws Exception {
    ctx = CommandContextFactory.getInstance().newCommandContext();
    ctx.setVariable(NODE_TYPE_VAR_NAME, NODE_TYPE_VAR_VALUE);
    ctx.setVariable(NODE_NAME_VAR_NAME, NODE_NAME_VAR_VALUE);
    ctx.setVariable(OP_VAR_NAME, OP_VAR_VALUE);
    ctx.setVariable(OP_PROP_VAR_NAME, OP_PROP_VAR_VALUE);
    ctx.setVariable("myvar", "/subsystem=logging");
}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:10,代码来源:VariablesTestCase.java



注:本文中的org.jboss.as.cli.CommandContextFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Application类代码示例发布时间:2022-05-23
下一篇:
Java DidOpenTextDocumentParams类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap