use of org.talend.esb.sam._2011._03.common.EventType in project tesb-rt-se by Talend.
the class AgentActivator method stop.
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
if (!checkConfig(context)) {
return;
}
if (monitoringService == null) {
initWsClient(context);
}
EventType serverStopEvent = createEventType(EventEnumType.SERVER_STOP);
putEvent(serverStopEvent);
LOG.info("Send SERVER_STOP event to SAM Server successful!");
}
use of org.talend.esb.sam._2011._03.common.EventType in project tesb-rt-se by Talend.
the class AgentActivator method createEventType.
/**
* Creates the event type.
*
* @param type the EventEnumType
* @return the event type
*/
private EventType createEventType(EventEnumType type) {
EventType eventType = new EventType();
eventType.setTimestamp(Converter.convertDate(new Date()));
eventType.setEventType(type);
OriginatorType origType = new OriginatorType();
origType.setProcessId(Converter.getPID());
try {
InetAddress inetAddress = InetAddress.getLocalHost();
origType.setIp(inetAddress.getHostAddress());
origType.setHostname(inetAddress.getHostName());
} catch (UnknownHostException e) {
origType.setHostname("Unknown hostname");
origType.setIp("Unknown ip address");
}
eventType.setOriginator(origType);
String path = System.getProperty("karaf.home");
CustomInfoType ciType = new CustomInfoType();
CustomInfoType.Item cItem = new CustomInfoType.Item();
cItem.setKey("path");
cItem.setValue(path);
ciType.getItem().add(cItem);
eventType.setCustomInfo(ciType);
return eventType;
}
use of org.talend.esb.sam._2011._03.common.EventType in project tesb-rt-se by Talend.
the class EventMapper method map.
/**
* convert Event bean to EventType manually.
*
* @param event the event
* @return the event type
*/
public static EventType map(Event event) {
EventType eventType = new EventType();
eventType.setTimestamp(Converter.convertDate(event.getTimestamp()));
eventType.setEventType(convertEventType(event.getEventType()));
OriginatorType origType = mapOriginator(event.getOriginator());
eventType.setOriginator(origType);
MessageInfoType miType = mapMessageInfo(event.getMessageInfo());
eventType.setMessageInfo(miType);
eventType.setCustomInfo(convertCustomInfo(event.getCustomInfo()));
eventType.setContentCut(event.isContentCut());
if (event.getContent() != null) {
DataHandler datHandler = getDataHandlerForString(event);
eventType.setContent(datHandler);
}
return eventType;
}
use of org.talend.esb.sam._2011._03.common.EventType in project tesb-rt-se by Talend.
the class EventMapperTest method testEventMapper.
@Test
public void testEventMapper() throws IOException {
Event event = new Event();
event.setContent("testContent");
EventType eventOut = EventMapper.map(event);
DataHandler dh = eventOut.getContent();
String outContent = getContent(dh);
Assert.assertEquals(event.getContent(), outContent);
// TODO test the other properties
}
Aggregations