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.processor;
9   
10  import it.imolinfo.jbi4corba.Logger;
11  import it.imolinfo.jbi4corba.LoggerFactory;
12  import it.imolinfo.jbi4corba.jbi.Messages;
13  
14  import it.imolinfo.jbi4corba.jbi.endpoint.ConsumerEndpoint;
15  
16  import javax.jbi.messaging.MessageExchange;
17  
18  
19  
20  /**
21   * ConsumerExchangeProcessor.
22   * 
23   * @author raffaele 
24   */
25  public class ConsumerExchangeProcessor implements ExchangeProcessor {
26  
27    /**
28     * Logger.
29     */
30    private static final transient Logger LOG
31      = LoggerFactory.getLogger(ConsumerExchangeProcessor.class);
32    private static final Messages MESSAGES = 
33    	Messages.getMessages(ConsumerExchangeProcessor.class);
34  
35  
36  /** 
37   * The consumer endpoint.
38   */
39  ConsumerEndpoint consumerEndpoint;
40    
41   /**
42    * 
43    * @param consumerEndpoint  The consumer endpoint
44    */
45    public ConsumerExchangeProcessor(ConsumerEndpoint consumerEndpoint) {
46      this.consumerEndpoint = consumerEndpoint;
47    }
48  
49    // private Map locksMap=Collections.synchronizedMap(new HashMap<K, V>)
50   /**
51    * @param messageexchange  The message exchange
52    * @throws Exception       The exception
53    */
54    public void process(MessageExchange messageExchange) {
55        
56      LOG.debug("process - MessageExchange=" + messageExchange);
57      
58      try {
59          if (messageExchange != null) {
60              consumerEndpoint.getConsumerServiceDescriptor()
61                  .getConsumerInvocationHandler().process(messageExchange);
62          } else {
63              LOG.debug("process - No Operations to do.");
64          }
65      } catch (Exception ex)  {
66      	String msg=MESSAGES.getString("CRB000800_Error_in_message_exchange", 
67      			new Object[] {ex.getMessage()});
68          LOG.error(msg);
69          // No exception is thrown...       
70      }
71    }
72  
73  }