You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/09/15 21:07:03 UTC
svn commit: r289289 [109/134] - in /webservices/axis2/trunk/java: ./ etc/
modules/addressing/ modules/addressing/src/META-INF/
modules/addressing/src/org/apache/axis2/handlers/addressing/
modules/addressing/test-resources/ modules/addressing/test/org/a...
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/emitter/MultiLanguageClientEmitter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java Thu Sep 15 11:52:11 2005
@@ -1,29 +1,29 @@
-/*
- * Copyright 2001-2004 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.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * @author chathura@opensource.lk
- */
-public abstract class AbstractCodeGenerationExtension implements CodeGenExtension {
- protected Log log = LogFactory.getLog(this.getClass());
- protected CodeGenConfiguration configuration;
-}
+/*
+ * Copyright 2001-2004 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @author chathura@opensource.lk
+ */
+public abstract class AbstractCodeGenerationExtension implements CodeGenExtension {
+ protected Log log = LogFactory.getLog(this.getClass());
+ protected CodeGenConfiguration configuration;
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AbstractCodeGenerationExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java Thu Sep 15 11:52:11 2005
@@ -1,93 +1,93 @@
-/*
- * Copyright 2001-2004 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.wsdl.*;
-
-import javax.xml.namespace.QName;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Collection;
-import java.util.Vector;
-
-/**
- * The purpose of this extension is to build the bindings. bindings however may not be present
- * @author chathura@opensource.lk
- */
-public class AxisBindingBuilder extends AbstractCodeGenerationExtension implements CodeGenExtension {
-
- public static final String AXIS_NAMESPACE = "http://ws.apache.org/axis2/";
-
- public static final QName AXIS_BINDING_QNAME = new QName(AXIS_NAMESPACE,
- "codeGenerationBinding",
- "axis");
-
-
- public AxisBindingBuilder() {
- }
-
- public void init(CodeGenConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void engage() {
- WSDLDescription wom = this.configuration.getWom();
- Map bindingMap = wom.getBindings();
- Vector bindingVector = new Vector();
-
- if (bindingMap==null || bindingMap.isEmpty()) {
- log.info(" bindings are not present in the original document");
- //just fall through
- }else{
- Collection bindingCollection = bindingMap.values();
- for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
-
- WSDLBinding binding = (WSDLBinding)iterator.next();
-
- WSDLBinding newBinding = wom.createBinding();
- newBinding.setName(AXIS_BINDING_QNAME);
-
- WSDLInterface boundInterface = binding.getBoundInterface();
- newBinding.setBoundInterface(boundInterface);
-
- newBinding.setBindingFaults(binding.getBindingFaults());
- newBinding.setBindingOperations(binding.getBindingOperations());
- Iterator elementIterator = binding.getExtensibilityElements().iterator();
- while (elementIterator.hasNext()) {
- newBinding.addExtensibilityElement(
- (WSDLExtensibilityElement) elementIterator.next());
- }
-
- Iterator attributeIterator = binding.getExtensibilityAttributes()
- .iterator();
- while (attributeIterator.hasNext()) {
- newBinding.addExtensibleAttributes(
- (WSDLExtensibilityAttribute) attributeIterator.next());
- }
- bindingVector.add(newBinding);
-
- }
- //drop all the bindings and add the new ones
- wom.getBindings().clear();
- for (int i = 0; i < bindingVector.size(); i++) {
- wom.addBinding ((WSDLBinding) bindingVector.get(i));
- }
-
- }
- }
-}
+/*
+ * Copyright 2001-2004 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.wsdl.*;
+
+import javax.xml.namespace.QName;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Collection;
+import java.util.Vector;
+
+/**
+ * The purpose of this extension is to build the bindings. bindings however may not be present
+ * @author chathura@opensource.lk
+ */
+public class AxisBindingBuilder extends AbstractCodeGenerationExtension implements CodeGenExtension {
+
+ public static final String AXIS_NAMESPACE = "http://ws.apache.org/axis2/";
+
+ public static final QName AXIS_BINDING_QNAME = new QName(AXIS_NAMESPACE,
+ "codeGenerationBinding",
+ "axis");
+
+
+ public AxisBindingBuilder() {
+ }
+
+ public void init(CodeGenConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public void engage() {
+ WSDLDescription wom = this.configuration.getWom();
+ Map bindingMap = wom.getBindings();
+ Vector bindingVector = new Vector();
+
+ if (bindingMap==null || bindingMap.isEmpty()) {
+ log.info(" bindings are not present in the original document");
+ //just fall through
+ }else{
+ Collection bindingCollection = bindingMap.values();
+ for (Iterator iterator = bindingCollection.iterator(); iterator.hasNext();) {
+
+ WSDLBinding binding = (WSDLBinding)iterator.next();
+
+ WSDLBinding newBinding = wom.createBinding();
+ newBinding.setName(AXIS_BINDING_QNAME);
+
+ WSDLInterface boundInterface = binding.getBoundInterface();
+ newBinding.setBoundInterface(boundInterface);
+
+ newBinding.setBindingFaults(binding.getBindingFaults());
+ newBinding.setBindingOperations(binding.getBindingOperations());
+ Iterator elementIterator = binding.getExtensibilityElements().iterator();
+ while (elementIterator.hasNext()) {
+ newBinding.addExtensibilityElement(
+ (WSDLExtensibilityElement) elementIterator.next());
+ }
+
+ Iterator attributeIterator = binding.getExtensibilityAttributes()
+ .iterator();
+ while (attributeIterator.hasNext()) {
+ newBinding.addExtensibleAttributes(
+ (WSDLExtensibilityAttribute) attributeIterator.next());
+ }
+ bindingVector.add(newBinding);
+
+ }
+ //drop all the bindings and add the new ones
+ wom.getBindings().clear();
+ for (int i = 0; i < bindingVector.size(); i++) {
+ wom.addBinding ((WSDLBinding) bindingVector.get(i));
+ }
+
+ }
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/AxisBindingBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java Thu Sep 15 11:52:11 2005
@@ -1,34 +1,34 @@
-/*
- * Copyright 2001-2004 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;
-
-
-/**
- * @author chathura@opensource.lk
- */
-public interface CodeGenExtension {
-
-
- public void init(CodeGenConfiguration configuration);
-
- public void engage() throws CodeGenerationException;
-
-
-}
+/*
+ * Copyright 2001-2004 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;
+
+
+/**
+ * @author chathura@opensource.lk
+ */
+public interface CodeGenExtension {
+
+
+ public void init(CodeGenConfiguration configuration);
+
+ public void engage() throws CodeGenerationException;
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/CodeGenExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java Thu Sep 15 11:52:11 2005
@@ -1,45 +1,45 @@
-package org.apache.axis2.wsdl.codegen.extension;
-
-import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
-import org.apache.axis2.wsdl.codegen.CodeGenerationException;
-import org.apache.axis2.wsdl.codegen.XSLTConstants;
-import org.apache.axis2.wsdl.databinding.TypeMapper;
-import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
-
-/*
- * 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.
- *
- * The function of this class is to fill the default information if it's not already filled
- * Note - This extension is meant to be the last of the extensions
- */
-public class DefaultDatabindingExtension extends AbstractCodeGenerationExtension {
- private CodeGenConfiguration configuration;
- public void init(CodeGenConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void engage() throws CodeGenerationException {
- TypeMapper mappper = configuration.getTypeMapper();
- if (configuration.getDatabindingType() == XSLTConstants.DataBindingTypes.NONE){
- configuration.setTypeMapper(new DefaultTypeMapper());
- }else{
- if (mappper==null){
- //this shouldn't happen
- throw new CodeGenerationException("No proper databinding has taken place");
- }
- }
-
- }
-}
+package org.apache.axis2.wsdl.codegen.extension;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.codegen.XSLTConstants;
+import org.apache.axis2.wsdl.databinding.TypeMapper;
+import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
+
+/*
+ * 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.
+ *
+ * The function of this class is to fill the default information if it's not already filled
+ * Note - This extension is meant to be the last of the extensions
+ */
+public class DefaultDatabindingExtension extends AbstractCodeGenerationExtension {
+ private CodeGenConfiguration configuration;
+ public void init(CodeGenConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public void engage() throws CodeGenerationException {
+ TypeMapper mappper = configuration.getTypeMapper();
+ if (configuration.getDatabindingType() == XSLTConstants.DataBindingTypes.NONE){
+ configuration.setTypeMapper(new DefaultTypeMapper());
+ }else{
+ if (mappper==null){
+ //this shouldn't happen
+ throw new CodeGenerationException("No proper databinding has taken place");
+ }
+ }
+
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/DefaultDatabindingExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java Thu Sep 15 11:52:11 2005
@@ -1,51 +1,51 @@
-/*
- * Copyright 2001-2004 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.util.URLProcessor;
-import org.apache.wsdl.WSDLBinding;
-
-/**
- * @author chathura@opensource.lk
- */
-public class PackageFinder extends AbstractCodeGenerationExtension {
-
- public void init(CodeGenConfiguration configuration) {
- this.configuration = configuration;
-
- }
-
- public void engage() {
- String packageName = this.configuration.getPackageName();
- if (packageName == null) {
- WSDLBinding binding = configuration.getWom().getBinding(
- AxisBindingBuilder.AXIS_BINDING_QNAME);
- String temp = binding.getBoundInterface().getName()
- .getNamespaceURI();
- packageName = URLProcessor.getNameSpaceFromURL(temp);
- }
-
- if (null == packageName || "".equals(packageName))
- packageName = URLProcessor.DEFAULT_PACKAGE;
-
- this.configuration.setPackageName(packageName.toLowerCase());
-
- }
-
-
+/*
+ * Copyright 2001-2004 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.util.URLProcessor;
+import org.apache.wsdl.WSDLBinding;
+
+/**
+ * @author chathura@opensource.lk
+ */
+public class PackageFinder extends AbstractCodeGenerationExtension {
+
+ public void init(CodeGenConfiguration configuration) {
+ this.configuration = configuration;
+
+ }
+
+ public void engage() {
+ String packageName = this.configuration.getPackageName();
+ if (packageName == null) {
+ WSDLBinding binding = configuration.getWom().getBinding(
+ AxisBindingBuilder.AXIS_BINDING_QNAME);
+ String temp = binding.getBoundInterface().getName()
+ .getNamespaceURI();
+ packageName = URLProcessor.getNameSpaceFromURL(temp);
+ }
+
+ if (null == packageName || "".equals(packageName))
+ packageName = URLProcessor.DEFAULT_PACKAGE;
+
+ this.configuration.setPackageName(packageName.toLowerCase());
+
+ }
+
+
}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PackageFinder.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java Thu Sep 15 11:52:11 2005
@@ -1,45 +1,45 @@
-/*
- * Copyright 2001-2004 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;
-
-
-/**
- * @author chathura@opensource.lk
- */
-public class PolicyEvaluator implements CodeGenExtension {
-
- CodeGenConfiguration configuration;
-
- public PolicyEvaluator() {
- }
-
- /**
- * Go through the WSDL and extract the WS-Policy elements
- * and map it into a Axis Module.
- */
- public void init(CodeGenConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void engage() {
-
-
- }
-
-}
+/*
+ * Copyright 2001-2004 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;
+
+
+/**
+ * @author chathura@opensource.lk
+ */
+public class PolicyEvaluator implements CodeGenExtension {
+
+ CodeGenConfiguration configuration;
+
+ public PolicyEvaluator() {
+ }
+
+ /**
+ * Go through the WSDL and extract the WS-Policy elements
+ * and map it into a Axis Module.
+ */
+ public void init(CodeGenConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public void engage() {
+
+
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/PolicyEvaluator.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java Thu Sep 15 11:52:11 2005
@@ -1,96 +1,96 @@
-package org.apache.axis2.wsdl.codegen.extension;
-
-/*
- * 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.
- *
- *
- */
-
-import org.apache.axis.xsd.xml.schema.XmlSchema;
-import org.apache.axis.xsd.xml.schema.XmlSchemaCollection;
-import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
-import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
-import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
-import org.apache.wsdl.WSDLExtensibilityElement;
-import org.apache.wsdl.WSDLTypes;
-import org.apache.wsdl.extensions.ExtensionConstants;
-import org.apache.wsdl.extensions.Schema;
-import org.w3c.dom.Element;
-
-import java.util.*;
-
-/**
- * Work in progress to test simple DataBinding with the XmlSchema lib
- *
- */
-public class SimpleDBExtension extends AbstractCodeGenerationExtension {
- public void init(CodeGenConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void engage() {
- try {
- WSDLTypes typesList = configuration.getWom().getTypes();
- if (typesList == null) {
- //there are no types to be code generated
- //However if the type mapper is left empty it will be a problem for the other
- //processes. Hence the default type mapper is set to the configuration
- this.configuration.setTypeMapper(new DefaultTypeMapper());
- return;
- }
-
- List typesArray = typesList.getExtensibilityElements();
- WSDLExtensibilityElement extensiblityElt = null;
-
- for (int i = 0; i < typesArray.size(); i++) {
- extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
- Vector xmlObjectsVector = new Vector();
- XmlSchemaCollection schemaColl = new XmlSchemaCollection();
- Schema schema = null;
-
- if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
- schema = (Schema) extensiblityElt;
- Map inScopeNS = configuration.getWom().getNamespaces();
- for (Iterator it = inScopeNS.keySet().iterator(); it.hasNext();) {
- String prefix = (String) it.next();
- schemaColl.mapNamespace(prefix,
- (String)inScopeNS.get(prefix));
- }
-
- Stack importedSchemaStack = schema.getImportedSchemaStack();
- //compile these schemas
- while (!importedSchemaStack.isEmpty()) {
- Element el = ((javax.wsdl.extensions.schema.Schema)importedSchemaStack.pop()).getElement();
- XmlSchema thisSchema = schemaColl.read(el);
- xmlObjectsVector.add(thisSchema);
- }
- }
-
- //create the type mapper
- JavaTypeMapper mapper = new JavaTypeMapper();
- int length = 0;
- for (int j = 0; j < length; j++) {
-// mapper.addTypeMapping();
- }
- //set the type mapper to the config
- configuration.setTypeMapper(mapper);
-
- }
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- }
-}
+package org.apache.axis2.wsdl.codegen.extension;
+
+/*
+ * 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.
+ *
+ *
+ */
+
+import org.apache.axis.xsd.xml.schema.XmlSchema;
+import org.apache.axis.xsd.xml.schema.XmlSchemaCollection;
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
+import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.apache.wsdl.WSDLExtensibilityElement;
+import org.apache.wsdl.WSDLTypes;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.Schema;
+import org.w3c.dom.Element;
+
+import java.util.*;
+
+/**
+ * Work in progress to test simple DataBinding with the XmlSchema lib
+ *
+ */
+public class SimpleDBExtension extends AbstractCodeGenerationExtension {
+ public void init(CodeGenConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public void engage() {
+ try {
+ WSDLTypes typesList = configuration.getWom().getTypes();
+ if (typesList == null) {
+ //there are no types to be code generated
+ //However if the type mapper is left empty it will be a problem for the other
+ //processes. Hence the default type mapper is set to the configuration
+ this.configuration.setTypeMapper(new DefaultTypeMapper());
+ return;
+ }
+
+ List typesArray = typesList.getExtensibilityElements();
+ WSDLExtensibilityElement extensiblityElt = null;
+
+ for (int i = 0; i < typesArray.size(); i++) {
+ extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
+ Vector xmlObjectsVector = new Vector();
+ XmlSchemaCollection schemaColl = new XmlSchemaCollection();
+ Schema schema = null;
+
+ if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
+ schema = (Schema) extensiblityElt;
+ Map inScopeNS = configuration.getWom().getNamespaces();
+ for (Iterator it = inScopeNS.keySet().iterator(); it.hasNext();) {
+ String prefix = (String) it.next();
+ schemaColl.mapNamespace(prefix,
+ (String)inScopeNS.get(prefix));
+ }
+
+ Stack importedSchemaStack = schema.getImportedSchemaStack();
+ //compile these schemas
+ while (!importedSchemaStack.isEmpty()) {
+ Element el = ((javax.wsdl.extensions.schema.Schema)importedSchemaStack.pop()).getElement();
+ XmlSchema thisSchema = schemaColl.read(el);
+ xmlObjectsVector.add(thisSchema);
+ }
+ }
+
+ //create the type mapper
+ JavaTypeMapper mapper = new JavaTypeMapper();
+ int length = 0;
+ for (int j = 0; j < length; j++) {
+// mapper.addTypeMapping();
+ }
+ //set the type mapper to the config
+ configuration.setTypeMapper(mapper);
+
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/SimpleDBExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java Thu Sep 15 11:52:11 2005
@@ -1,81 +1,81 @@
-/*
-* Copyright 2001-2004 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 org.apache.wsdl.WSDLExtensibilityElement;
-import org.apache.wsdl.WSDLTypes;
-import org.apache.wsdl.extensions.ExtensionConstants;
-import org.apache.wsdl.extensions.Schema;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import java.util.Iterator;
-
-/**
- * @author chathura@opensource.lk
- */
-public class WSDLValidatorExtension extends AbstractCodeGenerationExtension {
- private static String TARGETNAMESPACE_STRING = "targetNamespace";
-
- public void init(CodeGenConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void engage() throws CodeGenerationException {
- //WSDLDescription wom = this.configuration.getWom();
- WSDLTypes typesList = configuration.getWom().getTypes();
- if (typesList == null) {
- //there are no types to be considered
- return;
- }
- Iterator iterator = typesList.getExtensibilityElements().iterator();
- while (iterator.hasNext()) {
- WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator.next();
- boolean targetnamespaceFound = false;
- if (ExtensionConstants.SCHEMA.equals(element.getType())) {
- Schema schema = (Schema) element;
- Element schemaElement = schema.getElement();
- //first check whether the schema include only a single import statement.
- //As per the nature of WSDL if the schema has a single import ONLY, then the
- //schema element need not contain a target namespace.
- NodeList importNodeList = schemaElement.getElementsByTagNameNS(schemaElement.getNamespaceURI(),"import");
- NodeList allNodes = schemaElement.getElementsByTagName("*");
- //checking the number of child elements and the number of import elements should get us what we need
- if (importNodeList.getLength()==1 && allNodes.getLength()==1){
- return;
- }
-
-
- NamedNodeMap attributes = schemaElement.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- if (TARGETNAMESPACE_STRING.equalsIgnoreCase(
- attributes.item(i).getLocalName())){
- targetnamespaceFound = true;
- break;
- }
- }
- if (!targetnamespaceFound)
- throw new CodeGenerationException(
- "Invalid WSDL: The WSDL Types Schema does not define a targetNamespace in "+schema.getName() );
- }
-
- }
- }
-}
+/*
+* Copyright 2001-2004 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 org.apache.wsdl.WSDLExtensibilityElement;
+import org.apache.wsdl.WSDLTypes;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.Schema;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.util.Iterator;
+
+/**
+ * @author chathura@opensource.lk
+ */
+public class WSDLValidatorExtension extends AbstractCodeGenerationExtension {
+ private static String TARGETNAMESPACE_STRING = "targetNamespace";
+
+ public void init(CodeGenConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public void engage() throws CodeGenerationException {
+ //WSDLDescription wom = this.configuration.getWom();
+ WSDLTypes typesList = configuration.getWom().getTypes();
+ if (typesList == null) {
+ //there are no types to be considered
+ return;
+ }
+ Iterator iterator = typesList.getExtensibilityElements().iterator();
+ while (iterator.hasNext()) {
+ WSDLExtensibilityElement element = (WSDLExtensibilityElement) iterator.next();
+ boolean targetnamespaceFound = false;
+ if (ExtensionConstants.SCHEMA.equals(element.getType())) {
+ Schema schema = (Schema) element;
+ Element schemaElement = schema.getElement();
+ //first check whether the schema include only a single import statement.
+ //As per the nature of WSDL if the schema has a single import ONLY, then the
+ //schema element need not contain a target namespace.
+ NodeList importNodeList = schemaElement.getElementsByTagNameNS(schemaElement.getNamespaceURI(),"import");
+ NodeList allNodes = schemaElement.getElementsByTagName("*");
+ //checking the number of child elements and the number of import elements should get us what we need
+ if (importNodeList.getLength()==1 && allNodes.getLength()==1){
+ return;
+ }
+
+
+ NamedNodeMap attributes = schemaElement.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ if (TARGETNAMESPACE_STRING.equalsIgnoreCase(
+ attributes.item(i).getLocalName())){
+ targetnamespaceFound = true;
+ break;
+ }
+ }
+ if (!targetnamespaceFound)
+ throw new CodeGenerationException(
+ "Invalid WSDL: The WSDL Types Schema does not define a targetNamespace in "+schema.getName() );
+ }
+
+ }
+ }
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/WSDLValidatorExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java Thu Sep 15 11:52:11 2005
@@ -1,282 +1,282 @@
-package org.apache.axis2.wsdl.codegen.extension;
-
-import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
-import org.apache.axis2.wsdl.codegen.XSLTConstants;
-import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
-import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
-import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
-import org.apache.wsdl.*;
-import org.apache.wsdl.extensions.ExtensionConstants;
-import org.apache.wsdl.extensions.Schema;
-import org.apache.wsdl.extensions.SOAPBody;
-import org.apache.xmlbeans.*;
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.*;
-import java.util.*;
-
-/*
-* 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.
-*
-*
-*/
-
-public class XMLBeansExtension extends AbstractCodeGenerationExtension {
- private static final String DEFAULT_STS_NAME = "foo";
-
-
-
- public void init(CodeGenConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void engage() {
-
- //test the databinding type. If not just fall through
- if (configuration.getDatabindingType()!= XSLTConstants.DataBindingTypes.XML_BEANS){
- return;
- }
-
- //check the comptibilty
- checkCompatibility();
-
- Element[] additionalSchemas = loadAdditionalSchemas();
-
- try {
- //get the types from the types section
- WSDLTypes typesList = configuration.getWom().getTypes();
-
- //check for the imported types. Any imported types are supposed to be here also
- if (typesList == null) {
- //there are no types to be code generated
- //However if the type mapper is left empty it will be a problem for the other
- //processes. Hence the default type mapper is set to the configuration
- this.configuration.setTypeMapper(new DefaultTypeMapper());
- return;
- }
-
- List typesArray = typesList.getExtensibilityElements();
- WSDLExtensibilityElement extensiblityElt;
- SchemaTypeSystem sts;
- Vector xmlObjectsVector= new Vector();
- //create the type mapper
- JavaTypeMapper mapper = new JavaTypeMapper();
-
- for (int i = 0; i < typesArray.size(); i++) {
- extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
- Schema schema;
-
- if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
- schema = (Schema) extensiblityElt;
- XmlOptions options = new XmlOptions();
- options.setLoadAdditionalNamespaces(
- configuration.getWom().getNamespaces()); //add the namespaces
-
-
- Stack importedSchemaStack = schema.getImportedSchemaStack();
- //compile these schemas
- while (!importedSchemaStack.isEmpty()){
- javax.wsdl.extensions.schema.Schema tempSchema = (javax.wsdl.extensions.schema.Schema) importedSchemaStack.pop();
- Element element = tempSchema.getElement();
- xmlObjectsVector.add(
- XmlObject.Factory.parse(
- element
- ,options));
- }
- }
- }
-
- // add the third party schemas
- //todo pehaps checking the namespaces would be a good idea to
- //make the generated code work efficiently
- for (int i = 0; i < additionalSchemas.length; i++) {
- xmlObjectsVector.add(XmlObject.Factory.parse(
- additionalSchemas[i]
- ,null));
- }
-
- //compile the type system
- sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
- convertToXMLObjectArray(xmlObjectsVector),
- new BindingConfig(), XmlBeans.getContextTypeLoader(),
- new Axis2Filer(),
- null);
-
- // prune the generated schema type system and add the list of base64 types
- FindBase64Types(sts);
-
- //get the schematypes and add the document types to the type mapper
- SchemaType[] schemaType = sts.documentTypes();
- SchemaType type;
- for (int j = 0; j < schemaType.length; j++) {
- type = schemaType[j];
- mapper.addTypeMapping(type.getDocumentElementName(),
- type.getFullJavaName());
- }
- //set the type mapper to the config
- configuration.setTypeMapper(mapper);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- }
-
- /**
- * Populate the base64 types
- * The algo is to look for simpletypes that have base64 content, and then step out of that
- * onestep and get the element. For now there's an extended check to see whether the simple type
- * is related to the Xmime:contentType!
- * @param sts
- */
- private void FindBase64Types(SchemaTypeSystem sts) {
- List allSeenTypes = new ArrayList();
- List base64ElementQNamesList = new ArrayList();
- SchemaType outerType;
- //add the document types and global types
- allSeenTypes.addAll(Arrays.asList(sts.documentTypes()));
- allSeenTypes.addAll(Arrays.asList(sts.globalTypes()));
- for (int i = 0; i < allSeenTypes.size(); i++){
- SchemaType sType = (SchemaType)allSeenTypes.get(i);
-
- if (sType.getContentType()==SchemaType.SIMPLE_CONTENT && sType.getPrimitiveType()!=null) {
- if (XSLTConstants.BASE_64_CONTENT_QNAME.equals(sType.getPrimitiveType().getName())){
- outerType = sType.getOuterType();
- //check the outer type further to see whether it has the contenttype attribute from
- //XMime namespace
- SchemaProperty[] properties = sType.getProperties();
- for (int j = 0; j < properties.length; j++) {
- if (XSLTConstants.XMIME_CONTENT_TYPE_QNAME.equals(properties[j].getName())){
- base64ElementQNamesList.add(outerType.getDocumentElementName());
- break;
- }
- }
- }
- }
- //add any of the child types if there are any
- allSeenTypes.addAll(Arrays.asList(sType.getAnonymousTypes()));
- }
-
- configuration.put(XSLTConstants.BASE_64_PROPERTY_KEY,base64ElementQNamesList);
- }
-
- /**
- * Loading the external schemas.
- * @return element array consisting of the the DOM element objects that represent schemas
- *
- */
- private Element[] loadAdditionalSchemas() {
- //load additional schemas
- String[] schemaNames = ConfigPropertyFileLoader.getThirdPartySchemaNames();
- Element[] schemaElements = null;
-
- try {
- ArrayList additionalSchemaElements = new ArrayList();
- DocumentBuilder documentBuilder = getNamespaceAwareDocumentBuilder();
- for (int i = 0; i < schemaNames.length; i++) {
- InputStream schemaStream = this.getClass().getResourceAsStream("/org/apache/axis2/wsdl/codegen/schema/"+ schemaNames[i]);
- Document doc = documentBuilder.parse(schemaStream);
- additionalSchemaElements.add(doc.getDocumentElement());
- }
-
- //Create the Schema element array
- schemaElements = new Element[additionalSchemaElements.size()];
- for (int i = 0; i < additionalSchemaElements.size(); i++) {
- schemaElements[i] = (Element) additionalSchemaElements.get(i);
-
- }
- } catch (Exception e) {
- throw new RuntimeException("Additional schema loading failed!!",e);
- }
-
- return schemaElements;
- }
-
- private DocumentBuilder getNamespaceAwareDocumentBuilder() throws ParserConfigurationException {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
- documentBuilderFactory.setNamespaceAware(true);
- return documentBuilderFactory.newDocumentBuilder();
- }
-
-
- /**
- * Checking the compatibilty has to do with generating RPC/encoded stubs.
- * If the XMLBeans bindings are used encoded binding cannot be done.
- */
- private void checkCompatibility(){
- Map bindingMap = this.configuration.getWom().getBindings();
- Collection col = bindingMap.values();
-
- for (Iterator iterator = col.iterator(); iterator.hasNext();) {
- WSDLBinding b = (WSDLBinding)iterator.next();
- HashMap bindingOps = b.getBindingOperations();
- Collection bindingOpsCollection = bindingOps.values();
- for (Iterator iterator1 = bindingOpsCollection.iterator(); iterator1.hasNext();) {
- foo((WSDLBindingOperation)iterator1.next());
- }
-
- }
- }
- protected void foo(WSDLBindingOperation bindingOp) {
- Iterator extIterator = bindingOp.getInput().getExtensibilityElements()
- .iterator();
- while (extIterator.hasNext()) {
- WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
- if (ExtensionConstants.SOAP_11_BODY.equals(element.getType()) ||
- ExtensionConstants.SOAP_12_BODY.equals(element.getType())) {
- if (WSDLConstants.WSDL_USE_ENCODED.equals(
- ((SOAPBody) element).getUse())) {
- throw new RuntimeException(
- "The use 'encoded' is not supported!");
- }
- }
- }
- }
- private XmlObject[] convertToXMLObjectArray(Vector vec){
- XmlObject[] xmlObjects = new XmlObject[vec.size()];
- for (int i = 0; i < vec.size(); i++) {
- xmlObjects[i] = (XmlObject)vec.get(i);
- }
- return xmlObjects;
- }
- /**
- * Private class to generate the filer
- */
- private class Axis2Filer implements Filer{
-
- public OutputStream createBinaryFile(String typename)
- throws IOException {
- File file = new File(configuration.getOutputLocation(), typename);
- file.getParentFile().mkdirs();
- file.createNewFile();
- return new FileOutputStream(file);
- }
-
- public Writer createSourceFile(String typename)
- throws IOException {
- typename =
- typename.replace('.', File.separatorChar);
- File file = new File(configuration.getOutputLocation(),
- typename + ".java");
- file.getParentFile().mkdirs();
- file.createNewFile();
- return new FileWriter(file);
- }
- }
-}
-
+package org.apache.axis2.wsdl.codegen.extension;
+
+import org.apache.axis2.wsdl.codegen.CodeGenConfiguration;
+import org.apache.axis2.wsdl.codegen.XSLTConstants;
+import org.apache.axis2.wsdl.databinding.DefaultTypeMapper;
+import org.apache.axis2.wsdl.databinding.JavaTypeMapper;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
+import org.apache.wsdl.*;
+import org.apache.wsdl.extensions.ExtensionConstants;
+import org.apache.wsdl.extensions.Schema;
+import org.apache.wsdl.extensions.SOAPBody;
+import org.apache.xmlbeans.*;
+import org.w3c.dom.Element;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import java.io.*;
+import java.util.*;
+
+/*
+* 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.
+*
+*
+*/
+
+public class XMLBeansExtension extends AbstractCodeGenerationExtension {
+ private static final String DEFAULT_STS_NAME = "foo";
+
+
+
+ public void init(CodeGenConfiguration configuration) {
+ this.configuration = configuration;
+ }
+
+ public void engage() {
+
+ //test the databinding type. If not just fall through
+ if (configuration.getDatabindingType()!= XSLTConstants.DataBindingTypes.XML_BEANS){
+ return;
+ }
+
+ //check the comptibilty
+ checkCompatibility();
+
+ Element[] additionalSchemas = loadAdditionalSchemas();
+
+ try {
+ //get the types from the types section
+ WSDLTypes typesList = configuration.getWom().getTypes();
+
+ //check for the imported types. Any imported types are supposed to be here also
+ if (typesList == null) {
+ //there are no types to be code generated
+ //However if the type mapper is left empty it will be a problem for the other
+ //processes. Hence the default type mapper is set to the configuration
+ this.configuration.setTypeMapper(new DefaultTypeMapper());
+ return;
+ }
+
+ List typesArray = typesList.getExtensibilityElements();
+ WSDLExtensibilityElement extensiblityElt;
+ SchemaTypeSystem sts;
+ Vector xmlObjectsVector= new Vector();
+ //create the type mapper
+ JavaTypeMapper mapper = new JavaTypeMapper();
+
+ for (int i = 0; i < typesArray.size(); i++) {
+ extensiblityElt = (WSDLExtensibilityElement) typesArray.get(i);
+ Schema schema;
+
+ if (ExtensionConstants.SCHEMA.equals(extensiblityElt.getType())) {
+ schema = (Schema) extensiblityElt;
+ XmlOptions options = new XmlOptions();
+ options.setLoadAdditionalNamespaces(
+ configuration.getWom().getNamespaces()); //add the namespaces
+
+
+ Stack importedSchemaStack = schema.getImportedSchemaStack();
+ //compile these schemas
+ while (!importedSchemaStack.isEmpty()){
+ javax.wsdl.extensions.schema.Schema tempSchema = (javax.wsdl.extensions.schema.Schema) importedSchemaStack.pop();
+ Element element = tempSchema.getElement();
+ xmlObjectsVector.add(
+ XmlObject.Factory.parse(
+ element
+ ,options));
+ }
+ }
+ }
+
+ // add the third party schemas
+ //todo pehaps checking the namespaces would be a good idea to
+ //make the generated code work efficiently
+ for (int i = 0; i < additionalSchemas.length; i++) {
+ xmlObjectsVector.add(XmlObject.Factory.parse(
+ additionalSchemas[i]
+ ,null));
+ }
+
+ //compile the type system
+ sts = XmlBeans.compileXmlBeans(DEFAULT_STS_NAME, null,
+ convertToXMLObjectArray(xmlObjectsVector),
+ new BindingConfig(), XmlBeans.getContextTypeLoader(),
+ new Axis2Filer(),
+ null);
+
+ // prune the generated schema type system and add the list of base64 types
+ FindBase64Types(sts);
+
+ //get the schematypes and add the document types to the type mapper
+ SchemaType[] schemaType = sts.documentTypes();
+ SchemaType type;
+ for (int j = 0; j < schemaType.length; j++) {
+ type = schemaType[j];
+ mapper.addTypeMapping(type.getDocumentElementName(),
+ type.getFullJavaName());
+ }
+ //set the type mapper to the config
+ configuration.setTypeMapper(mapper);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+
+ /**
+ * Populate the base64 types
+ * The algo is to look for simpletypes that have base64 content, and then step out of that
+ * onestep and get the element. For now there's an extended check to see whether the simple type
+ * is related to the Xmime:contentType!
+ * @param sts
+ */
+ private void FindBase64Types(SchemaTypeSystem sts) {
+ List allSeenTypes = new ArrayList();
+ List base64ElementQNamesList = new ArrayList();
+ SchemaType outerType;
+ //add the document types and global types
+ allSeenTypes.addAll(Arrays.asList(sts.documentTypes()));
+ allSeenTypes.addAll(Arrays.asList(sts.globalTypes()));
+ for (int i = 0; i < allSeenTypes.size(); i++){
+ SchemaType sType = (SchemaType)allSeenTypes.get(i);
+
+ if (sType.getContentType()==SchemaType.SIMPLE_CONTENT && sType.getPrimitiveType()!=null) {
+ if (XSLTConstants.BASE_64_CONTENT_QNAME.equals(sType.getPrimitiveType().getName())){
+ outerType = sType.getOuterType();
+ //check the outer type further to see whether it has the contenttype attribute from
+ //XMime namespace
+ SchemaProperty[] properties = sType.getProperties();
+ for (int j = 0; j < properties.length; j++) {
+ if (XSLTConstants.XMIME_CONTENT_TYPE_QNAME.equals(properties[j].getName())){
+ base64ElementQNamesList.add(outerType.getDocumentElementName());
+ break;
+ }
+ }
+ }
+ }
+ //add any of the child types if there are any
+ allSeenTypes.addAll(Arrays.asList(sType.getAnonymousTypes()));
+ }
+
+ configuration.put(XSLTConstants.BASE_64_PROPERTY_KEY,base64ElementQNamesList);
+ }
+
+ /**
+ * Loading the external schemas.
+ * @return element array consisting of the the DOM element objects that represent schemas
+ *
+ */
+ private Element[] loadAdditionalSchemas() {
+ //load additional schemas
+ String[] schemaNames = ConfigPropertyFileLoader.getThirdPartySchemaNames();
+ Element[] schemaElements = null;
+
+ try {
+ ArrayList additionalSchemaElements = new ArrayList();
+ DocumentBuilder documentBuilder = getNamespaceAwareDocumentBuilder();
+ for (int i = 0; i < schemaNames.length; i++) {
+ InputStream schemaStream = this.getClass().getResourceAsStream("/org/apache/axis2/wsdl/codegen/schema/"+ schemaNames[i]);
+ Document doc = documentBuilder.parse(schemaStream);
+ additionalSchemaElements.add(doc.getDocumentElement());
+ }
+
+ //Create the Schema element array
+ schemaElements = new Element[additionalSchemaElements.size()];
+ for (int i = 0; i < additionalSchemaElements.size(); i++) {
+ schemaElements[i] = (Element) additionalSchemaElements.get(i);
+
+ }
+ } catch (Exception e) {
+ throw new RuntimeException("Additional schema loading failed!!",e);
+ }
+
+ return schemaElements;
+ }
+
+ private DocumentBuilder getNamespaceAwareDocumentBuilder() throws ParserConfigurationException {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ documentBuilderFactory.setNamespaceAware(true);
+ return documentBuilderFactory.newDocumentBuilder();
+ }
+
+
+ /**
+ * Checking the compatibilty has to do with generating RPC/encoded stubs.
+ * If the XMLBeans bindings are used encoded binding cannot be done.
+ */
+ private void checkCompatibility(){
+ Map bindingMap = this.configuration.getWom().getBindings();
+ Collection col = bindingMap.values();
+
+ for (Iterator iterator = col.iterator(); iterator.hasNext();) {
+ WSDLBinding b = (WSDLBinding)iterator.next();
+ HashMap bindingOps = b.getBindingOperations();
+ Collection bindingOpsCollection = bindingOps.values();
+ for (Iterator iterator1 = bindingOpsCollection.iterator(); iterator1.hasNext();) {
+ foo((WSDLBindingOperation)iterator1.next());
+ }
+
+ }
+ }
+ protected void foo(WSDLBindingOperation bindingOp) {
+ Iterator extIterator = bindingOp.getInput().getExtensibilityElements()
+ .iterator();
+ while (extIterator.hasNext()) {
+ WSDLExtensibilityElement element = (WSDLExtensibilityElement) extIterator.next();
+ if (ExtensionConstants.SOAP_11_BODY.equals(element.getType()) ||
+ ExtensionConstants.SOAP_12_BODY.equals(element.getType())) {
+ if (WSDLConstants.WSDL_USE_ENCODED.equals(
+ ((SOAPBody) element).getUse())) {
+ throw new RuntimeException(
+ "The use 'encoded' is not supported!");
+ }
+ }
+ }
+ }
+ private XmlObject[] convertToXMLObjectArray(Vector vec){
+ XmlObject[] xmlObjects = new XmlObject[vec.size()];
+ for (int i = 0; i < vec.size(); i++) {
+ xmlObjects[i] = (XmlObject)vec.get(i);
+ }
+ return xmlObjects;
+ }
+ /**
+ * Private class to generate the filer
+ */
+ private class Axis2Filer implements Filer{
+
+ public OutputStream createBinaryFile(String typename)
+ throws IOException {
+ File file = new File(configuration.getOutputLocation(), typename);
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ return new FileOutputStream(file);
+ }
+
+ public Writer createSourceFile(String typename)
+ throws IOException {
+ typename =
+ typename.replace('.', File.separatorChar);
+ File file = new File(configuration.getOutputLocation(),
+ typename + ".java");
+ file.getParentFile().mkdirs();
+ file.createNewFile();
+ return new FileWriter(file);
+ }
+ }
+}
+
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/extension/XMLBeansExtension.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java Thu Sep 15 11:52:11 2005
@@ -1,36 +1,36 @@
-package org.apache.axis2.wsdl.codegen.writer;
-
-import org.apache.axis2.wsdl.codegen.XSLTConstants;
-
-import java.io.File;
-
-/*
- * 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.
- *
- *
- */
-
-public class BeanWriter extends ClassWriter {
-
- public BeanWriter(String outputFileLocation) {
- this.outputFileLocation = new File(outputFileLocation);
- }
-
- public BeanWriter(File outputFileLocation, String language) {
- this.outputFileLocation = outputFileLocation;
- this.language = language;
- }
-
-}
+package org.apache.axis2.wsdl.codegen.writer;
+
+import org.apache.axis2.wsdl.codegen.XSLTConstants;
+
+import java.io.File;
+
+/*
+ * 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.
+ *
+ *
+ */
+
+public class BeanWriter extends ClassWriter {
+
+ public BeanWriter(String outputFileLocation) {
+ this.outputFileLocation = new File(outputFileLocation);
+ }
+
+ public BeanWriter(File outputFileLocation, String language) {
+ this.outputFileLocation = outputFileLocation;
+ this.language = language;
+ }
+
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/BeanWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java Thu Sep 15 11:52:11 2005
@@ -1,38 +1,38 @@
-/*
- * Copyright 2001-2004 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.writer;
-
-import org.apache.axis2.wsdl.codegen.XSLTConstants;
-
-import java.io.File;
-
-/**
- * @author chathura@opensource.lk
- */
-public class CallbackHandlerWriter extends ClassWriter {
-
- public CallbackHandlerWriter(String outputFileLocation) {
- this.outputFileLocation = new File(outputFileLocation);
- }
-
- public CallbackHandlerWriter(File outputFileLocation, String language) {
- this.outputFileLocation = outputFileLocation;
- this.language = language;
- }
-
-
-}
+/*
+ * Copyright 2001-2004 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.writer;
+
+import org.apache.axis2.wsdl.codegen.XSLTConstants;
+
+import java.io.File;
+
+/**
+ * @author chathura@opensource.lk
+ */
+public class CallbackHandlerWriter extends ClassWriter {
+
+ public CallbackHandlerWriter(String outputFileLocation) {
+ this.outputFileLocation = new File(outputFileLocation);
+ }
+
+ public CallbackHandlerWriter(File outputFileLocation, String language) {
+ this.outputFileLocation = outputFileLocation;
+ this.language = language;
+ }
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/CallbackHandlerWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java?rev=289289&r1=289288&r2=289289&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java (original)
+++ webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java Thu Sep 15 11:52:11 2005
@@ -1,163 +1,163 @@
-package org.apache.axis2.wsdl.codegen.writer;
-
-import org.apache.axis2.wsdl.codegen.XSLTConstants;
-import org.apache.axis2.wsdl.codegen.CodeGenerationException;
-import org.apache.axis2.wsdl.util.FileWriter;
-import org.apache.axis2.wsdl.util.XSLTTemplateProcessor;
-import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Enumeration;
-import java.util.Iterator;
-
-/*
-* 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.
-*
-*
-* Abstract writer to be extended by writers. To use a class writer one needs to call the
-* methods in order
-* ususally it is setLanguage() ->loadTemplate() ->createOutFile() ->WriteOutFile()
-*/
-
-public abstract class ClassWriter {
-
- protected File outputFileLocation = null;
- protected FileOutputStream stream = null;
- protected InputStream xsltStream = null;
- protected String language = ConfigPropertyFileLoader.getDefaultLanguage(); //default would java
-
- protected static final String TEMPLATE_SUFFIX = ".template";
- protected static final String EXTENSION_SUFFIX = ".extension";
- protected static final String SEPERATOR_STRING = ",";
-
- /**
- * Sets the language
- *
- * @param language
- */
- public void setLanguage(String language) {
- this.language = language;
- }
-
- /**
- * Load the template
- */
- public void loadTemplate() throws CodeGenerationException{
- // the default behavior for the class writers is to use the property map from the languge specific types
- // The properties are arranged in the following order
- // <lang-name>.* .template=<write-class>,<template-name>
-
- //first get the language specific property map
- Class clazz = this.getClass();
- Map languageSpecificPropertyMap = (Map)ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
- if (languageSpecificPropertyMap==null){
- throw new CodeGenerationException("No language specific properties!!!");
- }
-
- String templateName = findTemplate(languageSpecificPropertyMap);
- if (templateName!=null){
- this.xsltStream = clazz.getResourceAsStream(templateName);
- }else{
- throw new CodeGenerationException("template for this writer is not found");
- }
-
-
- }
-
- protected String findTemplate(Map languageSpecificPropertyMap) {
- //search through the proprty names to find the template relevant to this class
-
- String ownClazzName = this.getClass().getName();
- String key;
- String propertyValue;
- String templateName = null;
- Iterator keys = languageSpecificPropertyMap.keySet().iterator();
-
- while (keys.hasNext()) {
- //check for template entries
- key = keys.next().toString();
- if (key.endsWith(TEMPLATE_SUFFIX)){
- // check if the class name is there
- propertyValue = languageSpecificPropertyMap.get(key).toString();
- if (propertyValue.startsWith(ownClazzName)){
- //bingo! we found the right template
- templateName = propertyValue.substring(propertyValue.indexOf(SEPERATOR_STRING)+1) ;
- break;
- }
- }
-
- }
- return templateName;
- }
-
- /**
- * Creates the output file
- *
- * @param packageName
- * @param fileName
- * @throws Exception
- */
- public void createOutFile(String packageName, String fileName) throws Exception {
- File outputFile = FileWriter.createClassFile(outputFileLocation,
- packageName,
- fileName,
- getFileExtensionForLanguage(language));
- this.stream = new FileOutputStream(outputFile);
- }
-
- /**
- * Find the file name extension
- * @param language
- * @return
- */
- protected String getFileExtensionForLanguage(String language){
- Map languageSpecificPropertyMap = (Map)ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
- Iterator keys = languageSpecificPropertyMap.keySet().iterator();
- String key;
- String extension = null;
- while (keys.hasNext()) {
- //check for template entries
- key = keys.next().toString();
- if (key.endsWith(EXTENSION_SUFFIX)){
- extension = languageSpecificPropertyMap.get(key).toString();
- //add a . to the front
- extension = "." + extension;
- }
- }
-
- return extension;
- }
-
- /**
- * Writes the output file
- *
- * @param documentStream
- * @throws Exception
- */
- public void writeOutFile(InputStream documentStream) throws Exception {
- XSLTTemplateProcessor.parse(this.stream,
- documentStream,
- this.xsltStream);
- this.stream.flush();
- this.stream.close();
-
-
- }
-
-
-}
+package org.apache.axis2.wsdl.codegen.writer;
+
+import org.apache.axis2.wsdl.codegen.XSLTConstants;
+import org.apache.axis2.wsdl.codegen.CodeGenerationException;
+import org.apache.axis2.wsdl.util.FileWriter;
+import org.apache.axis2.wsdl.util.XSLTTemplateProcessor;
+import org.apache.axis2.wsdl.util.ConfigPropertyFileLoader;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Enumeration;
+import java.util.Iterator;
+
+/*
+* 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.
+*
+*
+* Abstract writer to be extended by writers. To use a class writer one needs to call the
+* methods in order
+* ususally it is setLanguage() ->loadTemplate() ->createOutFile() ->WriteOutFile()
+*/
+
+public abstract class ClassWriter {
+
+ protected File outputFileLocation = null;
+ protected FileOutputStream stream = null;
+ protected InputStream xsltStream = null;
+ protected String language = ConfigPropertyFileLoader.getDefaultLanguage(); //default would java
+
+ protected static final String TEMPLATE_SUFFIX = ".template";
+ protected static final String EXTENSION_SUFFIX = ".extension";
+ protected static final String SEPERATOR_STRING = ",";
+
+ /**
+ * Sets the language
+ *
+ * @param language
+ */
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ /**
+ * Load the template
+ */
+ public void loadTemplate() throws CodeGenerationException{
+ // the default behavior for the class writers is to use the property map from the languge specific types
+ // The properties are arranged in the following order
+ // <lang-name>.* .template=<write-class>,<template-name>
+
+ //first get the language specific property map
+ Class clazz = this.getClass();
+ Map languageSpecificPropertyMap = (Map)ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
+ if (languageSpecificPropertyMap==null){
+ throw new CodeGenerationException("No language specific properties!!!");
+ }
+
+ String templateName = findTemplate(languageSpecificPropertyMap);
+ if (templateName!=null){
+ this.xsltStream = clazz.getResourceAsStream(templateName);
+ }else{
+ throw new CodeGenerationException("template for this writer is not found");
+ }
+
+
+ }
+
+ protected String findTemplate(Map languageSpecificPropertyMap) {
+ //search through the proprty names to find the template relevant to this class
+
+ String ownClazzName = this.getClass().getName();
+ String key;
+ String propertyValue;
+ String templateName = null;
+ Iterator keys = languageSpecificPropertyMap.keySet().iterator();
+
+ while (keys.hasNext()) {
+ //check for template entries
+ key = keys.next().toString();
+ if (key.endsWith(TEMPLATE_SUFFIX)){
+ // check if the class name is there
+ propertyValue = languageSpecificPropertyMap.get(key).toString();
+ if (propertyValue.startsWith(ownClazzName)){
+ //bingo! we found the right template
+ templateName = propertyValue.substring(propertyValue.indexOf(SEPERATOR_STRING)+1) ;
+ break;
+ }
+ }
+
+ }
+ return templateName;
+ }
+
+ /**
+ * Creates the output file
+ *
+ * @param packageName
+ * @param fileName
+ * @throws Exception
+ */
+ public void createOutFile(String packageName, String fileName) throws Exception {
+ File outputFile = FileWriter.createClassFile(outputFileLocation,
+ packageName,
+ fileName,
+ getFileExtensionForLanguage(language));
+ this.stream = new FileOutputStream(outputFile);
+ }
+
+ /**
+ * Find the file name extension
+ * @param language
+ * @return
+ */
+ protected String getFileExtensionForLanguage(String language){
+ Map languageSpecificPropertyMap = (Map)ConfigPropertyFileLoader.getLanguageSpecificPropertiesMap().get(this.language);
+ Iterator keys = languageSpecificPropertyMap.keySet().iterator();
+ String key;
+ String extension = null;
+ while (keys.hasNext()) {
+ //check for template entries
+ key = keys.next().toString();
+ if (key.endsWith(EXTENSION_SUFFIX)){
+ extension = languageSpecificPropertyMap.get(key).toString();
+ //add a . to the front
+ extension = "." + extension;
+ }
+ }
+
+ return extension;
+ }
+
+ /**
+ * Writes the output file
+ *
+ * @param documentStream
+ * @throws Exception
+ */
+ public void writeOutFile(InputStream documentStream) throws Exception {
+ XSLTTemplateProcessor.parse(this.stream,
+ documentStream,
+ this.xsltStream);
+ this.stream.flush();
+ this.stream.close();
+
+
+ }
+
+
+}
Propchange: webservices/axis2/trunk/java/modules/wsdl/src/org/apache/axis2/wsdl/codegen/writer/ClassWriter.java
------------------------------------------------------------------------------
svn:eol-style = native