KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > webservice > InvInterfaceCreationListenerImpl


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
24 package com.sun.enterprise.webservice;
25
26 import java.util.Set JavaDoc;
27 import java.util.Iterator JavaDoc;
28
29 import java.util.logging.Level JavaDoc;
30 import javax.xml.ws.BindingProvider;
31 import javax.xml.ws.Binding;
32 import javax.xml.ws.soap.SOAPBinding;
33 import javax.xml.ws.Dispatch;
34
35 import com.sun.enterprise.deployment.ServiceReferenceDescriptor;
36 import com.sun.enterprise.deployment.ServiceRefPortInfo;
37 import com.sun.enterprise.webservice.spi.InvInterfaceCreationListener;
38 import com.sun.enterprise.deployment.NameValuePairDescriptor;
39
40 /**
41  * Listens to all port creation for a particular Service
42  *
43  * @author Jerome Dochez
44  */

45 public class InvInterfaceCreationListenerImpl implements InvInterfaceCreationListener {
46     
47     ServiceReferenceDescriptor ref;
48     
49     /** Creates a new instance of PortCreationListenerImpl */
50     public InvInterfaceCreationListenerImpl(ServiceReferenceDescriptor ref) {
51         this.ref = ref;
52     }
53     
54     /**
55      * Notification of a new port created on the service instance.
56      * @param port being created.
57      * @param interface type
58      */

59     public <T> void portCreated(T port, Class JavaDoc<T> serviceEndpointInterface) {
60         
61         ServiceRefPortInfo portInfo = ref.getPortInfoBySEI(serviceEndpointInterface.getName());
62         if (portInfo!=null) {
63             // Set MTOM for this port
64
BindingProvider bProv = (BindingProvider) port;
65             boolean mtomEnabled = false;
66             if(portInfo.getMtomEnabled() != null &&
67                 (new Boolean JavaDoc(portInfo.getMtomEnabled())).booleanValue()) {
68                 mtomEnabled = true;
69             }
70             if (mtomEnabled) {
71                 Binding bType = bProv.getBinding();
72                 // enable mtom valid only for SOAPBindings
73
if(SOAPBinding.class.isAssignableFrom(bType.getClass())) {
74                     ((SOAPBinding)bType).setMTOMEnabled(true);
75                 } else {
76                     WsUtil.getDefaultLogger().log(Level.SEVERE,
77                             WsUtil.getDefaultStringManager().getLocalString("serviceref.invalidmtom",
78                             "MTOM is valid only for SOAP Bindings; Ignoring Enable-MTOM for port {0}",
79                             new Object JavaDoc[] {serviceEndpointInterface}));
80                 }
81             }
82             
83             // Set stub properties
84
Set JavaDoc properties = portInfo.getStubProperties();
85             for(Iterator JavaDoc iter = properties.iterator(); iter.hasNext();) {
86                 NameValuePairDescriptor next = (NameValuePairDescriptor)
87                     iter.next();
88                 bProv.getRequestContext().put(next.getName(), next.getValue());
89             }
90         }
91     }
92     
93     /**
94      * Notification of a dispatch instance creation. The dispatch creation is
95      * blocked until the method returns so lengthly process should be done
96      * asynchronously
97      * @param dispatch instance
98      * @param service endpoint interface type
99      */

100     public <T> void dispatchCreated(Dispatch<T> dispatch, Class JavaDoc<T> serviceEndpointInterface) {
101         
102     }
103         
104 }
105
Popular Tags