You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by jb...@apache.org on 2007/03/10 22:57:16 UTC
svn commit: r516794 - in /incubator/tuscany/java/sca/kernel:
core/src/main/java/org/apache/tuscany/core/component/
core/src/main/java/org/apache/tuscany/core/implementation/
core/src/main/java/org/apache/tuscany/core/implementation/system/builder/
core...
Author: jboynes
Date: Sat Mar 10 13:57:15 2007
New Revision: 516794
URL: http://svn.apache.org/viewvc?view=rev&rev=516794
Log:
start of SystemComponent implementation using InstanceFactory
Added:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java (with props)
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java (with props)
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemPhysicalComponentBuilder.java (with props)
Modified:
incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemComponent.java
incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java?view=auto&rev=516794
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java Sat Mar 10 13:57:15 2007
@@ -0,0 +1,49 @@
+/*
+ * 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.core.component;
+
+import java.util.List;
+
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface InstanceFactoryProvider<T> {
+ /**
+ * Attach the outbound wire for a single-valued reference.
+ *
+ * @param wire the outbound wire to attach
+ */
+ void attachWire(Wire wire);
+
+ /**
+ * Attach the outbound wires for a multi-valued reference.
+ *
+ * @param wires the outbound wires to attach
+ */
+ void attachWires(List<Wire> wires);
+
+ /**
+ * Create an instance factory that can be used to create component instances.
+ *
+ * @return a new instance factory
+ */
+ InstanceFactory<T> createFactory();
+}
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/component/InstanceFactoryProvider.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java?view=auto&rev=516794
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java Sat Mar 10 13:57:15 2007
@@ -0,0 +1,94 @@
+/*
+ * 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.core.implementation;
+
+import java.net.URI;
+import java.util.List;
+
+import org.apache.tuscany.core.component.InstanceFactory;
+import org.apache.tuscany.core.component.InstanceFactoryProvider;
+import org.apache.tuscany.spi.component.AbstractSCAObject;
+import org.apache.tuscany.spi.component.AtomicComponent;
+import org.apache.tuscany.spi.component.InstanceWrapper;
+import org.apache.tuscany.spi.wire.Wire;
+
+/**
+ * Base class for Component implementations based on Java objects.
+ *
+ * @version $Rev$ $Date$
+ * @param <T> the implementation class
+ */
+public abstract class PojoComponent<T> extends AbstractSCAObject implements AtomicComponent {
+ private final InstanceFactoryProvider<T> provider;
+ private final int initLevel;
+ private final long maxIdleTime;
+ private final long maxAge;
+ private InstanceFactory<T> instanceFactory;
+
+ public PojoComponent(URI componentId,
+ InstanceFactoryProvider<T> provider,
+ int initLevel,
+ long maxIdleTime,
+ long maxAge) {
+ super(componentId);
+ this.provider = provider;
+ this.initLevel = initLevel;
+ this.maxIdleTime = maxIdleTime;
+ this.maxAge = maxAge;
+ }
+
+ public void attachWire(Wire wire) {
+ provider.attachWire(wire);
+ }
+
+ public void attachWires(List<Wire> wires) {
+ provider.attachWires(wires);
+ }
+
+ public void start() {
+ super.start();
+ instanceFactory = provider.createFactory();
+ }
+
+ public void stop() {
+ instanceFactory = null;
+ super.stop();
+ }
+
+ public InstanceWrapper<T> createInstanceWrapper() {
+ return instanceFactory.newInstance();
+ }
+
+
+ public boolean isEagerInit() {
+ return initLevel > 0;
+ }
+
+ public int getInitLevel() {
+ return initLevel;
+ }
+
+ public long getMaxIdleTime() {
+ return maxIdleTime;
+ }
+
+ public long getMaxAge() {
+ return maxAge;
+ }
+}
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/PojoComponent.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemPhysicalComponentBuilder.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemPhysicalComponentBuilder.java?view=auto&rev=516794
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemPhysicalComponentBuilder.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemPhysicalComponentBuilder.java Sat Mar 10 13:57:15 2007
@@ -0,0 +1,35 @@
+/*
+ * 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.core.implementation.system.builder;
+
+import org.apache.tuscany.core.implementation.system.component.SystemComponent;
+import org.apache.tuscany.core.implementation.system.model.SystemPhysicalComponentDefinition;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class SystemPhysicalComponentBuilder {
+ <T> SystemComponent<T> build(SystemPhysicalComponentDefinition<T> definition) {
+ throw new UnsupportedOperationException();
+/*
+ SystemComponent<T> component = new SystemComponent<T>();
+ return component;
+*/
+ }
+}
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemPhysicalComponentBuilder.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/builder/SystemPhysicalComponentBuilder.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemComponent.java?view=diff&rev=516794&r1=516793&r2=516794
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemComponent.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/implementation/system/component/SystemComponent.java Sat Mar 10 13:57:15 2007
@@ -18,23 +18,22 @@
*/
package org.apache.tuscany.core.implementation.system.component;
-import org.apache.tuscany.core.component.InstanceFactory;
-import org.apache.tuscany.spi.component.InstanceWrapper;
+import java.net.URI;
+
+import org.apache.tuscany.core.component.InstanceFactoryProvider;
+import org.apache.tuscany.core.implementation.PojoComponent;
/**
* @version $Rev$ $Date$
* @param <T> the implementation class for the defined component
*/
-public class SystemComponent<T> {
- private InstanceFactory<T> instanceFactory;
-
- public void start() {
+public abstract class SystemComponent<T> extends PojoComponent<T> {
+ public SystemComponent(URI componentId,
+ InstanceFactoryProvider<T> provider,
+ int initLevel,
+ int maxIdleTime,
+ int maxAge) {
+ super(componentId, provider, initLevel, maxIdleTime, maxAge);
}
- public void stop() {
- }
-
- public InstanceWrapper<T> createInstance() {
- return instanceFactory.newInstance();
- }
}
Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java?view=diff&rev=516794&r1=516793&r2=516794
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/component/AtomicComponent.java Sat Mar 10 13:57:15 2007
@@ -68,6 +68,7 @@
*
* @throws TargetInitializationException
*/
+ @Deprecated
void init(Object instance) throws TargetInitializationException;
/**
@@ -75,6 +76,7 @@
*
* @throws TargetDestructionException
*/
+ @Deprecated
void destroy(Object instance) throws TargetDestructionException;
/**
@@ -119,6 +121,4 @@
* @throws TargetResolutionException
*/
public Object getAssociatedTargetInstance() throws TargetResolutionException;
-
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org