当前位置: 首页>>代码示例>>Java>>正文


Java CommandSession类代码示例

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


CommandSession类属于org.apache.felix.service.command包,在下文中一共展示了CommandSession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getType

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
private UsesArtifactCommand.SearchType getType() {
    final CommandSession session = CommandSessionHolder.getSession();
    if (session == null) {
        return null;
    }
    final ArgumentCompleter.ArgumentList argList = (ArgumentCompleter.ArgumentList) session
            .get(ArgumentCompleter.ARGUMENTS_LIST);
    if (argList == null || argList.getArguments() == null || argList.getArguments().length == 0) {
        return null;
    }
    final List<String> arguments = Arrays.asList(argList.getArguments());
    int argumentOffset = 1; // command is first argument
    for (int index = 0, count = arguments.size(); index < count; ++index) {
        if (arguments.get(index).startsWith("-")) {
            argumentOffset = index;
        }
    }
    // XXX: assuming the last option does not accept a value here
    if (argumentOffset < arguments.size()) {
        return UsesArtifactCommand.SearchType.valueOf(arguments.get(argumentOffset));
    }
    return null;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:24,代码来源:ArtifactCompleter.java

示例2: getType

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
private ShowMetricsCommand.SearchType getType() {
    final CommandSession session = CommandSessionHolder.getSession();
    if (session == null) {
        return null;
    }
    final ArgumentCompleter.ArgumentList argList = (ArgumentCompleter.ArgumentList) session
            .get(ArgumentCompleter.ARGUMENTS_LIST);
    if (argList == null || argList.getArguments() == null || argList.getArguments().length == 0) {
        return null;
    }
    final List<String> arguments = Arrays.asList(argList.getArguments());
    int argumentOffset = 1; // command is first argument
    for (int index = 0, count = arguments.size(); index < count; ++index) {
        if (arguments.get(index).startsWith("-")) {
            argumentOffset = index;
        }
    }
    if (argumentOffset < arguments.size()) {
        return ShowMetricsCommand.SearchType.valueOf(arguments.get(argumentOffset));
    }
    return null;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:23,代码来源:ShowMetricsPatternCompleter.java

示例3: getType

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
private ResetMetricsCommand.SearchType getType() {
    final CommandSession session = CommandSessionHolder.getSession();
    if (session == null) {
        return null;
    }
    final ArgumentCompleter.ArgumentList argList = (ArgumentCompleter.ArgumentList) session
            .get(ArgumentCompleter.ARGUMENTS_LIST);
    if (argList == null || argList.getArguments() == null || argList.getArguments().length == 0) {
        return null;
    }
    final List<String> arguments = Arrays.asList(argList.getArguments());
    int argumentOffset = 1; // command is first argument
    for (int index = 0, count = arguments.size(); index < count; ++index) {
        if (arguments.get(index).startsWith("-")) {
            argumentOffset = index;
        }
    }
    if (argumentOffset < arguments.size()) {
        return ResetMetricsCommand.SearchType.valueOf(arguments.get(argumentOffset));
    }
    return null;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:23,代码来源:ResetMetricsPatternCompleter.java

示例4: filter

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Descriptor("Apply a filter on a set of Resource")
public void filter(@Descriptor("automatically supplied shell session") CommandSession session,
                   @Descriptor("request for the filter creation") String request
)   {
    System.out.println("Request " + request);
    ListResourceContainer listResourceContainer = (ListResourceContainer) session.get(LISTRESOURCE);
    if ( listResourceContainer == null){
        System.out.println(" NO ENTRY TO FILTER ");
        return;
    }
    try{
        QueryFilter parserQuery = new QueryFilter(request,m_everestClient.getM_everest());
        ResourceFilter resourceFilter = parserQuery.input();
        ListResourceContainer filterResourceList = listResourceContainer.filter(resourceFilter);
        printResource(filterResourceList);
        session.put(LISTRESOURCE,filterResourceList);
    }catch (Exception e){
        e.printStackTrace();
    }
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:21,代码来源:EverestGoGoCommand.java

示例5: testNoProcessesRunning

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Test
public void testNoProcessesRunning() throws Exception {
    final ProcessEngine processEngine = newProcessEngineMock(Collections.<ProcessInstance>emptyList());

    ListPoolsCommand command = new ListPoolsCommand(processEngine);
    command.setOut(out);

    CommandSession session = mock(CommandSession.class);
    command.execute(session);
    out.flush();

    assertThat(outputStream.toString()).containsIgnoringCase("no active pools found");
    outputStream.reset();

    command.setKey("dummy");
    command.execute(session);
    out.flush();

    assertThat(outputStream.toString()).containsIgnoringCase("no active pools found");
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:21,代码来源:ListPoolsCommandTest.java

示例6: testListServices

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Test
public void testListServices() throws Exception {
    List<Provisionr> services = ImmutableList.of(
        newProvisionrMockWithId("p1"),
        newProvisionrMockWithId("p2")
    );

    ListServicesCommand command = new ListServicesCommand(services);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    PrintStream out = new PrintStream(outputStream);
    command.setOut(out);

    CommandSession session = mock(CommandSession.class);
    command.execute(session);
    out.close();

    for (Provisionr service : services) {
        verify(service).getId();
    }

    assertThat(outputStream.toString()).isEqualTo("Services: p1, p2\n");
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:24,代码来源:ListServicesCommandTest.java

示例7: executeCommandWithResponse

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
public Object executeCommandWithResponse(String command) throws Exception {
	// Run some commands to make sure they are installed properly
	ByteArrayOutputStream outputError = new ByteArrayOutputStream();
	PrintStream psE = new PrintStream(outputError);
	ByteArrayOutputStream output = new ByteArrayOutputStream();
	PrintStream ps = new PrintStream(output);
	CommandSession cs = commandProcessor.createSession(System.in, ps, psE);
	Object commandOutput = null;
	try {
		commandOutput = cs.execute(command);
		return commandOutput;
	} catch (IllegalArgumentException e) {
		Assert.fail("Action should have thrown an exception because: " + e.toString());
	} catch (NoSuchMethodException a) {
		log.error("Method for command not found: " + a.getLocalizedMessage());
		Assert.fail("Method for command not found.");
	} finally {
		cs.close();
	}
	return commandOutput;
}
 
开发者ID:dana-i2cat,项目名称:opennaas-routing-nfv,代码行数:22,代码来源:ConnectionsKarafCommandsTest.java

示例8: execute

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Override
public Object execute( final CommandSession session ) throws Exception
{
    try
    {
        Command command = this.getClass().getAnnotation( Command.class );
        log.debug( String.format( "Executing command: %s:%s", command.scope(), command.name() ) );

        return doExecute();
    }
    finally
    {
        ungetServices();
    }
}
 
开发者ID:subutai-io,项目名称:base,代码行数:16,代码来源:SubutaiShellCommandSupport.java

示例9: perform

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
private void perform(final String commandLine) throws Exception {
    if("shutdown".equals(commandLine)) {
        context.getBundle(0).stop();
        return;
    }

    ByteArrayOutputStream sysOut = new ByteArrayOutputStream();
    ByteArrayOutputStream sysErr = new ByteArrayOutputStream();

    final PrintStream printStreamOut = new PrintStream(sysOut);
    final PrintStream printErrOut = new PrintStream(sysErr);
    try {
        final CommandSession commandSession = commandProcessor.createSession(System.in, printStreamOut, printErrOut);
        Object result = commandSession.execute(commandLine);

        if(result != null) {
            printStreamOut.println(commandSession.format(result, Converter.INSPECT));
        }

        if(sysOut.size() > 0) {
            LOGGER.log(Level.INFO, new String(sysOut.toByteArray()));
        }

        if(sysErr.size() > 0) {
            LOGGER.log(Level.SEVERE, new String(sysErr.toByteArray()));
        }
    }
    catch(Throwable ex) {
        LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
    }
    finally {
        printStreamOut.close();
        printErrOut.close();
    }
}
 
开发者ID:gvSIGAssociation,项目名称:gvnix1,代码行数:36,代码来源:FelixDelegator.java

示例10: canDoExecute

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Test
public void canDoExecute() throws Exception {
    FabricService service = Mockito.mock(FabricService.class);
    Action action = new ContainerStatusAction(service);

    action.execute(Mockito.mock(CommandSession.class));
}
 
开发者ID:garethahealy,项目名称:karaf-commands,代码行数:8,代码来源:ContainerStatusActionTest.java

示例11: logt

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Descriptor("Trace the log")
public void logt(CommandSession session) throws IOException {
	PrintStream console = session.getConsole();
	logTracker.addConsole(console);
	try {
		session.getKeyboard().read();
	} finally {
		logTracker.removeConsole(console);
	}
}
 
开发者ID:osgi,项目名称:osgi.iot.contest.sdk,代码行数:11,代码来源:ExtraImpl.java

示例12: execute

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
public Object execute(CommandSession session) throws Exception {
    List<DataPoint> dps = dpService.getAll();
    for (DataPoint dp : dps) {
        System.out.println(dp.getId() + ", " + dp.getName());
    }
    return null;
}
 
开发者ID:hibernate,项目名称:hibernate-demos,代码行数:8,代码来源:GetAllCommand.java

示例13: execute

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
public Object execute(CommandSession session) throws Exception {
	Map<Number, DefaultRevisionEntity> revisions = dpService.getRevisions(Long.valueOf( id ));
    for (Number revisionNum : revisions.keySet()) {
    	DefaultRevisionEntity dre = revisions.get( revisionNum );
        System.out.println(revisionNum + ": " + dre.getId() + ", " + dre.getTimestamp());
    }
    return null;
}
 
开发者ID:hibernate,项目名称:hibernate-demos,代码行数:9,代码来源:GetRevisionsCommand.java

示例14: relation

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Descriptor("Get Resource target by relation/relations of a resource")
public void relation( @Descriptor("automatically supplied shell session") CommandSession session,
                      @Descriptor("create") String... handleId
) {
    String bufferOut = new String();
    try {
        String path;
        if (handleId.length == 0) {
            bufferOut = bufferOut + "Error : Must have at least 1 argument \n";
        } else if (handleId.length == 1) {
            path = handleId[0];
            List<Resource> resources = m_everestClient.read(path).relations().retrieve();
            session.put(LISTRESOURCE,m_everestClient.read(path).relations());
            printResource(resources);
        } else {
            path = handleId[0];
            for (String currentString : handleId) {
                if (!(currentString.equalsIgnoreCase(handleId[0]))) {
                    Resource resource = m_everestClient.read(path).relation(currentString).retrieve();
                    printResource(resource);
                } else {
                    bufferOut = bufferOut + "\nNo relation named :\"" + currentString + "\"\n";
                }
            }
        }
    } catch (Exception e) {
        System.out.println(bufferOut);
        e.printStackTrace();
        bufferOut = null;
    }
    System.out.println(bufferOut);

}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:34,代码来源:EverestGoGoCommand.java

示例15: testProvisioningServiceNotFound

import org.apache.felix.service.command.CommandSession; //导入依赖的package包/类
@Test(expected = NoSuchElementException.class)
public void testProvisioningServiceNotFound() throws Exception {
    CreatePoolCommand command = new CreatePoolCommand(Collections.<Provisionr>emptyList(),
        Collections.<PoolTemplate>emptyList(), PATH_TO_PUBLIC_KEY, PATH_TO_PRIVATE_KEY);
    command.setId("dummy");

    CommandSession session = mock(CommandSession.class);
    command.execute(session);
}
 
开发者ID:apache,项目名称:incubator-provisionr,代码行数:10,代码来源:CreatePoolCommandTest.java


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