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


Java StaticApplicationContext.addApplicationListener方法代码示例

本文整理汇总了Java中org.springframework.context.support.StaticApplicationContext.addApplicationListener方法的典型用法代码示例。如果您正苦于以下问题:Java StaticApplicationContext.addApplicationListener方法的具体用法?Java StaticApplicationContext.addApplicationListener怎么用?Java StaticApplicationContext.addApplicationListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.context.support.StaticApplicationContext的用法示例。


在下文中一共展示了StaticApplicationContext.addApplicationListener方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getStaticApplicationContext

import org.springframework.context.support.StaticApplicationContext; //导入方法依赖的package包/类
private StaticApplicationContext getStaticApplicationContext()
{
    clientConnectedCount.set(0);
    clientDisconnectedCount.set(0);
    clientLostConnectionCount.set(0);
    clientFailedConnectionCount.set(0);
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.addApplicationListener(this);
    applicationContext.refresh();
    applicationContext.start();
    return applicationContext;
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:13,代码来源:AutomaticReconnectTest.java

示例2: getStaticApplicationContext

import org.springframework.context.support.StaticApplicationContext; //导入方法依赖的package包/类
private StaticApplicationContext getStaticApplicationContext()
{
    StaticApplicationContext applicationContext = new StaticApplicationContext();
    applicationContext.addApplicationListener(this);
    applicationContext.refresh();
    applicationContext.start();
    return applicationContext;
}
 
开发者ID:christophersmith,项目名称:summer-mqtt,代码行数:9,代码来源:ConnectionStatusTest.java

示例3: fruCacheEventTest

import org.springframework.context.support.StaticApplicationContext; //导入方法依赖的package包/类
/**
 * Test Server FRU Component Cache Event Publisher
 */
@Test
public void fruCacheEventTest()
{

    HmsDataCache cache = new HmsDataCache();

    FruCacheUpdateListener listener = new FruCacheUpdateListener();
    listener.setHmsDataCache( cache );

    StaticApplicationContext context = new StaticApplicationContext();
    context.addApplicationListener( listener );

    context.refresh();

    // Adding dummy CPU Information
    List<CpuInfo> listCpu = new ArrayList<CpuInfo>();
    CpuInfo cpu1 = new CpuInfo();
    ComponentIdentifier cpuIdentifier1 = new ComponentIdentifier();
    cpuIdentifier1.setManufacturer( "INTEL" );
    cpuIdentifier1.setProduct( "Intel Xeon Processor" );
    cpu1.setComponentIdentifier( cpuIdentifier1 );
    cpu1.setId( "1" );
    cpu1.setCpuFrequencyInHertz( 2600 );
    cpu1.setNumOfCores( 4 );
    listCpu.add( cpu1 );

    FruDataChangeMessage event =
        new FruDataChangeMessage( (List<FruComponent>) (List<?>) listCpu, "TestNode", ServerComponent.CPU );
    context.publishEvent( event );

    assertNotNull( listener.getHmsDataCache().getServerInfoMap().containsKey( "TestNode" ) );
    // assertNotNull(listener.getHmsDataCache().getServerInfoMap().get("TestNode").getCpuInfo().get(0).getComponentIdentifier().getManufacturer());

    context.close();
    context.destroy();

}
 
开发者ID:vmware,项目名称:OHMS,代码行数:41,代码来源:HmsCacheEventTest.java

示例4: serverCacheEventTest

import org.springframework.context.support.StaticApplicationContext; //导入方法依赖的package包/类
/**
 * Test Server Cache Event Publisher
 */
@Test
public void serverCacheEventTest()
{

    HmsDataCache cache = new HmsDataCache();

    ServerCacheUpdateListener listener = new ServerCacheUpdateListener();
    listener.setHmsDataCache( cache );

    StaticApplicationContext context = new StaticApplicationContext();
    context.addApplicationListener( listener );

    context.refresh();

    // Adding dummy Server Information
    ServerInfo serverInfo = new ServerInfo();
    ComponentIdentifier serverComponentIdentifier = new ComponentIdentifier();
    serverComponentIdentifier.setManufacturer( "Testware" );
    serverComponentIdentifier.setProduct( "VM360" );
    serverComponentIdentifier.setPartNumber( "JFD32254" );
    serverComponentIdentifier.setSerialNumber( "32355567" );
    serverInfo.setComponentIdentifier( serverComponentIdentifier );
    serverInfo.setFruId( "53543454" );
    serverInfo.setInBandIpAddress( "127.0.0.1" );
    serverInfo.setLocation( "2U" );
    serverInfo.setManagementIpAddress( "127.0.0.1" );
    serverInfo.setNodeId( "TestNode" );
    serverInfo.setOperationalStatus( FruOperationalStatus.Operational );

    ServerDataChangeMessage event = new ServerDataChangeMessage( serverInfo, ServerComponent.SERVER );

    context.publishEvent( event );

    assertNotNull( listener.getHmsDataCache().getServerInfoMap().containsKey( "TestNode" ) );
    assertNotNull( listener.getHmsDataCache().getServerInfoMap().get( "TestNode" ).getNodeId() );

    context.close();
    context.destroy();

}
 
开发者ID:vmware,项目名称:OHMS,代码行数:44,代码来源:HmsCacheEventTest.java

示例5: switchCacheEventTest

import org.springframework.context.support.StaticApplicationContext; //导入方法依赖的package包/类
/**
 * Test Switch Cache Event Publisher
 */
@Test
public void switchCacheEventTest()
{

    HmsDataCache cache = new HmsDataCache();

    SwitchCacheUpdateListener listener = new SwitchCacheUpdateListener();
    listener.setHmsDataCache( cache );

    StaticApplicationContext context = new StaticApplicationContext();
    context.addApplicationListener( listener );

    context.refresh();

    // Adding dummy Switch Information
    NBSwitchInfo switchInfo = new NBSwitchInfo();
    ComponentIdentifier switchComponentIdentifier = new ComponentIdentifier();
    switchComponentIdentifier.setManufacturer( "Testware" );
    switchComponentIdentifier.setProduct( "VM-Switch" );
    switchComponentIdentifier.setPartNumber( "5435GFFGF" );
    switchComponentIdentifier.setSerialNumber( "6546547" );
    switchInfo.setComponentIdentifier( switchComponentIdentifier );
    switchInfo.setFirmwareName( "firmwareTest" );
    switchInfo.setFirmwareVersion( "dsd2321" );
    switchInfo.setLocation( "3U" );
    switchInfo.setFruId( "443254576" );
    switchInfo.setOperationalStatus( FruOperationalStatus.Operational );
    switchInfo.setSwitchId( "TestSwitch" );
    // switchInfo.setRole(SwitchRoleType.MANAGEMENT);

    SwitchDataChangeMessage event = new SwitchDataChangeMessage( switchInfo, SwitchComponentEnum.SWITCH );

    context.publishEvent( event );

    assertNotNull( listener.getHmsDataCache().getServerInfoMap().containsKey( "TestSwitch" ) );
    assertNotNull( listener.getHmsDataCache().getSwitchInfoMap().get( "TestSwitch" ).getSwitchId() );

    context.close();
    context.destroy();

}
 
开发者ID:vmware,项目名称:OHMS,代码行数:45,代码来源:HmsCacheEventTest.java

示例6: fruHmsEventCacheEventTest

import org.springframework.context.support.StaticApplicationContext; //导入方法依赖的package包/类
/**
 * Test HMS Event Publisher to refresh the cache on Event
 */
@Test
public void fruHmsEventCacheEventTest()
{

    HmsDataCache cache = new HmsDataCache();

    FruEventDataUpdateListener listener = new FruEventDataUpdateListener();
    listener.setHmsDataCache( cache );

    StaticApplicationContext context = new StaticApplicationContext();
    context.addApplicationListener( listener );

    context.refresh();

    List<Event> events = new ArrayList<Event>();
    Event event = new Event();
    Body body = new Body();
    Header header = new Header();
    Map<EventComponent, String> componentIdentifier = new HashMap<EventComponent, String>();
    componentIdentifier.put( EventComponent.SERVER, "N9" );

    // Adding dummy Event
    body.setDescription( "CPU for rack EVO:RACK node N5 and CPU processor 1 has shutdown due to POST Failure." );
    header.setAgent( "HMS" );
    header.setEventName( EventCatalog.CPU_POST_FAILURE );
    header.setSeverity( EventSeverity.CRITICAL );
    header.setVersion( "1.0" );
    header.addComponentIdentifier( componentIdentifier );

    event.setBody( body );
    event.setHeader( header );

    events.add( event );

    FruEventStateChangeMessage eventMessage = new FruEventStateChangeMessage( events, ServerComponent.CPU );
    context.publishEvent( eventMessage );

    assertNotNull( listener.getHmsDataCache().getServerInfoMap().containsKey( "TestNode" ) );

    context.close();
    context.destroy();

}
 
开发者ID:vmware,项目名称:OHMS,代码行数:47,代码来源:HmsCacheEventTest.java


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