1 10 11 package org.mule.providers.jbi.components; 12 13 import org.mule.MuleManager; 14 import org.mule.impl.endpoint.MuleEndpoint; 15 import org.mule.umo.UMOException; 16 import org.mule.umo.endpoint.UMOEndpoint; 17 18 import javax.jbi.JBIException; 19 20 import java.util.Map ; 21 22 29 public abstract class AbstractEndpointComponent extends AbstractJbiComponent 30 { 31 32 protected UMOEndpoint muleEndpoint; 33 34 protected String endpoint; 35 36 protected Map endpointProperties; 37 38 protected AbstractEndpointComponent() 39 { 40 if (!MuleManager.isInstanciated()) 41 { 42 MuleManager.getConfiguration().setEmbedded(true); 43 try 44 { 45 MuleManager.getInstance().start(); 46 } 47 catch (UMOException e) 48 { 49 e.printStackTrace(); 50 } 51 } 52 } 53 54 public UMOEndpoint getMuleEndpoint() 55 { 56 return muleEndpoint; 57 } 58 59 public void setMuleEndpoint(UMOEndpoint muleEndpoint) 60 { 61 this.muleEndpoint = muleEndpoint; 62 } 63 64 public String getEndpoint() 65 { 66 return endpoint; 67 } 68 69 public void setEndpoint(String endpoint) 70 { 71 this.endpoint = endpoint; 72 } 73 74 public Map getEndpointProperties() 75 { 76 return endpointProperties; 77 } 78 79 public void setEndpointProperties(Map endpointProperties) 80 { 81 this.endpointProperties = endpointProperties; 82 } 83 84 protected void doInit() throws JBIException 85 { 86 try 87 { 88 if (muleEndpoint == null) 89 { 90 if (endpoint == null) 91 { 92 throw new NullPointerException ("A Mule muleEndpoint must be set on this component"); 93 } 94 else 95 { 96 muleEndpoint = new MuleEndpoint(endpoint, true); 97 } 98 } 99 100 if (endpointProperties != null) 101 { 102 muleEndpoint.getProperties().putAll(endpointProperties); 103 } 104 muleEndpoint.initialise(); 105 106 } 107 catch (Exception e) 108 { 109 throw new JBIException(e); 110 } 111 } 112 } 113 | Popular Tags |