Search in sources :

Example 6 with EventType

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!");
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType)

Example 7 with EventType

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;
}
Also used : UnknownHostException(java.net.UnknownHostException) CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) InetAddress(java.net.InetAddress) Date(java.util.Date)

Example 8 with 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;
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) DataHandler(javax.activation.DataHandler) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType)

Example 9 with 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
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType) Event(org.talend.esb.sam.common.event.Event) DataHandler(javax.activation.DataHandler) Test(org.junit.Test)

Aggregations

EventType (org.talend.esb.sam._2011._03.common.EventType)9 DataHandler (javax.activation.DataHandler)4 Test (org.junit.Test)4 Event (org.talend.esb.sam.common.event.Event)4 CustomInfoType (org.talend.esb.sam._2011._03.common.CustomInfoType)3 MessageInfoType (org.talend.esb.sam._2011._03.common.MessageInfoType)3 OriginatorType (org.talend.esb.sam._2011._03.common.OriginatorType)3 ArrayList (java.util.ArrayList)2 InetAddress (java.net.InetAddress)1 URL (java.net.URL)1 UnknownHostException (java.net.UnknownHostException)1 Date (java.util.Date)1 Client (org.apache.cxf.endpoint.Client)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 MessageInfo (org.talend.esb.sam.common.event.MessageInfo)1 MonitoringException (org.talend.esb.sam.common.event.MonitoringException)1 Originator (org.talend.esb.sam.common.event.Originator)1