summaryrefslogtreecommitdiffstats
path: root/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system')
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java21
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java33
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java38
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java37
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java38
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java41
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java41
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java94
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java383
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java63
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java77
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java140
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java92
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java97
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java92
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java666
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java198
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java82
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java82
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java56
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java50
-rw-r--r--tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java49
22 files changed, 0 insertions, 2470 deletions
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java
deleted file mode 100644
index bcb06812e8..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/Autowire.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package org.apache.tuscany.core.system.annotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * A system annotation to inject an autowired instance
- *
- * @version $Rev$ $Date$
- */
-@Target( { METHOD, FIELD })
-@Retention(RUNTIME)
-public @interface Autowire {
-
- public boolean required() default true;
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java
deleted file mode 100644
index f3d2c0216b..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/annotation/ParentContext.java
+++ /dev/null
@@ -1,33 +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.system.annotation;
-
-import static java.lang.annotation.ElementType.FIELD;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.RUNTIME;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-
-/**
- * A system annotation to inject the parent context
- *
- * @version $Rev$ $Date$
- */
-
-@Target( { METHOD, FIELD })
-@Retention(RUNTIME)
-public @interface ParentContext {
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java
deleted file mode 100644
index d230df8dd7..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemAssemblyFactory.java
+++ /dev/null
@@ -1,38 +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.system.assembly;
-
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-
-/**
- * A factory for building system assembly model artifacts
- *
- * @version $Rev$ $Date$
- */
-public interface SystemAssemblyFactory extends AssemblyFactory {
-
- /**
- * Returns an assembly model artifact representing a system component implementation
- */
- SystemImplementation createSystemImplementation();
-
- /**
- * Returns an assembly model artifact representing a system binding
- */
- SystemBinding createSystemBinding();
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java
deleted file mode 100644
index edc7c87c85..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemBinding.java
+++ /dev/null
@@ -1,37 +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.system.assembly;
-
-import org.apache.tuscany.model.assembly.Binding;
-
-/**
- * Represents a system binding
- *
- * @version $Rev$ $Date$
- */
-public interface SystemBinding extends Binding {
-
- /**
- * Returns the qualified name of the wire target the binding is associated with in component/service form
- */
- public String getTargetName();
-
- /**
- * Sets the qualified name of the wire target the binding is associated with in component/service form
- */
- public void setTargetName(String name);
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java
deleted file mode 100644
index 7fae0ebad3..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/SystemImplementation.java
+++ /dev/null
@@ -1,38 +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.system.assembly;
-
-import org.apache.tuscany.model.assembly.ComponentImplementation;
-
-/**
- * Represents a system component implementation
- *
- * @version $Rev$ $Date$
- */
-public interface SystemImplementation extends ComponentImplementation {
-
- /**
- * Returns the implementation class of the system component
- */
- Class getImplementationClass();
-
- /**
- * Sets the implementation class of the system component
- */
- void setImplementationClass(Class value);
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java
deleted file mode 100644
index 668b7dd8b1..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemAssemblyFactoryImpl.java
+++ /dev/null
@@ -1,41 +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.system.assembly.impl;
-
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
-
-/**
- * The default implementation of the system assembly factory
- *
- * @version $Rev$ $Date$
- */
-public class SystemAssemblyFactoryImpl extends AssemblyFactoryImpl implements SystemAssemblyFactory {
-
- public SystemAssemblyFactoryImpl() {
- }
-
- public SystemImplementation createSystemImplementation() {
- return new SystemImplementationImpl();
- }
-
- public SystemBinding createSystemBinding() {
- return new SystemBindingImpl();
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java
deleted file mode 100644
index a9996065e2..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemBindingImpl.java
+++ /dev/null
@@ -1,41 +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.system.assembly.impl;
-
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-import org.apache.tuscany.model.assembly.impl.BindingImpl;
-
-/**
- * The default implementation of the system binding assembly artifact
- *
- * @version $Rev$ $Date$
- */
-public class SystemBindingImpl extends BindingImpl implements SystemBinding {
-
- protected SystemBindingImpl() {
- }
-
- private String name;
-
- public String getTargetName() {
- return name;
- }
-
- public void setTargetName(String name) {
- this.name = name;
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java
deleted file mode 100644
index 5d54132464..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/assembly/impl/SystemImplementationImpl.java
+++ /dev/null
@@ -1,94 +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.system.assembly.impl;
-
-import java.net.URL;
-
-import org.apache.tuscany.core.config.ComponentTypeIntrospector;
-import org.apache.tuscany.core.config.ConfigurationException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.core.config.impl.Java5ComponentTypeIntrospector;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-import org.apache.tuscany.model.assembly.AssemblyFactory;
-import org.apache.tuscany.model.assembly.AssemblyModelContext;
-import org.apache.tuscany.model.assembly.ComponentType;
-import org.apache.tuscany.model.assembly.Scope;
-import org.apache.tuscany.model.assembly.Service;
-import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
-import org.apache.tuscany.model.assembly.impl.ComponentImplementationImpl;
-
-/**
- * The default implementation of the system implementation assembly artifact
- *
- * @version $Rev$ $Date$
- */
-public class SystemImplementationImpl extends ComponentImplementationImpl implements SystemImplementation {
-
- private Class<?> implementationClass;
-
- private AssemblyModelContext modelContext;
-
- protected SystemImplementationImpl() {
- }
-
- public Class getImplementationClass() {
- return implementationClass;
- }
-
- public void setImplementationClass(Class value) {
- checkNotFrozen();
- implementationClass = value;
- }
-
- public void initialize(AssemblyModelContext context) {
- if (isInitialized())
- return;
- this.modelContext = context;
- // Initialize the component type
- ComponentType componentType = getComponentType();
- if (componentType == null) {
- componentType = createComponentType(implementationClass);
- setComponentType(componentType);
- }
- super.initialize(modelContext);
- }
-
- /**
- * Creates the component type
- */
- private ComponentType createComponentType(Class<?> implClass) {
- ComponentType componentType;
- String baseName = JavaIntrospectionHelper.getBaseName(implClass);
- URL componentTypeFile = implClass.getResource(baseName + ".componentType");
- if (componentTypeFile != null) {
- componentType = modelContext.getAssemblyLoader().loadComponentType(componentTypeFile.toString());
- // FIXME workaround for TUSCANY-46 where the scope is not read - default system implementations to MODULE scope
- for (Service service : componentType.getServices()) {
- service.getServiceContract().setScope(Scope.MODULE);
- }
- } else {
- AssemblyFactory factory = new AssemblyFactoryImpl();
- ComponentTypeIntrospector introspector = new Java5ComponentTypeIntrospector(factory);
- try {
- componentType = introspector.introspect(implClass);
- } catch (ConfigurationException e) {
- throw new IllegalArgumentException("Unable to introspect implementation class: " + implClass.getName(), e);
- }
- }
- return componentType;
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java
deleted file mode 100644
index ac65a3de49..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemComponentContextBuilder.java
+++ /dev/null
@@ -1,383 +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.system.builder;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.tuscany.common.monitor.MonitorFactory;
-import org.apache.tuscany.core.builder.BuilderConfigException;
-import org.apache.tuscany.core.builder.BuilderException;
-import org.apache.tuscany.core.builder.NoAccessorException;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.builder.UnknownTypeException;
-import org.apache.tuscany.core.config.JavaIntrospectionHelper;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.AutowireContext;
-import org.apache.tuscany.core.context.ConfigurationContext;
-import org.apache.tuscany.core.context.SystemAggregateContext;
-import org.apache.tuscany.core.context.impl.AggregateContextImpl;
-import org.apache.tuscany.core.injection.EventInvoker;
-import org.apache.tuscany.core.injection.FieldInjector;
-import org.apache.tuscany.core.injection.Injector;
-import org.apache.tuscany.core.injection.MethodEventInvoker;
-import org.apache.tuscany.core.injection.MethodInjector;
-import org.apache.tuscany.core.injection.ObjectCreationException;
-import org.apache.tuscany.core.injection.ReferenceTargetFactory;
-import org.apache.tuscany.core.injection.SDOObjectFactory;
-import org.apache.tuscany.core.injection.SingletonObjectFactory;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.system.annotation.ParentContext;
-import org.apache.tuscany.core.system.assembly.SystemImplementation;
-import org.apache.tuscany.core.system.config.SystemComponentRuntimeConfiguration;
-import org.apache.tuscany.core.system.context.SystemAggregateContextImpl;
-import org.apache.tuscany.model.assembly.AssemblyModelObject;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.ComponentImplementation;
-import org.apache.tuscany.model.assembly.ConfiguredProperty;
-import org.apache.tuscany.model.assembly.ConfiguredReference;
-import org.apache.tuscany.model.assembly.ConfiguredService;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.Scope;
-import org.osoa.sca.annotations.ComponentName;
-import org.osoa.sca.annotations.Context;
-import org.osoa.sca.annotations.Destroy;
-import org.osoa.sca.annotations.Init;
-
-import commonj.sdo.DataObject;
-
-/**
- * Decorates components whose implementation type is a
- * {@link org.apache.tuscany.core.system.assembly.SystemImplementation} with the appropriate runtime configuration.
- * System components are not proxied.
- *
- * @version $Rev$ $Date$
- */
-public class SystemComponentContextBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemComponentContextBuilder() {
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public void build(AssemblyModelObject modelObject, AggregateContext parentContext) throws BuilderException {
- if (!(modelObject instanceof Component)) {
- return;
- }
- Component component = (Component) modelObject;
-
- Class implClass = null;
- Scope scope = null;
-
- // Get the component implementation
- ComponentImplementation componentImplementation = component.getComponentImplementation();
- if (componentImplementation instanceof SystemImplementation
- && componentImplementation.getRuntimeConfiguration() == null) {
-
- // The component is a system component, implemented by a Java class
- SystemImplementation javaImpl = (SystemImplementation) componentImplementation;
- scope = componentImplementation.getComponentType().getServices().get(0).getServiceContract().getScope();
- implClass = javaImpl.getImplementationClass();
-
- } else if (componentImplementation instanceof Module) {
- if (((Module)componentImplementation).getName().startsWith("org.apache.tuscany.core.system")) {
-
- // The component is a system module component, fix the implementation class to our implementation
- // of system module component context
- implClass=SystemAggregateContextImpl.class;
- scope = Scope.AGGREGATE;
-
- } else {
-
- // The component is an app module component, fix the implementation class to our implementation
- // of app module component context
- implClass=AggregateContextImpl.class;
- scope = Scope.AGGREGATE;
-
- }
-
- } else {
- return;
- }
-
- // FIXME scope
- Set<Field> fields;
- Set<Method> methods;
- try {
- fields = JavaIntrospectionHelper.getAllFields(implClass);
- methods = JavaIntrospectionHelper.getAllUniqueMethods(implClass);
- String name = component.getName();
- Constructor ctr = implClass.getConstructor((Class[]) null);
-
- List<Injector> injectors = new ArrayList();
-
- // handle properties
- List<ConfiguredProperty> configuredProperties = component.getConfiguredProperties();
- if (configuredProperties != null) {
- for (ConfiguredProperty property : configuredProperties) {
- Injector injector = createPropertyInjector(property, fields, methods);
- injectors.add(injector);
- }
- }
-
- //FIXME do not inject references on an application module yet
- if (implClass!=AggregateContextImpl.class) {
- // handle references
- List<ConfiguredReference> configuredReferences = component.getConfiguredReferences();
- if (configuredReferences != null) {
- for (ConfiguredReference reference : configuredReferences) {
- Injector injector = createReferenceInjector(parentContext.getName(), component.getName(), parentContext,
- reference, fields, methods);
- injectors.add(injector);
- }
- }
- }
-
- // create factory for the component implementation type
- EventInvoker initInvoker = null;
- boolean eagerInit = false;
- EventInvoker destroyInvoker = null;
- for (Field field : fields) {
- ComponentName compName = field.getAnnotation(ComponentName.class);
- if (compName != null) {
- Injector injector = new FieldInjector(field, new SingletonObjectFactory(name));
- injectors.add(injector);
- }
- Context context = field.getAnnotation(Context.class);
- if (context != null) {
- Injector injector = new FieldInjector(field, new SingletonObjectFactory(parentContext));
- injectors.add(injector);
- }
- ParentContext parentField = field.getAnnotation(ParentContext.class);
- if (parentField != null) {
- if (!(parentContext instanceof AggregateContext)) {
- BuilderConfigException e = new BuilderConfigException("Component must be a child of");
- e.setIdentifier(AggregateContext.class.getName());
- throw e;
- }
- Injector injector = new FieldInjector(field, new SingletonObjectFactory((parentContext)));
- injectors.add(injector);
- }
- Autowire autowire = field.getAnnotation(Autowire.class);
- if (autowire != null) {
- if (!(parentContext instanceof AutowireContext)) {
- BuilderConfigException e = new BuilderConfigException("Parent context must implement");
- e.setIdentifier(AutowireContext.class.getName());
- throw e;
- }
- AutowireContext ctx = (AutowireContext) parentContext;
- // for system aggregate context types, only allow autowire of certain types, otherwise we have a
- // chicken-and-egg problem
- if (SystemAggregateContext.class.isAssignableFrom(implClass)
- && !(field.getType().equals(ConfigurationContext.class)
- || field.getType().equals(MonitorFactory.class)
- || field.getType().equals(RuntimeContext.class) || field.getType().equals(
- AutowireContext.class))) {
- BuilderConfigException e = new BuilderConfigException("Illegal autowire type for system context");
- e.setIdentifier(field.getType().getName());
- throw e;
- }
-
- Object o = ctx.resolveInstance(field.getType());
- if (autowire.required() && o == null) {
- BuilderConfigException e = new BuilderConfigException("No autowire found for field");
- e.setIdentifier(field.getName());
- throw e;
- }
- Injector injector = new FieldInjector(field, new SingletonObjectFactory(o));
- injectors.add(injector);
- }
- }
- for (Method method : methods) {
- Init init = method.getAnnotation(Init.class);
- if (init != null && initInvoker == null) {
- initInvoker = new MethodEventInvoker(method);
- eagerInit = init.eager();
- continue;
- }
- Destroy destroy = method.getAnnotation(Destroy.class);
- if (destroy != null && destroyInvoker == null) {
- destroyInvoker = new MethodEventInvoker(method);
- continue;
- }
- ComponentName compName = method.getAnnotation(ComponentName.class);
- if (compName != null) {
- Injector injector = new MethodInjector(method, new SingletonObjectFactory(name));
- injectors.add(injector);
- }
- Context context = method.getAnnotation(Context.class);
- if (context != null) {
- Injector injector = new MethodInjector(method, new SingletonObjectFactory(parentContext));
- injectors.add(injector);
- }
- ParentContext parentMethod = method.getAnnotation(ParentContext.class);
- if (parentMethod != null) {
- if (!(parentContext instanceof AggregateContext)) {
- BuilderConfigException e = new BuilderConfigException("Component must be a child of ");
- e.setIdentifier(AggregateContext.class.getName());
- throw e;
- }
- Injector injector = new MethodInjector(method, new SingletonObjectFactory((parentContext)));
- injectors.add(injector);
- }
- Autowire autowire = method.getAnnotation(Autowire.class);
- if (autowire != null) {
- if (!(parentContext instanceof AutowireContext)) {
- BuilderConfigException e = new BuilderConfigException("Parent context must implement)");
- e.setIdentifier(AutowireContext.class.getName());
- throw e;
- }
- if (method.getParameterTypes() == null || method.getParameterTypes().length != 1) {
- BuilderConfigException e = new BuilderConfigException(
- "Autowire setter methods must take one parameter");
- e.setIdentifier(method.getName());
- throw e;
- }
- AutowireContext ctx = (AutowireContext) parentContext;
- Class paramType = method.getParameterTypes()[0];
- // for system aggregate context types, only allow autowire of certain types, otherwise we have a
- // chicken-and-egg problem
- if (SystemAggregateContext.class.isAssignableFrom(implClass)
- && !(paramType.equals(ConfigurationContext.class) || paramType.equals(MonitorFactory.class)
- || paramType.equals(RuntimeContext.class) || paramType.equals(AutowireContext.class))) {
- BuilderConfigException e = new BuilderConfigException("Illegal autowire type for system context");
- e.setIdentifier(paramType.getName());
- throw e;
- }
- Object o = ctx.resolveInstance(paramType);
- if (autowire.required() && o == null) {
- BuilderConfigException e = new BuilderConfigException("No autowire found for method ");
- e.setIdentifier(method.getName());
- throw e;
- }
-
- Injector injector = new MethodInjector(method, new SingletonObjectFactory(o));
- injectors.add(injector);
- }
- }
- // decorate the logical model
- SystemComponentRuntimeConfiguration config = new SystemComponentRuntimeConfiguration(name,
- JavaIntrospectionHelper.getDefaultConstructor(implClass), injectors, eagerInit, initInvoker,
- destroyInvoker, scope);
- componentImplementation.setRuntimeConfiguration(config);
- } catch (BuilderConfigException e) {
- e.addContextName(component.getName());
- e.addContextName(parentContext.getName());
- throw e;
- } catch (NoSuchMethodException e) {
- BuilderConfigException ce = new BuilderConfigException("Class does not have a no-arg constructor", e);
- ce.setIdentifier(implClass.getName());
- throw ce;
- }
- }
-
- // ----------------------------------
- // Private methods
- // ----------------------------------
-
- /**
- * Creates an <code>Injector</code> for component properties
- */
- private Injector createPropertyInjector(ConfiguredProperty property, Set<Field> fields, Set<Method> methods)
- throws NoAccessorException {
- Object value = property.getValue();
- String propName = property.getProperty().getName();
- // @FIXME is this how to get property type of object
- Class type = value.getClass();
-
- // There is no efficient way to do this
- Method method = null;
- Field field = JavaIntrospectionHelper.findClosestMatchingField(propName, type, fields);
- if (field == null) {
- method = JavaIntrospectionHelper.findClosestMatchingMethod(propName, new Class[] { type }, methods);
- if (method == null) {
- throw new NoAccessorException(propName);
- }
- }
- Injector injector = null;
- // FIXME support types other than String
- if (value instanceof DataObject) {
- if (field != null) {
- injector = new FieldInjector(field, new SDOObjectFactory((DataObject) value));
- } else {
- injector = new MethodInjector(method, new SDOObjectFactory((DataObject) value));
- }
- } else if (JavaIntrospectionHelper.isImmutable(type)) {
- if (field != null) {
- injector = new FieldInjector(field, new SingletonObjectFactory(value));
- } else {
- injector = new MethodInjector(method, new SingletonObjectFactory(value));
- }
- } else {
- if (field != null) {
- throw new UnknownTypeException(field.getName());
- } else {
- throw new UnknownTypeException(method.getName());
- }
- }
- return injector;
-
- }
-
- /**
- * Creates an <code>Injector</code> for service references
- */
- private Injector createReferenceInjector(String moduleName, String componentName, AggregateContext parentContext,
- ConfiguredReference reference, Set<Field> fields, Set<Method> methods) throws NoAccessorException,
- BuilderConfigException {
- String refName = reference.getReference().getName();
- List<ConfiguredService> services = reference.getTargetConfiguredServices();
- Class type;
- if (services.size() == 1) {
- // get the interface
- type = reference.getReference().getServiceContract().getInterface();
- } else {
- // FIXME do we support arrays?
- type = List.class;
- }
- Method method = null;
- Field field = JavaIntrospectionHelper.findClosestMatchingField(refName, type, fields);
- if (field == null) {
- method = JavaIntrospectionHelper.findClosestMatchingMethod(refName, new Class[] { type }, methods);
- if (method == null) {
- throw new NoAccessorException(refName);
- }
- }
- Injector injector;
- try {
- if (field != null) {
- injector = new FieldInjector(field, new ReferenceTargetFactory(reference, parentContext));
- } else {
- injector = new MethodInjector(method, new ReferenceTargetFactory(reference, parentContext));
- }
- } catch (ObjectCreationException e) {
- BuilderConfigException ce = new BuilderConfigException("Error configuring reference", e);
- ce.setIdentifier(refName);
- throw ce;
- }
- return injector;
-
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java
deleted file mode 100644
index 6520fc0557..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemEntryPointBuilder.java
+++ /dev/null
@@ -1,63 +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.system.builder;
-
-import org.apache.tuscany.core.builder.BuilderException;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.injection.FactoryInitException;
-import org.apache.tuscany.core.injection.ReferenceTargetFactory;
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-import org.apache.tuscany.core.system.config.SystemEntryPointRuntimeConfiguration;
-import org.apache.tuscany.model.assembly.AssemblyModelObject;
-import org.apache.tuscany.model.assembly.EntryPoint;
-
-/**
- * Decorates the logical model with entry point context configuration builders
- *
- * @version $Rev$ $Date$
- */
-public class SystemEntryPointBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemEntryPointBuilder() {
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public void build(AssemblyModelObject modelObject, AggregateContext context) throws BuilderException {
- if (!(modelObject instanceof EntryPoint)) {
- return;
- }
- EntryPoint entryPoint = (EntryPoint) modelObject;
- if (!(entryPoint.getBindings().get(0) instanceof SystemBinding)
- || entryPoint.getConfiguredReference().getRuntimeConfiguration() != null) {
- return;
- }
- try {
- SystemEntryPointRuntimeConfiguration config = new SystemEntryPointRuntimeConfiguration(entryPoint.getName(),
- new ReferenceTargetFactory(entryPoint.getConfiguredReference(), context));
- entryPoint.getConfiguredReference().setRuntimeConfiguration(config);
- } catch (FactoryInitException e) {
- e.addContextName(entryPoint.getName());
- e.addContextName(context.getName());
- throw e;
- }
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java
deleted file mode 100644
index dc00e6505f..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/builder/SystemExternalServiceBuilder.java
+++ /dev/null
@@ -1,77 +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.system.builder;
-
-import org.apache.tuscany.core.builder.BuilderConfigException;
-import org.apache.tuscany.core.builder.BuilderException;
-import org.apache.tuscany.core.builder.RuntimeConfigurationBuilder;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.AutowireContext;
-import org.apache.tuscany.core.injection.ReferenceTargetFactory;
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-import org.apache.tuscany.core.system.config.SystemExternalServiceRuntimeConfiguration;
-import org.apache.tuscany.core.system.injection.AutowireFactory;
-import org.apache.tuscany.model.assembly.AssemblyModelObject;
-import org.apache.tuscany.model.assembly.ExternalService;
-
-/**
- * Creates runtime configurations for system type external services
- *
- * @version $Rev$ $Date$
- */
-public class SystemExternalServiceBuilder implements RuntimeConfigurationBuilder<AggregateContext> {
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemExternalServiceBuilder() {
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public void build(AssemblyModelObject modelObject, AggregateContext context) throws BuilderException {
- if (!(modelObject instanceof ExternalService)) {
- return;
- }
- ExternalService externalService = (ExternalService) modelObject;
- if (externalService.getConfiguredService() != null
- && externalService.getConfiguredService().getRuntimeConfiguration() != null) {
- return;
- } else if (externalService.getBindings() == null || externalService.getBindings().size() < 1
- || !(externalService.getBindings().get(0) instanceof SystemBinding)) {
- return;
- }
- SystemBinding binding = (SystemBinding)externalService.getBindings().get(0);
- if (binding.getTargetName() != null) {
- SystemExternalServiceRuntimeConfiguration config = new SystemExternalServiceRuntimeConfiguration(externalService
- .getName(), new ReferenceTargetFactory(binding.getTargetName(), context));
- externalService.getConfiguredService().setRuntimeConfiguration(config);
- } else if (externalService.getConfiguredService().getService().getServiceContract().getInterface() != null) {
- // autowire
- Class<?> claz = externalService.getConfiguredService().getService().getServiceContract().getInterface();
- if (claz == null) {
- BuilderException e = new BuilderConfigException("Interface type not specified");
- e.setIdentifier(externalService.getName());
- e.addContextName(externalService.getName());
- e.addContextName(context.getName());
- throw e;
- }
- SystemExternalServiceRuntimeConfiguration config = new SystemExternalServiceRuntimeConfiguration(externalService
- .getName(), new AutowireFactory(claz, (AutowireContext) context));
- externalService.getConfiguredService().setRuntimeConfiguration(config);
- }
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java
deleted file mode 100644
index cf05059b90..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemComponentRuntimeConfiguration.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package org.apache.tuscany.core.system.config;
-
-import java.lang.reflect.Constructor;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tuscany.core.builder.ContextCreationException;
-import org.apache.tuscany.core.builder.RuntimeConfiguration;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.InstanceContext;
-import org.apache.tuscany.core.injection.EventInvoker;
-import org.apache.tuscany.core.injection.Injector;
-import org.apache.tuscany.core.injection.PojoObjectFactory;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.core.system.context.SystemComponentContext;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * A RuntimeConfiguration that handles system component implementation types
- *
- * @version $Rev$ $Date$
- */
-public class SystemComponentRuntimeConfiguration implements RuntimeConfiguration<InstanceContext> {
-
- // the component name as configured in the hosting module
- private String name;
-
- // the implementation type constructor
- private Constructor ctr;
-
- // injectors for properties, references and other metadata values such as @Context
- private List<Injector> setters;
-
- // an invoker for a method decorated with @Init
- private EventInvoker init;
-
- // whether the component should be eagerly initialized when its scope starts
- private boolean eagerInit;
-
- // an invoker for a method decorated with @Destroy
- private EventInvoker destroy;
-
- // the scope of the implementation instance
- private Scope scope;
-
- // if the component implementation scope is stateless
- private boolean stateless;
-
- // if the component implementation is an aggregate context
- private boolean isAggregate;
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- /**
- * Creates the runtime configuration
- *
- * @param name the SCDL name of the component the context refers to
- * @param ctr the implementation type constructor
- * @param setters a collection of <code>Injectors</code> used to configure properties, references and other meta
- * data values on implementation instances
- * @param eagerInit whether the component should be eagerly initialized
- * @param init an <code>Invoker</code> pointing to a method on the implementation type decorated with
- * <code>@Init</code>
- * @param destroy an <code>Invoker</code> pointing to a method on the implementation type decorated with
- * <code>@Destroy</code>
- * @param scope the scope of the component implementation type
- */
- public SystemComponentRuntimeConfiguration(String name, Constructor ctr, List<Injector> setters, boolean eagerInit,
- EventInvoker init, EventInvoker destroy, Scope scope) {
- assert (name != null) : "Name was null";
- assert (ctr != null) : "Constructor was null";
- assert (setters != null) : "Setters were null";
- this.name = name;
- this.ctr = ctr;
- this.isAggregate = AggregateContext.class.isAssignableFrom(ctr.getDeclaringClass());
- this.setters = setters;
- this.eagerInit = eagerInit;
- this.init = init;
- this.destroy = destroy;
- this.scope = scope;
- stateless = (scope == Scope.INSTANCE);
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public String getName() {
- return name;
- }
-
- public Scope getScope() {
- return scope;
- }
-
- public InstanceContext createInstanceContext() throws ContextCreationException {
- if (isAggregate) {
- // aggregate context types are themselves an instance context
- PojoObjectFactory objectFactory = new PojoObjectFactory(ctr, null, setters);
- AggregateContext ctx = (AggregateContext) objectFactory.getInstance();
- ctx.setName(name);
- return ctx;
- } else {
- PojoObjectFactory objectFactory = new PojoObjectFactory(ctr, null, setters);
- return new SystemComponentContext(name, objectFactory, eagerInit, init, destroy, stateless);
- }
- }
-
- // -- Proxy
-
- public void prepare() {
- }
-
- public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getTargetProxyFactory(String serviceName) {
- return null;
- }
-
- public Map<String, ProxyFactory> getTargetProxyFactories() {
- return null;
- }
-
- public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getSourceProxyFactory(String referenceName) {
- return null;
- }
-
- public Map<String, ProxyFactory> getSourceProxyFactories() {
- return null;
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java
deleted file mode 100644
index f6c25e9b86..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemEntryPointRuntimeConfiguration.java
+++ /dev/null
@@ -1,92 +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.system.config;
-
-import java.util.Map;
-
-import org.apache.tuscany.core.builder.ContextCreationException;
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.builder.RuntimeConfiguration;
-import org.apache.tuscany.core.context.EntryPointContext;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.core.system.context.SystemEntryPointContext;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Creates {@link SystemEntryPointContext} instances based on an entry point configuration in an assembly model
- *
- * @version $Rev$ $Date$
- */
-public class SystemEntryPointRuntimeConfiguration implements RuntimeConfiguration<EntryPointContext> {
-
- // the name of the entry point
- private String name;
-
- // the factory for returning a reference to the implementation instance of the component exposed by the entry point
- private ObjectFactory factory;
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemEntryPointRuntimeConfiguration(String name, ObjectFactory factory) {
- this.name = name;
- this.factory = factory;
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public EntryPointContext createInstanceContext() throws ContextCreationException {
- return new SystemEntryPointContext(name, factory);
- }
-
- public Scope getScope() {
- return Scope.MODULE;
- }
-
- public String getName() {
- return name;
- }
-
- // -- Proxy
- public void prepare() {
- }
-
- public void addTargetProxyFactory(String serviceName, ProxyFactory pFactory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getTargetProxyFactory(String serviceName) {
- return null;
- }
-
- public Map<String, ProxyFactory> getTargetProxyFactories() {
- return null;
- }
-
- public void addSourceProxyFactory(String referenceName, ProxyFactory pFactory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getSourceProxyFactory(String referenceName) {
- return null;
- }
-
- public Map<String, ProxyFactory> getSourceProxyFactories() {
- return null;
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java
deleted file mode 100644
index 789982bdcf..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemExternalServiceRuntimeConfiguration.java
+++ /dev/null
@@ -1,97 +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.system.config;
-
-import java.util.Map;
-
-import org.apache.tuscany.core.builder.ContextCreationException;
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.builder.RuntimeConfiguration;
-import org.apache.tuscany.core.context.ExternalServiceContext;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.core.system.context.SystemExternalServiceContext;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Creates system type external service contexts
- *
- * @see org.apache.tuscany.core.context.ExternalServiceContext
- * @see org.apache.tuscany.core.system.context.SystemExternalServiceContext
- *
- * @version $Rev$ $Date$
- */
-public class SystemExternalServiceRuntimeConfiguration implements RuntimeConfiguration<ExternalServiceContext> {
-
- // the name of the external service
- private String name;
-
- // the factory for returning a reference to the implementation instance of the component represented by the external service
- private ObjectFactory factory;
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemExternalServiceRuntimeConfiguration(String name, ObjectFactory factory) {
- assert (name != null) : "Name was null";
- assert (factory != null) : "Object factory was null";
- this.name = name;
- this.factory = factory;
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public Scope getScope() {
- return Scope.MODULE;
- }
-
- public String getName() {
- return name;
- }
-
- public ExternalServiceContext createInstanceContext() throws ContextCreationException {
- return new SystemExternalServiceContext(name, factory);
- }
-
- // -- Proxy
- public void prepare() {
- }
-
- public void addTargetProxyFactory(String serviceName, ProxyFactory pFactory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getTargetProxyFactory(String serviceName) {
- return null;
- }
-
- public Map<String, ProxyFactory> getTargetProxyFactories() {
- return null;
- }
-
- public void addSourceProxyFactory(String referenceName, ProxyFactory pFactory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getSourceProxyFactory(String referenceName) {
- return null;
- }
-
- public Map<String, ProxyFactory> getSourceProxyFactories() {
- return null;
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java
deleted file mode 100644
index 06acb12deb..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/config/SystemObjectRuntimeConfiguration.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/**
- *
- * Copyright 2005 BEA Systems Inc.
- * Copyright 2005 International Business Machines Corporation
- *
- * 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.system.config;
-
-import java.util.Map;
-
-import org.apache.tuscany.core.builder.ContextCreationException;
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.builder.RuntimeConfiguration;
-import org.apache.tuscany.core.context.Context;
-import org.apache.tuscany.core.injection.SingletonObjectFactory;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.core.system.context.SystemComponentContext;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * A RuntimeConfiguration that contains the configuration needed to convert a simple
- * Java Object into a component. The object is assumed to be fully initialized and
- * will always be added with MODULE scope.
- *
- * @version $Rev$ $Date$
- */
-public class SystemObjectRuntimeConfiguration implements RuntimeConfiguration {
- private final String name;
- private final ObjectFactory<?> objectFactory;
-
- /**
- * Construct a RuntimeConfiguration for the supplied Java Object.
- *
- * @param name the name to be assigned to the resulting component
- * @param instance the Java Object that provides the implementation
- */
- public SystemObjectRuntimeConfiguration(String name, Object instance) {
- this.name = name;
- objectFactory = new SingletonObjectFactory(instance);
- }
-
- public Context createInstanceContext() throws ContextCreationException {
- return new SystemComponentContext(name, objectFactory, false, null, null, false);
- }
-
- public Scope getScope() {
- return Scope.MODULE;
- }
-
- public String getName() {
- return name;
- }
-
- public void prepare() {
- throw new UnsupportedOperationException();
- }
-
- public void addTargetProxyFactory(String serviceName, ProxyFactory factory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getTargetProxyFactory(String serviceName) {
- throw new UnsupportedOperationException();
- }
-
- public Map getTargetProxyFactories() {
- throw new UnsupportedOperationException();
- }
-
- public void addSourceProxyFactory(String referenceName, ProxyFactory factory) {
- throw new UnsupportedOperationException();
- }
-
- public ProxyFactory getSourceProxyFactory(String referenceName) {
- throw new UnsupportedOperationException();
- }
-
- public Map getSourceProxyFactories() {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java
deleted file mode 100644
index a2efc35ac1..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemAggregateContextImpl.java
+++ /dev/null
@@ -1,666 +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.system.context;
-
-import static org.apache.tuscany.core.context.EventContext.HTTP_SESSION;
-import static org.apache.tuscany.core.context.EventContext.REQUEST_END;
-import static org.apache.tuscany.core.context.EventContext.SESSION_NOTIFY;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.tuscany.common.monitor.MonitorFactory;
-import org.apache.tuscany.core.builder.BuilderConfigException;
-import org.apache.tuscany.core.builder.RuntimeConfiguration;
-import org.apache.tuscany.core.config.ConfigurationException;
-import org.apache.tuscany.core.context.AbstractContext;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.AutowireContext;
-import org.apache.tuscany.core.context.AutowireResolutionException;
-import org.apache.tuscany.core.context.ConfigurationContext;
-import org.apache.tuscany.core.context.ContextInitException;
-import org.apache.tuscany.core.context.CoreRuntimeException;
-import org.apache.tuscany.core.context.DuplicateNameException;
-import org.apache.tuscany.core.context.EntryPointContext;
-import org.apache.tuscany.core.context.EventContext;
-import org.apache.tuscany.core.context.EventException;
-import org.apache.tuscany.core.context.InstanceContext;
-import org.apache.tuscany.core.context.LifecycleEventListener;
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.context.RuntimeEventListener;
-import org.apache.tuscany.core.context.ScopeContext;
-import org.apache.tuscany.core.context.ScopeRuntimeException;
-import org.apache.tuscany.core.context.ScopeStrategy;
-import org.apache.tuscany.core.context.SimpleComponentContext;
-import org.apache.tuscany.core.context.SystemAggregateContext;
-import org.apache.tuscany.core.context.TargetException;
-import org.apache.tuscany.core.context.impl.EventContextImpl;
-import org.apache.tuscany.core.invocation.jdk.JDKProxyFactoryFactory;
-import org.apache.tuscany.core.invocation.spi.ProxyFactory;
-import org.apache.tuscany.core.invocation.spi.ProxyFactoryFactory;
-import org.apache.tuscany.core.message.MessageFactory;
-import org.apache.tuscany.core.message.impl.MessageFactoryImpl;
-import org.apache.tuscany.core.runtime.RuntimeContext;
-import org.apache.tuscany.core.system.annotation.Autowire;
-import org.apache.tuscany.core.system.annotation.ParentContext;
-import org.apache.tuscany.core.system.assembly.SystemBinding;
-import org.apache.tuscany.core.system.config.SystemObjectRuntimeConfiguration;
-import org.apache.tuscany.model.assembly.Aggregate;
-import org.apache.tuscany.model.assembly.Component;
-import org.apache.tuscany.model.assembly.EntryPoint;
-import org.apache.tuscany.model.assembly.Extensible;
-import org.apache.tuscany.model.assembly.ExternalService;
-import org.apache.tuscany.model.assembly.Module;
-import org.apache.tuscany.model.assembly.AggregatePart;
-import org.apache.tuscany.model.assembly.Scope;
-import org.apache.tuscany.model.assembly.impl.AssemblyFactoryImpl;
-
-/**
- * Implements an aggregate context for system components. By default a system context uses the scopes specified by
- * {@link org.apache.tuscany.core.system.context.SystemScopeStrategy}. In addition, it implements an autowire policy
- * where entry points configured with a {@link org.apache.tuscany.core.system.assembly.SystemBinding} are matched
- * according to their exposed interface. A system context may contain child aggregate contexts but an entry point in a
- * child context will only be outwardly accessible if there is an entry point that exposes it configured in the
- * top-level system context.
- *
- * @version $Rev$ $Date$
- */
-public class SystemAggregateContextImpl extends AbstractContext implements SystemAggregateContext {
-
- public static final int DEFAULT_WAIT = 1000 * 60;
-
- // ----------------------------------
- // Fields
- // ----------------------------------
-
- // The parent context, if one exists
- @ParentContext
- protected AggregateContext parentContext;
-
- // The parent configuration context, if one exists
- @Autowire(required = false)
- protected ConfigurationContext configurationContext;
-
- // The system monitor factory
- @Autowire(required = false)
- protected MonitorFactory monitorFactory;
-
- // The logical model representing the module assembly
- // protected ModuleComponent moduleComponent;
- protected Module module;
-
- protected List<RuntimeConfiguration<InstanceContext>> configurations = new ArrayList();
-
- protected ScopeStrategy scopeStrategy;
-
- // The event context for associating context events to threads
- protected EventContext eventContext;
-
- // The scopes for this context
- protected Map<Scope, ScopeContext> scopeContexts;
-
- protected Map<Scope, ScopeContext> immutableScopeContexts;
-
- // A component context name to scope context index
- protected Map<String, ScopeContext> scopeIndex;
-
- // Listeners for context events
- protected List<RuntimeEventListener> listeners = new CopyOnWriteArrayList();
-
- // Blocking latch to ensure the module is initialized exactly once prior to servicing requests
- protected CountDownLatch initializeLatch = new CountDownLatch(1);
-
- // Indicates whether the module context has been initialized
- protected boolean initialized;
-
- // a mapping of service type to component name
- private Map<Class, NameToScope> autowireIndex = new ConcurrentHashMap();
-
- @Autowire(required = false)
- private AutowireContext autowireContext;
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemAggregateContextImpl() {
- super();
- scopeIndex = new ConcurrentHashMap();
- // FIXME the assembly factory should be injected here
- module = new AssemblyFactoryImpl().createModule();
- eventContext = new EventContextImpl();
- scopeStrategy = new SystemScopeStrategy();
- }
-
- public SystemAggregateContextImpl(String name, AggregateContext parent, AutowireContext autowire, ScopeStrategy strategy,
- EventContext ctx, ConfigurationContext configCtx, MonitorFactory factory) {
- super(name);
- this.parentContext = parent;
- this.autowireContext = autowire;
- this.scopeStrategy = strategy;
- this.eventContext = ctx;
- this.configurationContext = configCtx;
- this.monitorFactory = factory;
- scopeIndex = new ConcurrentHashMap();
- // FIXME the assembly factory should be injected here
- module = new AssemblyFactoryImpl().createModule();
- }
-
- // ----------------------------------
- // Lifecycle methods
- // ----------------------------------
-
- public void start() {
- synchronized (initializeLatch) {
- try {
- if (lifecycleState != UNINITIALIZED && lifecycleState != STOPPED) {
- throw new IllegalStateException("Context not in UNINITIALIZED state");
- }
-
- lifecycleState = INITIALIZING;
- initializeScopes();
-
- Map<Scope, List<RuntimeConfiguration<SimpleComponentContext>>> configurationsByScope = new HashMap();
- if (configurations != null) {
- for (RuntimeConfiguration config : configurations) {
- // FIXME scopes are defined at the interface level
- Scope scope = config.getScope();
- // ensure duplicate names were not added before the context was started
- if (scopeIndex.get(config.getName()) != null) {
- throw new DuplicateNameException(config.getName());
- }
- scopeIndex.put(config.getName(), scopeContexts.get(scope));
- List<RuntimeConfiguration<SimpleComponentContext>> list = configurationsByScope.get(scope);
- if (list == null) {
- list = new ArrayList();
- configurationsByScope.put(scope, list);
- }
- list.add(config);
- }
- }
- for (EntryPoint ep : module.getEntryPoints()) {
- registerAutowire(ep);
- }
- for (Component component : module.getComponents()) {
- registerAutowire(component);
- }
- for (ExternalService es : module.getExternalServices()) {
- registerAutowire(es);
- }
- for (Map.Entry entries : configurationsByScope.entrySet()) {
- // register configurations with scope contexts
- ScopeContext scope = scopeContexts.get(entries.getKey());
- scope.registerConfigurations((List<RuntimeConfiguration<InstanceContext>>) entries.getValue());
- }
- for (ScopeContext scope : scopeContexts.values()) {
- // register scope contexts as a listeners for events in the aggregate context
- registerListener(scope);
- scope.start();
- }
- lifecycleState = RUNNING;
- } catch (ConfigurationException e) {
- lifecycleState = ERROR;
- throw new ContextInitException(e);
- } catch (CoreRuntimeException e) {
- lifecycleState = ERROR;
- e.addContextName(getName());
- throw e;
- } finally {
- initialized = true;
- // release the latch and allow requests to be processed
- initializeLatch.countDown();
- }
- }
- }
-
- public void stop() {
- if (lifecycleState == STOPPED) {
- return;
- }
- // need to block a start until reset is complete
- initializeLatch = new CountDownLatch(2);
- lifecycleState = STOPPING;
- initialized = false;
- if (scopeContexts != null) {
- for (ScopeContext scope : scopeContexts.values()) {
- try {
- if (scope.getLifecycleState() == ScopeContext.RUNNING) {
- scope.stop();
- }
- } catch (ScopeRuntimeException e) {
- // log.error("Error stopping scope container [" + scopeContainers[i].getName() + "]", e);
- }
- }
- }
- scopeContexts = null;
- scopeIndex.clear();
- // allow initialized to be called
- initializeLatch.countDown();
- lifecycleState = STOPPED;
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public void setModule(Module module) {
- assert (module != null) : "Module cannot be null";
- name = module.getName();
- this.module = module;
- }
-
- public void addContextListener(LifecycleEventListener listener) {
- super.addContextListener(listener);
- }
-
- public void setEventContext(EventContext eventContext) {
- this.eventContext = eventContext;
- }
-
- public void setMonitorFactory(MonitorFactory factory) {
- this.monitorFactory = factory;
- }
-
- public AggregateContext getParent() {
- return parentContext;
- }
-
- public void registerModelObjects(List<Extensible> models) throws ConfigurationException {
- assert (models != null) : "Model object collection was null";
- for (Extensible model : models) {
- registerModelObject(model);
- }
- }
-
- public void registerModelObject(Extensible model) throws ConfigurationException {
- assert (model != null) : "Model object was null";
- initializeScopes();
- if (configurationContext != null) {
- try {
- configurationContext.configure(model);
- configurationContext.build(this, model);
- } catch (ConfigurationException e) {
- e.addContextName(getName());
- throw e;
- } catch (BuilderConfigException e) {
- e.addContextName(getName());
- throw e;
- }
- }
- RuntimeConfiguration<InstanceContext> configuration = null;
- if (model instanceof Module) {
- // merge new module definition with the existing one
- Module oldModule = module;
- Module newModule = (Module) model;
- module = newModule;
- for (Component component : newModule.getComponents()) {
- configuration = (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation()
- .getRuntimeConfiguration();
- if (configuration == null) {
- ConfigurationException e = new ConfigurationException("Runtime configuration not set");
- e.addContextName(component.getName());
- e.addContextName(getName());
- throw e;
- }
- registerConfiguration(configuration);
- registerAutowire(component);
- }
- for (EntryPoint ep : newModule.getEntryPoints()) {
- configuration = (RuntimeConfiguration<InstanceContext>) ep.getConfiguredReference().getRuntimeConfiguration();
- if (configuration == null) {
- ConfigurationException e = new ConfigurationException("Runtime configuration not set");
- e.setIdentifier(ep.getName());
- e.addContextName(getName());
- throw e;
- }
- registerConfiguration(configuration);
- registerAutowire(ep);
- }
- for (ExternalService service : newModule.getExternalServices()) {
- configuration = (RuntimeConfiguration<InstanceContext>) service.getConfiguredService().getRuntimeConfiguration();
- if (configuration == null) {
- ConfigurationException e = new ConfigurationException("Runtime configuration not set");
- e.setIdentifier(service.getName());
- e.addContextName(getName());
- throw e;
- }
- registerConfiguration(configuration);
- registerAutowire(service);
- }
- // merge existing module component assets
- module.getComponents().addAll(oldModule.getComponents());
- module.getEntryPoints().addAll(oldModule.getEntryPoints());
- module.getExternalServices().addAll(oldModule.getExternalServices());
- } else {
- if (model instanceof Component) {
- Component component = (Component) model;
- module.getComponents().add(component);
- configuration = (RuntimeConfiguration<InstanceContext>) component.getComponentImplementation()
- .getRuntimeConfiguration();
- } else if (model instanceof EntryPoint) {
- EntryPoint ep = (EntryPoint) model;
- module.getEntryPoints().add(ep);
- configuration = (RuntimeConfiguration<InstanceContext>) ep.getConfiguredReference().getRuntimeConfiguration();
- } else if (model instanceof ExternalService) {
- ExternalService service = (ExternalService) model;
- module.getExternalServices().add(service);
- configuration = (RuntimeConfiguration<InstanceContext>) service.getConfiguredService().getRuntimeConfiguration();
- } else {
- BuilderConfigException e = new BuilderConfigException("Unknown model type");
- e.setIdentifier(model.getClass().getName());
- e.addContextName(getName());
- throw e;
- }
- if (configuration == null) {
- ConfigurationException e = new ConfigurationException(
- "Runtime configuration not set. Ensure a runtime configuration builder is registered for the component implementation type");
- if (model instanceof AggregatePart) {
- e.setIdentifier(((AggregatePart) model).getName());
- }
- e.addContextName(getName());
- throw e;
- }
- registerConfiguration(configuration);
- registerAutowire(model);
- }
- }
-
- public void registerJavaObject(String componentName, Object instance) throws ConfigurationException {
- registerConfiguration(new SystemObjectRuntimeConfiguration(componentName, instance));
- }
-
- protected void registerConfiguration(RuntimeConfiguration<InstanceContext> configuration) throws ConfigurationException {
- if (lifecycleState == RUNNING) {
- if (scopeIndex.get(configuration.getName()) != null) {
- throw new DuplicateNameException(configuration.getName());
- }
- ScopeContext scope = scopeContexts.get(configuration.getScope());
- if (scope == null) {
- ConfigurationException e = new ConfigurationException("Component has an unknown scope");
- e.addContextName(configuration.getName());
- e.addContextName(getName());
- throw e;
- }
- scope.registerConfiguration(configuration);
- scopeIndex.put(configuration.getName(), scope);
- } else {
- configurations.add(configuration);
- }
-
- }
-
- public void registerListener(RuntimeEventListener listener) {
- assert (listener != null) : "Listener cannot be null";
- listeners.add(listener);
- }
-
- public void fireEvent(int eventType, Object message) throws EventException {
- checkInit();
- if (eventType == SESSION_NOTIFY) {
- // update context
- eventContext.setIdentifier(HTTP_SESSION, message);
- } else if (eventType == REQUEST_END) {
- // be very careful with pooled threads, ensuring threadlocals are cleaned up
- eventContext.clearIdentifier(HTTP_SESSION);
- }
- for (RuntimeEventListener listener : listeners) {
- listener.onEvent(eventType, message);
- }
- }
-
- public InstanceContext getContext(String componentName) {
- checkInit();
- assert (componentName != null) : "Name was null";
- ScopeContext scope = scopeIndex.get(componentName);
- if (scope == null) {
- return null;
- }
- return scope.getContext(componentName);
-
- }
-
- /**
- * @see org.apache.tuscany.core.context.AggregateContext#getAggregate()
- */
- public Aggregate getAggregate() {
- return module;
- }
-
- public Object getInstance(QualifiedName qName) throws TargetException {
- return getInstance(qName, true);
- }
-
- public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
- assert (qName != null) : "Name was null ";
- // use the port name to get the context since entry points ports
- ScopeContext scope = scopeIndex.get(qName.getPortName());
- if (scope == null) {
- return null;
- }
- InstanceContext ctx = scope.getContext(qName.getPortName());
- if (!(ctx instanceof EntryPointContext)) {
- TargetException e = new TargetException("Target not an entry point");
- e.setIdentifier(qName.getQualifiedName());
- e.addContextName(name);
- throw e;
- }
- return ctx.getInstance(null, notify);
- }
-
- public Object locateInstance(String qualifiedName) throws TargetException {
- checkInit();
- QualifiedName qName = new QualifiedName(qualifiedName);
- ScopeContext scope = scopeIndex.get(qName.getPartName());
- if (scope == null) {
- TargetException e = new TargetException("Component not found");
- e.setIdentifier(qualifiedName);
- e.addContextName(getName());
- throw e;
- }
- InstanceContext ctx = scope.getContext(qName.getPartName());
- try {
- return ctx.getInstance(qName, true);
- } catch (TargetException e) {
- e.addContextName(getName());
- throw e;
- }
- }
-
- // ----------------------------------
- // InstanceContext methods
- // ----------------------------------
-
- public Object getImplementationInstance() throws TargetException {
- return this;
- }
-
- public Object getImplementationInstance(boolean notify) throws TargetException {
- return this;
- }
-
- public Map<Scope, ScopeContext> getScopeContexts() {
- initializeScopes();
- return immutableScopeContexts;
- }
-
- // ----------------------------------
- // Protected methods
- // ----------------------------------
-
- /**
- * Blocks until the module context has been initialized
- */
- protected void checkInit() {
- if (!initialized) {
- try {
- /* block until the module has initialized */
- boolean success = initializeLatch.await(DEFAULT_WAIT, TimeUnit.MILLISECONDS);
- if (!success) {
- throw new ContextInitException("Timeout waiting for module context to initialize");
- }
- } catch (InterruptedException e) { // should not happen
- }
- }
-
- }
-
- protected void initializeScopes() {
- if (scopeContexts == null) {
- scopeContexts = scopeStrategy.createScopes(eventContext);
- immutableScopeContexts = Collections.unmodifiableMap(scopeContexts);
- }
- }
-
- // ////////////////////////////
-
- // ----------------------------------
- // AutowireContext methods
- // ----------------------------------
-
- // FIXME These should be removed and configured
- private static final MessageFactory messageFactory = new MessageFactoryImpl();
-
- private static final ProxyFactoryFactory proxyFactoryFactory = new JDKProxyFactoryFactory();
-
- public <T> T resolveInstance(Class<T> instanceInterface) throws AutowireResolutionException {
- if (RuntimeContext.class.equals(instanceInterface)) {
- return autowireContext.resolveInstance(instanceInterface);
- } else if (MonitorFactory.class.equals(instanceInterface)) {
- return instanceInterface.cast(monitorFactory);
- } else if (ConfigurationContext.class.equals(instanceInterface)) {
- return instanceInterface.cast(this);
- } else if (AggregateContext.class.equals(instanceInterface)) {
- return instanceInterface.cast(this);
- } else if (AutowireContext.class.equals(instanceInterface)) {
- return instanceInterface.cast(this);
- } else if (MessageFactory.class.equals(instanceInterface)) {
- return instanceInterface.cast(messageFactory);
- } else if (ProxyFactoryFactory.class.equals(instanceInterface)) {
- return instanceInterface.cast(proxyFactoryFactory);
- }
-
- NameToScope mapping = autowireIndex.get(instanceInterface);
- if (mapping != null) {
- try {
- return instanceInterface.cast(mapping.getScopeContext().getInstance(mapping.getName()));
- } catch (TargetException e) {
- AutowireResolutionException ae = new AutowireResolutionException("Autowire instance not found", e);
- ae.addContextName(getName());
- throw ae;
- }
- }
- return null;
- }
-
- private void registerAutowire(Extensible model) throws ConfigurationException {
- if (lifecycleState == INITIALIZING || lifecycleState == INITIALIZED || lifecycleState == RUNNING) {
- // only autowire entry points with system bindings
- if (model instanceof EntryPoint) {
- EntryPoint ep = (EntryPoint) model;
- if (ep.getBindings() != null) {
- if (ep.getBindings().get(0) instanceof SystemBinding) {
- ScopeContext scope = scopeContexts.get(((RuntimeConfiguration) ep.getConfiguredReference()
- .getRuntimeConfiguration()).getScope());
- if (scope == null) {
- ConfigurationException ce = new ConfigurationException("Scope not found for entry point");
- ce.setIdentifier(ep.getName());
- ce.addContextName(getName());
- throw ce;
- }
- NameToScope mapping = new NameToScope(new QualifiedName(ep.getName()), scope);
- autowireIndex.put(ep.getConfiguredService().getService().getServiceContract().getInterface(), mapping);
- }
- }
- }
- }
- }
-
- // ----------------------------------
- // ConfigurationContext methods
- // ----------------------------------
-
- public void configure(Extensible model) throws ConfigurationException {
- if (configurationContext != null) {
- configurationContext.configure(model);
- }
- }
-
- public void build(AggregateContext parent, Extensible model) throws BuilderConfigException {
- if (configurationContext != null) {
- configurationContext.build(parent, model);
- }
- }
-
- public void wire(ProxyFactory sourceFactory, ProxyFactory targetFactory, Class targetType, boolean downScope,
- ScopeContext targetScopeContext) throws BuilderConfigException {
- if (configurationContext != null) {
- try {
- configurationContext.wire(sourceFactory, targetFactory, targetType, downScope, targetScopeContext);
- } catch (BuilderConfigException e) {
- e.addContextName(getName());
- throw e;
- }
- }
- }
-
- public void wire(ProxyFactory targetFactory, Class targetType, ScopeContext targetScopeContext) throws BuilderConfigException {
- if (configurationContext != null) {
- try {
- configurationContext.wire(targetFactory, targetType, targetScopeContext);
- } catch (BuilderConfigException e) {
- e.addContextName(getName());
- throw e;
- }
- }
- }
-
- // ----------------------------------
- // Inner classes
- // ----------------------------------
-
- /**
- * Maps a context name to a scope
- */
- private class NameToScope {
-
- private QualifiedName epName;
-
- private ScopeContext scope;
-
- public NameToScope(QualifiedName epName, ScopeContext scope) {
- this.epName = epName;
- this.scope = scope;
- }
-
- public QualifiedName getName() {
- return epName;
- }
-
- public ScopeContext getScopeContext() {
- return scope;
- }
-
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java
deleted file mode 100644
index 4418f52e19..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemComponentContext.java
+++ /dev/null
@@ -1,198 +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.system.context;
-
-import java.util.Iterator;
-
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.context.AbstractContext;
-import org.apache.tuscany.core.context.Context;
-import org.apache.tuscany.core.context.ContextInitException;
-import org.apache.tuscany.core.context.LifecycleEventListener;
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.context.SimpleComponentContext;
-import org.apache.tuscany.core.context.TargetException;
-import org.apache.tuscany.core.injection.EventInvoker;
-import org.apache.tuscany.core.injection.Injector;
-import org.apache.tuscany.core.injection.ObjectCallbackException;
-import org.apache.tuscany.core.injection.ObjectCreationException;
-
-/**
- * Manages system component implementation instances
- *
- * @version $Rev$ $Date$
- */
-public class SystemComponentContext extends AbstractContext implements SimpleComponentContext {
-
- private boolean eagerInit;
-
- private EventInvoker initInvoker;
-
- private EventInvoker destroyInvoker;
-
- private Injector componentName;
-
- private Injector moduleContext;
-
- private boolean stateless;
-
- // the cached target instance
- private Object cachedTargetInstance;
-
- // responsible for creating a new implementation instance with injected references and properties
- private ObjectFactory objectFactory;
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemComponentContext(String name, ObjectFactory objectFactory, boolean eagerInit, EventInvoker initInvoker,
- EventInvoker destroyInvoker, boolean stateless) {
- super(name);
- assert (objectFactory != null) : "Object factory was null";
- if (eagerInit == true && initInvoker == null) {
- throw new AssertionError("No intialization method found for eager init implementation");
- }
- this.objectFactory = objectFactory;
-
- this.eagerInit = eagerInit;
- this.initInvoker = initInvoker;
- this.destroyInvoker = destroyInvoker;
- this.stateless = stateless;
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public void setName(String name) {
- super.setName(name);
- }
-
- protected int type;
-
- public int getType() {
- return type;
- }
-
- public void setType(int type) {
- this.type = type;
- }
-
- public synchronized Object getInstance(QualifiedName qName) throws TargetException {
- return getInstance(qName, true);
- }
-
- public synchronized Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
- if (cachedTargetInstance != null) {
- return cachedTargetInstance; // already cached, just return
- }
-
- if (getLifecycleState() == ERROR || getLifecycleState() == CONFIG_ERROR) {
- return null;
- }
- synchronized (this) {
- try {
- Object instance = objectFactory.getInstance();
- startInstance(instance);
- if (notify) {
- for (Iterator iter = contextListener.iterator(); iter.hasNext();) {
- LifecycleEventListener listener = (LifecycleEventListener) iter.next();
- listener.onInstanceCreate(this);
- }
- }
- setLifecycleState(RUNNING);
- if (stateless) {
- return instance;
- } else {
- // cache the actual instance
- cachedTargetInstance = instance;
- return cachedTargetInstance;
- }
- } catch (ObjectCreationException e) {
- setLifecycleState(Context.ERROR);
- TargetException te = new TargetException("Error creating instance for component", e);
- te.setIdentifier(getName());
- throw te;
- }
- }
-
- }
-
- public Object getImplementationInstance() throws TargetException {
- return getInstance(null);
- }
-
- public Object getImplementationInstance(boolean notify) throws TargetException {
- return getInstance(null, notify);
- }
-
- public boolean isEagerInit() {
- return eagerInit;
- }
-
- public boolean isDestroyable() {
- return (destroyInvoker != null);
- }
-
- // ----------------------------------
- // Lifecycle methods
- // ----------------------------------
-
- public void start() throws ContextInitException {
- if (getLifecycleState() != UNINITIALIZED && getLifecycleState() != STOPPED) {
- throw new IllegalStateException("Component must be in UNINITIALIZED state [" + getLifecycleState() + "]");
- }
- if (objectFactory == null) {
- setLifecycleState(ERROR);
- ContextInitException e = new ContextInitException("Object factory not found ");
- e.setIdentifier(getName());
- throw e;
- }
- setLifecycleState(INITIALIZED);
- }
-
- public void stop() {
- if (cachedTargetInstance != null) {
- if (destroyInvoker != null) {
- try {
- destroyInvoker.invokeEvent(cachedTargetInstance);
- } catch (ObjectCallbackException e) {
- throw new TargetException(e.getCause());
- }
- }
- }
- setLifecycleState(STOPPED);
- }
-
- // ----------------------------------
- // Private methods
- // ----------------------------------
- private void startInstance(Object instance) throws TargetException {
- try {
- // handle @Init
- if (initInvoker != null) {
- initInvoker.invokeEvent(instance);
- }
- } catch (ObjectCallbackException e) {
- TargetException te = new TargetException("Error initializing instance", e);
- te.setIdentifier(getName());
- throw te;
- }
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java
deleted file mode 100644
index 5533424334..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemEntryPointContext.java
+++ /dev/null
@@ -1,82 +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.system.context;
-
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.context.AbstractContext;
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.context.CoreRuntimeException;
-import org.apache.tuscany.core.context.EntryPointContext;
-import org.apache.tuscany.core.context.TargetException;
-
-/**
- * Manages an entry point into a system module. System entry points cache a direct (i.e. non-proxied) reference to a
- * component instance.
- *
- * @version $Rev$ $Date$
- */
-public class SystemEntryPointContext extends AbstractContext implements EntryPointContext {
-
- // responsible for resolving the component implementation instance exposed by the entry point
- private ObjectFactory factory;
-
- // a reference to the component's implementation instance exposed by the entry point
- private Object cachedInstance;
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemEntryPointContext(String name, ObjectFactory factory) {
- super(name);
- assert (factory != null) : "Object factory was null";
- this.factory = factory;
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public Object getInstance(QualifiedName qName) throws TargetException {
- return getInstance(qName, true);
- }
-
- public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
- try {
- if (cachedInstance == null) {
- cachedInstance = factory.getInstance();
- }
- return cachedInstance;
- } catch (TargetException e) {
- e.addContextName(getName());
- throw e;
- }
- }
-
- public void start() throws CoreRuntimeException {
- lifecycleState = RUNNING;
- }
-
- public void stop() throws CoreRuntimeException {
- lifecycleState = STOPPED;
- }
-
- public Object getImplementationInstance() throws TargetException{
- return getInstance(null);
- }
-
- public Object getImplementationInstance(boolean notify) throws TargetException{
- return getInstance(null,notify);
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java
deleted file mode 100644
index 9b09cea082..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemExternalServiceContext.java
+++ /dev/null
@@ -1,82 +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.system.context;
-
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.context.AbstractContext;
-import org.apache.tuscany.core.context.ExternalServiceContext;
-import org.apache.tuscany.core.context.QualifiedName;
-import org.apache.tuscany.core.context.TargetException;
-
-/**
- * An implementation of an external service for system wiring. As system components are not proxied and the system
- * binding is by-reference, the implementation caches a reference to its configured target.
- *
- * @version $Rev$ $Date$
- */
-public class SystemExternalServiceContext extends AbstractContext implements ExternalServiceContext {
-
- // a factory for retrieving the target of the external service wire
- private ObjectFactory factory;
-
- // the cached target
- private Object cachedInstance;
-
- // ----------------------------------
- // Constructors
- // ----------------------------------
-
- public SystemExternalServiceContext(String name, ObjectFactory factory) {
- super(name);
- assert (factory != null) : "Object factory was null";
- this.factory = factory;
- }
-
- // ----------------------------------
- // Methods
- // ----------------------------------
-
- public Object getInstance(QualifiedName qName) throws TargetException {
- return getInstance(qName, false);
- }
-
- public Object getInstance(QualifiedName qName, boolean notify) throws TargetException {
- try {
- if (cachedInstance == null) {
- cachedInstance = factory.getInstance();
- }
- return cachedInstance;
- } catch (TargetException e) {
- e.addContextName(getName());
- throw e;
- }
-
- }
-
- public void start() {
- lifecycleState = RUNNING;
- }
-
- public void stop() {
- lifecycleState = STOPPED;
- }
-
- public Object getImplementationInstance() throws TargetException {
- return this;
- }
-
- public Object getImplementationInstance(boolean notify) throws TargetException {
- return this;
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java
deleted file mode 100644
index 0dbd75da19..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/context/SystemScopeStrategy.java
+++ /dev/null
@@ -1,56 +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.system.context;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tuscany.core.context.EventContext;
-import org.apache.tuscany.core.context.ScopeContext;
-import org.apache.tuscany.core.context.scope.AbstractScopeStrategy;
-import org.apache.tuscany.core.context.scope.AggregateScopeContext;
-import org.apache.tuscany.core.context.scope.ModuleScopeContext;
-import org.apache.tuscany.core.context.scope.StatelessScopeContext;
-import org.apache.tuscany.model.assembly.Scope;
-
-/**
- * Implements a {@link org.apache.tuscany.core.context.ScopeStrategy} for a system aggregate context with the following scopes:
- * <ul>
- * <li>{@link org.apache.tuscany.model.assembly.Scope#AGGREGATE</li>
- * <li>{@link org.apache.tuscany.model.assembly.Scope#MODULE</li>
- * <li>{@link org.apache.tuscany.model.assembly.Scope#INSTANCE</li>
- * </ul>
- *
- * @version $Rev$ $Date$
- */
-public class SystemScopeStrategy extends AbstractScopeStrategy {
-
- public SystemScopeStrategy() {
- }
-
- public Map<Scope, ScopeContext> createScopes(EventContext eventContext) {
- ScopeContext aggregrateScope = new AggregateScopeContext(eventContext);
- ScopeContext moduleScoper = new ModuleScopeContext(eventContext);
- ScopeContext statelessScope = new StatelessScopeContext(eventContext);
- Map<Scope, ScopeContext> scopes = new HashMap();
- scopes.put(Scope.AGGREGATE, aggregrateScope);
- scopes.put(Scope.MODULE, moduleScoper);
- scopes.put(Scope.INSTANCE, statelessScope);
- return scopes;
- }
-
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java
deleted file mode 100644
index 3bde49dbbe..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/injection/AutowireFactory.java
+++ /dev/null
@@ -1,50 +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.system.injection;
-
-import org.apache.tuscany.core.builder.ObjectFactory;
-import org.apache.tuscany.core.context.AggregateContext;
-import org.apache.tuscany.core.context.AutowireContext;
-import org.apache.tuscany.core.injection.FactoryInitException;
-import org.apache.tuscany.core.injection.ObjectCreationException;
-
-/**
- * Implementation of ObjectFactory that returns an instance by resolving against an AutowireContext.
- *
- * @version $Rev$ $Date$
- */
-public class AutowireFactory<T> implements ObjectFactory<T> {
-
- private AutowireContext autoWireContext;
-
- private Class<T> implementationType;
-
- /**
- * Constructor specifying the context to wire against and the type of service required.
- *
- * @param implementationType the type of service required
- * @param autoWireContext the context to wire against
- */
- public AutowireFactory(Class<T> implementationType, AutowireContext autoWireContext) {
- assert (implementationType != null) : "Implementation type was null";
- assert (autoWireContext != null) : "Autowire context was null";
- this.implementationType = implementationType;
- this.autoWireContext = autoWireContext;
- }
-
- public T getInstance() throws ObjectCreationException {
- // todo what about required? should this just return null?
- return autoWireContext.resolveInstance(implementationType);
- }
-}
diff --git a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java b/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java
deleted file mode 100644
index f49efe3ebc..0000000000
--- a/tags/java-stable-20060304/sca/core/src/main/java/org/apache/tuscany/core/system/loader/SystemSCDLModelLoader.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.apache.tuscany.core.system.loader;
-
-import org.apache.tuscany.core.system.assembly.SystemAssemblyFactory;
-import org.apache.tuscany.core.system.assembly.impl.SystemAssemblyFactoryImpl;
-import org.apache.tuscany.core.system.scdl.ScdlFactory;
-import org.apache.tuscany.core.system.scdl.SystemImplementation;
-import org.apache.tuscany.model.assembly.AssemblyModelContext;
-import org.apache.tuscany.model.assembly.AssemblyModelObject;
-import org.apache.tuscany.model.scdl.loader.SCDLModelLoader;
-import org.apache.tuscany.sdo.util.SDOUtil;
-
-/**
- * Populates the assembly model from an SCDL model
- */
-public class SystemSCDLModelLoader implements SCDLModelLoader {
-
- private SystemAssemblyFactory systemFactory;
-
- static {
- // Register the system SCDL model
- SDOUtil.registerStaticTypes(ScdlFactory.class);
- }
-
- /**
- * Constructs a new JavaSCDLModelLoader.
- */
- public SystemSCDLModelLoader() {
- this.systemFactory=new SystemAssemblyFactoryImpl();
- }
-
- /**
- * @see org.apache.tuscany.model.scdl.loader.SCDLModelLoader#load(org.apache.tuscany.model.assembly.AssemblyModelContext, java.lang.Object)
- */
- public AssemblyModelObject load(AssemblyModelContext modelContext, Object object) {
- if (object instanceof SystemImplementation) {
- SystemImplementation scdlImplementation=(SystemImplementation)object;
- org.apache.tuscany.core.system.assembly.SystemImplementation implementation=systemFactory.createSystemImplementation();
- Class implementationClass;
- try {
- implementationClass=modelContext.getSystemResourceLoader().loadClass(scdlImplementation.getClass_());
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException(e);
- }
- implementation.setImplementationClass(implementationClass);
- return implementation;
- } else
- return null;
- }
-}