KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > jbi > JbiConnector


1 /*
2  * $Id: JbiConnector.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.jbi;
12
13 import org.mule.providers.AbstractServiceEnabledConnector;
14 import org.mule.umo.UMOException;
15
16 import javax.jbi.JBIException;
17 import javax.jbi.component.ComponentContext;
18 import javax.jbi.component.ComponentLifeCycle;
19 import javax.jbi.messaging.DeliveryChannel;
20 import javax.jbi.messaging.MessageExchangeFactory;
21 import javax.management.ObjectName JavaDoc;
22
23 /**
24  * <code>JbiConnector</code> can bind to a Jbi container allowing components to
25  * send events via Mule
26  *
27  * @author <a HREF="mailto:ross.mason@symphonysoft.com">Ross Mason</a>
28  * @version $Revision: 3798 $
29  */

30 public class JbiConnector extends AbstractServiceEnabledConnector implements ComponentLifeCycle
31 {
32
33     private ObjectName JavaDoc extensionMBeanName;
34     private ComponentContext context;
35     private DeliveryChannel deliveryChannel;
36     private MessageExchangeFactory exchangeFactory;
37
38     public String JavaDoc getProtocol()
39     {
40         return "jbi";
41     }
42
43     public ObjectName JavaDoc getExtensionMBeanName()
44     {
45         return extensionMBeanName;
46     }
47
48     public void setExtensionMBeanName(ObjectName JavaDoc extensionMBeanName)
49     {
50         this.extensionMBeanName = extensionMBeanName;
51     }
52
53     public ComponentContext getComponentContext()
54     {
55         return context;
56     }
57
58     public DeliveryChannel getDeliveryChannel()
59     {
60         return deliveryChannel;
61     }
62
63     public MessageExchangeFactory getExchangeFactory()
64     {
65         return exchangeFactory;
66     }
67
68     // TODO the start/stop/shutdown JBI lifecycle methods are rather picky,
69
// we should probably review the spec here again
70

71     public void init(ComponentContext componentContext) throws JBIException
72     {
73         this.context = componentContext;
74         this.deliveryChannel = context.getDeliveryChannel();
75         this.exchangeFactory = deliveryChannel.createExchangeFactory();
76     }
77
78     public void start()
79     {
80         try
81         {
82             startConnector();
83         }
84         catch (UMOException e)
85         {
86             handleException(e);
87         }
88     }
89
90     public void stop()
91     {
92         try
93         {
94             stopConnector();
95         }
96         catch (UMOException e)
97         {
98             handleException(e);
99         }
100     }
101
102     public void shutDown() throws JBIException
103     {
104         // nothing to do (for now?)
105
}
106 }
107
Popular Tags