1 22 23 package org.objectweb.petals.engine.pojo; 24 25 import java.util.HashMap ; 26 import java.util.Map ; 27 28 import javax.jbi.JBIException; 29 import javax.jbi.component.ComponentContext; 30 import javax.jbi.servicedesc.ServiceEndpoint; 31 32 import org.objectweb.petals.component.common.HandlingException; 33 import org.objectweb.petals.component.common.se.AbstractServiceEngine; 34 import org.objectweb.petals.component.common.su.ServiceUnitDataHandler; 35 import org.objectweb.petals.component.common.su.SimpleServiceUnitManager; 36 import org.objectweb.petals.component.common.util.MessageExchangeWrapper; 37 import org.objectweb.petals.tools.jbicommon.descriptor.Extensions; 38 39 public class PojoSE extends AbstractServiceEngine { 40 41 private Map <String , Pojo> pojos; 42 43 public void init(final ComponentContext compContext) throws JBIException { 44 super.init(compContext); 45 46 pojos = new HashMap <String , Pojo>(); 47 48 PojoServiceUnitListener suListener = new PojoServiceUnitListener(this, 50 pojos); 51 setServiceUnitListener(suListener); 52 } 53 54 @Override 55 protected boolean onExchange(MessageExchangeWrapper exchangeWrapper, Extensions extensions) 56 throws HandlingException { 57 ServiceEndpoint ep = exchangeWrapper.getEndpoint(); 58 59 ServiceUnitDataHandler suData = ((SimpleServiceUnitManager) getServiceUnitManager()) 60 .getSuDataHandlerForEp(ep); 61 62 if (suData == null) { 63 throw new HandlingException("No POJO is found for service " 64 + ep.getServiceName()); 65 } 66 Pojo pojo = pojos.get(suData.getName()); 67 return pojo.callOnExchangeMethod(exchangeWrapper); 68 } 69 70 } 71
| Popular Tags
|