diff options
Diffstat (limited to 'tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly')
16 files changed, 0 insertions, 1219 deletions
diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AbstractLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AbstractLoader.java deleted file mode 100644 index fce343df4b..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AbstractLoader.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import javax.xml.namespace.QName; - -import org.apache.tuscany.core.loader.StAXElementLoader; -import org.apache.tuscany.core.loader.StAXLoaderRegistry; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.osoa.sca.annotations.Destroy; -import org.osoa.sca.annotations.Init; - -/** - * @version $Rev$ $Date$ - */ -public abstract class AbstractLoader<T extends AssemblyObject> implements StAXElementLoader<T> { - protected SystemAssemblyFactory factory; - protected StAXLoaderRegistry registry; - - @Autowire - public void setFactory(SystemAssemblyFactory factory) { - this.factory = factory; - } - - @Autowire - public void setRegistry(StAXLoaderRegistry registry) { - this.registry = registry; - } - - @Init(eager = true) - public void start() { - registry.registerLoader(getXMLType(), this); - } - - @Destroy - public void stop() { - registry.unregisterLoader(getXMLType(), this); - } - - /** - * Returns the QName of the element that this implementation handles. - * @return the QName of the element that this implementation handles - */ - protected abstract QName getXMLType(); -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AssemblyConstants.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AssemblyConstants.java deleted file mode 100644 index 73ef4119f8..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AssemblyConstants.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import javax.xml.namespace.QName; - -/** - * @version $Rev$ $Date$ - */ -public final class AssemblyConstants { - public static final String SCA_NAMESPACE = "http://www.osoa.org/xmlns/sca/0.9"; - - public static final QName COMPONENT = new QName(SCA_NAMESPACE, "component"); - public static final QName COMPONENT_TYPE = new QName(SCA_NAMESPACE, "componentType"); - public static final QName ENTRY_POINT = new QName(SCA_NAMESPACE, "entryPoint"); - public static final QName EXTERNAL_SERVICE = new QName(SCA_NAMESPACE, "externalService"); - public static final QName IMPORT_WSDL = new QName(SCA_NAMESPACE, "import.wsdl"); - public static final QName INTERFACE_JAVA = new QName(SCA_NAMESPACE, "interface.java"); - public static final QName INTERFACE_WSDL = new QName(SCA_NAMESPACE, "interface.wsdl"); - public static final QName MODULE = new QName(SCA_NAMESPACE, "module"); - public static final QName MODULE_FRAGMENT = new QName(SCA_NAMESPACE, "moduleFragment"); - public static final QName PROPERTY = new QName(SCA_NAMESPACE, "property"); - public static final QName PROPERTIES = new QName(SCA_NAMESPACE, "properties"); - public static final QName REFERENCE = new QName(SCA_NAMESPACE, "reference"); - public static final QName REFERENCES = new QName(SCA_NAMESPACE, "references"); - public static final QName SERVICE = new QName(SCA_NAMESPACE, "service"); - public static final QName WIRE = new QName(SCA_NAMESPACE, "wire"); - public static final QName WIRE_SOURCE = new QName(SCA_NAMESPACE, "source.uri"); - public static final QName WIRE_TARGET = new QName(SCA_NAMESPACE, "target.uri"); - - private AssemblyConstants() { - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentLoader.java deleted file mode 100644 index 0fa3e7ddeb..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentLoader.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import java.util.List; -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.core.builder.ObjectFactory; -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.InvalidPropertyFactoryException; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.core.loader.StAXPropertyFactory; -import org.apache.tuscany.core.loader.StAXUtil; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.*; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Component; -import org.apache.tuscany.model.assembly.ComponentType; -import org.apache.tuscany.model.assembly.ConfiguredProperty; -import org.apache.tuscany.model.assembly.ConfiguredReference; -import org.apache.tuscany.model.assembly.Implementation; -import org.apache.tuscany.model.assembly.OverrideOption; -import org.apache.tuscany.model.assembly.Property; -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ComponentLoader extends AbstractLoader { - private StAXPropertyFactory<?> defaultPropertyFactory; - - @Autowire - public void setDefaultPropertyFactory(StAXPropertyFactory<?> defaultPropertyFactory) { - this.defaultPropertyFactory = defaultPropertyFactory; - } - - public QName getXMLType() { - return COMPONENT; - } - - public Component load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert COMPONENT.equals(reader.getName()); - - Component component = factory.createSimpleComponent(); - component.setName(reader.getAttributeValue(null, "name")); - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - QName name = reader.getName(); - if (PROPERTIES.equals(name)) { - loadProperties(reader, loaderContext.getResourceLoader(), component); - } else if (REFERENCES.equals(name)) { - loadReferences(reader, component); - } else { - AssemblyObject o = registry.load(reader, loaderContext); - if (o instanceof Implementation) { - Implementation impl = (Implementation) o; - impl.initialize(registry.getContext()); - component.setImplementation(impl); - } - } - reader.next(); - break; - case END_ELEMENT: - List<Property> props = component.getImplementation().getComponentType().getProperties(); - for (Property property : props) { - if (property.isRequired()) { - if (component.getConfiguredProperty(property.getName()) == null) { - ConfigurationLoadException e = new ConfigurationLoadException("Required property not configured"); - e.setIdentifier(property.getName()); - throw e; - } - } - } - return component; - } - } - } - - protected void loadProperties(XMLStreamReader reader, ResourceLoader resourceLoader, Component<?> component) throws XMLStreamException, ConfigurationLoadException { - ComponentType componentType = component.getImplementation().getComponentType(); - List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties(); - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - String name = reader.getLocalName(); - Property property = componentType.getProperty(name); - if (property == null) { - throw new ConfigurationLoadException(name); - } - OverrideOption override = StAXUtil.overrideOption(reader.getAttributeValue(null, "override"), OverrideOption.NO); - -// get a factory for the property - StAXPropertyFactory<?> propertyFactory; - String factoryName = reader.getAttributeValue(null, "factory"); - if (factoryName == null) { - propertyFactory = defaultPropertyFactory; - } else { - propertyFactory = getPropertyFactory(factoryName, resourceLoader); - } - - // create the property value - // FIXME to support complex types we probably should store the factory in the ConfiguredProperty - // FIXME instead of the value as the value may be mutable and should not be shared between instances - ObjectFactory<?> objectFactory = propertyFactory.createObjectFactory(reader, property); - Object value = objectFactory.getInstance(); - - // create the configured property definition - ConfiguredProperty configuredProperty = factory.createConfiguredProperty(); - configuredProperty.setName(name); - configuredProperty.setValue(value); - configuredProperty.setOverrideOption(override); - configuredProperties.add(configuredProperty); - break; - case END_ELEMENT: - return; - } - } - } - - protected StAXPropertyFactory<?> getPropertyFactory(String factoryName, ResourceLoader resourceLoader) throws InvalidPropertyFactoryException { - Class<?> impl; - try { - // try to load factory from application classloader - impl = resourceLoader.loadClass(factoryName); - } catch (ClassNotFoundException e) { - try { - // try to load factory from container classloader - impl = Class.forName(factoryName); - } catch (ClassNotFoundException e1) { - throw new InvalidPropertyFactoryException(factoryName, e); - } - } - try { - return (StAXPropertyFactory<?>) impl.newInstance(); - } catch (InstantiationException e) { - throw new InvalidPropertyFactoryException(factoryName, e); - } catch (IllegalAccessException e) { - throw new InvalidPropertyFactoryException(factoryName, e); - } catch (ClassCastException e) { - throw new InvalidPropertyFactoryException(factoryName, e); - } - } - - protected void loadReferences(XMLStreamReader reader, Component<?> component) throws XMLStreamException { - List<ConfiguredReference> configuredReferences = component.getConfiguredReferences(); - while (true) { - switch (reader.next()) { - case START_ELEMENT: - String name = reader.getLocalName(); - String uri = reader.getElementText(); - - ConfiguredReference configuredReference = component.getConfiguredReference(name); - if (configuredReference == null) { - configuredReference = factory.createConfiguredReference(); - configuredReference.setName(name); - configuredReferences.add(configuredReference); - } - - configuredReference.getTargets().add(uri); - break; - case END_ELEMENT: - return; - } - } - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoader.java deleted file mode 100644 index fdb8893830..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoader.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.COMPONENT_TYPE; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.ComponentType; -import org.apache.tuscany.model.assembly.Property; -import org.apache.tuscany.model.assembly.Reference; -import org.apache.tuscany.model.assembly.Service; -import org.osoa.sca.annotations.Scope; - -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ComponentTypeLoader extends AbstractLoader { - public QName getXMLType() { - return COMPONENT_TYPE; - } - - public ComponentType load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert COMPONENT_TYPE.equals(reader.getName()); - ComponentType componentType = factory.createComponentType(); - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - AssemblyObject o = registry.load(reader, loaderContext); - if (o instanceof Service) { - componentType.getServices().add((Service) o); - } else if (o instanceof Reference) { - componentType.getReferences().add((Reference) o); - } else if (o instanceof Property) { - componentType.getProperties().add((Property) o); - } - break; - case END_ELEMENT: - return componentType; - } - } - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/CompositeLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/CompositeLoader.java deleted file mode 100644 index 9b22a24784..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/CompositeLoader.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Component; -import org.apache.tuscany.model.assembly.Composite; -import org.apache.tuscany.model.assembly.EntryPoint; -import org.apache.tuscany.model.assembly.ExternalService; -import org.apache.tuscany.model.assembly.ImportWSDL; -import org.apache.tuscany.model.assembly.Wire; - -/** - * @version $Rev$ $Date$ - */ -public abstract class CompositeLoader extends AbstractLoader { - public void loadComposite(XMLStreamReader reader, Composite composite, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - composite.setName(reader.getAttributeValue(null, "name")); - while (true) { - switch (reader.next()) { - case START_ELEMENT: - AssemblyObject o = registry.load(reader, loaderContext); - if (o instanceof EntryPoint) { - composite.getEntryPoints().add((EntryPoint) o); - } else if (o instanceof ExternalService) { - composite.getExternalServices().add((ExternalService) o); - } else if (o instanceof Component) { - composite.getComponents().add((Component) o); - } else if (o instanceof Wire) { - composite.getWires().add((Wire) o); - } else if (o instanceof ImportWSDL) { - composite.getWSDLImports().add((ImportWSDL) o); - } - reader.next(); - break; - case END_ELEMENT: - return; - } - } - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/EntryPointLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/EntryPointLoader.java deleted file mode 100644 index 14b60964d5..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/EntryPointLoader.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.StAXUtil; -import org.apache.tuscany.core.loader.LoaderContext; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.ENTRY_POINT; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Binding; -import org.apache.tuscany.model.assembly.ConfiguredReference; -import org.apache.tuscany.model.assembly.ConfiguredService; -import org.apache.tuscany.model.assembly.EntryPoint; -import org.apache.tuscany.model.assembly.Multiplicity; -import org.apache.tuscany.model.assembly.Reference; -import org.apache.tuscany.model.assembly.Service; -import org.apache.tuscany.model.assembly.ServiceContract; -import org.osoa.sca.annotations.Scope; - -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class EntryPointLoader extends AbstractLoader { - public QName getXMLType() { - return ENTRY_POINT; - } - - public EntryPoint load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert ENTRY_POINT.equals(reader.getName()); - EntryPoint entryPoint = factory.createEntryPoint(); - String name = reader.getAttributeValue(null, "name"); - entryPoint.setName(name); - - Service service = factory.createService(); - service.setName(name); - ConfiguredService configuredService = factory.createConfiguredService(); - configuredService.setPort(service); - entryPoint.setConfiguredService(configuredService); - - Reference reference = factory.createReference(); - reference.setMultiplicity(StAXUtil.multiplicity(reader.getAttributeValue(null, "multiplicity"), Multiplicity.ONE_ONE)); - ConfiguredReference configuredReference = factory.createConfiguredReference(); - configuredReference.setPort(reference); - entryPoint.setConfiguredReference(configuredReference); - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - QName qname = reader.getName(); - if (AssemblyConstants.REFERENCE.equals(qname)) { - String uri = reader.getElementText(); - configuredReference.getTargets().add(uri); - } else { - AssemblyObject o = registry.load(reader, loaderContext); - if (o instanceof Binding) { - entryPoint.getBindings().add((Binding) o); - } else if (o instanceof ServiceContract) { - service.setServiceContract((ServiceContract) o); - reference.setServiceContract((ServiceContract) o); - } - } - reader.next(); - break; - case END_ELEMENT: - return entryPoint; - } - } - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoader.java deleted file mode 100644 index 4910c016d8..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoader.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.StAXUtil; -import org.apache.tuscany.core.loader.LoaderContext; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.EXTERNAL_SERVICE; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Binding; -import org.apache.tuscany.model.assembly.ConfiguredService; -import org.apache.tuscany.model.assembly.ExternalService; -import org.apache.tuscany.model.assembly.OverrideOption; -import org.apache.tuscany.model.assembly.Service; -import org.apache.tuscany.model.assembly.ServiceContract; -import org.osoa.sca.annotations.Scope; - -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ExternalServiceLoader extends AbstractLoader { - public QName getXMLType() { - return EXTERNAL_SERVICE; - } - - public ExternalService load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert EXTERNAL_SERVICE.equals(reader.getName()); - String name = reader.getAttributeValue(null, "name"); - ExternalService externalService = factory.createExternalService(); - externalService.setName(name); - externalService.setOverrideOption(StAXUtil.overrideOption(reader.getAttributeValue(null, "overridable"), OverrideOption.NO)); - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - AssemblyObject o = registry.load(reader, loaderContext); - if (o instanceof ServiceContract) { - Service service = factory.createService(); - service.setName(name); - service.setServiceContract((ServiceContract) o); - ConfiguredService configuredService = factory.createConfiguredService(); - configuredService.setPort(service); - externalService.setConfiguredService(configuredService); - } else if (o instanceof Binding) { - externalService.getBindings().add((Binding) o); - } - reader.next(); - break; - case END_ELEMENT: - return externalService; - } - } - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ImportWSDLLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ImportWSDLLoader.java deleted file mode 100644 index 6981f05372..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ImportWSDLLoader.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.IMPORT_WSDL; - -import java.io.IOException; -import java.net.URL; - -import javax.wsdl.Definition; -import javax.wsdl.WSDLException; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.config.MissingResourceException; -import org.apache.tuscany.core.config.SidefileLoadException; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.core.loader.StAXUtil; -import org.apache.tuscany.core.loader.WSDLDefinitionRegistry; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.apache.tuscany.model.assembly.ImportWSDL; -import org.osoa.sca.annotations.Scope; - -/** - * Loader that handles <import.wsdl> elements. - * - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ImportWSDLLoader extends AbstractLoader { - private WSDLDefinitionRegistry wsdlRegistry; - - @Autowire - public void setWsdlRegistry(WSDLDefinitionRegistry wsdlRegistry) { - this.wsdlRegistry = wsdlRegistry; - } - - public QName getXMLType() { - return IMPORT_WSDL; - } - - public ImportWSDL load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert AssemblyConstants.IMPORT_WSDL.equals(reader.getName()); - String namespace = reader.getAttributeValue(null, "namespace"); - String location = reader.getAttributeValue(null, "location"); - if (location == null) - location = reader.getAttributeValue(null, "wsdlLocation"); - ImportWSDL importWSDL = factory.createImportWSDL(location, namespace); - - Definition definition = loadDefinition(namespace, location, loaderContext.getResourceLoader()); -// importWSDL.setDefinition(definition); - - StAXUtil.skipToEndElement(reader); - return importWSDL; - } - - protected Definition loadDefinition(String namespace, String location, ResourceLoader resourceLoader) throws MissingResourceException, SidefileLoadException { - Definition definition; - URL wsdlURL = resourceLoader.getResource(location); - if (wsdlURL == null) { - throw new MissingResourceException(location); - } - - try { - definition = wsdlRegistry.loadDefinition(namespace, wsdlURL, resourceLoader); - } catch (IOException e) { - SidefileLoadException sfe = new SidefileLoadException(e.getMessage()); - sfe.setResourceURI(location); - throw sfe; - } catch (WSDLException e) { - SidefileLoadException sfe = new SidefileLoadException(e.getMessage()); - sfe.setResourceURI(location); - throw sfe; - } - - return definition; - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceJavaLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceJavaLoader.java deleted file mode 100644 index 602cf2cc0a..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceJavaLoader.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.model.assembly.Scope; -import org.apache.tuscany.model.types.java.JavaServiceContract; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * @version $Rev$ $Date$ - */ -@org.osoa.sca.annotations.Scope("MODULE") -public class InterfaceJavaLoader extends AbstractLoader { - public QName getXMLType() { - return AssemblyConstants.INTERFACE_JAVA; - } - - public JavaServiceContract load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert AssemblyConstants.INTERFACE_JAVA.equals(reader.getName()); - JavaServiceContract serviceContract = factory.createJavaServiceContract(); - serviceContract.setScope(Scope.INSTANCE); - serviceContract.setInterfaceName(reader.getAttributeValue(null, "interface")); - serviceContract.setCallbackInterfaceName(reader.getAttributeValue(null, "callbackInterface")); - return serviceContract; - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoader.java deleted file mode 100644 index 9617cf805f..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoader.java +++ /dev/null @@ -1,110 +0,0 @@ -/** - * - * Copyright 2006 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import java.io.IOException; - -import org.apache.tuscany.common.resource.ResourceLoader; -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.config.MissingInterfaceException; -import org.apache.tuscany.core.loader.WSDLDefinitionRegistry; -import org.apache.tuscany.core.loader.StAXUtil; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.core.system.annotation.Autowire; -import org.apache.tuscany.model.assembly.Scope; -import org.apache.tuscany.model.types.wsdl.WSDLServiceContract; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.wsdl.PortType; -import javax.wsdl.WSDLException; - -/** - * @version $Rev$ $Date$ - */ -@org.osoa.sca.annotations.Scope("MODULE") -public class InterfaceWSDLLoader extends AbstractLoader { - private static final String WSDLI = "http://www.w3.org/2006/01/wsdl-instance"; - private static final String WSDLI_LOCATION = "wsdlLocation"; - - private WSDLDefinitionRegistry wsdlRegistry; - - @Autowire - public void setWsdlRegistry(WSDLDefinitionRegistry wsdlRegistry) { - this.wsdlRegistry = wsdlRegistry; - } - - public QName getXMLType() { - return AssemblyConstants.INTERFACE_WSDL; - } - - public WSDLServiceContract load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert AssemblyConstants.INTERFACE_WSDL.equals(reader.getName()); - WSDLServiceContract serviceContract = factory.createWSDLServiceContract(); - serviceContract.setScope(Scope.INSTANCE); - - ResourceLoader resourceLoader = loaderContext.getResourceLoader(); - - String location = reader.getAttributeValue(WSDLI, WSDLI_LOCATION); - if (location != null) { - try { - wsdlRegistry.loadDefinition(location, resourceLoader); - } catch (IOException e) { - throw new MissingInterfaceException(e); - } catch (WSDLException e) { - throw new MissingInterfaceException(e); - } - } - - String portTypeURI = reader.getAttributeValue(null, "interface"); - if (portTypeURI != null) { - serviceContract.setPortType(getPortType(portTypeURI, resourceLoader)); - } - - portTypeURI = reader.getAttributeValue(null, "callbackInterface"); - if (portTypeURI != null) { - serviceContract.setCallbackPortType(getPortType(portTypeURI, resourceLoader)); - } - StAXUtil.skipToEndElement(reader); - return serviceContract; - } - - protected PortType getPortType(String uri, ResourceLoader resourceLoader) throws MissingInterfaceException { - - // We currently support two syntaxes for specifying a WSDL portType: - // namespace#portTypeName, this is what we supported in the initial contribution, we will - // deprecate this after M1 - // namespace#wsdl.interface(portTypeName), this is the WSDL 2.0 syntax - - int index = uri.indexOf('#'); - String namespace = uri.substring(0, index); - String fragment = uri.substring(index + 1); - String localName; - if (fragment.startsWith("wsdl.interface(") && fragment.endsWith(")")) { - localName = fragment.substring(15, fragment.length()-1); - } else { - localName = fragment; - } - QName qname = new QName(namespace, localName); - PortType portType = wsdlRegistry.getPortType(qname, resourceLoader); - if (portType == null) { - throw new MissingInterfaceException(uri); - } - return portType; - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleFragmentLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleFragmentLoader.java deleted file mode 100644 index 4b3e96cfab..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleFragmentLoader.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.model.assembly.ModuleFragment; -import org.osoa.sca.annotations.Scope; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ModuleFragmentLoader extends CompositeLoader { - public QName getXMLType() { - return AssemblyConstants.MODULE_FRAGMENT; - } - - public ModuleFragment load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - ModuleFragment fragment = factory.createModuleFragment(); - loadComposite(reader, fragment, loaderContext); - return fragment; - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleLoader.java deleted file mode 100644 index 08ab23b3a6..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleLoader.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.context.impl.CompositeContextImpl; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.core.system.context.SystemCompositeContextImpl; -import org.apache.tuscany.model.assembly.Module; -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ModuleLoader extends CompositeLoader { - public QName getXMLType() { - return AssemblyConstants.MODULE; - } - - public Module load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - Module module = factory.createModule(); - loadComposite(reader, module, loaderContext); - // JFM Hack until recursive model in place - if (module.getName().startsWith("org.apache.tuscany.core.system")) { - module.setImplementationClass(SystemCompositeContextImpl.class); - } else { - module.setImplementationClass(CompositeContextImpl.class); - } - return module; - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/PropertyLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/PropertyLoader.java deleted file mode 100644 index cbf1ca00df..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/PropertyLoader.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.StAXUtil; -import org.apache.tuscany.core.loader.LoaderContext; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.PROPERTY; -import org.apache.tuscany.model.assembly.Property; -import org.osoa.sca.annotations.Scope; - -import javax.xml.namespace.QName; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import java.util.HashMap; -import java.util.Map; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class PropertyLoader extends AbstractLoader { - private static final String XSD = "http://www.w3.org/2001/XMLSchema"; - - private static final Map<QName, Class<?>> TYPE_MAP; - static { - // todo support more XSD types, or remove if we store the QName - TYPE_MAP = new HashMap<QName, Class<?>>(17); - TYPE_MAP.put(new QName(XSD, "string"), String.class); - } - - public QName getXMLType() { - return PROPERTY; - } - - public Property load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert PROPERTY.equals(reader.getName()); - Property property = factory.createProperty(); - property.setName(reader.getAttributeValue(null, "name")); - String typeName = reader.getAttributeValue(null, "type"); - // support XSD type or Java class name - // todo perhaps we should just store the QName for the PropertyFactory to use - int index = typeName.indexOf(':'); - if (index != -1) { - String prefix = typeName.substring(0, index); - String namespaceURI = reader.getNamespaceURI(prefix); - QName qname = new QName(namespaceURI, typeName.substring(index+1)); - property.setType(TYPE_MAP.get(qname)); - } else { - try { - Class<?> type = loaderContext.getResourceLoader().loadClass(typeName); - property.setType(type); - } catch (ClassNotFoundException e) { - throw new ConfigurationLoadException(e); - } - } - property.setMany(Boolean.parseBoolean(reader.getAttributeValue(null, "many"))); - property.setDefaultValue(reader.getAttributeValue(null, "default")); - String required = reader.getAttributeValue(null, "required"); - property.setRequired(required != null && Boolean.valueOf(required)); - - StAXUtil.skipToEndElement(reader); - return property; - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ReferenceLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ReferenceLoader.java deleted file mode 100644 index aa95210757..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ReferenceLoader.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.StAXUtil; -import org.apache.tuscany.core.loader.LoaderContext; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.REFERENCE; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Multiplicity; -import org.apache.tuscany.model.assembly.Reference; -import org.apache.tuscany.model.assembly.ServiceContract; -import org.osoa.sca.annotations.Scope; - -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ReferenceLoader extends AbstractLoader { - public QName getXMLType() { - return REFERENCE; - } - - public Reference load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert REFERENCE.equals(reader.getName()); - Reference reference = factory.createReference(); - reference.setName(reader.getAttributeValue(null, "name")); - reference.setMultiplicity(StAXUtil.multiplicity(reader.getAttributeValue(null, "multiplicity"), Multiplicity.ONE_ONE)); - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - AssemblyObject o = registry.load(reader, loaderContext); - if (o instanceof ServiceContract) { - reference.setServiceContract((ServiceContract) o); - } - reader.next(); - break; - case END_ELEMENT: - return reference; - } - } - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ServiceLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ServiceLoader.java deleted file mode 100644 index 9cb31b55ff..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ServiceLoader.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import static org.apache.tuscany.core.loader.assembly.AssemblyConstants.SERVICE; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.model.assembly.AssemblyObject; -import org.apache.tuscany.model.assembly.Service; -import org.apache.tuscany.model.assembly.ServiceContract; -import org.osoa.sca.annotations.Scope; - -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class ServiceLoader extends AbstractLoader { - public QName getXMLType() { - return SERVICE; - } - - public Service load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert SERVICE.equals(reader.getName()); - Service service = factory.createService(); - service.setName(reader.getAttributeValue(null, "name")); - - while (true) { - switch (reader.next()) { - case START_ELEMENT: - AssemblyObject o = registry.load(reader, loaderContext); - if (o instanceof ServiceContract) { - service.setServiceContract((ServiceContract) o); - } - reader.next(); - break; - case END_ELEMENT: - return service; - } - } - } -} diff --git a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/WireLoader.java b/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/WireLoader.java deleted file mode 100644 index 0ae3c4405d..0000000000 --- a/tags/java-M1-20060518/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/WireLoader.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.tuscany.core.loader.assembly; - -import java.util.HashMap; -import java.util.Map; -import javax.xml.namespace.QName; -import static javax.xml.stream.XMLStreamConstants.END_ELEMENT; -import static javax.xml.stream.XMLStreamConstants.START_ELEMENT; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.tuscany.core.config.ConfigurationLoadException; -import org.apache.tuscany.core.loader.LoaderContext; -import org.apache.tuscany.model.assembly.Wire; -import org.osoa.sca.annotations.Scope; - -/** - * @version $Rev$ $Date$ - */ -@Scope("MODULE") -public class WireLoader extends AbstractLoader { - private static final String XSD = "http://www.w3.org/2001/XMLSchema"; - - private static final Map<QName, Class<?>> TYPE_MAP; - - static { - // todo support more XSD types, or remove if we store the QName - TYPE_MAP = new HashMap<QName, Class<?>>(17); - TYPE_MAP.put(new QName(XSD, "string"), String.class); - } - - public QName getXMLType() { - return AssemblyConstants.WIRE; - } - - public Wire load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException { - assert AssemblyConstants.WIRE.equals(reader.getName()); - Wire wire = factory.createWire(); - while (true) { - switch (reader.next()) { - case START_ELEMENT: - QName qname = reader.getName(); - if (AssemblyConstants.WIRE_SOURCE.equals(qname)) { - String uri = reader.getElementText(); - int pos = uri.indexOf('/'); - if (pos < 1) { - throw new ConfigurationLoadException("Invalid source wire"); - } - String partName = uri.substring(0, pos); - String portName = uri.substring(pos + 1); - wire.setSource(factory.createServiceURI(null, partName, portName)); - } else if (AssemblyConstants.WIRE_TARGET.equals(qname)) { - String uri = reader.getElementText(); - int pos = uri.indexOf('/'); - if (pos < 1) { - wire.setTarget(factory.createServiceURI(null, uri)); - }else{ - String partName = uri.substring(0, pos); - String portName = uri.substring(pos + 1); - wire.setTarget(factory.createServiceURI(null, partName, portName)); - } - } - break; - case END_ELEMENT: - return wire; - } - } - } -} |