diff options
Diffstat (limited to 'branches/sca-java-M2/sca/services/idl/wsdl/src')
31 files changed, 0 insertions, 2889 deletions
diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospector.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospector.java deleted file mode 100644 index 1b9326acab..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospector.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import javax.wsdl.PortType; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; - -/** - * Introspector for creating WSDLServiceContract definitions from WSDL PortTypes. - * - * @version $Rev$ $Date$ - */ -public interface InterfaceWSDLIntrospector { - - /** - * Introspect a WSDL portType and return a service contract definition. - * - * @param type the portType to inspect - * @return a WSDLServiceContract corresponding to the WSDL portType - */ - WSDLServiceContract introspect(PortType portType) throws InvalidServiceContractException; - - /** - * Introspect a WSDL portType and return a service contract definition. - * - * @param type the portType to inspect - * @param callback the callback portType to inspec - * @return a WSDLServiceContract corresponding to the WSDL portType - */ - WSDLServiceContract introspect(PortType type, PortType callback) throws InvalidServiceContractException; -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImpl.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImpl.java deleted file mode 100644 index bbfb3b3d01..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.util.HashMap; -import java.util.Map; - -import javax.wsdl.Operation; -import javax.wsdl.PortType; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.model.InteractionScope; -import org.osoa.sca.annotations.Constructor; - -/** - * Introspector for creating WSDLServiceContract definitions from WSDL PortTypes. - */ -public class InterfaceWSDLIntrospectorImpl implements InterfaceWSDLIntrospector { - public static final String INPUT_PARTS = "idl:input"; - - private WSDLDefinitionRegistry wsdlDefinitionRegistry; - - /** - * @param wsdlDefinitionRegistry - */ - @Constructor("wsdlDefinitionRegistry") - public InterfaceWSDLIntrospectorImpl(@Autowire WSDLDefinitionRegistry wsdlDefinitionRegistry) { - super(); - this.wsdlDefinitionRegistry = wsdlDefinitionRegistry; - } - - // FIXME: Do we want to deal with document-literal wrapped style based on the JAX-WS spec? - protected Map<String, org.apache.tuscany.spi.model.Operation<QName>> introspectOperations(PortType portType) - throws InvalidServiceContractException { - Map<String, org.apache.tuscany.spi.model.Operation<QName>> operations = - new HashMap<String, org.apache.tuscany.spi.model.Operation<QName>>(); - for (Object op : portType.getOperations()) { - Operation wsdlOp = (Operation) op; - operations.put(wsdlOp.getName(), introspectOperation(wsdlOp)); - } - return operations; - } - - protected org.apache.tuscany.spi.model.Operation<QName> introspectOperation(Operation wsdlOp) - throws InvalidServiceContractException { - - WSDLOperation op = new WSDLOperation(wsdlOp, null, wsdlDefinitionRegistry.getSchemaRegistry()); - return op.getOperation(); - } - - /** - * @see org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospector#introspect(javax.wsdl.PortType) - */ - public WSDLServiceContract introspect(PortType portType) throws InvalidServiceContractException { - WSDLServiceContract contract = new WSDLServiceContract(); - contract.setPortType(portType); - contract.setInterfaceName(portType.getQName().getLocalPart()); - contract.setOperations(introspectOperations(portType)); - // FIXME: set to Non-conversational for now - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - return contract; - } - - /** - * @see org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospector#introspect(javax.wsdl.PortType, javax.wsdl.PortType) - */ - public WSDLServiceContract introspect(PortType portType, PortType callbackPortType) - throws InvalidServiceContractException { - assert portType != null : "PortType cannot be null"; - WSDLServiceContract contract = new WSDLServiceContract(); - // FIXME: set to Non-conversational for now - contract.setInteractionScope(InteractionScope.NONCONVERSATIONAL); - contract.setPortType(portType); - contract.setInterfaceName(portType.getQName().getLocalPart()); - contract.setOperations(introspectOperations(portType)); - if (callbackPortType != null) { - contract.setCallbackPortType(callbackPortType); - contract.setCallbackName(callbackPortType.getQName().getLocalPart()); - contract.setCallbackOperations(introspectOperations(callbackPortType)); - } - return contract; - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLLoader.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLLoader.java deleted file mode 100644 index cdb74becfd..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLLoader.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -import javax.wsdl.PortType; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamConstants; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import static org.osoa.sca.Version.XML_NAMESPACE_1_0; -import org.osoa.sca.annotations.Constructor; - -import org.apache.tuscany.spi.annotation.Autowire; -import org.apache.tuscany.spi.component.CompositeComponent; -import org.apache.tuscany.spi.deployer.DeploymentContext; -import org.apache.tuscany.spi.extension.LoaderExtension; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.loader.InvalidValueException; -import org.apache.tuscany.spi.loader.LoaderException; -import org.apache.tuscany.spi.loader.LoaderRegistry; -import org.apache.tuscany.spi.loader.LoaderUtil; -import org.apache.tuscany.spi.loader.MissingResourceException; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.ModelObject; -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * Loads a WSDL interface definition from an XML-based assembly file - * - * @version $Rev$ $Date$ - */ -public class InterfaceWSDLLoader extends LoaderExtension { - public static final QName INTERFACE_WSDL = new QName(XML_NAMESPACE_1_0, "interface.wsdl"); - - private static final String WSDLI = "http://www.w3.org/2006/01/wsdl-instance"; - - private static final String WSDLI_LOCATION = "wsdlLocation"; - - private WSDLDefinitionRegistry wsdlRegistry; - - private InterfaceWSDLIntrospector introspector; - - @Constructor ({ "registry", "wsdlRegistry", "introspector" }) - public InterfaceWSDLLoader(@Autowire LoaderRegistry registry, - @Autowire WSDLDefinitionRegistry wsdlRegistry, - @Autowire InterfaceWSDLIntrospector introspector) { - super(registry); - this.wsdlRegistry = wsdlRegistry; - this.introspector = introspector; - } - - public QName getXMLType() { - return INTERFACE_WSDL; - } - - public WSDLServiceContract load( - CompositeComponent parent, - XMLStreamReader reader, - DeploymentContext deploymentContext) throws XMLStreamException, LoaderException { - assert INTERFACE_WSDL.equals(reader.getName()); - - String interfaceURI = reader.getAttributeValue(null, "interface"); - if (interfaceURI == null) { - throw new InvalidValueException("interface"); - } - - String callbackURI = reader.getAttributeValue(null, "callbackInterface"); - String wsdlLocation = reader.getAttributeValue(WSDLI, WSDLI_LOCATION); - - Map<Class<?>, ModelObject> extensions = new HashMap<Class<?>, ModelObject>(); - while (true) { - int event = reader.next(); - if (event == XMLStreamConstants.START_ELEMENT) { - ModelObject mo = registry.load(parent, reader, deploymentContext); - if (mo != null) { - extensions.put(mo.getClass(), mo); - } - } else if (event == XMLStreamConstants.END_ELEMENT) { - if (reader.getName().equals(INTERFACE_WSDL)) { - break; - } - } - } - // FIXME set the interaction scope - // serviceContract.setInteractionScope(StAXUtil.interactionScope(reader.getAttributeValue(null, "scope"))); - - if (wsdlLocation != null) { - try { - wsdlRegistry.loadDefinition(wsdlLocation, deploymentContext.getClassLoader()); - } catch (IOException e) { - LoaderException le = new LoaderException(e); - le.setIdentifier(wsdlLocation); - throw le; - } catch (WSDLException e) { - LoaderException le = new LoaderException(e); - le.setIdentifier(wsdlLocation); - throw le; - } - } - - PortType portType = getPortType(interfaceURI); - if (portType == null) { - throw new MissingResourceException(interfaceURI); - } - PortType callback = null; - if (callbackURI != null) { - callback = getPortType(callbackURI); - } - try { - WSDLServiceContract contract = introspector.introspect(portType, callback); - DataType<?> dataType = (DataType<?>) extensions.get(DataType.class); - if (dataType != null) { - contract.setDataBinding(dataType.getDataBinding()); - } - contract.getExtensions().putAll(extensions); - return contract; - } catch (InvalidServiceContractException e) { - LoaderException le = new LoaderException(e); - le.setIdentifier(wsdlLocation); - throw le; - } - } - - protected PortType getPortType(String uri) { - // Syntax: <WSDL-namespace-URI>#wsdl.interface(<portTypeOrInterface-name>) - int index = uri.indexOf('#'); - String namespace = uri.substring(0, index); - String name = uri.substring(index + 1); - name = name.substring("wsdl.interface(".length(), name.length() - 1); - QName qname = new QName(namespace, name); - return wsdlRegistry.getPortType(qname); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidFragmentException.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidFragmentException.java deleted file mode 100644 index 55decc9313..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidFragmentException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -/** - * @version $Rev$ $Date$ - */ -public class InvalidFragmentException extends WSDLLoaderException { - public InvalidFragmentException() { - } - - public InvalidFragmentException(String message) { - super(message); - } - - public InvalidFragmentException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidFragmentException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLException.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLException.java deleted file mode 100644 index 17dde17b19..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; - -/** - * An exception to indicate the WSDL definition is invalid - */ -public class InvalidWSDLException extends InvalidServiceContractException { - - /** - * - */ - public InvalidWSDLException() { - } - - /** - * @param message - */ - public InvalidWSDLException(String message) { - super(message); - } - - /** - * @param message - * @param cause - */ - public InvalidWSDLException(String message, Throwable cause) { - super(message, cause); - } - - /** - * @param cause - */ - public InvalidWSDLException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLLocationException.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLLocationException.java deleted file mode 100644 index 7c5ab0bfc1..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/InvalidWSDLLocationException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -/** - * @version $Rev$ $Date$ - */ -public class InvalidWSDLLocationException extends WSDLLoaderException { - public InvalidWSDLLocationException() { - } - - public InvalidWSDLLocationException(String message) { - super(message); - } - - public InvalidWSDLLocationException(String message, Throwable cause) { - super(message, cause); - } - - public InvalidWSDLLocationException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/MissingWSDLException.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/MissingWSDLException.java deleted file mode 100644 index 92a2b2099e..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/MissingWSDLException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -/** - * @version $Rev$ $Date$ - */ -public class MissingWSDLException extends WSDLLoaderException { - public MissingWSDLException() { - } - - public MissingWSDLException(String message) { - super(message); - } - - public MissingWSDLException(String message, Throwable cause) { - super(message, cause); - } - - public MissingWSDLException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/NotSupportedWSDLException.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/NotSupportedWSDLException.java deleted file mode 100644 index 0d69d401f8..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/NotSupportedWSDLException.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; - -/** - * An exception to indicate some WSDL styles that we don't support - */ -public class NotSupportedWSDLException extends InvalidServiceContractException { - - /** - * - */ - public NotSupportedWSDLException() { - } - - /** - * @param message - */ - public NotSupportedWSDLException(String message) { - super(message); - } - - /** - * @param message - * @param cause - */ - public NotSupportedWSDLException(String message, Throwable cause) { - super(message, cause); - } - - /** - * @param cause - */ - public NotSupportedWSDLException(Throwable cause) { - super(cause); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/UnresolveableResourceException.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/UnresolveableResourceException.java deleted file mode 100644 index 0454569e87..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/UnresolveableResourceException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -/** - * @version $Rev$ $Date$ - */ -public class UnresolveableResourceException extends WSDLLoaderException { - public UnresolveableResourceException() { - } - - public UnresolveableResourceException(String message) { - super(message); - } - - public UnresolveableResourceException(String message, Throwable cause) { - super(message, cause); - } - - public UnresolveableResourceException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistry.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistry.java deleted file mode 100644 index 0694811f0d..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistry.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.io.IOException; -import java.net.URL; -import javax.wsdl.Definition; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.WSDLException; -import javax.wsdl.extensions.ExtensionRegistry; -import javax.xml.namespace.QName; - -/** - * A service for caching WSDLs - * - * @version $Rev$ $Date$ - */ -@Deprecated -public interface WSDLDefinitionRegistry { - /** - * Loads and registers a WSDL Definition. - * - * @param namespace the expected namespace, or null if any namespace should be allowed - * @param location the location to load the definition from - * @return the loaded Definition - * @throws IOException if there was a problem reading the document - * @throws WSDLException if there was a problem parsing the definition - */ - Definition loadDefinition(String namespace, URL location) throws IOException, WSDLException; - - /** - * Load and register a WSDL definition as specified in a WSDL2.0 wsdlLocation attribute. - * - * @param wsdlLocation the value of the wsdlLocation attribute - * @param classLoader application classloader used to support relative locations - * @return the loaded Definition - * @throws IOException if there was a problem reading the document - * @throws WSDLException if there was a problem parsing the definition - */ - Definition loadDefinition(String wsdlLocation, ClassLoader classLoader) throws IOException, WSDLException; - - /** - * Returns the PortType with the supplied qualified name, or null if no such port has been defined. - * - * @param name the qualified name of the WSDL portType - * @return the PortType for the supplied name, or null if none has been defined - */ - PortType getPortType(QName name); - - /** - * Returns the ServiceDefinition with the supplied qualified name, or null if no such service has been defined. - * - * @param name the qualified name of the WSDL service - * @return the ServiceDefinition for the supplied name, or null if none has been defined - */ - Service getService(QName name); - - - /** - * Returns the ExtensionRegistry that is used when parsing WSDL documents during the loadDefinition call. - * - * @return the ExtensionRegistry that is used when parsing WSDL documents. - */ - ExtensionRegistry getExtensionRegistry(); - - /** - * Get the XMLSchemaRegistry - * - * @return - */ - XMLSchemaRegistry getSchemaRegistry(); -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryImpl.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryImpl.java deleted file mode 100644 index 976a09caca..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryImpl.java +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import javax.wsdl.Definition; -import javax.wsdl.Import; -import javax.wsdl.PortType; -import javax.wsdl.Service; -import javax.wsdl.WSDLException; -import javax.wsdl.extensions.ExtensionRegistry; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.annotation.Autowire; - -/** - * The default implementation of the runtime WSDL registry - * - * @version $Rev$ $Date$ - */ -public class WSDLDefinitionRegistryImpl implements WSDLDefinitionRegistry { - private final WSDLFactory wsdlFactory; - - private final ExtensionRegistry registry; - - private final Map<URL, Definition> definitionsByLocation = new HashMap<URL, Definition>(); - - private final Map<String, List<Definition>> definitionsByNamespace = new HashMap<String, List<Definition>>(); - - private Monitor monitor; - - private XMLSchemaRegistry schemaRegistry; - - public WSDLDefinitionRegistryImpl() throws WSDLException { - wsdlFactory = WSDLFactory.newInstance(); - registry = wsdlFactory.newPopulatedExtensionRegistry(); - } - - @Autowire - public void setSchemaRegistry(XMLSchemaRegistry schemaRegistry) { - this.schemaRegistry = schemaRegistry; - } - - @org.apache.tuscany.api.annotation.Monitor - public void setMonitor(Monitor monitor) { - this.monitor = monitor; - } - - public ExtensionRegistry getExtensionRegistry() { - return registry; - } - - public Definition loadDefinition(String wsdlLocation, ClassLoader classLoader) throws IOException, WSDLException { - int index = wsdlLocation.indexOf(' '); - if (index == -1) { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Invalid wsdlLocation: " + wsdlLocation); - } - String namespace = wsdlLocation.substring(0, index).trim(); - URL url; - URI uri; - try { - uri = new URI(wsdlLocation.substring(index + 1).trim()); - } catch (URISyntaxException e) { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Invalid wsdlLocation: " + wsdlLocation); - } - if (uri.isAbsolute()) { - url = uri.toURL(); - } else { - url = classLoader.getResource(uri.toString()); - if (url == null) { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Resource not found: " + uri); - } - } - return loadDefinition(namespace, url); - } - - public Definition loadDefinition(String namespace, URL location) throws IOException, WSDLException { - Definition definition = definitionsByLocation.get(location); - if (definition != null) { - // return cached copy - return definition; - } - - if (monitor != null) { - monitor.readingWSDL(namespace, location); - } - WSDLReader reader = wsdlFactory.newWSDLReader(); - reader.setFeature("javax.wsdl.verbose", false); - reader.setExtensionRegistry(registry); - - definition = reader.readWSDL(location.toString()); - String definitionNamespace = definition.getTargetNamespace(); - if (namespace != null && !namespace.equals(definitionNamespace)) { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, namespace + " != " - + definition.getTargetNamespace()); - } - - // Load inline schemas - getSchemaRegistry().loadSchemas(definition); - for (Object i : definition.getImports().values()) { - Import imp = (Import) i; - Definition imported = imp.getDefinition(); - if (imported != null) { - getSchemaRegistry().loadSchemas(imported); - } - } - - if (monitor != null) { - monitor.cachingDefinition(definitionNamespace, location); - } - definitionsByLocation.put(location, definition); - List<Definition> definitions = definitionsByNamespace.get(definitionNamespace); - if (definitions == null) { - definitions = new ArrayList<Definition>(); - definitionsByNamespace.put(definitionNamespace, definitions); - } - definitions.add(definition); - - return definition; - } - - public PortType getPortType(QName name) { - String namespace = name.getNamespaceURI(); - List<Definition> definitions = definitionsByNamespace.get(namespace); - if (definitions == null) { - return null; - } - for (Definition definition : definitions) { - PortType portType = definition.getPortType(name); - if (portType != null) { - return portType; - } - } - return null; - } - - public Service getService(QName name) { - String namespace = name.getNamespaceURI(); - List<Definition> definitions = definitionsByNamespace.get(namespace); - if (definitions == null) { - return null; - } - for (Definition definition : definitions) { - Service service = definition.getService(name); - if (service != null) { - return service; - } - } - return null; - } - - public static interface Monitor { - /** - * Monitor event emitted immediately before an attempt is made to read WSDL for the supplied namespace from the - * supplied location. - * - * @param namespace the target namespace expected in the WSDL; may be null - * @param location the location where we will attempt to read the WSDL definition from - */ - void readingWSDL(String namespace, URL location); - - /** - * Monitor event emitted immediately before registering a WSDL definition in the cache. - * - * @param namespace the target namespace for the WSDL - * @param location the location where the WSDL definition was read from - */ - void cachingDefinition(String namespace, URL location); - } - - public XMLSchemaRegistry getSchemaRegistry() { - if (schemaRegistry == null) { - // Default - schemaRegistry = new XMLSchemaRegistryImpl(); - } - return schemaRegistry; - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoader.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoader.java deleted file mode 100644 index fb90e839f5..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoader.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.net.URI; -import java.util.Collection; -import javax.wsdl.Definition; -import javax.wsdl.PortType; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; - -/** - * Interface for implementations that allow WSDL definitions to be loaded. Currently we do not have a complete solution - * for handling both WSDL2.0 and WSDL1.1 definitions so the current implementation only deals with loading WSDL1.1. This - * will change in the near future (for example when Woden supports both forms) so all WSDL1.1 specific methods are - * deprecated. - * - * @version $Rev$ $Date$ - */ -public interface WSDLLoader { - /** - * Load a WSDL 1.1 Definition for a namespace from one of specified locations. - * - * @param namespace the namespace whose definition should be loaded - * @param locations a set of possible locations to load from - * @return the loaded Definition - * @throws WSDLException if there was a problem loading the definition - */ - @Deprecated - Definition loadDefinition(String namespace, Collection<WSDLLocation> locations) - throws WSDLException, UnresolveableResourceException; - - /** - * Load a WSDL 1.1 Definition from the specified location - * - * @param location the location to load from - * @return the loaded Definition - * @throws WSDLException if there was a problem loading the definition - */ - @Deprecated - Definition loadDefinition(WSDLLocation location) throws WSDLException; - - /** - * Return the WSDL1.1 PortType for the specified interface IRI. - * - * @param interfaceIRI the WSDL2.0 interface IRI - * @param wsdlLocation the location of the WSDL instance - * @param base a Classloader from which to load - * @return the specified port type - */ - @Deprecated - PortType loadPortType(URI interfaceIRI, String wsdlLocation, ClassLoader base) - throws WSDLLoaderException, WSDLException; - - /** - * Parses a WSDL2.0 wsdlLocation attribute definition and returns a Collection of all locations it contains. - * - * @param wsdlLocation a list of namespace/location pairs as specified by WSDL2.0 - * @param base a ClassLoader to use to resolve relative URLs - * @return a collection of locations parsed from the string - * @throws InvalidWSDLLocationException - */ - Collection<WSDLLocation> getLocations(String wsdlLocation, ClassLoader base) throws InvalidWSDLLocationException; - - /** - * Returns the fully qualified name of a WSDL interface parsed from a IRI as defined by WSDL2.0. The value of the - * IRI defines the namespace, the fragment specifies the interface component; for example - * <code>http://example.org/TicketAgent.wsdl20#wsdl.interface(TicketAgent)</code> - * - * @param interfaceIRI the IRI for the interface - * @return the qualified name of the interface - * @throws UnresolveableResourceException if the URI is relative - * @throws InvalidFragmentException if the fragment is incorrectly formed - */ - QName getInterfaceName(URI interfaceIRI) throws UnresolveableResourceException, InvalidFragmentException; - - /** - * Returns an interface parsed from a wsdl.interface fragment. - * - * @param fragment the fragment value - * @return the interface name - * @throws InvalidFragmentException if the fragment is incorrectly formed - */ - String getInterfaceName(String fragment) throws InvalidFragmentException; - - /** - * Returns a namespace parsed from an IRI. This is the URI with any fragment removed. - * - * @param iri the IRI - * @return a namespace created by stripping fragment information from the URI - * @throws UnresolveableResourceException if the URI is relative - */ - String getNamespace(URI iri) throws UnresolveableResourceException; -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderException.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderException.java deleted file mode 100644 index 47a4b8ef1f..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderException.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import org.apache.tuscany.api.TuscanyException; - -/** - * @version $Rev$ $Date$ - */ -public abstract class WSDLLoaderException extends TuscanyException { - protected WSDLLoaderException() { - } - - protected WSDLLoaderException(String message) { - super(message); - } - - protected WSDLLoaderException(String message, Throwable cause) { - super(message, cause); - } - - protected WSDLLoaderException(Throwable cause) { - super(cause); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImpl.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImpl.java deleted file mode 100644 index cdf69fa1e8..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImpl.java +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import javax.wsdl.Definition; -import javax.wsdl.PortType; -import javax.wsdl.WSDLException; -import javax.wsdl.extensions.ExtensionRegistry; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.xml.namespace.QName; - -/** - * @version $Rev$ $Date$ - */ -public class WSDLLoaderImpl implements WSDLLoader { - private final WSDLFactory wsdlFactory; - - private final ExtensionRegistry registry; - - public WSDLLoaderImpl() throws WSDLException { - wsdlFactory = WSDLFactory.newInstance(); - registry = wsdlFactory.newPopulatedExtensionRegistry(); - } - - public PortType loadPortType(URI interfaceIRI, String wsdlLocation, ClassLoader base) - throws WSDLLoaderException, WSDLException { - Collection<WSDLLocation> locations = getLocations(wsdlLocation, base); - QName interfaceName = getInterfaceName(interfaceIRI); - - Definition definition = loadDefinition(interfaceName.getNamespaceURI(), locations); - return definition.getPortType(interfaceName); - } - - public Definition loadDefinition(String namespace, Collection<WSDLLocation> locations) - throws WSDLException, UnresolveableResourceException { - for (WSDLLocation location : locations) { - if (namespace.equals(location.getNamespace()) && location.getLocation() != null) { - return loadDefinition(location); - } - } - throw new UnresolveableResourceException(namespace); - } - - public Definition loadDefinition(WSDLLocation location) throws WSDLException { - String namespace = location.getNamespace(); - - WSDLReader reader = wsdlFactory.newWSDLReader(); - reader.setFeature("javax.wsdl.verbose", false); - reader.setExtensionRegistry(registry); - - Definition definition = reader.readWSDL(location.getLocation().toString()); - String definitionNamespace = definition.getTargetNamespace(); - if (namespace != null && !namespace.equals(definitionNamespace)) { - throw new WSDLException(WSDLException.CONFIGURATION_ERROR, namespace + " != " - + definition.getTargetNamespace()); - } - return definition; - } - - public Collection<WSDLLocation> getLocations(String wsdlLocation, ClassLoader base) - throws InvalidWSDLLocationException { - String parts[] = wsdlLocation.split("\\s"); - // check the number of parts is a multiple of two - if ((parts.length & 1) != 0) { - throw new InvalidWSDLLocationException(wsdlLocation); - } - List<WSDLLocation> locations = new ArrayList<WSDLLocation>(parts.length >>> 1); - for (int i = 0; i < parts.length; i += 2) { - URL url; - try { - URI uri = new URI(parts[i + 1]); - if (uri.isAbsolute()) { - url = uri.toURL(); - } else { - url = base.getResource(uri.toString()); - } - } catch (MalformedURLException e) { - throw new InvalidWSDLLocationException(e); - } catch (URISyntaxException e) { - throw new InvalidWSDLLocationException(e); - } - WSDLLocation location = new WSDLLocation(parts[i], url); - locations.add(location); - } - return locations; - } - - public QName getInterfaceName(URI interfaceIRI) throws UnresolveableResourceException, InvalidFragmentException { - String namespace = getNamespace(interfaceIRI); - String interfaceName = getInterfaceName(interfaceIRI.getFragment()); - return new QName(namespace, interfaceName); - } - - public String getInterfaceName(String fragment) throws InvalidFragmentException { - if (fragment == null) { - throw new InvalidFragmentException("missing fragment"); - } - String[] parts = fragment.split("\\s"); - for (String part : parts) { - if (part.startsWith("wsdl.interface(") && part.charAt(part.length() - 1) == ')') { - return part.substring(15, part.length() - 1); - } - } - throw new InvalidFragmentException(fragment); - } - - public String getNamespace(URI iri) throws UnresolveableResourceException { - if (!iri.isAbsolute()) { - UnresolveableResourceException ure = new UnresolveableResourceException("no namespace defined in " + iri); - ure.setIdentifier(iri.toString()); - throw ure; - } - StringBuilder s = new StringBuilder(); - s.append(iri.getScheme()); - s.append(':'); - s.append(iri.getSchemeSpecificPart()); - return s.toString(); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLocation.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLocation.java deleted file mode 100644 index a124294c3a..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLLocation.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.net.URL; - -/** - * A location where the WSDL for a namespace can be found. - * - * @version $Rev$ $Date$ - */ -public class WSDLLocation { - private final String namespace; - private final URL location; - - /** - * Constructor specifying a namespace and where its WSDL can be found. - * - * @param namespace the target namespace - * @param location the location of the WSDL - */ - public WSDLLocation(String namespace, URL location) { - this.namespace = namespace; - this.location = location; - } - - /** - * Returns the target namespace. - * - * @return the target namespace - */ - public String getNamespace() { - return namespace; - } - - /** - * Returns the location where the WSDL definition can be found. - * - * @return the location where the WSDL definition can be found - */ - public URL getLocation() { - return location; - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java deleted file mode 100644 index 75fe1b9964..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLOperation.java +++ /dev/null @@ -1,500 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import javax.wsdl.Fault; -import javax.wsdl.Input; -import javax.wsdl.Message; -import javax.wsdl.Operation; -import javax.wsdl.Output; -import javax.wsdl.Part; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.idl.TypeInfo; -import org.apache.tuscany.spi.idl.WrapperInfo; -import org.apache.tuscany.spi.model.DataType; -import org.apache.ws.commons.schema.XmlSchemaComplexType; -import org.apache.ws.commons.schema.XmlSchemaElement; -import org.apache.ws.commons.schema.XmlSchemaObject; -import org.apache.ws.commons.schema.XmlSchemaObjectCollection; -import org.apache.ws.commons.schema.XmlSchemaParticle; -import org.apache.ws.commons.schema.XmlSchemaSequence; -import org.apache.ws.commons.schema.XmlSchemaSimpleType; -import org.apache.ws.commons.schema.XmlSchemaType; - -/** - * Metadata for a WSDL operation - */ -public class WSDLOperation { - private static final String OPERATION_KEY = org.apache.tuscany.spi.model.Operation.class.getName(); - - protected XMLSchemaRegistry schemaRegistry; - - protected Operation operation; - - private String dataBinding; - - protected org.apache.tuscany.spi.model.Operation<QName> operationModel; - - protected DataType<List<DataType<QName>>> inputType; - - protected DataType<QName> outputType; - - protected List<DataType<QName>> faultTypes; - - /** - * @param operation The WSDL4J operation - * @param dataBinding The default databinding - * @param schemaRegistry The XML Schema registry - */ - public WSDLOperation(Operation operation, String dataBinding, XMLSchemaRegistry schemaRegistry) { - super(); - this.operation = operation; - this.dataBinding = dataBinding; - this.schemaRegistry = schemaRegistry; - this.wrapper = new Wrapper(); - } - - private Wrapper wrapper; - - private Boolean wrapperStyle; - - /** - * Test if the operation qualifies wrapper style as defined by the JAX-WS 2.0 spec - * - * @return true if the operation qualifies wrapper style, otherwise false - */ - public boolean isWrapperStyle() { - if (wrapperStyle == null) { - wrapperStyle = - Boolean.valueOf(wrapper.getInputChildElements() != null - && (operation.getOutput() == null || wrapper.getOutputChildElements() != null)); - } - return wrapperStyle.booleanValue(); - } - - public Wrapper getWrapper() { - if (!isWrapperStyle()) { - throw new IllegalStateException("The operation is not wrapper style."); - } else { - return wrapper; - } - } - - /** - * @return - * @throws InvalidServiceContractException - */ - public DataType<List<DataType<QName>>> getInputType() throws InvalidServiceContractException { - if (inputType == null) { - Input input = operation.getInput(); - Message message = (input == null) ? null : input.getMessage(); - inputType = getMessageType(message); - inputType.setDataBinding("idl:input"); - } - return inputType; - } - - /** - * @return - * @throws NotSupportedWSDLException - */ - public DataType<QName> getOutputType() throws InvalidServiceContractException { - if (outputType == null) { - Output output = operation.getOutput(); - Message outputMsg = (output == null) ? null : output.getMessage(); - - List outputParts = (outputMsg == null) ? null : outputMsg.getOrderedParts(null); - if (outputParts != null && outputParts.size() > 0) { - if (outputParts.size() > 1) { - // We don't support output with multiple parts - throw new NotSupportedWSDLException("Multi-part output is not supported"); - } - Part part = (Part) outputParts.get(0); - outputType = new WSDLPart(part).getDataType(); - // outputType.setMetadata(WSDLOperation.class.getName(), this); - } - } - return outputType; - } - - /** - * @return - * @throws NotSupportedWSDLException - */ - public List<DataType<QName>> getFaultTypes() throws InvalidServiceContractException { - if (faultTypes == null) { - Collection faults = operation.getFaults().values(); - faultTypes = new ArrayList<DataType<QName>>(); - for (Object f : faults) { - Fault fault = (Fault) f; - Message faultMsg = fault.getMessage(); - List faultParts = faultMsg.getOrderedParts(null); - if (faultParts.size() != 1) { - throw new NotSupportedWSDLException("The fault message MUST have a single part"); - } - Part part = (Part) faultParts.get(0); - WSDLPart wsdlPart = new WSDLPart(part); - faultTypes.add(wsdlPart.getDataType()); - } - } - return faultTypes; - } - - private DataType<List<DataType<QName>>> getMessageType(Message message) throws InvalidServiceContractException { - List<DataType<QName>> partTypes = new ArrayList<DataType<QName>>(); - if (message != null) { - Collection parts = message.getOrderedParts(null); - for (Object p : parts) { - WSDLPart part = new WSDLPart((Part) p); - DataType<QName> partType = part.getDataType(); - partTypes.add(partType); - } - } - return new DataType<List<DataType<QName>>>(dataBinding, Object[].class, partTypes); - } - - /** - * @return - * @throws NotSupportedWSDLException - */ - public org.apache.tuscany.spi.model.Operation<QName> getOperation() throws InvalidServiceContractException { - if (operationModel == null) { - boolean oneway = (operation.getOutput() == null); - operationModel = - new org.apache.tuscany.spi.model.Operation<QName>(operation.getName(), getInputType(), - getOutputType(), getFaultTypes(), oneway, dataBinding); - operationModel.setWrapperStyle(isWrapperStyle()); - // operationModel.setMetaData(WSDLOperation.class.getName(), this); - if (isWrapperStyle()) { - operationModel.setWrapper(getWrapper().getWrapperInfo()); - // Register the operation with the types - for (DataType<?> d : wrapper.getUnwrappedInputType().getLogical()) { - d.setMetadata(OPERATION_KEY, operationModel); - } - if (wrapper.getUnwrappedOutputType() != null) { - wrapper.getUnwrappedOutputType().setMetadata(OPERATION_KEY, operationModel); - } - } - } - inputType.setMetadata(OPERATION_KEY, operationModel); - if (outputType != null) { - outputType.setMetadata(OPERATION_KEY, operationModel); - } - return operationModel; - } - - /** - * Metadata for a WSDL part - */ - public class WSDLPart { - private Part part; - - private XmlSchemaElement element; - - private DataType<QName> dataType; - - public WSDLPart(Part part) throws InvalidWSDLException { - this.part = part; - QName elementName = part.getElementName(); - if (elementName != null) { - element = schemaRegistry.getElement(elementName); - if (element == null) { - throw new InvalidWSDLException("Element cannot be resolved: " + elementName); - } - } else { - // Create an faked XSD element to host the metadata - element = new XmlSchemaElement(); - element.setName(part.getName()); - element.setQName(new QName(null, part.getName())); - QName typeName = part.getTypeName(); - if (typeName != null) { - XmlSchemaType type = schemaRegistry.getType(typeName); - if (type == null) { - throw new InvalidWSDLException("Type cannot be resolved: " + typeName); - } - element.setSchemaType(type); - element.setSchemaTypeName(type.getQName()); - } - } - dataType = new DataType<QName>(dataBinding, Object.class, element.getQName()); - // dataType.setMetadata(WSDLPart.class.getName(), this); - dataType.setMetadata(ElementInfo.class.getName(), getElementInfo(element)); - } - - /** - * @return the element - */ - public XmlSchemaElement getElement() { - return element; - } - - /** - * @return the part - */ - public Part getPart() { - return part; - } - - /** - * @return the dataType - */ - public DataType<QName> getDataType() { - return dataType; - } - } - - /** - * The "Wrapper Style" WSDL operation is defined by The Java API for XML-Based Web Services (JAX-WS) 2.0 - * specification, section 2.3.1.2 Wrapper Style. - * <p> - * A WSDL operation qualifies for wrapper style mapping only if the following criteria are met: - * <ul> - * <li>(i) The operation’s input and output messages (if present) each contain only a single part - * <li>(ii) The input message part refers to a global element declaration whose localname is equal to the operation - * name - * <li>(iii) The output message part refers to a global element declaration - * <li>(iv) The elements referred to by the input and output message parts (henceforth referred to as wrapper - * elements) are both complex types defined using the xsd:sequence compositor - * <li>(v) The wrapper elements only contain child elements, they must not contain other structures such as - * wildcards (element or attribute), xsd:choice, substitution groups (element references are not permitted) or - * attributes; furthermore, they must not be nillable. - * </ul> - */ - public class Wrapper { - private XmlSchemaElement inputWrapperElement; - - private XmlSchemaElement outputWrapperElement; - - private List<XmlSchemaElement> inputElements; - - private List<XmlSchemaElement> outputElements; - - private DataType<List<DataType<QName>>> unwrappedInputType; - - private DataType<QName> unwrappedOutputType; - - private transient WrapperInfo wrapperInfo; - - private List<XmlSchemaElement> getChildElements(XmlSchemaElement element) { - if (element == null) { - return null; - } - XmlSchemaType type = element.getSchemaType(); - if (!(type instanceof XmlSchemaComplexType)) { - // Has to be a complexType - return null; - } - XmlSchemaComplexType complexType = (XmlSchemaComplexType) type; - if (complexType.getAttributes().getCount() != 0 || complexType.getAnyAttribute() != null) { - // No attributes - return null; - } - XmlSchemaParticle particle = complexType.getParticle(); - if (particle == null) { - // No particle - return Collections.emptyList(); - } - if (!(particle instanceof XmlSchemaSequence)) { - return null; - } - XmlSchemaSequence sequence = (XmlSchemaSequence) complexType.getParticle(); - XmlSchemaObjectCollection items = sequence.getItems(); - List<XmlSchemaElement> childElements = new ArrayList<XmlSchemaElement>(); - for (int i = 0; i < items.getCount(); i++) { - XmlSchemaObject schemaObject = items.getItem(i); - if (!(schemaObject instanceof XmlSchemaElement)) { - return null; - } - XmlSchemaElement childElement = (XmlSchemaElement) schemaObject; - if (childElement.getName() == null || childElement.getRefName() != null || childElement.isNillable()) { - return null; - } - // TODO: Do we support maxOccurs >1 ? - if (childElement.getMaxOccurs() > 1) { - return null; - } - childElements.add(childElement); - } - return childElements; - } - - /** - * Return a list of child XSD elements under the wrapped request element - * - * @return a list of child XSD elements or null if if the request element is not wrapped - */ - public List<XmlSchemaElement> getInputChildElements() { - if (inputElements != null) { - return inputElements; - } - Input input = operation.getInput(); - if (input != null) { - Message inputMsg = input.getMessage(); - Collection parts = inputMsg.getParts().values(); - if (parts.size() != 1) { - return null; - } - Part part = (Part) parts.iterator().next(); - QName elementName = part.getElementName(); - if (elementName == null) { - return null; - } - if (!operation.getName().equals(elementName.getLocalPart())) { - return null; - } - inputWrapperElement = schemaRegistry.getElement(elementName); - if (inputWrapperElement == null) { - return null; - } - inputElements = getChildElements(inputWrapperElement); - return inputElements; - } else { - return null; - } - } - - /** - * Return a list of child XSD elements under the wrapped response element - * - * @return a list of child XSD elements or null if if the response element is not wrapped - */ - public List<XmlSchemaElement> getOutputChildElements() { - if (outputElements != null) { - return outputElements; - } - Output output = operation.getOutput(); - if (output != null) { - Message outputMsg = output.getMessage(); - Collection parts = outputMsg.getParts().values(); - if (parts.size() != 1) { - return null; - } - Part part = (Part) parts.iterator().next(); - QName elementName = part.getElementName(); - if (elementName == null) { - return null; - } - outputWrapperElement = schemaRegistry.getElement(elementName); - if (outputWrapperElement == null) { - return null; - } - outputElements = getChildElements(outputWrapperElement); - // FIXME: Do we support multiple child elements for the response? - return outputElements; - } else { - return null; - } - } - - /** - * @return the inputWrapperElement - */ - public XmlSchemaElement getInputWrapperElement() { - return inputWrapperElement; - } - - /** - * @return the outputWrapperElement - */ - public XmlSchemaElement getOutputWrapperElement() { - return outputWrapperElement; - } - - public DataType<List<DataType<QName>>> getUnwrappedInputType() { - if (unwrappedInputType == null) { - List<DataType<QName>> childTypes = new ArrayList<DataType<QName>>(); - for (XmlSchemaElement element : getInputChildElements()) { - DataType<QName> type = new DataType<QName>(dataBinding, Object.class, element.getQName()); - type.setMetadata(ElementInfo.class.getName(), getElementInfo(element)); - childTypes.add(type); - } - unwrappedInputType = - new DataType<List<DataType<QName>>>("idl:unwrapped.input", Object[].class, childTypes); - } - return unwrappedInputType; - } - - public DataType<QName> getUnwrappedOutputType() throws InvalidServiceContractException { - if (unwrappedOutputType == null) { - List<XmlSchemaElement> elements = getOutputChildElements(); - if (elements != null && elements.size() > 0) { - if (elements.size() > 1) { - // We don't support output with multiple parts - throw new NotSupportedWSDLException("Multi-part output is not supported"); - } - XmlSchemaElement element = elements.get(0); - unwrappedOutputType = new DataType<QName>(dataBinding, Object.class, element.getQName()); - unwrappedOutputType.setMetadata(ElementInfo.class.getName(), getElementInfo(element)); - } - } - return unwrappedOutputType; - } - - public WrapperInfo getWrapperInfo() throws InvalidServiceContractException { - if (wrapperInfo == null) { - ElementInfo in = getElementInfo(getInputWrapperElement()); - ElementInfo out = getElementInfo(getOutputWrapperElement()); - List<ElementInfo> inChildren = new ArrayList<ElementInfo>(); - for (XmlSchemaElement e : getInputChildElements()) { - inChildren.add(getElementInfo(e)); - } - List<ElementInfo> outChildren = new ArrayList<ElementInfo>(); - if (out != null) { - for (XmlSchemaElement e : getOutputChildElements()) { - outChildren.add(getElementInfo(e)); - } - } - wrapperInfo = - new WrapperInfo(in, out, inChildren, outChildren, getUnwrappedInputType(), getUnwrappedOutputType()); - } - return wrapperInfo; - } - } - - private static ElementInfo getElementInfo(XmlSchemaElement element) { - if (element == null) { - return null; - } - return new ElementInfo(element.getQName(), getTypeInfo(element.getSchemaType())); - } - - private static TypeInfo getTypeInfo(XmlSchemaType type) { - if (type == null) { - return null; - } - XmlSchemaType baseType = (XmlSchemaType) type.getBaseSchemaType(); - QName name = type.getQName(); - boolean simple = (type instanceof XmlSchemaSimpleType); - if (baseType == null) { - return new TypeInfo(name, simple, null); - } else { - return new TypeInfo(name, simple, getTypeInfo(baseType)); - } - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLServiceContract.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLServiceContract.java deleted file mode 100644 index 868ad0f3b4..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLServiceContract.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import javax.wsdl.PortType; -import javax.xml.namespace.QName; - -import org.apache.tuscany.spi.model.ServiceContract; - -/** - * Represents a service contract specified by a WSDL - * - * @version $Rev$ $Date$ - */ -public class WSDLServiceContract extends ServiceContract<QName> { - private PortType portType; - private PortType callbackPortType; - - /** - * - */ - public WSDLServiceContract() { - super(); - this.remotable = true; // WSDL interface is always remotable by the SCA spec - } - - - public PortType getPortType() { - return portType; - } - - public void setPortType(PortType portType) { - this.portType = portType; - } - - public PortType getCallbackPortType() { - return callbackPortType; - } - - public void setCallbackPortType(PortType callbackPortType) { - this.callbackPortType = callbackPortType; - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistry.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistry.java deleted file mode 100644 index 681e08be4d..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistry.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.io.IOException; -import java.net.URL; -import java.util.List; - -import javax.wsdl.Definition; -import javax.xml.namespace.QName; - -import org.apache.ws.commons.schema.XmlSchema; -import org.apache.ws.commons.schema.XmlSchemaElement; -import org.apache.ws.commons.schema.XmlSchemaException; -import org.apache.ws.commons.schema.XmlSchemaType; - -/** - * A service for caching XML Schemas - * - * @version $Rev$ $Date$ - */ -public interface XMLSchemaRegistry { - /** - * Load all inline schemas from the WSDL definition - * - * @param definition The WSDL defintion whose types element contains a list of schemas - * @return A list of inline schemas - */ - List<XmlSchema> loadSchemas(Definition definition); - - /** - * Loads and registers a XML schema. - * - * @param namespace the expected namespace, or null if any namespace should be allowed - * @param location the location to load the schema from - * @return the loaded Definition - * @throws IOException if there was a problem reading the document - * @throws XmlSchemaException if there was a problem parsing the schema - */ - XmlSchema loadSchema(String namespace, URL location) throws IOException, XmlSchemaException; - - /** - * Load and register a XML schema as specified in a XSD schemaLocation attribute. - * - * @param schemaLocation the value of the schemaLocation attribute - * @param classLoader application classloader used to support relative locations - * @return the loaded schema - * @throws IOException if there was a problem reading the document - * @throws XmlSchemaException if there was a problem parsing the schema - */ - XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader) throws IOException, XmlSchemaException; - - /** - * Returns the XSD Element with the supplied qualified name, or null if no such element has been defined. - * - * @param name the qualified name of the XSD element - * @return the XSD element for the supplied name, or null if none has been defined - */ - XmlSchemaElement getElement(QName name); - - /** - * Returns the XmlSchemaType with the supplied qualified name, or null if no such type has been defined. - * - * @param name the qualified name of the XSD type - * @return the XSD type for the supplied name, or null if none has been defined - */ - XmlSchemaType getType(QName name); - - - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImpl.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImpl.java deleted file mode 100644 index 08600e4b7e..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImpl.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import javax.wsdl.Definition; -import javax.wsdl.Types; -import javax.wsdl.extensions.schema.Schema; -import javax.xml.namespace.QName; - -import org.apache.ws.commons.schema.XmlSchema; -import org.apache.ws.commons.schema.XmlSchemaCollection; -import org.apache.ws.commons.schema.XmlSchemaElement; -import org.apache.ws.commons.schema.XmlSchemaException; -import org.apache.ws.commons.schema.XmlSchemaType; -import org.osoa.sca.annotations.Service; -import org.w3c.dom.Element; - -/** - * Default implementation of XMLSchemaRegistry - */ -@Service(XMLSchemaRegistry.class) -public class XMLSchemaRegistryImpl implements XMLSchemaRegistry { - private final XmlSchemaCollection collection; - - /** - * @param collection - */ - public XMLSchemaRegistryImpl(XmlSchemaCollection collection) { - super(); - this.collection = collection; - } - - public XMLSchemaRegistryImpl() { - super(); - this.collection = new XmlSchemaCollection(); - } - - public XmlSchemaElement getElement(QName name) { - return collection.getElementByQName(name); - } - - public XmlSchemaType getType(QName name) { - return collection.getTypeByQName(name); - } - - public List<XmlSchema> loadSchemas(Definition definition) { - Types types = definition.getTypes(); - if (types == null) { - return Collections.emptyList(); - } - List<XmlSchema> schemas = new ArrayList<XmlSchema>(); - for (Object ext : types.getExtensibilityElements()) { - if (ext instanceof Schema) { - Element element = ((Schema) ext).getElement(); - XmlSchema s = collection.read(element, element.getBaseURI()); - schemas.add(s); - } - } - return schemas; - } - - public XmlSchema loadSchema(String namespace, URL location) throws IOException, XmlSchemaException { - XmlSchema schema; - XmlSchema[] schemaList = collection.getXmlSchema(location.toExternalForm()); - if (schemaList != null && schemaList.length > 0) { - schema = schemaList[0]; - } else { - InputStream is = location.openStream(); - schema = collection.read(new InputStreamReader(is), null); - is.close(); - } - if (namespace != null && schema != null && !namespace.equals(schema.getTargetNamespace())) { - throw new XmlSchemaException(namespace + " != " + schema.getTargetNamespace()); - } - return schema; - } - - public XmlSchema loadSchema(String schemaLocation, ClassLoader classLoader) throws IOException, XmlSchemaException { - int index = schemaLocation.indexOf(' '); - if (index == -1) { - throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation); - } - String namespace = schemaLocation.substring(0, index).trim(); - URL url; - URI uri; - try { - uri = new URI(schemaLocation.substring(index + 1).trim()); - } catch (URISyntaxException e) { - throw new XmlSchemaException("Invalid schemaLocation: " + schemaLocation); - } - if (uri.isAbsolute()) { - url = uri.toURL(); - } else { - url = classLoader.getResource(uri.toString()); - if (url == null) { - throw new XmlSchemaException("Resource cannot be resolved: schemaLocation: " + schemaLocation); - } - } - return loadSchema(namespace, url); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/default.scdl b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/default.scdl deleted file mode 100644 index 142df15171..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/default.scdl +++ /dev/null @@ -1,50 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
--->
-<!--
- IDL WSDL extension
-
- $Rev: 440894 $ $Date: 2006-09-06 15:52:01 -0700 (Wed, 06 Sep 2006) $
--->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
- name="org.apache.tuscany.idl.wsdl">
-
- <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
- <group>org.apache.tuscany.sca.services.idl</group>
- <name>wsdl</name>
- <version>1.0-incubator-M2-SNAPSHOT</version>
- </dependency>
-
- <component name="interface.wsdl.Loader">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLLoader" />
- </component>
-
- <component name="wsdl.Registry">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl" initLevel="40" />
- </component>
-
- <component name="xmlSchema.registry">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl" initLevel="35" />
- </component>
-
- <component name="interface.wsdl.Introspector">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospectorImpl" initLevel="40" />
- </component>
-
-</composite>
\ No newline at end of file diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/idl.wsdl.scdl b/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/idl.wsdl.scdl deleted file mode 100644 index 28b3458bf1..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/main/resources/META-INF/sca/idl.wsdl.scdl +++ /dev/null @@ -1,52 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
--->
-<!--
- IDL WSDL extension
-
- This is a copy to be included by other extensions
-
- $Rev: 440894 $ $Date: 2006-09-06 15:52:01 -0700 (Wed, 06 Sep 2006) $
--->
-<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" xmlns:system="http://incubator.apache.org/tuscany/xmlns/system/1.0-incubator-M2"
- name="org.apache.tuscany.idl.wsdl.include">
-
- <dependency xmlns="http://incubator.apache.org/tuscany/xmlns/1.0-incubator-M2">
- <group>org.apache.tuscany.sca.services.idl</group>
- <name>wsdl</name>
- <version>1.0-incubator-M2-SNAPSHOT</version>
- </dependency>
-
- <component name="interface.wsdl.Loader">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLLoader" />
- </component>
-
- <component name="wsdl.Registry">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.WSDLDefinitionRegistryImpl" initLevel="40" />
- </component>
-
- <component name="xmlSchema.registry">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.XMLSchemaRegistryImpl" initLevel="35" />
- </component>
-
- <component name="interface.wsdl.Introspector">
- <system:implementation.system class="org.apache.tuscany.idl.wsdl.InterfaceWSDLIntrospectorImpl" initLevel="40" />
- </component>
-
-</composite>
\ No newline at end of file diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImplTestCase.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImplTestCase.java deleted file mode 100644 index 8f263607e0..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/InterfaceWSDLIntrospectorImplTestCase.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.net.URL; -import java.util.List; -import java.util.Map; - -import javax.wsdl.Definition; -import javax.wsdl.PortType; -import javax.xml.namespace.QName; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.spi.idl.InvalidServiceContractException; -import org.apache.tuscany.spi.model.DataType; -import org.apache.tuscany.spi.model.Operation; - -/** - * Test case for InterfaceWSDLIntrospectorImpl - */ -public class InterfaceWSDLIntrospectorImplTestCase extends TestCase { - private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); - - private WSDLDefinitionRegistryImpl registry; - private PortType portType; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - registry = new WSDLDefinitionRegistryImpl(); - registry.setSchemaRegistry(new XMLSchemaRegistryImpl()); - URL url = getClass().getResource("stockquote.wsdl"); - Definition definition = registry.loadDefinition(null, url); - portType = definition.getPortType(PORTTYPE_NAME); - } - - public final void testIntrospectPortType() throws InvalidServiceContractException { - InterfaceWSDLIntrospector introspector = new InterfaceWSDLIntrospectorImpl(registry); - WSDLServiceContract contract = introspector.introspect(portType); - Assert.assertEquals(contract.getInterfaceName(), "StockQuotePortType"); - Map<String, Operation<QName>> operations = contract.getOperations(); - Assert.assertEquals(1, operations.size()); - Operation<QName> operation = operations.get("getLastTradePrice"); - Assert.assertNotNull(operation); - DataType<List<DataType<QName>>> inputType = operation.getInputType(); - Assert.assertEquals(1, inputType.getLogical().size()); - DataType<QName> returnType = operation.getOutputType(); - Assert.assertNotNull(returnType); - Assert.assertEquals(0, operation.getFaultTypes().size()); - Assert.assertEquals(1, operation.getWrapper().getInputChildElements().size()); - Assert.assertEquals(1, operation.getWrapper().getOutputChildElements().size()); - } - - public final void testIntrospectPortTypePortType() throws InvalidServiceContractException { - InterfaceWSDLIntrospector introspector = new InterfaceWSDLIntrospectorImpl(registry); - WSDLServiceContract contract = introspector.introspect(portType, portType); - Assert.assertEquals("StockQuotePortType", contract.getInterfaceName()); - Assert.assertEquals("StockQuotePortType", contract.getCallbackName()); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryTestCase.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryTestCase.java deleted file mode 100644 index a7d7457f76..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLDefinitionRegistryTestCase.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.io.IOException; -import java.net.URL; -import javax.wsdl.Definition; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; - -import junit.framework.TestCase; -import junit.framework.Assert; - -/** - * Verifies the default WSDL registry implementation - * - * @version $Rev$ $Date$ - */ -public class WSDLDefinitionRegistryTestCase extends TestCase { - private static final String NS = "http://www.example.org"; - private static final WSDLDefinitionRegistryImpl.Monitor NULL_MONITOR = new WSDLDefinitionRegistryImpl.Monitor() { - public void readingWSDL(String namespace, URL location) { - } - - public void cachingDefinition(String namespace, URL location) { - } - }; - private WSDLDefinitionRegistryImpl wsdlRegistry; - private ClassLoader cl; - private URL exampleWsdl; - - - public void testLoadFromAbsoluteWSDLLocation() { - try { - Definition def = wsdlRegistry.loadDefinition(NS + ' ' + exampleWsdl, cl); - Assert.assertNotNull(def.getPortType(new QName(NS, "HelloWorld"))); - } catch (IOException e) { - Assert.fail(e.getMessage()); - } catch (WSDLException e) { - Assert.fail(e.getMessage()); - } - } - - public void testLoadFromRelativeWSDLLocation() { - try { - Definition def = wsdlRegistry.loadDefinition(NS + " org/apache/tuscany/idl/wsdl/example.wsdl", cl); - Assert.assertNotNull(def.getPortType(new QName(NS, "HelloWorld"))); - } catch (IOException e) { - Assert.fail(e.getMessage()); - } catch (WSDLException e) { - Assert.fail(e.getMessage()); - } - } - - protected void setUp() throws Exception { - super.setUp(); - wsdlRegistry = new WSDLDefinitionRegistryImpl(); - wsdlRegistry.setSchemaRegistry(new XMLSchemaRegistryImpl()); - wsdlRegistry.setMonitor(NULL_MONITOR); - exampleWsdl = getClass().getResource("example.wsdl"); - cl = getClass().getClassLoader(); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImplTestCase.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImplTestCase.java deleted file mode 100644 index c05cf9770f..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLLoaderImplTestCase.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.net.URI; - -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -/** - * @version $Rev$ $Date$ - */ -public class WSDLLoaderImplTestCase extends TestCase { - private WSDLLoaderImpl loader; - private URI exampleURI; - private QName exampleName; - - public void testGetNamespace() throws UnresolveableResourceException { - assertEquals("http://example.org/TicketAgent.wsdl20", loader.getNamespace(exampleURI)); - } - - public void testGetInterfaceNameFromFragment() throws UnresolveableResourceException, InvalidFragmentException { - assertEquals("TicketAgent", loader.getInterfaceName("wsdl.interface(TicketAgent)")); - } - - public void testGetInterfaceNameFromURI() throws UnresolveableResourceException, InvalidFragmentException { - assertEquals(exampleName, loader.getInterfaceName(exampleURI)); - } - - protected void setUp() throws Exception { - super.setUp(); - loader = new WSDLLoaderImpl(); - exampleURI = URI.create("http://example.org/TicketAgent.wsdl20#wsdl.interface(TicketAgent)"); - exampleName = new QName("http://example.org/TicketAgent.wsdl20", "TicketAgent"); - } -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java deleted file mode 100644 index b77e88d408..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WSDLOperationTestCase.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.net.URL; -import java.util.List; - -import javax.wsdl.Definition; -import javax.wsdl.Operation; -import javax.wsdl.PortType; -import javax.xml.namespace.QName; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.tuscany.spi.idl.ElementInfo; -import org.apache.tuscany.spi.model.DataType; - -/** - * Test case for WSDLOperation - */ -public class WSDLOperationTestCase extends TestCase { - private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); - - private WSDLDefinitionRegistryImpl registry; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - registry = new WSDLDefinitionRegistryImpl(); - registry.setSchemaRegistry(new XMLSchemaRegistryImpl()); - } - - public final void testWrappedOperation() throws Exception { - URL url = getClass().getResource("stockquote.wsdl"); - Definition definition = registry.loadDefinition(null, url); - PortType portType = definition.getPortType(PORTTYPE_NAME); - Operation operation = portType.getOperation("getLastTradePrice", null, null); - - WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry()); - - DataType<List<DataType<QName>>> inputType = op.getInputType(); - Assert.assertEquals(1, inputType.getLogical().size()); - Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePrice"), inputType.getLogical() - .get(0).getLogical()); - - DataType<QName> outputType = op.getOutputType(); - Assert.assertEquals(new QName("http://example.com/stockquote.xsd", "getLastTradePriceResponse"), outputType - .getLogical()); - Assert.assertTrue(op.isWrapperStyle()); - - DataType<List<DataType<QName>>> unwrappedInputType = op.getWrapper().getUnwrappedInputType(); - List<DataType<QName>> childTypes = unwrappedInputType.getLogical(); - Assert.assertEquals(1, childTypes.size()); - DataType<QName> childType = childTypes.get(0); - Assert.assertEquals(new QName(null, "tickerSymbol"), childType.getLogical()); - ElementInfo element = (ElementInfo) childType.getMetadata(ElementInfo.class.getName()); - Assert.assertNotNull(element); - - childType = op.getWrapper().getUnwrappedOutputType(); - Assert.assertEquals(new QName(null, "price"), childType.getLogical()); - element = (ElementInfo) childType.getMetadata(ElementInfo.class.getName()); - Assert.assertNotNull(element); - } - - public final void testUnwrappedOperation() throws Exception { - URL url = getClass().getResource("unwrapped-stockquote.wsdl"); - Definition definition = registry.loadDefinition(null, url); - PortType portType = definition.getPortType(PORTTYPE_NAME); - - Operation operation = portType.getOperation("getLastTradePrice1", null, null); - WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry()); - Assert.assertFalse(op.isWrapperStyle()); - Assert.assertEquals(1, op.getInputType().getLogical().size()); - - operation = portType.getOperation("getLastTradePrice2", null, null); - op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry()); - Assert.assertFalse(op.isWrapperStyle()); - Assert.assertEquals(2, op.getInputType().getLogical().size()); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WrapperStyleOperationTestCase.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WrapperStyleOperationTestCase.java deleted file mode 100644 index 748c790297..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/WrapperStyleOperationTestCase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.net.URL; - -import javax.wsdl.Definition; -import javax.wsdl.Operation; -import javax.wsdl.PortType; -import javax.xml.namespace.QName; - -import junit.framework.Assert; -import junit.framework.TestCase; - -/** - * Test case for WSDLOperation - */ -public class WrapperStyleOperationTestCase extends TestCase { - private static final QName PORTTYPE_NAME = new QName("http://example.com/stockquote.wsdl", "StockQuotePortType"); - - private WSDLDefinitionRegistryImpl registry; - - /** - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - registry = new WSDLDefinitionRegistryImpl(); - registry.setSchemaRegistry(new XMLSchemaRegistryImpl()); - } - - public final void testWrappedOperation() throws Exception { - URL url = getClass().getResource("stockquote.wsdl"); - Definition definition = registry.loadDefinition(null, url); - PortType portType = definition.getPortType(PORTTYPE_NAME); - Operation operation = portType.getOperation("getLastTradePrice", null, null); - WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry()); - Assert.assertTrue(op.isWrapperStyle()); - Assert.assertEquals(1, op.getWrapper().getInputChildElements().size()); - Assert.assertEquals(1, op.getWrapper().getOutputChildElements().size()); - } - - public final void testUnwrappedOperation() throws Exception { - URL url = getClass().getResource("unwrapped-stockquote.wsdl"); - Definition definition = registry.loadDefinition(null, url); - PortType portType = definition.getPortType(PORTTYPE_NAME); - Operation operation = portType.getOperation("getLastTradePrice1", null, null); - WSDLOperation op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry()); - Assert.assertFalse(op.isWrapperStyle()); - operation = portType.getOperation("getLastTradePrice2", null, null); - op = new WSDLOperation(operation, "org.w3c.dom.Node", registry.getSchemaRegistry()); - Assert.assertFalse(op.isWrapperStyle()); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImplTestCase.java b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImplTestCase.java deleted file mode 100644 index 60433d3bc1..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/java/org/apache/tuscany/idl/wsdl/XMLSchemaRegistryImplTestCase.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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.tuscany.idl.wsdl; - -import java.io.IOException; -import java.net.URL; -import java.util.List; - -import javax.wsdl.Definition; -import javax.xml.namespace.QName; - -import junit.framework.Assert; -import junit.framework.TestCase; - -import org.apache.ws.commons.schema.XmlSchema; -import org.apache.ws.commons.schema.XmlSchemaComplexType; -import org.apache.ws.commons.schema.XmlSchemaElement; -import org.apache.ws.commons.schema.XmlSchemaException; -import org.apache.ws.commons.schema.XmlSchemaObjectCollection; -import org.apache.ws.commons.schema.XmlSchemaSequence; -import org.apache.ws.commons.schema.XmlSchemaType; - -/** - * Verifies the default XSD registry implementation - * - * @version $Rev$ $Date$ - */ -public class XMLSchemaRegistryImplTestCase extends TestCase { - private static final QName PO_ELEMENT_NAME = new QName("http://www.example.com/IPO", "purchaseOrder"); - private static final QName PO_TYPE_NAME = new QName("http://www.example.com/IPO", "PurchaseOrderType"); - - private static final String NS = "http://example.com/stockquote.xsd"; - private static final QName GET_LAST_TRADE_PRICE_ELEMENT_NAME = new QName(NS, "getLastTradePrice"); - - private XMLSchemaRegistryImpl xsdRegistry; - - private WSDLDefinitionRegistryImpl wsdlRegistry; - - private ClassLoader cl; - - private URL wsdl; - - public void testLoadFromAbsoluteWSDLLocation() { - try { - Definition definition = wsdlRegistry.loadDefinition(null, wsdl); - List<XmlSchema> schemas = xsdRegistry.loadSchemas(definition); - Assert.assertTrue(schemas.size() == 1); - XmlSchema schema = schemas.get(0); - XmlSchemaElement element = schema.getElementByName(GET_LAST_TRADE_PRICE_ELEMENT_NAME); - Assert.assertNotNull(element); - XmlSchemaType type = element.getSchemaType(); - XmlSchemaComplexType complexType = (XmlSchemaComplexType) type; - XmlSchemaSequence sequence = (XmlSchemaSequence) complexType.getParticle(); - XmlSchemaObjectCollection items = sequence.getItems(); - Assert.assertTrue(items.getItem(0) instanceof XmlSchemaElement); - } catch (Exception e) { - Assert.fail(e.getMessage()); - } - } - - public void testSchemaLocation() throws IOException { - String schemaLocation = "http://www.example.com/IPO org/apache/tuscany/idl/wsdl/ipo.xsd"; - XmlSchema schema = xsdRegistry.loadSchema(schemaLocation, cl); - Assert.assertNotNull(schema); - Assert.assertNotNull(schema.getElementByName(PO_ELEMENT_NAME)); - Assert.assertNotNull(xsdRegistry.getElement(PO_ELEMENT_NAME)); - Assert.assertNotNull(schema.getTypeByName(PO_TYPE_NAME)); - Assert.assertNotNull(xsdRegistry.getType(PO_TYPE_NAME)); - - - schemaLocation = "http://www.example.com/IPO1 org/apache/tuscany/idl/wsdl/ipo.xsd"; - try { - schema = xsdRegistry.loadSchema(schemaLocation, cl); - Assert.fail(""); - } catch (XmlSchemaException e) { - Assert.assertTrue(e.getMessage().contains("http://www.example.com/IPO1 !=")); - } - } - - protected void setUp() throws Exception { - super.setUp(); - xsdRegistry = new XMLSchemaRegistryImpl(); - wsdlRegistry = new WSDLDefinitionRegistryImpl(); - wsdlRegistry.setSchemaRegistry(xsdRegistry); - wsdl = getClass().getResource("stockquote.wsdl"); - cl = getClass().getClassLoader(); - } - -} diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/example.wsdl b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/example.wsdl deleted file mode 100644 index 5e8e5dad0d..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/example.wsdl +++ /dev/null @@ -1,26 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. ---> -<wsdl:definitions targetNamespace="http://www.example.org" - xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" - name="example"> - - <wsdl:portType name="HelloWorld"> - </wsdl:portType> -</wsdl:definitions> diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/ipo.xsd b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/ipo.xsd deleted file mode 100644 index 241ec15d36..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/ipo.xsd +++ /dev/null @@ -1,136 +0,0 @@ -<!-- - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. ---> -<schema targetNamespace="http://www.example.com/IPO" - xmlns="http://www.w3.org/2001/XMLSchema" - xmlns:ipo="http://www.example.com/IPO"> - - <annotation> - <documentation xml:lang="en"> - International Purchase order schema for Example.com - Copyright 2000 Example.com. All rights reserved. - </documentation> - </annotation> - - - <element name="purchaseOrder" type="ipo:PurchaseOrderType" /> - - <element name="comment" type="string" /> - - <complexType name="PurchaseOrderType"> - <sequence> - <element name="shipTo" type="ipo:Address" /> - <element name="billTo" type="ipo:Address" /> - <element ref="ipo:comment" minOccurs="0" /> - <element name="items" type="ipo:Items" /> - </sequence> - <attribute name="orderDate" type="date" /> - </complexType> - - <complexType name="Items"> - <sequence> - <element name="item" minOccurs="0" maxOccurs="unbounded"> - <complexType> - <sequence> - <element name="productName" type="string" /> - <element name="quantity"> - <simpleType> - <restriction base="positiveInteger"> - <maxExclusive value="100" /> - </restriction> - </simpleType> - </element> - <element name="USPrice" type="decimal" /> - <element ref="ipo:comment" minOccurs="0" /> - <element name="shipDate" type="date" - minOccurs="0" /> - </sequence> - <attribute name="partNum" type="ipo:SKU" - use="required" /> - </complexType> - </element> - </sequence> - </complexType> - - <simpleType name="SKU"> - <restriction base="string"> - <pattern value="\d{3}-[A-Z]{2}" /> - </restriction> - </simpleType> - - <complexType name="Address"> - <sequence> - <element name="name" type="string" /> - <element name="street" type="string" /> - <element name="city" type="string" /> - </sequence> - </complexType> - - <complexType name="USAddress"> - <complexContent> - <extension base="ipo:Address"> - <sequence> - <element name="state" type="ipo:USState" /> - <element name="zip" type="positiveInteger" /> - </sequence> - </extension> - </complexContent> - </complexType> - - <complexType name="UKAddress"> - <complexContent> - <extension base="ipo:Address"> - <sequence> - <element name="postcode" type="ipo:UKPostcode" /> - </sequence> - <attribute name="exportCode" type="positiveInteger" - fixed="1" /> - </extension> - </complexContent> - </complexType> - - <!-- other Address derivations for more countries --> - - <simpleType name="USState"> - <restriction base="string"> - <enumeration value="AK" /> - <enumeration value="AL" /> - <enumeration value="AR" /> - <enumeration value="CA" /> - <enumeration value="PA" /> - <!-- and so on ... --> - </restriction> - </simpleType> - - <simpleType name="Postcode"> - <restriction base="string"> - <length value="7" fixed="true" /> - </restriction> - </simpleType> - - - <simpleType name="UKPostcode"> - <restriction base="ipo:Postcode"> - <pattern value="[A-Z]{2}\d\s\d[A-Z]{2}" /> - </restriction> - </simpleType> - - - -</schema> - diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/stockquote.wsdl b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/stockquote.wsdl deleted file mode 100644 index 78e6bfe785..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/stockquote.wsdl +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
--->
-<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
- xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
- xmlns="http://schemas.xmlsoap.org/wsdl/">
-
- <types>
- <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
- <element name="getLastTradePrice">
- <complexType>
- <sequence>
- <element name="tickerSymbol" type="string" />
- </sequence>
- </complexType>
- </element>
- <element name="getLastTradePriceResponse">
- <complexType>
- <sequence>
- <element name="price" type="float" />
- </sequence>
- </complexType>
- </element>
- </schema>
- </types>
-
- <message name="GetLastTradePriceInput">
- <part name="body" element="xsd1:getLastTradePrice" />
- </message>
-
- <message name="GetLastTradePriceOutput">
- <part name="body" element="xsd1:getLastTradePriceResponse" />
- </message>
-
- <portType name="StockQuotePortType">
- <operation name="getLastTradePrice">
- <input message="tns:GetLastTradePriceInput" />
- <output message="tns:GetLastTradePriceOutput" />
- </operation>
- </portType>
-
-</definitions>
diff --git a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/unwrapped-stockquote.wsdl b/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/unwrapped-stockquote.wsdl deleted file mode 100644 index c74c0c9b64..0000000000 --- a/branches/sca-java-M2/sca/services/idl/wsdl/src/test/resources/org/apache/tuscany/idl/wsdl/unwrapped-stockquote.wsdl +++ /dev/null @@ -1,76 +0,0 @@ -<?xml version="1.0"?>
-<!--
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.
--->
-<definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl"
- xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd1="http://example.com/stockquote.xsd"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns="http://schemas.xmlsoap.org/wsdl/">
-
- <types>
- <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2001/XMLSchema">
- <element name="getLastTradePrice">
- <complexType>
- <sequence>
- <element name="tickerSymbol" type="string" />
- </sequence>
- </complexType>
- </element>
- <element name="getLastTradePriceResponse">
- <complexType>
- <sequence>
- <element name="price" type="float" />
- </sequence>
- </complexType>
- </element>
- </schema>
- </types>
-
- <message name="GetLastTradePriceInput1">
- <part name="body" element="xsd1:getLastTradePrice" />
- </message>
-
- <message name="GetLastTradePriceOutput1">
- <part name="body" element="xsd1:getLastTradePriceResponse" />
- </message>
-
- <message name="GetLastTradePriceInput2">
- <part name="body" element="xsd1:getLastTradePrice" />
- <part name="other" type="xsd:string"/>
- </message>
-
- <message name="GetLastTradePriceOutput2">
- <part name="body" element="xsd1:getLastTradePriceResponse" />
- </message>
-
- <portType name="StockQuotePortType">
- <operation name="getLastTradePrice">
- <input message="tns:GetLastTradePriceInput1" />
- <output message="tns:GetLastTradePriceOutput1" />
- </operation>
- <operation name="getLastTradePrice1">
- <input message="tns:GetLastTradePriceInput1" />
- <output message="tns:GetLastTradePriceOutput1" />
- </operation>
- <operation name="getLastTradePrice2">
- <input message="tns:GetLastTradePriceInput2" />
- <output message="tns:GetLastTradePriceOutput2" />
- </operation>
- </portType>
-
-</definitions>
|