View Javadoc

1   /*
2    * The contents of this file are subject to the terms
3    * of the Common Development and Distribution License
4    * (the "License").  You may not use this file except
5    * in compliance with the License.
6    *
7    * You can obtain a copy of the license at
8    * https://open-esb.dev.java.net/public/CDDLv1.0.html.
9    * See the License for the specific language governing
10   * permissions and limitations under the License.
11   *
12   * When distributing Covered Code, include this CDDL
13   * HEADER in each file and include the License file at
14   * https://open-esb.dev.java.net/public/CDDLv1.0.html.
15   * If applicable add the following below this CDDL HEADER,
16   * with the fields enclosed by brackets "[]" replaced with
17   * your own identifying information: Portions Copyright
18   * [year] [name of copyright owner]
19   */
20  
21  /*
22   * Copyright 2004-2006 Sun Microsystems, Inc. All Rights Reserved.
23   */
24  
25  /*
26   * DefaultMessageExchangeHandler.java
27   *
28   */
29  
30  package it.imolinfo.jbi4ejb.jbi.component.runtime;
31  
32  import it.imolinfo.jbi4ejb.Logger;
33  import it.imolinfo.jbi4ejb.LoggerFactory;
34  import it.imolinfo.jbi4ejb.jbi.Messages;
35  
36  import javax.jbi.messaging.Fault;
37  import javax.jbi.messaging.MessageExchange;
38  import javax.jbi.messaging.MessagingException;
39  import javax.jbi.messaging.NormalizedMessage;
40  
41  /**
42   *
43   * @author Sun Microsystems, Inc.
44   */
45  public class DefaultMessageExchangeHandler extends AbstractMessageExchangeHandler {
46  	/** The logger. */
47      private static final Logger LOG = LoggerFactory.getLogger( DefaultMessageExchangeHandler.class);    
48      private static final Messages MESSAGES = Messages.getMessages( DefaultMessageExchangeHandler.class);   
49      /** Creates a new instance of AbstractMessageExchangeHandler */
50      public DefaultMessageExchangeHandler() {
51          super();
52      }
53      
54      protected void processError(Exception ex) {
55          
56          System.out.println("Default MessageExchange Handler processing Error");
57          ex.printStackTrace();
58          System.out.println("Default MessageExchange Handler processed Error");
59      }
60      
61      protected void processDone() {
62          
63          System.out.println("Default MessageExchange Handler processed DONE");
64      }
65      
66      protected  void processFault(Fault fault) {
67          
68          System.out.println("Default MessageExchange Handler processing FAULT");
69          System.out.println(fault.toString());
70          System.out.println("Default MessageExchange Handler processed FAULT");
71      }
72      
73      protected void processMessage() {
74          
75          System.out.println("Default MessageExchange Handler processing Message");
76          NormalizedMessage inMsg = this.getMessageExchange().getMessage(IN_MESSAGE);
77          NormalizedMessage outMsg = this.getMessageExchange().getMessage(IN_MESSAGE);
78          System.out.println("IN MESSAGE ::::::: \n" + inMsg );
79          System.out.println("OUT MESSAGE ::::::: \n" + outMsg );
80          System.out.println("Default MessageExchange Handler processed Message");
81      }
82      
83      protected void validateMessageExchange() throws MessagingException {
84          MessageExchange msgExchange = this.getMessageExchange();
85          
86          if ( this.getMessageExchange() == null ) {
87  
88          	String msg=MESSAGES.getString("EJB000215_MessageExchange_Object_null_in_DefaultMessageExchageHandler");
89              LOG.error(msg);
90              throw new MessagingException(msg);   
91  
92          	 
93          }
94      }
95      
96  }