summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context')
-rw-r--r--tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java43
-rw-r--r--tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java49
-rw-r--r--tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java86
-rw-r--r--tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java55
4 files changed, 0 insertions, 233 deletions
diff --git a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java b/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java
deleted file mode 100644
index e2d99852d8..0000000000
--- a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactory.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.context;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-
-/**
- * Interface for a factory that returns an injected component instance.
- * This is used by a Component implementation to create new instances of
- * application implementation objects as determined by the component scope's
- * lifecycle.
- * <p/>
- * The implementation of this interface may be supplied by the user,
- * may be generated during deployment, or may be dynamic.
- *
- * @version $Rev$ $Date$
- * @param <T> Type of the instance generated by the factory.
- */
-public interface InstanceFactory<T> {
- /**
- * Creates a new instance of the component.
- * All injected values must be set but any @Init methods must not have been invoked.
- *
- * @return A wrapper for the created component instance.
- */
- InstanceWrapper<T> newInstance();
-}
diff --git a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java b/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java
deleted file mode 100644
index df21e013f1..0000000000
--- a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/InstanceFactoryProvider.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.context;
-
-import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.implementation.java.JavaElementImpl;
-
-/**
- * @version $Rev$ $Date$
- */
-public interface InstanceFactoryProvider<T> {
- /**
- * Return the implementation class.
- *
- * @return the implementation class.
- */
- Class<T> getImplementationClass();
-
- /**
- * Sets an object factory for an injection site
- *
- * @param element the injection site name
- * @param objectFactory the object factory
- */
- void setObjectFactory(JavaElementImpl element, ObjectFactory<?> objectFactory);
-
- /**
- * Create an instance factory that can be used to create component instances.
- *
- * @return a new instance factory
- */
- InstanceFactory<T> createFactory();
-}
diff --git a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java b/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
deleted file mode 100644
index 73b7990a79..0000000000
--- a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceFactory.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.context;
-
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.factory.ObjectCreationException;
-import org.apache.tuscany.sca.core.factory.ObjectFactory;
-import org.apache.tuscany.sca.implementation.java.injection.Injector;
-import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ReflectiveInstanceFactory<T> implements InstanceFactory<T> {
- private final Constructor<T> ctr;
- private final ObjectFactory<?>[] ctrArgs;
- private final Injector<T>[] injectors;
- private final EventInvoker<T> initInvoker;
- private final EventInvoker<T> destroyInvoker;
-
- public ReflectiveInstanceFactory(Constructor<T> ctr,
- ObjectFactory<?>[] ctrArgs,
- Injector<T>[] injectors,
- EventInvoker<T> initInvoker,
- EventInvoker<T> destroyInvoker) {
- this.ctr = ctr;
- this.ctrArgs = ctrArgs;
- this.injectors = injectors;
- this.initInvoker = initInvoker;
- this.destroyInvoker = destroyInvoker;
- }
-
- public InstanceWrapper<T> newInstance() {
- T instance;
- try {
- if (ctrArgs != null) {
- Object[] args = new Object[ctrArgs.length];
- for (int i = 0; i < args.length; i++) {
- args[i] = ctrArgs[i].getInstance();
- }
- instance = ctr.newInstance(args);
- } else {
- instance = ctr.newInstance();
- }
- } catch (InstantiationException e) {
- String name = ctr.getDeclaringClass().getName();
- throw new AssertionError("Class is not instantiable [" + name + "]");
- } catch (IllegalAccessException e) {
- String name = ctr.getName();
- throw new AssertionError("Constructor is not accessible [" + name + "]");
- } catch (
- InvocationTargetException e) {
- String name = ctr.getName();
- throw new ObjectCreationException("Exception thrown by constructor: " + name, e);
- }
-
- if (injectors != null) {
- for (Injector<T> injector : injectors) {
- //FIXME Injectors should never be null
- if (injector != null)
- injector.inject(instance);
- }
- }
-
- return new ReflectiveInstanceWrapper<T>(instance, initInvoker, destroyInvoker);
- }
-}
diff --git a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java b/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java
deleted file mode 100644
index aeaf60e957..0000000000
--- a/tags/java/sca/2.0-M1/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/context/ReflectiveInstanceWrapper.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tuscany.sca.implementation.java.context;
-
-import org.apache.tuscany.sca.core.factory.InstanceWrapper;
-import org.apache.tuscany.sca.core.scope.TargetDestructionException;
-import org.apache.tuscany.sca.core.scope.TargetInitializationException;
-import org.apache.tuscany.sca.implementation.java.invocation.EventInvoker;
-
-/**
- * @version $Rev$ $Date$
- */
-public class ReflectiveInstanceWrapper<T> implements InstanceWrapper<T> {
- private final EventInvoker<T> initInvoker;
- private final EventInvoker<T> destroyInvoker;
- private final T instance;
-
- public ReflectiveInstanceWrapper(T instance, EventInvoker<T> initInvoker, EventInvoker<T> destroyInvoker) {
- this.instance = instance;
- this.initInvoker = initInvoker;
- this.destroyInvoker = destroyInvoker;
- }
-
- public T getInstance() {
- return instance;
- }
-
- public void start() throws TargetInitializationException {
- if (initInvoker != null) {
- initInvoker.invokeEvent(instance);
- }
- }
-
- public void stop() throws TargetDestructionException {
- if (destroyInvoker != null) {
- destroyInvoker.invokeEvent(instance);
- }
- }
-}