KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > core > ServiceFileCreator


1 package org.apache.axis.tool.core;
2
3 import java.io.File JavaDoc;
4 import java.io.FileWriter JavaDoc;
5 import java.util.ArrayList JavaDoc;
6
7 /*
8 * Copyright 2004,2005 The Apache Software Foundation.
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */

22
23 public class ServiceFileCreator {
24     public File JavaDoc createServiceFile(String JavaDoc providerClassName,String JavaDoc serviceClass,ArrayList JavaDoc methodList) throws Exception JavaDoc {
25         
26
27         String JavaDoc content = this.getFileString(providerClassName,serviceClass,methodList);
28         File JavaDoc serviceFile = new File JavaDoc("service.xml");
29
30         FileWriter JavaDoc fileWriter = new FileWriter JavaDoc(serviceFile);
31         fileWriter.write(content);
32         fileWriter.flush();
33
34         return serviceFile;
35
36
37
38
39     }
40
41     private String JavaDoc getFileString(String JavaDoc providerClassName,String JavaDoc serviceClass,ArrayList JavaDoc methodList){
42         String JavaDoc str = "<service provider=\"" +
43                 providerClassName + "\" >" +
44                 " <java:implementation class=\"" +
45                 serviceClass + "\" " +
46                 "xmlns:java=\"http://ws.apache.org/axis2/deployment/java\"/>\n" ;
47         for (int i = 0; i < methodList.size(); i++) {
48             str = str + " <operation name=\"" +
49                     methodList.get(i).toString() +
50                     "\" qname=\"" +
51                     methodList.get(i).toString() +
52                     "\" >\n";
53
54         }
55         str = str + "</service>";
56         return str;
57     }
58
59 }
60
Popular Tags