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.toWs.dd.geronimo;
18  
19  import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
20  import org.apache.geronimo.ews.ws4j2ee.toWs.AbstractWriter;
21  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
22  import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
23  
24  /***
25   * @author hemapani
26   */
27  public class GeronimoDDWriter extends AbstractWriter {
28      public GeronimoDDWriter(J2EEWebServiceContext j2eewscontext) throws GenerationFault {
29          super(j2eewscontext, j2eewscontext.getMiscInfo().getOutPutPath() +
30                  "/META-INF/" + GenerationConstants.GERONIMO_DD);
31      }
32  
33      public void writeCode() throws GenerationFault {
34          writeEJBDD();
35      }
36  	
37  //	<?xml version="1.0"?>
38  //	<openejb-jar
39  //		xmlns="http://www.openejb.org/xml/ns/openejb-jar"
40  //		configId="your/domain/name/Example"
41  //		parentId="org/apache/geronimo/Server">
42  //
43  //		<enterprise-beans>
44  //			<session>
45  //				<ejb-name>SimpleStatelessSession</ejb-name>
46  //				<jndi-name>client/test/simple/SimpleStatelessSessionHome</jndi-name>
47  //			</session>
48  //		</enterprise-beans>
49  //	</openejb-jar>
50      public void writeEJBDD() {
51          String ejbname = j2eewscontext.getWSDLContext().getTargetPortType().getName().toLowerCase();
52          int index = ejbname.lastIndexOf(".");
53          if (index > 0) {
54              ejbname = ejbname.substring(index + 1);
55          }
56          out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
57          out.write("<openejb-jar\n");
58          out.write("    xmlns=\"http://www.openejb.org/xml/ns/openejb-jar\"\n");
59          out.write("    configId=\"j2ee/geronimo/ews/" + ejbname + "\"\n");
60          out.write("    parentId=\"org/apache/geronimo/Server\">\n");
61          out.write("    <enterprise-beans>\n");
62          out.write("        <session>\n");
63          out.write("            <ejb-name>" + ejbname + "</ejb-name>\n");
64          String implStyle = j2eewscontext.getMiscInfo().getImplStyle();
65          if (GenerationConstants.USE_LOCAL_AND_REMOTE.equals(implStyle)
66                  || GenerationConstants.USE_REMOTE.equals(implStyle)) {
67              out.write("	  <jndi-name>" + "ejb/" + ejbname + "</jndi-name>\n");
68          }
69          if (GenerationConstants.USE_LOCAL_AND_REMOTE.equals(implStyle)
70                  || GenerationConstants.USE_LOCAL.equals(implStyle)) {
71              out.write("	  <local-jndi-name>" + "ejb/" + ejbname + "Local" + "</local-jndi-name>\n");
72          }
73          out.write("         </session>\n");
74          out.write("     </enterprise-beans>\n");
75          out.write("</openejb-jar>\n");
76          out.flush();
77      }
78  	
79  
80  //	<?xml version="1.0" encoding="UTF-8"?>
81  //	<web-app
82  //		xmlns="http://geronimo.apache.org/xml/ns/web/jetty"
83  //		configId="your/domain/name/Example"
84  //		parentId="org/apache/geronimo/Server"
85  //		>
86  //		<context-root>/debug-tool</context-root>
87  //		<context-priority-classloader>false</context-priority-classloader>
88  //	</web-app>
89      public void writeWebDD() {
90          String ejbname = j2eewscontext.getWSDLContext().getTargetPortType().getName().toLowerCase();
91          int index = ejbname.lastIndexOf(".");
92          if (index > 0) {
93              ejbname = ejbname.substring(index + 1);
94          }
95          out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
96          out.write("<web-app\n");
97          out.write("    xmlns=\"http://www.openejb.org/xml/ns/openejb-jar\"\n");
98          out.write("    configId=\"j2ee/geronimo/ews/" + ejbname + "\"\n");
99          out.write("    parentId=\"org/apache/geronimo/Server\">\n");
100         out.write("    <context-root>/axis</context-root>");
101         out.write("    <context-priority-classloader>false</context-priority-classloader>");
102         out.write("</web-app>");
103     }
104 
105 }