summaryrefslogtreecommitdiffstats
path: root/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader')
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/InvalidPropertyFactoryException.java46
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/LoaderContext.java47
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXElementLoader.java40
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXLoaderRegistry.java91
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXPropertyFactory.java42
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java160
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/WSDLDefinitionRegistry.java95
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AbstractLoader.java61
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AssemblyConstants.java47
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentLoader.java189
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoader.java65
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/CompositeLoader.java62
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/EntryPointLoader.java90
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoader.java75
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ImportWSDLLoader.java95
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceJavaLoader.java45
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoader.java110
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleFragmentLoader.java42
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleLoader.java50
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/PropertyLoader.java79
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ReferenceLoader.java64
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ServiceLoader.java61
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/WireLoader.java84
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/JNDIPropertyFactory.java62
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StAXLoaderRegistryImpl.java105
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StringParserPropertyFactory.java110
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java202
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemBindingLoader.java47
-rw-r--r--tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemImplementationLoader.java68
29 files changed, 0 insertions, 2334 deletions
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/InvalidPropertyFactoryException.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/InvalidPropertyFactoryException.java
deleted file mode 100644
index 9ccbbb3a7a..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/InvalidPropertyFactoryException.java
+++ /dev/null
@@ -1,46 +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;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-
-/**
- * Exception raised if there is a problem configuring a PropertyFactory.
- *
- * @version $Rev$ $Date$
- */
-public class InvalidPropertyFactoryException extends ConfigurationLoadException {
- private static final long serialVersionUID = 5017976138519117474L;
-
- /**
- * Constructor indicating the cause why the property factory could not be created.
- *
- * @param className the name of the class that is intended to be the PropertyFactory
- * @param cause the Throwable that prevented the PropertyFactory from being created
- */
- public InvalidPropertyFactoryException(String className, Throwable cause) {
- super(className, cause);
- }
-
- /**
- * Returns the name of the property factory implementation class.
- * @return the name of the property factory implementation class
- */
- public String getClassName() {
- return getMessage();
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/LoaderContext.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/LoaderContext.java
deleted file mode 100644
index cef7353bbf..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/LoaderContext.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/**
- *
- * Copyright 2006 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;
-
-import org.apache.tuscany.common.resource.ResourceLoader;
-
-/**
- * Context holder that can be used during the load process to store information
- * that is not part of the logical model. This should be regarded as transient
- * and references to this context should not be stored inside the model.
- *
- * @version $Rev$ $Date$
- */
-public class LoaderContext {
- private final ResourceLoader resourceLoader;
-
- /**
- * Constructor specifying the loader for application resources.
- *
- * @param resourceLoader the loader for application resources
- */
- public LoaderContext(ResourceLoader resourceLoader) {
- this.resourceLoader = resourceLoader;
- }
-
- /**
- * Returns a resource loader that can be used to load application resources.
- * @return a resource loader that can be used to load application resources
- */
- public ResourceLoader getResourceLoader() {
- return resourceLoader;
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXElementLoader.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXElementLoader.java
deleted file mode 100644
index e1a9f55ca4..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXElementLoader.java
+++ /dev/null
@@ -1,40 +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;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.model.assembly.AssemblyObject;
-
-/**
- * A loader that creates a model object from a StAX input stream.
- *
- * @version $Rev$ $Date$
- */
-public interface StAXElementLoader<T extends AssemblyObject> {
- /**
- * Build the model object for an element in an XML stream.
- * When this method returns the stream will be positioned on the corresponding END_ELEMENT.
- *
- * @param reader the XML stream reader positioned on the applicable START_ELEMENT
- * @param loaderContext the context for the load operation
- * @return the model object for that element
- */
- T load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException;
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXLoaderRegistry.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXLoaderRegistry.java
deleted file mode 100644
index a38d388815..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXLoaderRegistry.java
+++ /dev/null
@@ -1,91 +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;
-
-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.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.AssemblyObject;
-
-/**
- * Registry for XML loaders that can parse a StAX input stream and return model objects.
- * <p/>
- * Loaders will typically be contributed to the system by any extension that needs to
- * handle extension specific information contained in some XML configuration file.
- * The loader can be contributed as a system component with an autowire reference
- * to this registry which is used during initialization to actually register.
- * </p>
- * This registry can also be used to parse an input stream, dispatching to the
- * appropriate loader for each element accepted. Loaders can call back to the
- * registry to load sub-elements that they are not able to handle directly.
- *
- * @version $Rev$ $Date$
- */
-public interface StAXLoaderRegistry {
- /**
- * Register a loader. This operation will typically be called by a loader
- * during its initialization.
- *
- * @param element the element that should be delegated to the contibuted loader
- * @param loader a loader that is being contributed to the system
- */
- <T extends AssemblyObject> void registerLoader(QName element, StAXElementLoader<T> loader);
-
- /**
- * Unregister a loader. This will typically be called by a loader as it is being destroyed.
- *
- * @param element the element that was being delegated to the contibuted loader
- * @param loader a loader that should no longer be used
- */
- <T extends AssemblyObject> void unregisterLoader(QName element, StAXElementLoader<T> loader);
-
- /**
- * Parse the supplied XML stream dispatching to the appropriate registered loader
- * for each element encountered in the stream.
- * <p/>
- * This method must be called with the XML cursor positioned on a START_ELEMENT event.
- * When this method returns, the stream will be positioned on the corresponding
- * END_ELEMENT event.
- *
- * @param reader the XML stream to parse
- * @param loaderContext
- * @return the model object obtained by parsing the current element on the stream
- * @throws XMLStreamException if there was a problem reading the stream
- */
- AssemblyObject load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException;
-
- /**
- * Hack to allow loaders to initialize model objects on the fly.
- * Remove when initialization has been moved from the model implementation to the loader.
- *
- * @return the model context for this load operation
- */
- @Deprecated
- AssemblyContext getContext();
-
- /**
- * Hack to allow loaders to initialize model objects on the fly.
- * Remove when initialization has been moved from the model implementation to the loader.
- *
- * @param context the model context for this load operation
- */
- @Deprecated
- void setContext(AssemblyContext context);
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXPropertyFactory.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXPropertyFactory.java
deleted file mode 100644
index a05597b51b..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXPropertyFactory.java
+++ /dev/null
@@ -1,42 +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;
-
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.model.assembly.Property;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-/**
- * A factory that will create an ObjectFactory for a property by parsing a StAX XMLStreamReader.
- *
- * @version $Rev$ $Date$
- */
-public interface StAXPropertyFactory<T> {
- /**
- * Return an ObjectFactory for instances of a property defined in an XML stream.
- *
- * @param reader the reader to use to access the XML stream
- * @param property the Property definition that the resulting ObjectFactory must be able to assign to
- * @return an ObjectFactory that can produce instances that can be assigned to the supplied Property
- * @throws XMLStreamException if there is a problem reading the stream
- * @throws ConfigurationLoadException if there is a problem creating the ObjectFactory
- */
- ObjectFactory<T> createObjectFactory(XMLStreamReader reader, Property property) throws XMLStreamException, ConfigurationLoadException;
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java
deleted file mode 100644
index f9ac2b0559..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/StAXUtil.java
+++ /dev/null
@@ -1,160 +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;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import javax.xml.stream.XMLStreamConstants;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.tuscany.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.ConfigurationException;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.config.impl.Java5ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.processor.ProcessorUtils;
-import org.apache.tuscany.core.loader.assembly.ComponentLoader;
-import org.apache.tuscany.core.loader.assembly.EntryPointLoader;
-import org.apache.tuscany.core.loader.assembly.InterfaceJavaLoader;
-import org.apache.tuscany.core.loader.assembly.ModuleFragmentLoader;
-import org.apache.tuscany.core.loader.assembly.ModuleLoader;
-import org.apache.tuscany.core.loader.impl.StAXLoaderRegistryImpl;
-import org.apache.tuscany.core.loader.impl.StringParserPropertyFactory;
-import org.apache.tuscany.core.loader.system.SystemBindingLoader;
-import org.apache.tuscany.core.loader.system.SystemImplementationLoader;
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.ModuleComponent;
-import org.apache.tuscany.model.assembly.Multiplicity;
-import org.apache.tuscany.model.assembly.OverrideOption;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * @version $Rev$ $Date$
- */
-public final class StAXUtil {
- private static final Map<String, Multiplicity> MULTIPLICITY = new HashMap<String, Multiplicity>(4);
- private static final Map<String, OverrideOption> OVERRIDE_OPTIONS = new HashMap<String, OverrideOption>(3);
-
- static {
- MULTIPLICITY.put("0..1", Multiplicity.ZERO_ONE);
- MULTIPLICITY.put("1..1", Multiplicity.ONE_ONE);
- MULTIPLICITY.put("0..n", Multiplicity.ZERO_N);
- MULTIPLICITY.put("1..n", Multiplicity.ONE_N);
-
- OVERRIDE_OPTIONS.put("no", OverrideOption.NO);
- OVERRIDE_OPTIONS.put("may", OverrideOption.MAY);
- OVERRIDE_OPTIONS.put("must", OverrideOption.MUST);
- }
-
- private StAXUtil() {
- }
-
- public static void skipToEndElement(XMLStreamReader reader) throws XMLStreamException {
- int depth = 0;
- while (true) {
- int event = reader.next();
- if (event == XMLStreamConstants.START_ELEMENT) {
- depth++;
- } else if (event == XMLStreamConstants.END_ELEMENT) {
- if (depth == 0) {
- return;
- }
- depth--;
- }
- }
- }
-
- public static Multiplicity multiplicity(String multiplicity, Multiplicity def) {
- return multiplicity == null ? def : MULTIPLICITY.get(multiplicity);
- }
-
- public static OverrideOption overrideOption(String overrideOption, OverrideOption def) {
- return overrideOption == null ? def : OVERRIDE_OPTIONS.get(overrideOption);
- }
-
- public static ModuleComponent bootstrapLoader(String name, AssemblyContext context) throws ConfigurationLoadException {
- SystemAssemblyFactory factory = new SystemAssemblyFactoryImpl();
- ComponentTypeIntrospector introspector = ProcessorUtils.createCoreIntrospector(factory);
- Module module = factory.createModule();
- module.setName("org.apache.tuscany.core.system.loader");
-
- List<Component> components = module.getComponents();
-
- // bootstrap the minimal set of loaders needed to read the system module files
- // all others should be defined in the system.module file
- components.add(bootstrapLoader(factory, introspector, ModuleLoader.class));
- components.add(bootstrapLoader(factory, introspector, ModuleFragmentLoader.class));
- Component propFactory = factory.createSystemComponent("org.apache.tuscany.core.system.loader.DefaultPropertyFactory", StAXPropertyFactory.class, StringParserPropertyFactory.class, Scope.MODULE);
- introspector.introspect(StAXPropertyFactory.class);
- components.add(propFactory);
- components.add(bootstrapLoader(factory, introspector, ComponentLoader.class));
- components.add(bootstrapLoader(factory, introspector, EntryPointLoader.class));
- components.add(bootstrapLoader(factory, introspector, InterfaceJavaLoader.class));
- components.add(bootstrapLoader(factory, introspector, SystemImplementationLoader.class));
- components.add(bootstrapLoader(factory, introspector, SystemBindingLoader.class));
- // do not add additional loaders above - they should be in the system.module file
-
- // bootstrap the registries needed by the bootstrap loaders above
- bootstrapService(factory, introspector, module, StAXLoaderRegistry.class, StAXLoaderRegistryImpl.class);
- bootstrapService(factory, introspector, module, SystemAssemblyFactory.class, SystemAssemblyFactoryImpl.class);
- bootstrapService(factory, introspector, module, ComponentTypeIntrospector.class, Java5ComponentTypeIntrospector.class);
-
- ModuleComponent mc = factory.createModuleComponent();
- mc.setName(name);
- mc.setImplementation(module);
- mc.initialize(context);
- return mc;
- }
-
- private static Component bootstrapLoader(SystemAssemblyFactory factory, ComponentTypeIntrospector introspector, Class<?> loaderClass) {
- SystemImplementation implementation = factory.createSystemImplementation();
- implementation.setImplementationClass(loaderClass);
- try {
- implementation.setComponentType(introspector.introspect(loaderClass));
- } catch (ConfigurationException e) {
- throw (AssertionError) new AssertionError("Invalid bootstrap loader").initCause(e);
- }
- Component component = factory.createSimpleComponent();
- component.setName(loaderClass.getName());
- component.setImplementation(implementation);
- return component;
- }
-
- private static <T> void bootstrapService(SystemAssemblyFactory factory, ComponentTypeIntrospector introspector, Module module, Class<T> service, Class<? extends T> impl) {
- String epName = service.getName();
- String compName = impl.getName();
-
- Component component = factory.createSystemComponent(compName, service, impl, Scope.MODULE);
- try {
- component.getImplementation().setComponentType(introspector.introspect(impl));
- } catch (ConfigurationException e) {
- throw (AssertionError) new AssertionError("Invalid bootstrap loader").initCause(e);
- }
-
- EntryPoint entryPoint = factory.createSystemEntryPoint(epName, service, compName);
-
- module.getComponents().add(component);
- module.getEntryPoints().add(entryPoint);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/WSDLDefinitionRegistry.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/WSDLDefinitionRegistry.java
deleted file mode 100644
index f88e0f0b35..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/WSDLDefinitionRegistry.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;
-
-import java.net.URL;
-import java.util.List;
-import java.io.IOException;
-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;
-
-import org.apache.tuscany.common.resource.ResourceLoader;
-
-/**
- * @version $Rev$ $Date$
- */
-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
- * @param resourceLoader the application resource loader
- * @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, ResourceLoader resourceLoader) 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 resourceLoader application resource loader 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, ResourceLoader resourceLoader) 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
- * @param resourceLoader the application resource loader
- * @return the PortType for the supplied name, or null if none has been defined
- */
- PortType getPortType(QName name, ResourceLoader resourceLoader);
-
- /**
- * Returns the Service with the supplied qualified name, or null if no such service has been defined.
- *
- * @param name the qualified name of the WSDL service
- * @param resourceLoader the application resource loader
- * @return the Service for the supplied name, or null if none has been defined
- */
- Service getService(QName name, ResourceLoader resourceLoader);
-
-
- /**
- * Returns a list of definitions that have been loaded for the given namespace, or null if
- * no WSDL documents have been loaded for the given namespace
- *
- * @param namespace the namespace to lookup
- * @param resourceLoader the application resource loader
- * @return The list of definitions that have been loaded for the given namespace, or null
- */
- List<Definition> getDefinitionsForNamespace(String namespace, ResourceLoader resourceLoader);
-
-
- /**
- * 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();
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AbstractLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/AssemblyConstants.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ComponentTypeLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/CompositeLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/EntryPointLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ExternalServiceLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ImportWSDLLoader.java b/tags/java-M1-20060522/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-20060522/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 &lt;import.wsdl&gt; 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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceJavaLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/InterfaceWSDLLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleFragmentLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ModuleLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/PropertyLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ReferenceLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/ServiceLoader.java b/tags/java-M1-20060522/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-20060522/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-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/assembly/WireLoader.java b/tags/java-M1-20060522/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-20060522/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;
- }
- }
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/JNDIPropertyFactory.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/JNDIPropertyFactory.java
deleted file mode 100644
index 763c88295c..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/JNDIPropertyFactory.java
+++ /dev/null
@@ -1,62 +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.impl;
-
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.XMLStreamException;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-import org.apache.tuscany.core.loader.StAXPropertyFactory;
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.injection.JNDIObjectFactory;
-import org.apache.tuscany.model.assembly.Property;
-
-/**
- * A StAXPropertyFactory that creates property values by looking them
- * up in the default JNDI InitialContext.
- *
- * This can be used to locate resources in a J2EE environment and inject
- * them as configuration properties. For example, to access a database
- * a component could write:
- * <code>
- * &at;Property DataSource myDB;
- * </code>
- * and configure with
- * <code>
- * &lt;properties&gt;
- * &lt;v:myDb&gt;java:comp/env/jdbc/MyDatabase&lt;/v:myDB&gt;
- * &lt;/properties&gt;
- * </code>
- *
- * @version $Rev$ $Date$
- */
-public class JNDIPropertyFactory implements StAXPropertyFactory {
- public ObjectFactory<?> createObjectFactory(XMLStreamReader reader, Property property) throws XMLStreamException, ConfigurationLoadException {
- Class<?> type = property.getType();
- assert type != null : "property type is null";
- String text = reader.getElementText();
- try {
- Context context = new InitialContext();
- return new JNDIObjectFactory(context, text);
- } catch (NamingException e) {
- throw new ConfigurationLoadException(e);
- }
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StAXLoaderRegistryImpl.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StAXLoaderRegistryImpl.java
deleted file mode 100644
index 1e9e8ec8fb..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StAXLoaderRegistryImpl.java
+++ /dev/null
@@ -1,105 +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.impl;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.loader.StAXElementLoader;
-import org.apache.tuscany.core.loader.StAXLoaderRegistry;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.model.assembly.AssemblyContext;
-import org.apache.tuscany.model.assembly.AssemblyObject;
-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 StAXLoaderRegistryImpl implements StAXLoaderRegistry {
- private final Map<QName, StAXElementLoader<? extends AssemblyObject>> loaders = new HashMap<QName, StAXElementLoader<? extends AssemblyObject>>();
-
- private Monitor monitor;
-
- @org.apache.tuscany.core.system.annotation.Monitor
- public void setMonitor(Monitor monitor) {
- this.monitor = monitor;
- }
-
- public <T extends AssemblyObject> void registerLoader(QName element, StAXElementLoader<T> loader) {
- monitor.registeringLoader(element);
- loaders.put(element, loader);
- }
-
- public <T extends AssemblyObject> void unregisterLoader(QName element, StAXElementLoader<T> loader) {
- monitor.unregisteringLoader(element);
- loaders.remove(element);
- }
-
- public AssemblyObject load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
- QName name = reader.getName();
- monitor.elementLoad(name);
- StAXElementLoader<? extends AssemblyObject> loader = loaders.get(name);
- if (loader == null) {
- ConfigurationLoadException e = new ConfigurationLoadException("Unrecognized element");
- e.setIdentifier(name.toString());
- throw e;
- } else {
- return loader.load(reader, loaderContext);
- }
- }
-
-
- private final ThreadLocal<AssemblyContext> modelContext = new ThreadLocal<AssemblyContext>();
-
- @Deprecated
- public AssemblyContext getContext() {
- return modelContext.get();
- }
-
- @Deprecated
- public void setContext(AssemblyContext context) {
- modelContext.set(context);
- }
-
- public static interface Monitor {
- /**
- * Event emitted when a StAX element loader is registered.
- *
- * @param xmlType the QName of the element the loader will handle
- */
- void registeringLoader(QName xmlType);
-
- /**
- * Event emitted when a StAX element loader is unregistered.
- *
- * @param xmlType the QName of the element the loader will handle
- */
- void unregisteringLoader(QName xmlType);
-
- /**
- * Event emitted when a request is made to load an element.
- *
- * @param xmlType the QName of the element that should be loaded
- */
- void elementLoad(QName xmlType);
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StringParserPropertyFactory.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StringParserPropertyFactory.java
deleted file mode 100644
index 2ed33f895c..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/StringParserPropertyFactory.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.impl;
-
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.injection.SingletonObjectFactory;
-import org.apache.tuscany.core.loader.StAXPropertyFactory;
-import org.apache.tuscany.model.assembly.Property;
-
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import java.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-
-import org.osoa.sca.annotations.Scope;
-import org.osoa.sca.annotations.Service;
-
-/**
- * @version $Rev$ $Date$
- */
-@Scope("MODULE")
-@Service(interfaces = {StAXPropertyFactory.class})
-public class StringParserPropertyFactory implements StAXPropertyFactory {
- public ObjectFactory<?> createObjectFactory(XMLStreamReader reader, Property property) throws XMLStreamException, ConfigurationLoadException {
- Class<?> type = property.getType();
- assert type != null : "property type is null";
- String text = reader.getElementText();
-
- // degenerate case where we are returning a String
- if (String.class.equals(type)) {
- return new SingletonObjectFactory(text);
- }
-
- // special handler to convert hexBinary to a byte[]
- if (byte[].class.equals(type)) {
- byte[] instance = new byte[text.length() >> 1];
- for (int i = 0; i < instance.length; i++) {
- instance[i] = (byte) (Character.digit(text.charAt(i << 1), 16) << 4 | Character.digit(text.charAt((i << 1) + 1), 16));
- }
- return new SingletonObjectFactory(instance);
- }
-
- // does this type have a static valueOf(String) method?
- try {
- Method valueOf = type.getMethod("valueOf", String.class);
- if (Modifier.isStatic(valueOf.getModifiers())) {
- try {
- return new SingletonObjectFactory(valueOf.invoke(null, text));
- } catch (IllegalAccessException e) {
- throw new AssertionError("getMethod returned an inaccessible method");
- } catch (InvocationTargetException e) {
- // FIXME we should throw something better
- throw new ConfigurationLoadException(e.getCause());
- }
- }
- } catch (NoSuchMethodException e) {
- // try something else
- }
-
- // does this type have a constructor that takes a String?
- try {
- Constructor<?> ctr = type.getConstructor(String.class);
- return new SingletonObjectFactory(ctr.newInstance(text));
- } catch (NoSuchMethodException e) {
- // try something else
- } catch (IllegalAccessException e) {
- throw new AssertionError("getConstructor returned an inaccessible method");
- } catch (InstantiationException e) {
- throw new ConfigurationLoadException("Property type cannot be instantiated: " + type.getName());
- } catch (InvocationTargetException e) {
- // FIXME we should throw something better
- throw new ConfigurationLoadException(e.getCause());
- }
-
- // do we have a property editor for it?
- PropertyEditor editor = PropertyEditorManager.findEditor(type);
- if (editor != null) {
- try {
- editor.setAsText(text);
- return new SingletonObjectFactory(editor.getValue());
- } catch (IllegalArgumentException e) {
- // FIXME we should throw something better
- throw new ConfigurationLoadException(e);
-
- }
- }
-
- // FIXME we should throw something better
- throw new ConfigurationLoadException("Do not have a way to parse a String into a " + type.getName());
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java
deleted file mode 100644
index 1063dec3fc..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/impl/WSDLDefinitionRegistryImpl.java
+++ /dev/null
@@ -1,202 +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.impl;
-
-import java.io.IOException;
-import java.net.URL;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import javax.wsdl.Definition;
-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.common.resource.ResourceLoader;
-import org.apache.tuscany.core.loader.WSDLDefinitionRegistry;
-import org.osoa.sca.annotations.Scope;
-
-/**
- * @version $Rev$ $Date$
- */
-@org.osoa.sca.annotations.Service(interfaces = {WSDLDefinitionRegistry.class})
-@Scope("MODULE")
-public class WSDLDefinitionRegistryImpl implements WSDLDefinitionRegistry {
- private final WSDLFactory wsdlFactory;
- private final ExtensionRegistry registry;
-
- private final Map<ResourceLoader,Map<URL, Definition>> definitionsByLocationByLoader = new WeakHashMap<ResourceLoader,Map<URL, Definition>>();
- private final Map<ResourceLoader,Map<String, List<Definition>>> definitionsByNamespaceByLoader = new WeakHashMap<ResourceLoader,Map<String, List<Definition>>>();
-
- private Monitor monitor;
-
- public WSDLDefinitionRegistryImpl() throws WSDLException {
- wsdlFactory = WSDLFactory.newInstance();
- registry = wsdlFactory.newPopulatedExtensionRegistry();
- }
-
- @org.apache.tuscany.core.system.annotation.Monitor
- public void setMonitor(Monitor monitor) {
- this.monitor = monitor;
- }
-
- public ExtensionRegistry getExtensionRegistry() {
- return registry;
- }
-
- public Definition loadDefinition(String wsdlLocation, ResourceLoader resourceLoader) 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 = resourceLoader.getResource(uri.toString());
- if (url == null) {
- throw new WSDLException(WSDLException.CONFIGURATION_ERROR, "Resource not found: " + uri);
- }
- }
- return loadDefinition(namespace, url, resourceLoader);
- }
-
- public Definition loadDefinition(String namespace, URL location, ResourceLoader resourceLoader) throws IOException, WSDLException {
- Map<URL, Definition> definitionsByLocation = getDefinitionsByLocation(resourceLoader);
- Map<String, List<Definition>> definitionsByNamespace = getDefinitionsByNamespace(resourceLoader);
-
- Definition definition = definitionsByLocation.get(location);
- if (definition != null) {
- // return cached copy
- return definition;
- }
-
- 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());
- }
-
- 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 List<Definition> getDefinitionsForNamespace(String namespace, ResourceLoader resourceLoader) {
- Map<String, List<Definition>> definitionsByNamespace = getDefinitionsByNamespace(resourceLoader);
- return definitionsByNamespace.get(namespace);
- }
-
- public PortType getPortType(QName name, ResourceLoader resourceLoader) {
- Map<String, List<Definition>> definitionsByNamespace = getDefinitionsByNamespace(resourceLoader);
- 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, ResourceLoader resourceLoader) {
- Map<String, List<Definition>> definitionsByNamespace = getDefinitionsByNamespace(resourceLoader);
- 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;
- }
-
- private Map<String, List<Definition>> getDefinitionsByNamespace(ResourceLoader resourceLoader) {
- Map<String, List<Definition>> map = definitionsByNamespaceByLoader.get(resourceLoader);
- if (map == null) {
- map = new HashMap<String, List<Definition>>();
- definitionsByNamespaceByLoader.put(resourceLoader, map);
- }
- return map;
- }
-
- private Map<URL, Definition> getDefinitionsByLocation(ResourceLoader resourceLoader) {
- Map<URL, Definition> map = definitionsByLocationByLoader.get(resourceLoader);
- if (map == null) {
- map = new HashMap<URL, Definition>();
- definitionsByLocationByLoader.put(resourceLoader, map);
- }
- return map;
- }
-
- 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);
- }
-
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemBindingLoader.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemBindingLoader.java
deleted file mode 100644
index d75f25a232..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemBindingLoader.java
+++ /dev/null
@@ -1,47 +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.system;
-
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.loader.StAXUtil;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.core.loader.assembly.AbstractLoader;
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-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 SystemBindingLoader extends AbstractLoader {
- public static final QName SYSTEM_BINDING = new QName("http://org.apache.tuscany/xmlns/system/0.9", "binding.system");
-
- protected QName getXMLType() {
- return SYSTEM_BINDING;
- }
-
- public SystemBinding load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
- assert SystemBindingLoader.SYSTEM_BINDING.equals(reader.getName());
- SystemBinding binding = factory.createSystemBinding();
- StAXUtil.skipToEndElement(reader);
- return binding;
- }
-}
diff --git a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemImplementationLoader.java b/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemImplementationLoader.java
deleted file mode 100644
index b9f35d8656..0000000000
--- a/tags/java-M1-20060522/java/sca/core/src/main/java/org/apache/tuscany/core/loader/system/SystemImplementationLoader.java
+++ /dev/null
@@ -1,68 +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.system;
-
-import org.apache.tuscany.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.ConfigurationLoadException;
-import org.apache.tuscany.core.loader.StAXUtil;
-import org.apache.tuscany.core.loader.LoaderContext;
-import org.apache.tuscany.core.loader.assembly.AbstractLoader;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-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 SystemImplementationLoader extends AbstractLoader {
- public static final QName SYSTEM_IMPLEMENTATION = new QName("http://org.apache.tuscany/xmlns/system/0.9", "implementation.system");
-
- private ComponentTypeIntrospector introspector;
-
- @Autowire
- public void setIntrospector(ComponentTypeIntrospector introspector) {
- this.introspector = introspector;
- }
-
- protected QName getXMLType() {
- return SYSTEM_IMPLEMENTATION;
- }
-
- public SystemImplementation load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
- assert SYSTEM_IMPLEMENTATION.equals(reader.getName());
- SystemImplementation implementation = factory.createSystemImplementation();
- String implClass = reader.getAttributeValue(null, "class");
- Class<?> implementationClass;
- try {
- implementationClass = loaderContext.getResourceLoader().loadClass(implClass);
- implementation.setImplementationClass(implementationClass);
- } catch (ClassNotFoundException e) {
- throw new ConfigurationLoadException(e);
- }
-
- // todo we should allow componentType sidefiles for system implementations
- implementation.setComponentType(introspector.introspect(implementationClass));
-
- StAXUtil.skipToEndElement(reader);
- return implementation;
- }
-}