KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > jbi > serviceengine > bridge > JAXWSMessageProcessor


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 in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.jbi.serviceengine.bridge;
24 import com.sun.enterprise.jbi.serviceengine.ServiceEngineException;
25 import com.sun.enterprise.jbi.serviceengine.bridge.transport.NMRServerConnection;
26 import com.sun.enterprise.jbi.serviceengine.comm.MessageProcessor;
27 import com.sun.xml.ws.spi.runtime.RuntimeEndpointInfo;
28 import com.sun.xml.ws.spi.runtime.Tie;
29 import com.sun.xml.ws.spi.runtime.WSRtObjectFactory;
30
31 import java.util.logging.Level JavaDoc;
32 import javax.jbi.messaging.MessageExchange;
33 import javax.xml.namespace.QName JavaDoc;
34
35 /**
36  * Process a MEP for a new incoming message from NMR.
37  * Processing always happen in a new thread.
38  *
39  * @authod Binod PG.
40  */

41 public class JAXWSMessageProcessor extends MessageProcessor {
42     /**
43      * MessageAcceptor uses this method to start processing the MEP.
44      */

45     public void process() {
46         execute();
47     }
48
49     /**
50      * Actual code that starts processing the MEP.
51      */

52     public void doWork() {
53         try {
54             // Add code here to process the received message.
55
MessageExchange me = getMessageExchange();
56             String JavaDoc endpoint = me.getEndpoint().getEndpointName();
57             QName JavaDoc service = me.getEndpoint().getServiceName();
58             NMRServerConnection connection = new NMRServerConnection(me);
59             try {
60                  debug(Level.FINEST,"serviceengine.process_incoming_request",
61                         new Object JavaDoc[]{service.getLocalPart(), endpoint});
62                         
63                  RuntimeEndpointInfo runtimeEndpointInfo =
64                     (RuntimeEndpointInfo)RuntimeEndpointInfoRegistryImpl.getInstance().
65                     getRuntimeEndpointInfo(service, endpoint);
66                  
67                  // Call Tie.handle using WSRtObjectFactory
68
Tie tie = WSRtObjectFactory.newInstance().createTie();
69                  tie.handle(connection,runtimeEndpointInfo);
70                 
71                 RuntimeEndpointInfoRegistryImpl.getInstance().releaseEndpoint(service, endpoint);
72                  
73                  debug(Level.FINEST,"serviceengine.success_incoming_request",
74                         new Object JavaDoc[]{service.getLocalPart(), endpoint});
75                         
76              } catch(Throwable JavaDoc e) {
77                  logger.log(Level.SEVERE, "serviceengine.error_incoming_request", e);
78                  
79                  ServiceEngineException seException = new ServiceEngineException(e);
80                  connection.handleException(seException);
81              }
82         } catch(Exception JavaDoc e) {
83             logger.log(Level.SEVERE, "JavaEEServiceEngine : Error processing request" + e , e);
84         }
85     }
86     
87     private void debug(Level JavaDoc logLevel, String JavaDoc msgID, Object JavaDoc[] params) {
88         logger.log(logLevel, msgID, params);
89     }
90 }
91
92
Popular Tags