summaryrefslogtreecommitdiffstats
path: root/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver')
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java107
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java69
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java81
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java70
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java89
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java125
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java179
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java74
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java52
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java45
-rw-r--r--java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java103
11 files changed, 0 insertions, 994 deletions
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java
deleted file mode 100644
index f3555ee71e..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ClassReference.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.lang.ref.WeakReference;
-
-import org.apache.tuscany.sca.assembly.Base;
-
-/**
- * A weak reference to a class, which should be used to register classes
- * with an ArtifactResolver and resolve these classes later.
- *
- * FIXME The core contribution model should not have dependencies on classes
- * and ClassLoaders. This should move to the Java import support module.
- *
- * @version $Rev$ $Date$
- */
-public class ClassReference implements Base {
-
- private WeakReference<Class<?>> clazz;
- private String className;
-
- /**
- * Constructs a new ClassReference.
- *
- * @param clazz The class reference
- */
- public ClassReference(Class<?> clazz) {
- this.clazz = new WeakReference<Class<?>>(clazz);
- this.className = clazz.getName();
- }
-
- /**
- * Constructs a new ClassReference.
- *
- * @param className The class name
- */
- public ClassReference(String className) {
- this.className = className;
- }
-
- /**
- * Get the referenced class.
- *
- * @return The referenced class
- */
- public Class<?> getJavaClass() {
- if (clazz != null) {
- return clazz.get();
- } else {
- return null;
- }
- }
-
- /**
- * Get the referenced class name.
- *
- * @return The class name
- */
- public String getClassName() {
- return className;
- }
-
- public boolean isUnresolved() {
- return clazz == null;
- }
-
- public void setUnresolved(boolean unresolved) {
- throw new IllegalStateException();
- }
-
- @Override
- public int hashCode() {
- return className.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else {
- if (obj instanceof ClassReference) {
- return className.equals(((ClassReference)obj).className);
- } else {
- return false;
- }
- }
- }
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java
deleted file mode 100644
index e17dd176a6..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultDelegatingModelResolver.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Base;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-
-/**
- * A model resolver implementation that delegates to a list of model resolvers.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultDelegatingModelResolver implements ModelResolver {
-
- private List<ModelResolver> resolvers;
-
- public DefaultDelegatingModelResolver(List<ModelResolver> resolvers) {
- this.resolvers = resolvers;
- }
-
- public void addModel(Object resolved, ProcessorContext context) {
- throw new IllegalStateException();
- }
-
- public Object removeModel(Object resolved, ProcessorContext context) {
- throw new IllegalStateException();
- }
-
- public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
-
- //TODO optimize and cache results of the resolution later
-
- // Go over all resolvers
- for (ModelResolver resolver: resolvers) {
-
- Object resolved = resolver.resolveModel(modelClass, unresolved, context);
-
- // Return the resolved model object
- if (resolved instanceof Base) {
- if (!((Base)resolved).isUnresolved()) {
- return modelClass.cast(resolved);
- }
- }
- }
-
- // Model object was not resolved
- return unresolved;
- }
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java
deleted file mode 100644
index 7745253bba..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportAllModelResolver.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Base;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.Export;
-import org.apache.tuscany.sca.contribution.Import;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-
-/**
- * A model resolver implementation that considers Exports in a list of contributions.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultImportAllModelResolver implements ModelResolver {
-
- private Import import_;
- private List<Contribution> contributions;
-
- public DefaultImportAllModelResolver(Import import_, List<Contribution> contributions) {
- this.import_ = import_;
- this.contributions = contributions;
- }
-
- public void addModel(Object resolved, ProcessorContext context) {
- throw new IllegalStateException();
- }
-
- public Object removeModel(Object resolved, ProcessorContext context) {
- throw new IllegalStateException();
- }
-
- public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
-
- //TODO optimize and cache results of the resolution later
-
- // Go over all available contributions
- for (Contribution contribution : contributions) {
-
- // Go over all exports in the contribution
- for (Export export : contribution.getExports()) {
-
- // If the export matches the export, try to resolve the model object
- if (import_.match(export)) {
- Object resolved = export.getModelResolver().resolveModel(modelClass, unresolved, context);
-
- // Return the resolved model object
- if (resolved instanceof Base) {
- if (!((Base)resolved).isUnresolved()) {
- return modelClass.cast(resolved);
- }
- }
- }
- }
- }
-
- // Model object was not resolved
- return unresolved;
- }
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java
deleted file mode 100644
index 8a11cb42f8..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultImportModelResolver.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Base;
-import org.apache.tuscany.sca.contribution.Export;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-
-/**
- * A model resolver implementation that delegates to a list of exports.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultImportModelResolver implements ModelResolver {
-
- private List<Export> exports;
-
- public DefaultImportModelResolver(List<Export> exports) {
- this.exports = exports;
- }
-
- public void addModel(Object resolved, ProcessorContext context) {
- throw new IllegalStateException();
- }
-
- public Object removeModel(Object resolved, ProcessorContext context) {
- throw new IllegalStateException();
- }
-
- public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
-
- //TODO optimize and cache results of the resolution later
-
- // Go over all exports
- for (Export export: exports) {
-
- Object resolved = export.getModelResolver().resolveModel(modelClass, unresolved, context);
-
- // Return the resolved model object
- if (resolved instanceof Base) {
- if (!((Base)resolved).isUnresolved()) {
- return modelClass.cast(resolved);
- }
- }
- }
-
- // Model object was not resolved
- return unresolved;
- }
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
deleted file mode 100644
index 94b2fb0058..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolver.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.DefaultImport;
-import org.apache.tuscany.sca.contribution.Import;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-
-/**
- * A default implementation of a model resolver based on a map.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultModelResolver implements ModelResolver {
-
- private Contribution contribution;
- private Map<Object, Object> map = new HashMap<Object, Object>();
-
- public DefaultModelResolver() {
- }
-
- public DefaultModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
- this.contribution = contribution;
- }
-
- public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
- Object resolved = map.get(unresolved);
- if (resolved != null) {
-
- // Return the resolved object
- return modelClass.cast(resolved);
-
- } else {
-
- // by default try and resolve through a default import
- // if there is one.
- if (contribution != null){
- for (Import _import : contribution.getImports()){
- if (_import instanceof DefaultImport){
- resolved = _import.getModelResolver().resolveModel(modelClass, unresolved, context);
- if (resolved != unresolved){
- return modelClass.cast(resolved);
- }
- }
- }
- }
-
- // Return the unresolved object
- return unresolved;
- }
- }
-
- public void addModel(Object resolved, ProcessorContext context) {
- map.put(resolved, resolved);
- }
-
- public Object removeModel(Object resolved, ProcessorContext context) {
- return map.remove(resolved);
- }
-
- // FIXME: TUSCANY-2499: temporarily give access to the models to get the jms binding
- // use of definitions.xml working while the definitions.xml processing is being refactored
- public Map<Object, Object> getModels() {
- return map;
- }
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
deleted file mode 100644
index ac16d413eb..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverExtensionPoint.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-
-
-/**
- * The default implementation of a model resolver extension point.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultModelResolverExtensionPoint implements ModelResolverExtensionPoint {
-
- private final Map<Class<?>, Class<? extends ModelResolver>> resolvers = new HashMap<Class<?>, Class<? extends ModelResolver>>();
- private Map<String, ServiceDeclaration> loadedResolvers;
- private ExtensionPointRegistry registry;
-
- /**
- * Constructs a new DefaultModelResolverExtensionPoint.
- */
- public DefaultModelResolverExtensionPoint(ExtensionPointRegistry registry) {
- this.registry = registry;
- }
-
- public void addResolver(Class<?> modelType, Class<? extends ModelResolver> resolver) {
- resolvers.put(modelType, resolver);
- }
-
- public void removeResolver(Class<?> modelType) {
- resolvers.remove(modelType);
- }
-
- @SuppressWarnings("unchecked")
- public Class<? extends ModelResolver> getResolver(Class<?> modelType) {
- loadModelResolvers();
-
- Class<?>[] classes = modelType.getInterfaces();
- for (Class<?> c : classes) {
- Class<? extends ModelResolver> resolver = resolvers.get(c);
- if (resolver == null) {
- ServiceDeclaration resolverClass = loadedResolvers.get(c.getName());
- if (resolverClass != null) {
- try {
- return (Class<? extends ModelResolver>)resolverClass.loadClass();
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException(e);
- }
- }
- } else {
- return resolver;
- }
- }
-
- Class<? extends ModelResolver > resolver = resolvers.get(modelType);
- if (resolver == null) {
- ServiceDeclaration resolverClass = loadedResolvers.get(modelType.getName());
- if (resolverClass != null) {
- try {
- return (Class<? extends ModelResolver>)resolverClass.loadClass();
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException(e);
- }
- }
- }
- return resolver;
- }
-
- /**
- * Dynamically load model resolvers declared under META-INF/services
- */
- private synchronized void loadModelResolvers() {
- if (loadedResolvers != null)
- return;
- loadedResolvers = new HashMap<String, ServiceDeclaration>();
-
- // Get the model resolver service declarations
- Collection<ServiceDeclaration> modelResolverDeclarations;
- try {
- modelResolverDeclarations = registry.getServiceDiscovery().getServiceDeclarations(ModelResolver.class.getName());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- // Load model resolvers
- for (ServiceDeclaration modelResolverDeclaration : modelResolverDeclarations) {
- Map<String, String> attributes = modelResolverDeclaration.getAttributes();
- String model = attributes.get("model");
- // The model can be a list of interfaces so that one model resolver can be used
- // to resolve different types of models
- if (model != null) {
- StringTokenizer tokenizer = new StringTokenizer(model);
- while (tokenizer.hasMoreTokens()) {
- String key = tokenizer.nextToken();
- loadedResolvers.put(key, modelResolverDeclaration);
- }
-
- }
- }
- }
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
deleted file mode 100644
index 72e4b03c7f..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolver.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.lang.reflect.Constructor;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-
-/**
- * An implementation of an extensible model resolver which delegates to the
- * proper resolver extension based on the class of the model to resolve.
- *
- * @version $Rev$ $Date$
- */
-public class ExtensibleModelResolver implements ModelResolver {
- private final ModelResolverExtensionPoint resolverExtensions;
- private final FactoryExtensionPoint modelFactories;
- private final Contribution contribution;
- private ModelResolver defaultResolver;
- private final Map<Class<?>, ModelResolver> resolversByModelType = new HashMap<Class<?>, ModelResolver>();
- private final Map<Class<?>, ModelResolver> resolversByImplementationClass = new HashMap<Class<?>, ModelResolver>();
- private Map<Object, Object> map = new HashMap<Object, Object>();
- private Object lastUnresolved;
-
- /**
- * Constructs an extensible model resolver
- *
- * @param resolverExtensions
- * @param contribution
- * @param modelFactories
- */
- public ExtensibleModelResolver(Contribution contribution,
- ModelResolverExtensionPoint resolverExtensions,
- FactoryExtensionPoint modelFactories) {
- this.contribution = contribution;
- this.resolverExtensions = resolverExtensions;
- this.modelFactories = modelFactories;
- }
-
- /**
- * Returns the proper resolver instance based on the interfaces of the model
- * If one is not available on the registry, instantiate on demand
- *
- * @param modelType
- * @return
- */
- private ModelResolver getModelResolverInstance(Class<?> modelType) {
- // Look up a model resolver instance for the model class or
- // each implemented interface
- Class<?>[] interfaces = modelType.getInterfaces();
- Class<?>[] classes = new Class<?>[interfaces.length + 1];
- classes[0] = modelType;
- if (interfaces.length != 0) {
- System.arraycopy(interfaces, 0, classes, 1, interfaces.length);
- }
- for (Class<?> c : classes) {
-
- // Look up an existing model resolver instance
- ModelResolver resolverInstance = resolversByModelType.get(c);
- if (resolverInstance != null) {
- return resolverInstance;
- }
-
- // We don't have an instance, lookup a model resolver class
- // and instantiate it
- Class<? extends ModelResolver> resolverClass = resolverExtensions.getResolver(c);
- if (resolverClass != null) {
-
- // Construct the model resolver instance and cache it
- resolverInstance = resolversByImplementationClass.get(resolverClass);
- if (resolverInstance != null) {
- resolversByModelType.put(c, resolverInstance);
- return resolverInstance;
- }
- try {
- Constructor<? extends ModelResolver> constructor =
- resolverClass
- .getConstructor(new Class[] {Contribution.class, FactoryExtensionPoint.class});
- if (constructor != null) {
-
- resolverInstance = constructor.newInstance(contribution, modelFactories);
- resolversByImplementationClass.put(resolverClass, resolverInstance);
- resolversByModelType.put(c, resolverInstance);
- return resolverInstance;
- }
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
- }
-
- return null;
- }
-
- public void addModel(Object resolved, ProcessorContext context) {
- ModelResolver resolver = getModelResolverInstance(resolved.getClass());
- if (resolver != null) {
- resolver.addModel(resolved, context);
- } else {
- map.put(resolved, resolved);
- }
- }
-
- public Object removeModel(Object resolved, ProcessorContext context) {
- ModelResolver resolver = getModelResolverInstance(resolved.getClass());
- if (resolver != null) {
- return resolver.removeModel(resolved, context);
- } else {
- return map.remove(resolved);
- }
- }
-
- public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
- // Protect against dependency cycles causing infinite recursion
- // Save the current unresolved object and check later if we are trying
- // to resolve the same object again
- if (unresolved == lastUnresolved) {
- return unresolved;
- }
- lastUnresolved = unresolved;
-
- ModelResolver resolver = getModelResolverInstance(unresolved.getClass());
- if (resolver != null) {
- Object resolved = resolver.resolveModel(modelClass, unresolved, context);
- if (resolved != null && resolved != unresolved) {
- lastUnresolved = null;
- return modelClass.cast(resolved);
- }
- } else {
- //FIXME Remove this default resolver, this is currently used to resolve policy declarations
- // but they should be handled by the contribution import/export mechanism instead of this
- // defaultResolver hack.
- if (defaultResolver != null) {
- Object resolved = defaultResolver.resolveModel(modelClass, unresolved, context);
- if (resolved != null && resolved != unresolved) {
- lastUnresolved = null;
- return modelClass.cast(resolved);
- }
- }
-
- Object resolved = map.get(unresolved);
- if (resolved != null) {
- // Return the resolved object
- lastUnresolved = null;
- return modelClass.cast(resolved);
- }
- }
-
- return unresolved;
- }
-
- // FIXME: TUSCANY-2499: temporarily give access to the defaultResolver to get the jms binding
- // use of definitions.xml working while the definitions.xml processing is being refactored
- public ModelResolver getDefaultModelResolver() {
- return defaultResolver;
- }
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java
deleted file mode 100644
index ec8495d1d2..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolver.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import org.apache.tuscany.sca.contribution.processor.ProcessorContext;
-
-/**
- * A model resolver, responsible for resolving models in the scope of an
- * SCA contribution.
- *
- * SCA Assemblies reference artifacts of a wide variety of types. These
- * include:
- * <ul>
- * <li> Reference from one SCA composite to another SCA composite
- * <li> Reference to PolicySet files
- * <li> Reference to interface definition files, either WSDL or Java interfaces
- * <li> Reference to XSD files
- * <li> Reference to any of a wide variety of implementation artifact files,
- * including Java classes, BPEL scripts, C++ DLLs and classes, PHP scripts
- * </ul>
- *
- * In the SCA assemblies, these various artifacts are referenced using either
- * QNames or logical URIs. Model resolvers are used to resolve these references
- * and get the in-memory models representing the referenced artifacts.
- *
- * @version $Rev$ $Date$
- */
-public interface ModelResolver {
-
- /**
- * Resolve the model representing an artifact.
- *
- * @param modelClass the type of artifact
- * @param unresolved the unresolved model
- * @param context The context
- * @return the resolved model
- */
- <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context);
-
- /**
- * Add a resolved model.
- *
- * @param resolved The model
- * @param context
- */
- void addModel(Object resolved, ProcessorContext context);
-
- /**
- * Remove a resolved model.
- *
- * @param resolved
- * @param context
- * @return The removed model, or null if the model was not removed
- */
- Object removeModel(Object resolved, ProcessorContext context);
-
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java
deleted file mode 100644
index 4a25059792..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ModelResolverExtensionPoint.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-
-/**
- * An extension point for model resolvers
- *
- * @version $Rev$ $Date$
- */
-public interface ModelResolverExtensionPoint {
-
- /**
- * Register a model resolver class using the model type as the key
- *
- * @param modelType The model type
- * @param resolver The model resolver Class
- */
- void addResolver(Class<?> modelType, Class <? extends ModelResolver> resolver);
-
- /**
- * Remove the model resolver class for a specific model type
- *
- * @param modelType The model type
- */
- void removeResolver(Class<?> modelType);
-
- /**
- * Retrieve a model resolver class for a specific model type
- *
- * @param modelType The model artifact type
- * @return The model resolver Class
- */
- Class <? extends ModelResolver> getResolver(Class<?> modelType);
-}
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java
deleted file mode 100644
index 74f0f2d71d..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResolverExtension.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-/**
- * Extension to assembly model implementations to provide a model resolver.
- *
- * @version $Rev$ $Date$
- */
-public interface ResolverExtension {
-
- /**
- * Returns the model resolver for the models representing the artifacts
- * visible in the scope of this contribution.
- *
- * @return The model resolver
- */
- ModelResolver getModelResolver();
-
- /**
- * Sets the model resolver for the models representing the artifacts
- * visible in the scope of this contribution.
- *
- * @param modelResolver The model resolver
- */
- void setModelResolver(ModelResolver modelResolver);
-
-} \ No newline at end of file
diff --git a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java b/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java
deleted file mode 100644
index dfe8f08719..0000000000
--- a/java/sca/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/resolver/ResourceReference.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tuscany.sca.contribution.resolver;
-
-import java.net.URL;
-
-/**
- * A resource URL, which should be used to register resources
- * with an ArtifactResolver and resolve these resources later.
- *
- * FIXME Don't use as its deprecated, use Artifact instead.
- *
- * @version $Rev$ $Date$
- */
-@Deprecated
-public class ResourceReference {
-
- private URL resourceURL;
- private String resourceName;
-
- /**
- * Constructs a new ResourceReference.
- *
- * @param resourceName Name of resource
- * @param resourceURL The resource URL
- */
- public ResourceReference(String resourceName, URL resourceURL) {
- this.resourceURL = resourceURL;
- this.resourceName = resourceName;
- }
-
- /**
- * Constructs a new ResourceReference.
- *
- * @param resourceName Name of resource
- */
- public ResourceReference(String resourceName) {
- this.resourceName = resourceName;
- }
-
- /**
- * Get the resource URL.
- *
- * @return The resource URL
- */
- public URL getResource() {
- return resourceURL;
- }
-
- /**
- * Get the resource name.
- *
- * @return The resource name
- */
- public String getResourceName() {
- return resourceName;
- }
-
- /**
- * Returns true if the resource reference is unresolved.
- *
- * @return Whether or not the resource has been resolved
- */
- public boolean isUnresolved() {
- return resourceURL == null;
- }
-
- @Override
- public int hashCode() {
- return resourceName.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- } else {
- if (obj instanceof ResourceReference) {
- return resourceName.equals(((ResourceReference)obj).resourceName);
- } else {
- return false;
- }
- }
- }
-
-}