本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}