View Javadoc

1   /*
2    * Copyright 2001-2004 The Apache Software Foundation.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.geronimo.ews.ws4j2ee.context.webservices.server;
18  
19  import org.apache.axis.wsdl.fromJava.Emitter;
20  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
21  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext;
22  import org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFWebserviceDescription;
23  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
24  
25  /***
26   * @author Srinath Perera(hemapani@opensource.lk)
27   * @see org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext
28   */
29  public class AxisEmitterBasedWSCFContext extends AbstractWSCFContext implements WSCFContext {
30      private Emitter emitter;
31      private J2EEWebServiceContext j2eeweserviceContext;
32  
33      public AxisEmitterBasedWSCFContext(Emitter emitter, J2EEWebServiceContext j2eeweserviceContext) {
34          this.emitter = emitter;
35          this.j2eeweserviceContext = j2eeweserviceContext;
36      }
37  
38      /* (non-Javadoc)
39       * @see org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext#getDescription()
40       */
41      public String getDescription() {
42          throw new UnsupportedOperationException();
43      }
44  
45      /* (non-Javadoc)
46       * @see org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext#getDisplayName()
47       */
48      public String getDisplayName() {
49          throw new UnsupportedOperationException();
50      }
51  
52      /* (non-Javadoc)
53       * @see org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext#getLargeIcon()
54       */
55      public String getLargeIcon() {
56          throw new UnsupportedOperationException();
57      }
58  
59      /* (non-Javadoc)
60       * @see org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext#getSmallIcon()
61       */
62      public String getSmallIcon() {
63          throw new UnsupportedOperationException();
64      }
65  
66      /* (non-Javadoc)
67       * @see org.apache.geronimo.ews.ws4j2ee.context.webservices.server.interfaces.WSCFContext#getWebServicesDescription()
68       */
69      public WSCFWebserviceDescription[] getWebServicesDescription() {
70          throw new UnsupportedOperationException();
71      }
72  
73      public void serialize(java.io.Writer out) throws GenerationFault {
74          try {
75              out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
76              out.write("<webservices xmlns=\"http://java.sun.com/xml/ns/j2ee\"\n");
77              out.write("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\n");
78              out.write("xmlns:ns1=\"http://www.Monson-Haefel.com/jwsbook/BookQuote\n");
79              out.write("xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee\n");
80              out.write("http://www.ibm.com/standards/xml/webservices/j2ee/j2ee_web_services_1_1.xsd\" version=\"1.1\">\n");
81              out.write("<webservice-description>\n");
82              out.write("<webservice-description-name>" + emitter.getServiceElementName() + "</webservice-description-name>\n");
83              out.write("<wsdl-file>" + j2eeweserviceContext.getMiscInfo().getWsdlFile() + "</wsdl-file>\n");
84              out.write("<jaxrpc-mapping-file>" + j2eeweserviceContext.getMiscInfo().getJaxrpcfile() + "</jaxrpc-mapping-file>\n");
85              out.write("<port-component>\n");
86              out.write("<port-component-name>" + emitter.getPortTypeName() + "</port-component-name>\n");
87              out.write("<wsdl-port xmlns:ns1=\"" + j2eeweserviceContext.getWSDLContext().getTargetNSURI() + "\">\n");
88              out.write("ns1:" + j2eeweserviceContext.getWSDLContext().getTargetPort().getName());
89              out.write("</wsdl-port>\n");
90              out.write("<service-endpoint-interface>" + emitter.getCls().getName() + "</service-endpoint-interface>\n");
91              out.write("<service-impl-bean>\n");
92  			
93              //TODO let usprint the port type name for now here
94              //we got to print the ejb name here parsing the ejb-jar.xml
95              String ejbName = j2eeweserviceContext.getMiscInfo().getJ2eeComponetLink();
96              if (ejbName == null)
97                  ejbName = emitter.getPortTypeName();
98              out.write("<ejb-link >" + ejbName + "</ejb-link>\n");
99              out.write("</service-impl-bean>\n");
100             out.write("</port-component>\n");
101             out.write("</webservice-description>\n");
102             out.write("</webservices>\n");
103         } catch (Exception e) {
104         }
105     }
106 
107 }