KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis2 > wsdl > codegen > extension > PackageFinder


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.axis2.wsdl.codegen.extension;
18
19 import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
20 import org.apache.axis2.wsdl.codegen.CommandLineOption;
21 import org.apache.axis2.wsdl.codegen.CommandLineOptionConstants;
22 import org.apache.axis2.wsdl.util.URLProcessor;
23 import org.apache.wsdl.WSDLBinding;
24
25 import java.util.Map JavaDoc;
26
27 /**
28  * @author chathura@opensource.lk
29  *
30  */

31 public class PackageFinder extends AbstractCodeGenerationExtension implements
32         CodeGenExtension {
33
34     public void init(CodeGenConfiguration configuration) {
35         this.configuration = configuration;
36
37     }
38
39     public void engage() {
40         Map JavaDoc allOptions = this.configuration.getParser().getAllOptions();
41         CommandLineOption packageOption = (CommandLineOption)(allOptions.get(CommandLineOptionConstants.PACKAGE_OPTION));
42         String JavaDoc packageName = packageOption==null?null:packageOption.getOptionValue();
43
44         if (packageName == null) {
45             WSDLBinding binding = configuration.getWom().getBinding(AxisBindingBuilder.AXIS_BINDING_QNAME);
46             String JavaDoc temp = binding.getBoundInterface().getName().getNamespaceURI();
47             packageName = URLProcessor.getNameSpaceFromURL(temp);
48         }
49         
50         if(null == packageName || "".equals(packageName))
51             packageName = URLProcessor.DEFAULT_PACKAGE;
52         
53         this.configuration.setPackageName(packageName.toLowerCase());
54
55     }
56
57     
58
59 }
Popular Tags