1 25 26 package org.objectweb.petals.monitoring; 27 28 import java.util.ArrayList ; 29 import java.util.List ; 30 31 import javax.jbi.messaging.ExchangeStatus; 32 import javax.jbi.messaging.MessageExchange.Role; 33 34 import org.objectweb.petals.jbi.messaging.MessageExchangeImpl; 35 import org.objectweb.petals.jbi.registry.AbstractEndpoint; 36 37 44 public class ExchangeStateReport { 45 46 private String id; 47 48 private List <ExchangeStateCapture> reportList = new ArrayList <ExchangeStateCapture>(); 49 50 public ExchangeStateReport(MessageExchangeImpl exchange){ 51 this.id=exchange.getExchangeId(); 52 53 } 54 55 public void reportState(MessageExchangeImpl exchange) { 56 ExchangeStateCapture state = new ExchangeStateCapture(); 57 state.time = System.currentTimeMillis(); 58 state.status = exchange.getStatus(); 59 60 state.role = exchange.getRole(); 61 62 if(Role.CONSUMER.equals(state.role)){ 63 state.component=exchange.getConsumerEndpoint().getComponentName(); 64 }else{ 65 state.component=((AbstractEndpoint)exchange.getEndpoint()).getComponentName(); 66 } 67 if (ExchangeStatus.ACTIVE.equals(state.status)) { 69 if(exchange.getMessages() != null && exchange.getMessages().size()>0){ 71 state.messageType = exchange.getMessages().keySet().iterator() 72 .next(); 73 } 74 if (state.messageType == null && exchange.getFault() != null) { 76 state.messageType = "fault"; 77 } 78 } 79 reportList.add(state); 80 } 81 82 public String getId() { 83 return id; 84 } 85 86 public List <ExchangeStateCapture> getReportList() { 87 return reportList; 88 } 89 } 90 | Popular Tags |