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

Java ComponentInstance类代码示例

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

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



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

示例1: execute

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Override
public Object execute() throws Exception {

    ShellTable table = new ShellTable();
    table.column("Name");
    table.column("Bundle Id");
    table.column("State");

    for (Architecture architecture : managerService.getArchitectures()) {
        InstanceDescription instanceDescription = architecture.getInstanceDescription();
        if (verbose || instanceDescription.getState() != ComponentInstance.DISPOSED) {
            table.addRow().addContent(instanceDescription.getName(), instanceDescription.getBundleId(), IPojoManagerService.instanceDescriptionState(instanceDescription.getState()));
        }
    }

    table.print(System.out);

    return null;
}
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:20,代码来源:InstancesCommand.java


示例2: instanceDescriptionState

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
static String instanceDescriptionState(int state) {

        switch (state) {
            case ComponentInstance.VALID:
                return Ansi.ansi().fg(Ansi.Color.GREEN).a("VALID").reset().toString();
            case ComponentInstance.INVALID:
                return Ansi.ansi().fg(Ansi.Color.RED).a("INVALID").reset().toString();
            case ComponentInstance.STOPPED:
                return Ansi.ansi().fg(Ansi.Color.YELLOW).a("STOPPED").reset().toString();
            case ComponentInstance.DISPOSED:
                return Ansi.ansi().fg(Ansi.Color.BLUE).a("DISPOSED").reset().toString();
        }
        // Should not happen (no other known component instances states)
        return Ansi.ansi().fg(Ansi.Color.RED).a("UNKNOWN").toString();


    }
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:18,代码来源:IPojoManagerService.java


示例3: testBindMessageHandler

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
/**
 * Test bind message handler.
 * 
 * @throws UnacceptableConfiguration
 *             the unacceptable configuration
 * @throws MissingHandlerException
 *             the missing handler exception
 * @throws ConfigurationException
 *             the configuration exception
 */
