View Javadoc

1    /****************************************************************************
2    * Copyright (c) 2005, 2006, 2007, 2008, 2009 Imola Informatica.
3    * All rights reserved. This program and the accompanying materials
4    * are made available under the terms of the LGPL License v2.1
5    * which accompanies this distribution, and is available at
6    * http://www.gnu.org/licenses/lgpl.html
7    ****************************************************************************/
8   package it.imolinfo.jbi4corba.jbi.component;
9   
10  import it.imolinfo.jbi4corba.Logger;
11  import it.imolinfo.jbi4corba.LoggerFactory;
12  import it.imolinfo.jbi4corba.jbi.Messages;
13  import it.imolinfo.jbi4corba.jbi.component.runtime.AbstractComponentLifeCycle;
14  import it.imolinfo.jbi4corba.jbi.component.runtime.ComponentRuntime;
15  import it.imolinfo.jbi4corba.jbi.component.runtime.MessageExchangeReceiver;
16  import it.imolinfo.jbi4corba.jbi.component.runtime.RuntimeConfiguration;
17  import it.imolinfo.jbi4corba.jbi.component.runtime.RuntimeContext;
18  
19  import javax.jbi.JBIException;
20  import javax.management.ObjectName;
21  import javax.management.StandardMBean;
22  
23  import com.sun.jbi.eManager.provider.StatusProviderHelper;
24  
25  /**
26   * Jbi4Corba <code>ComponentLifeCycle</code> implementation. 
27   * 
28   * @author <a href="mailto:mpiraccini@imolinfo.it">Marco Piraccini</a>
29   */
30  public class Jbi4CorbaLifeCycle extends AbstractComponentLifeCycle {
31      
32      /** The logger. */
33      private static final Logger LOG = LoggerFactory.getLogger(Jbi4CorbaLifeCycle.class);
34      private static final Messages MESSAGES = Messages.getMessages(Jbi4CorbaLifeCycle.class);
35  
36             
37      /**
38       * Instantiates a new jbi4corba life cycle.
39       * 
40       * @param compRuntime the component runtime
41       */
42      public Jbi4CorbaLifeCycle(ComponentRuntime compRuntime) {
43          super(compRuntime);                        
44      }       
45          
46      /**
47       * Init the Message Exchange Handler factory.
48       * @throws JBIException if some problem occurs
49       * @see it.imolinfo.jbi4corba.jbi.component.runtime.AbstractComponentLifeCycle#initMessageExchangeHandlerFactory()
50       */
51      protected void initMessageExchangeHandlerFactory() throws JBIException {
52                  
53          if (! ( this.getComponentRuntime().getServiceUnitManager() instanceof Jbi4CorbaSUManager)) {
54          	String msg=MESSAGES.getString("CRB000007_Service_Unit_Manager_wrong_type");
55          	LOG.error(msg);
56              throw new JBIException(msg);
57          }
58          Jbi4CorbaSUManager suManager = (Jbi4CorbaSUManager)this.getComponentRuntime().getServiceUnitManager();
59          RuntimeContext.getInstance().setMessageExchangeHandlerFactory(                
60                  new Jbi4CorbaMessageExchangeHandlerFactory(suManager));
61      }
62      
63      /**
64       * Create the message exchange receiver.
65       * @see it.imolinfo.jbi4corba.jbi.component.runtime.AbstractComponentLifeCycle#createMessageExchangeReceiver()
66       * @see it.imolinfo.jbi4corba.jbi.component.runtime.MessageExchangeReceiver
67       * @throws Exception if some problem occurs
68       * @return the <code>MessageExchangeReceiver</code>
69       */
70      protected MessageExchangeReceiver createMessageExchangeReceiver() throws Exception {
71          // JMXBinding component sample only provides synchornous isnbound message exchange.
72          // so no need to have the message receiver to get the message exchanges from delivery channel.
73          // return null;
74          return new MessageExchangeReceiver();
75      }
76          
77      /**
78       * Do nothing.
79       * @throws JBIException if some problem occurs
80       *  @see it.imolinfo.jbi4corba.jbi.component.runtime.AbstractComponentLifeCycle#activateServiceConsumers()
81       */
82      protected void activateServiceConsumers() throws JBIException {       
83          // DO nothing: no consumer for this component
84      }
85          
86      /**
87       * Do nothing.
88       * @throws JBIException if some problem occurs
89       * @see it.imolinfo.jbi4corba.jbi.component.runtime.AbstractComponentLifeCycle#deactivateServiceConsumers()
90       */
91      protected void deactivateServiceConsumers() throws JBIException {
92          // DO nothing: no consumer for this component
93      }
94      
95      /**
96       * Do nothing.
97       * @throws JBIException if some problem occurs
98       * @see it.imolinfo.jbi4corba.jbi.component.runtime.AbstractComponentLifeCycle#activateServiceProviders()
99       */    
100     protected void activateServiceProviders() throws JBIException {        
101         // Do nothing
102     }
103     
104     /**
105     * Do nothing.
106     * @throws JBIException if some problem occurs
107     * @see it.imolinfo.jbi4corba.jbi.component.runtime.AbstractComponentLifeCycle#deactivateServiceProviders()
108     */        
109     protected void deactivateServiceProviders() throws JBIException {
110         // Do nothing
111     }
112     
113     /**
114      * no extension mbean.
115      * 
116      * @return alway null
117      */
118     protected ObjectName createExtensionMBeanName() {
119         return null;
120     }
121     
122     /**
123      * no extension mbean.
124      * 
125      * @return always null
126      */
127     protected StandardMBean createExtensionMBean() {
128         return null;
129     }
130             
131     /**
132      * get the RuntimeConfigurationMbean object
133      */
134     public RuntimeConfiguration getRuntimeConfiguration(){
135         return mRuntimeConfig;
136     }
137     
138     StatusProviderHelper getStatusProviderHelper() {
139         return mStatusProviderHelper;
140     }    
141 }