You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by am...@apache.org on 2008/02/26 13:59:10 UTC
svn commit: r631206 - in
/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl:
codegen/ codegen/extension/ i18n/ util/
Author: amilas
Date: Tue Feb 26 04:59:03 2008
New Revision: 631206
URL: http://svn.apache.org/viewvc?rev=631206&view=rev
Log:
Add an option to delete packages from the generated code
Added:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/ExcludePackageExtension.java
Modified:
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java?rev=631206&r1=631205&r2=631206&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodeGenConfiguration.java Tue Feb 26 04:59:03 2008
@@ -581,5 +581,15 @@
setoutputSourceLocation = true;
}
-
+
+ private String excludeProperties;
+
+ public String getExcludeProperties() {
+ return excludeProperties;
+ }
+
+ public void setExcludeProperties(String excludeProperties) {
+ this.excludeProperties = excludeProperties;
+ }
+
}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java?rev=631206&r1=631205&r2=631206&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/CodegenConfigLoader.java Tue Feb 26 04:59:03 2008
@@ -271,6 +271,12 @@
System.setProperty("http.proxyPort", commandLineOption.getOptionValue());
}
+ commandLineOption = loadOption(WSDL2JavaConstants.EXCLUDE_PAKAGES_OPTION,
+ WSDL2JavaConstants.EXCLUDE_PAKAGES_OPTION_LONG, optionMap);
+ if (commandLineOption != null){
+ config.setExcludeProperties(commandLineOption.getOptionValue());
+ }
+
// setting the overrid and all ports options
config.setAllPorts(loadOption(WSDL2JavaConstants.All_PORTS_OPTION,
WSDL2JavaConstants.All_PORTS_OPTION_LONG,
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties?rev=631206&r1=631205&r2=631206&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/codegen-config.properties Tue Feb 26 04:59:03 2008
@@ -40,7 +40,9 @@
#formatters
post.codegen.extension=org.apache.axis2.wsdl.codegen.extension.JavaPrettyPrinterExtension, \
org.apache.axis2.wsdl.codegen.extension.XMLPrettyPrinterExtension, \
- org.apache.axis2.wsdl.codegen.extension.WSDLPrettyPrinterExtension
+ org.apache.axis2.wsdl.codegen.extension.WSDLPrettyPrinterExtension, \
+ org.apache.axis2.wsdl.codegen.extension.ExcludePackageExtension
+
#codegen.extension=org.apache.axis2.wsdl.codegen.extension.AxisBindingBuilder,org.apache.axis2.wsdl.codegen.extension.WSDLValidatorExtension,org.apache.axis2.wsdl.codegen.extension.PackageFinder,org.apache.axis2.wsdl.codegen.extension.SimpleDBExtension
# The third party schemas to be loaded. e.g. The Xmime extension
# Note - these will be loaded from the org.apache.axis2.wsdl.codegen.schema package.
Added: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/ExcludePackageExtension.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/ExcludePackageExtension.java?rev=631206&view=auto
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/ExcludePackageExtension.java (added)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/codegen/extension/ExcludePackageExtension.java Tue Feb 26 04:59:03 2008
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.wsdl.codegen.extension;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+
+import java.io.File;
+
+/**
+ * this extension deletes the packages sepcifies by the user from the
+ * generated code.
+ * this feature is very important to remove some commonly generated classes.
+ */
+
+public class ExcludePackageExtension extends AbstractCodeGenerationExtension {
+
+
+ public void engage(CodeGenConfiguration configuration) throws CodeGenerationException {
+ String excludePackagesString = configuration.getExcludeProperties();
+ if ((excludePackagesString != null) && (excludePackagesString.trim().length() > 0)) {
+ String[] excludePackages = excludePackagesString.split(",");
+ File outPutFileLocation = null;
+ if (configuration.isFlattenFiles()) {
+ outPutFileLocation = getOutputDirectory(configuration.getOutputLocation(), null);
+ } else {
+ outPutFileLocation = getOutputDirectory(configuration.getOutputLocation(), configuration.getSourceLocation());
+ }
+ String excluePackage = null;
+ File tempFile = null;
+ for (int i = 0; i < excludePackages.length; i++) {
+ tempFile = outPutFileLocation;
+ String[] directories = excludePackages[i].split("\\.");
+ int j = 0;
+ for (; j < directories.length; j++) {
+ tempFile = new File(tempFile, directories[j]);
+ if (!tempFile.exists()) {
+ break;
+ }
+ }
+ if (j == directories.length) {
+ // this means this loop has gone to end and a directory
+ // exists at the end
+ deleteDirectory(tempFile);
+ }
+ }
+ }
+ }
+
+
+ private void deleteDirectory(File directory) {
+ File[] children = directory.listFiles();
+ for (int i = 0; i < children.length; i++) {
+ if (children[i].isDirectory()) {
+ deleteDirectory(children[i]);
+ } else {
+ children[i].delete();
+ }
+ }
+ // delete this directory
+ directory.delete();
+ }
+
+ private File getOutputDirectory(File outputDir, String dir2) {
+ if (dir2 != null && !"".equals(dir2)) {
+ outputDir = new File(outputDir, dir2);
+ }
+
+ if (!outputDir.exists()) {
+ outputDir.mkdirs();
+ }
+
+ return outputDir;
+ }
+}
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties?rev=631206&r1=631205&r2=631206&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/i18n/resource.properties Tue Feb 26 04:59:03 2008
@@ -76,6 +76,7 @@
wsdl2code.arg40= --noMessageReceiver Don't generate a MessageReceiver in the generated sources
wsdl2code.arg41= --http-proxy-host Proxy host address if you are behind a firewall
wsdl2code.arg42= --http-proxy-port Proxy prot address if you are behind a firewall
+wsdl2code.arg43= -ep Exclude packages - these packages are deleted after codegeneration
################## prop file loader #################################
propfileload.frameworkMismatch=Number of frameworks and extension names do not match!
Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java?rev=631206&r1=631205&r2=631206&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/wsdl/util/WSDL2JavaOptionsValidator.java Tue Feb 26 04:59:03 2008
@@ -91,6 +91,8 @@
WSDL2JavaConstants.WSDL_VERSION_OPTION_LONG.equalsIgnoreCase(optionType) ||
WSDL2JavaConstants.HTTP_PROXY_HOST_OPTION_LONG.equalsIgnoreCase(optionType) ||
WSDL2JavaConstants.HTTP_PROXY_PORT_OPTION_LONG.equalsIgnoreCase(optionType) ||
+ WSDL2JavaConstants.EXCLUDE_PAKAGES_OPTION.equalsIgnoreCase(optionType) ||
+ WSDL2JavaConstants.EXCLUDE_PAKAGES_OPTION_LONG.equalsIgnoreCase(optionType) ||
XMLBeansExtension.XSDCONFIG_OPTION.equalsIgnoreCase(optionType) ||
XMLBeansExtension.XSDCONFIG_OPTION_LONG.equalsIgnoreCase(optionType)
);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org