@SuppressWarnings("rawtypes")
@Test
public void testBindMessageHandler() throws UnacceptableConfiguration,
        MissingHandlerException, ConfigurationException {
    ComponentInstance ciMock = EasyMock.createMock(ComponentInstance.class);
    Hashtable<String, CommunoteMessageHandler> configuration = new Hashtable<String, CommunoteMessageHandler>();
    configuration.put("messageHandler", testHandlerMock);
    EasyMock.expect(
            messageConsumerFactoryMock
                    .createComponentInstance(configuration))
            .andReturn(ciMock);
    EasyMock.replay(messageConsumerFactoryMock);
    ProviderMessageConsumerFactoryImpl factory = new ProviderMessageConsumerFactoryImpl();
    factory.setMessageConsumerFactory(messageConsumerFactoryMock);
    factory.bindMessageHandler(testHandlerMock);
    EasyMock.verify(messageConsumerFactoryMock);
    Assert.assertNotNull(factory.getMessageConsumers().get(testHandlerMock));
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:29,代码来源:ProviderMessageConsumerFactoryTest.java


示例4: testUnbindMessageHandler

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
/**
 * Test unbind message handler.
 */
@Test
public void testUnbindMessageHandler() {

    ComponentInstance componentInstanceMock = EasyMock
            .createMock(ComponentInstance.class);

    EasyMock.expect(messageConsumersMock.remove(testHandlerMock))
            .andReturn(componentInstanceMock);
    componentInstanceMock.dispose();

    EasyMock.replay(componentInstanceMock, messageConsumersMock);

    ProviderMessageConsumerFactoryImpl factory = new ProviderMessageConsumerFactoryImpl();
    factory.setMessageConsumerFactory(messageConsumerFactoryMock);
    factory.setMessageConsumers(messageConsumersMock);
    factory.unbindMessageHandler(testHandlerMock);
    EasyMock.verify(componentInstanceMock);

}
 
开发者ID:Communote,项目名称:communote-server,代码行数:23,代码来源:ProviderMessageConsumerFactoryTest.java


示例5: testMachineIsRunning_noSimulation_deployedAndStarted

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Test
public void testMachineIsRunning_noSimulation_deployedAndStarted() throws Exception {

	// Configure the mocks
	ComponentInstance componentInstance = Mockito.mock( ComponentInstance.class );
	Mockito.when( this.nazgulAgentFactory.createComponentInstance( Mockito.any( Dictionary.class ))).thenReturn( componentInstance );
	Mockito.when( this.nazgulAgentFactory.getInstancesNames()).thenReturn( new ArrayList<String>( 0 ));

	// Prepare
	Map<String,String> targetProperties = new HashMap<> ();
	targetProperties.put( InMemoryHandler.EXECUTE_REAL_RECIPES, "true" );
	TargetHandlerParameters parameters = new TargetHandlerParameters();
	parameters.targetProperties( targetProperties );

	this.app.getTomcatVm().setStatus( InstanceStatus.DEPLOYED_STARTED );
	String machineId = InstanceHelpers.computeInstancePath( this.app.getTomcatVm()) + " @ " + this.app.getName();

	// Run and verify
	Assert.assertTrue( this.handler.isMachineRunning( parameters, machineId ));
	Mockito.verify( this.nazgulAgentFactory, Mockito.times( 1 )).createComponentInstance( Mockito.any( Dictionary.class ));
	Mockito.verify( componentInstance, Mockito.times( 1 )).start();
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:23,代码来源:InMemoryHandlerWithRealManagerTest.java


示例6: testCreateMachine

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Test
public void testCreateMachine() throws Exception {

	// Configure the mocks
	ComponentInstance componentInstance = Mockito.mock( ComponentInstance.class );
	Mockito.when( this.standardAgentFactory.createComponentInstance( Mockito.any( Dictionary.class ))).thenReturn( componentInstance );

	// Create a machine and verify assertions
	Mockito.verifyZeroInteractions( this.standardAgentFactory );
	Mockito.verifyZeroInteractions( componentInstance );

	Map<String,String> targetProperties = new HashMap<> ();
	targetProperties.put( InMemoryHandler.AGENT_IP_ADDRESS, "127.0.0.1" );

	TargetHandlerParameters parameters = new TargetHandlerParameters()
			.targetProperties( targetProperties )
			.messagingProperties( this.msgCfg )
			.scopedInstancePath( "/VM" )
			.applicationName( "my-app" )
			.domain( "default-domain" );

	String machineId = this.handler.createMachine( parameters );
	Assert.assertEquals( "/VM @ my-app", machineId );
	Mockito.verify( this.standardAgentFactory, Mockito.times( 1 )).createComponentInstance( Mockito.any( Dictionary.class ));
	Mockito.verify( componentInstance, Mockito.times( 1 )).start();
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:27,代码来源:InMemoryHandlerMockedManagerTest.java


示例7: testTerminateMachine_simulatePlugins_noPojoWithTheRightName

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Test
public void testTerminateMachine_simulatePlugins_noPojoWithTheRightName() throws Exception {

	ComponentInstance componentInstance = Mockito.mock( ComponentInstance.class );
	Mockito.when( componentInstance.getInstanceName()).thenReturn( "NOT test @ test" );

	List<ComponentInstance> instances = new ArrayList<> ();
	instances.add( componentInstance );

	Mockito.when( this.standardAgentFactory.getInstances()).thenReturn( instances );
	TargetHandlerParameters parameters = new TargetHandlerParameters().targetProperties( new HashMap<String,String>( 0 ));
	this.handler.terminateMachine( parameters, "test @ test" );

	Mockito.verify( componentInstance, Mockito.only()).getInstanceName();
	Mockito.verifyZeroInteractions( this.manager );
	// No error, even if no matching iPojo instance was found
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:18,代码来源:InMemoryHandlerMockedManagerTest.java


示例8: testTerminateMachine_simulatePlugins

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Test
public void testTerminateMachine_simulatePlugins() throws Exception {

	// Configure the mocks
	ComponentInstance componentInstance = Mockito.mock( ComponentInstance.class );
	Mockito.when( componentInstance.getInstanceName()).thenReturn( "test @ test" );

	List<ComponentInstance> instances = new ArrayList<> ();
	instances.add( componentInstance );

	Mockito.when( this.standardAgentFactory.getInstances()).thenReturn( instances );

	// Execute and check
	TargetHandlerParameters parameters = new TargetHandlerParameters().targetProperties( new HashMap<String,String>( 0 ));
	this.handler.terminateMachine( parameters, "test @ test" );

	Mockito.verify( componentInstance, Mockito.times( 2 )).getInstanceName();
	Mockito.verify( componentInstance, Mockito.times( 1 )).dispose();
	Mockito.verifyZeroInteractions( this.manager );
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:21,代码来源:InMemoryHandlerMockedManagerTest.java


示例9: testStop

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Test
public void testStop() throws Exception {

	this.target.standardAgentFactory = Mockito.mock( Factory.class );
	this.target.nazgulAgentFactory = Mockito.mock( Factory.class );

	ComponentInstance agentMock = Mockito.mock( ComponentInstance.class );
	Mockito.when( this.target.standardAgentFactory .getInstances()).thenReturn( Arrays.asList( agentMock ));

	ComponentInstance nazgulMock = Mockito.mock( ComponentInstance.class );
	Mockito.when( this.target.nazgulAgentFactory .getInstances()).thenReturn( Arrays.asList( nazgulMock ));

	this.target.stop();
	Mockito.verify( this.target.standardAgentFactory, Mockito.only()).getInstances();
	Mockito.verify( this.target.nazgulAgentFactory, Mockito.only()).getInstances();

	Mockito.verify( agentMock ).dispose();
	Mockito.verify( nazgulMock ).dispose();
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:20,代码来源:InMemoryHandlerWithoutManagerTest.java


示例10: getCreatedInstanceNames

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
private Set<String> getCreatedInstanceNames(Factory factory) {
    Field weapon = null;
    try {
        weapon = IPojoFactory.class.getDeclaredField("m_componentInstances");
        weapon.setAccessible(true);
        @SuppressWarnings("unchecked")
        Map<String, ComponentInstance> instances = (Map<String, ComponentInstance>)weapon.get(factory);
        return instances.keySet();
    } catch (Exception e) {
        throw new RuntimeException("cannot get factory created instances", e);
    } finally {
        if (weapon != null) {
            weapon.setAccessible(false);
        }
    }
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:17,代码来源:FactoryResource.java


示例11: adaptTo

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Override
public <A> A adaptTo(Class<A> clazz) {
    if (clazz == Architecture.class) {
        // Returns null if reference has been released
        return clazz.cast(m_instance.get());
    } else if (clazz == ComponentInstance.class) {
        // Returns null if reference has been released
        Architecture a = m_instance.get();
        if (a == null) {
            return null;
        } else {
            return clazz.cast(getComponentInstance(a));
        }
    } else {
        return super.adaptTo(clazz);
    }
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:18,代码来源:InstanceResource.java


示例12: stateAsString

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
private static String stateAsString(int state) {
    switch (state) {
        case ComponentInstance.VALID:
            return "valid";
        case ComponentInstance.INVALID:
            return "invalid";
        case ComponentInstance.STOPPED:
            return "stopped";
        case ComponentInstance.DISPOSED:
            return "disposed";
        case -2:
            return "changing";
        default:
            return "unknown";
    }
}
 
开发者ID:ow2-chameleon,项目名称:everest,代码行数:17,代码来源:InstanceResource.java


示例13: getInvalidControllers

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
private List<InstanceDescription> getInvalidControllers() {
    List<InstanceDescription> invalid = new ArrayList<>();
    for (Architecture architecture : architectures) {
        final InstanceDescription description = architecture.getInstanceDescription();
        // Is it invalid ?
        if (description.getState() == ComponentInstance.INVALID) {
            // Is it a controller
            ProvidedServiceHandlerDescription hd = (ProvidedServiceHandlerDescription)
                    description.getHandlerDescription("org.apache.felix.ipojo:provides");
            if (hd != null) {
                for (ProvidedServiceDescription psd : hd.getProvidedServices()) {
                    if (Arrays.asList(psd.getServiceSpecifications()).contains(org.wisdom.api.Controller.class
                            .getName())) {
                        invalid.add(description);
                    }
                }
            }
        }
    }
    return invalid;
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:22,代码来源:ControllerExtension.java


示例14: testInstanceModel

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Test
public void testInstanceModel() {
    InstanceDescription description = mock(InstanceDescription.class);
    when(description.getName()).thenReturn("my-instance");
    when(description.getDescription()).thenReturn(new Element("instance", null));
    when(description.getState()).thenReturn(ComponentInstance.VALID);
    Architecture arch = mock(Architecture.class);
    when(arch.getInstanceDescription()).thenReturn(description);

    InstanceModel model = new InstanceModel(arch);

    assertThat(model.getName()).isEqualTo("my-instance");
    assertThat(model.getState()).isEqualTo("VALID");
    assertThat(model.getArchitecture()).contains("instance");

    // Check the other state.
    when(description.getState()).thenReturn(ComponentInstance.INVALID);
    assertThat(model.getState()).isEqualTo("INVALID");

    when(description.getState()).thenReturn(ComponentInstance.STOPPED);
    assertThat(model.getState()).isEqualTo("STOPPED");

    when(description.getState()).thenReturn(28);
    assertThat(model.getState()).isEqualTo("UNKNOWN");
}
 
开发者ID:wisdom-framework,项目名称:wisdom,代码行数:26,代码来源:InstanceModelTest.java


示例15: setUpFinal

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Before
public void setUpFinal() {
    // instantiate the importer
    Dictionary<String, String> conf = new Hashtable<String, String>();
    conf.put(INSTANCE_NAME_PROPERTY, IMPORTER_NAME);
    conf.put(TARGET_FILTER_PROPERTY, "(" + CONFIGS + "=jsonrpc)");
    ComponentInstance importer = ipojoHelper.createComponentInstance("org.ow2.chameleon.fuchsia.importer.jsonrpc.JSONRPCImporter", conf, 20000);
    if (importer == null) {
        fail("Fail to create the JSONRPC Importer.");
    }

    // create HttpServer
    try {
        httpServer = HttpServer.create(new InetSocketAddress(HTTP_PORT), 0);
    } catch (IOException e) {
        fail("Creation of httpServer fail", e);
    }
    httpServer.setExecutor(Executors.newCachedThreadPool());
    httpServer.start();
}
 
开发者ID:ow2-chameleon,项目名称:fuchsia,代码行数:21,代码来源:JSONRPCImporterTest.java


示例16: getInstanceDescription

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
@Override
public InstanceDescription getInstanceDescription(Object instance) {
    for (Architecture architecture : architectures) {
        if (architecture.getInstanceDescription().getState() == ComponentInstance.VALID) {
            if (architecture.getInstanceDescription().getInstance() instanceof InstanceManager) {
                InstanceManager instanceManager = (InstanceManager) architecture.getInstanceDescription().getInstance();
                if (Arrays.asList(instanceManager.getPojoObjects()).contains(instance)) {
                    return architecture.getInstanceDescription();
                }
            }
        }
    }

    return null;
}
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:16,代码来源:IPojoManagerProvider.java


示例17: getStateName

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
private String getStateName(int state) {
    switch (state) {
        case ComponentInstance.VALID:
            return "VALID";
        case ComponentInstance.INVALID:
            return "INVALID";
        case ComponentInstance.STOPPED:
            return "STOPPED";
        case ComponentInstance.DISPOSED:
            return "DISPOSED";
    }
    // Should not happen (no other known component instances states)
    return "";
}
 
开发者ID:andyphillips404,项目名称:awplab-core,代码行数:15,代码来源:InstanceCommand.java


示例18: unbindMessageHandler

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
/**
 * 
 * Is invoked when a communote message handler is removed from the OSGi context. The method is
 * responsible for stopping appropriate provider message consumer instance
 * 
 * @param messageHandler
 *            message handler, that was removed
 */
@Override
@Unbind
public void unbindMessageHandler(
        CommunoteMessageHandler<? extends BaseMessage> messageHandler) {
    ComponentInstance consumerToBeRemoved = messageConsumers.remove(messageHandler);
    if (consumerToBeRemoved != null) {
        consumerToBeRemoved.dispose();
        LOG.debug("Provider message consumer has been unbound");
    } else {
        LOG.warn("Provider message consumer for the removed message handler was not found. MessageHandler == "
                + messageHandler);
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:22,代码来源:ProviderMessageConsumerFactoryImpl.java


示例19: stop

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
/**
 * Invoked by iPojo (deletes all the in-memory agent).
 */
public void stop() throws Exception {

	if( this.nazgulAgentFactory != null ) {
		for( ComponentInstance nazgul : this.nazgulAgentFactory.getInstances())
			deleteIPojoInstance( nazgul );
	}

	if( this.standardAgentFactory != null ) {
		for( ComponentInstance agent : this.standardAgentFactory.getInstances())
			deleteIPojoInstance( agent );
	}
}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:16,代码来源:InMemoryHandler.java


示例20: deleteIPojo

import org.apache.felix.ipojo.ComponentInstance; //导入依赖的package包/类
private void deleteIPojo( Factory factory, String machineId ) {

		if( factory != null ) {
			for( ComponentInstance instance : factory.getInstances()) {
				if( machineId.equals( instance.getInstanceName())) {
					deleteIPojoInstance( instance );
					break;
				}
			}
		}
	}
 
开发者ID:roboconf,项目名称:roboconf-platform,代码行数:12,代码来源:InMemoryHandler.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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