felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clem...@apache.org
Subject svn commit: r653812 - in /felix/sandbox/clement: ipojo/ temporal/ temporal/org.apache.felix.ipojo.handler.temporal/ temporal/org.apache.felix.ipojo.handler.temporal/src/ temporal/org.apache.felix.ipojo.handler.temporal/src/main/ temporal/org.apache.fel...
Date Tue, 06 May 2008 15:30:48 GMT
Author: clement
Date: Tue May  6 08:30:47 2008
New Revision: 653812

URL: http://svn.apache.org/viewvc?rev=653812&view=rev
Log:
- Clean the sandbox
- Commit the temporal dependency handler allowing method-level (blocking) dependency
- Commit the temporal dependency test suite

Added:
    felix/sandbox/clement/temporal/   (with props)
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/   (with props)
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/pom.xml
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/resources/
    felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/resources/metadata.xml
    felix/sandbox/clement/temporal/tests.temporal.dependency/   (with props)
    felix/sandbox/clement/temporal/tests.temporal.dependency/pom.xml
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/service/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/resources/
    felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/resources/metadata.xml
Removed:
    felix/sandbox/clement/ipojo/
    felix/sandbox/clement/tutorial/

Propchange: felix/sandbox/clement/temporal/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May  6 08:30:47 2008
@@ -0,0 +1,8 @@
+.classpath
+.project
+.settings
+maven-eclipse*
+bin*
+target*
+classes*
+.externalToolBuilders

Propchange: felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May  6 08:30:47 2008
@@ -0,0 +1,8 @@
+.classpath
+.project
+.settings
+maven-eclipse*
+bin*
+target*
+classes*
+.externalToolBuilders

Added: felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/pom.xml?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/pom.xml (added)
+++ felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/pom.xml Tue May  6 08:30:47 2008
@@ -0,0 +1,89 @@
+<!--
+	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.
+-->
+<project>
+	<modelVersion>4.0.0</modelVersion>
+	<packaging>bundle</packaging>
+	<artifactId>org.apache.felix.ipojo.handler.temporal</artifactId>
+	<groupId>org.apache.felix</groupId>
+	<version>0.8.0-SNAPSHOT</version>
+	<name>Apache Felix iPOJO Temporal Service Dependency Handler</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.compendium</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo.metadata</artifactId>
+			<version>0.8.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo</artifactId>
+			<version>0.8.0-SNAPSHOT</version>
+		</dependency>
+	</dependencies>
+
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<version>1.4.0</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Private-Package>
+							org.apache.felix.ipojo.handler.temporal
+						</Private-Package>
+						<Bundle-Name>${pom.name}</Bundle-Name>
+						<Bundle-SymbolicName>
+							org.apache.felix.ipojo.handler.temporal
+						</Bundle-SymbolicName>
+						<Bundle-Vendor>
+							The Apache Software Foundation
+						</Bundle-Vendor>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-ipojo-plugin</artifactId>
+				<version>0.8.0-SNAPSHOT</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>ipojo-bundle</goal>
+						</goals>
+						<configuration>
+							<metadata>metadata.xml</metadata>
+						</configuration>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java (added)
+++ felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java Tue May  6 08:30:47 2008
@@ -0,0 +1,81 @@
+package org.apache.felix.ipojo.handler.temporal;
+
+import java.lang.reflect.Array;
+
+import org.apache.felix.ipojo.FieldInterceptor;
+import org.apache.felix.ipojo.util.DependencyModel;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+
+public class TemporalDependency extends DependencyModel implements FieldInterceptor {
+    
+    private long timeout;
+    private String field;
+
+    public TemporalDependency(Class spec, String field, boolean agg, Filter filter, BundleContext context, long timeout, TemporalHandler handler) {
+        super(spec, agg, true, filter, null, DependencyModel.DYNAMIC_BINDING_POLICY, context, handler);
+        this.field = field;
+        this.timeout = timeout;
+    }
+
+    public void onDependencyReconfiguration(ServiceReference[] arg0, ServiceReference[] arg1) { }
+
+    public void onServiceArrival(ServiceReference arg0) {
+        synchronized (this) {
+            notifyAll();
+        }
+    }
+
+    public synchronized void onServiceDeparture(ServiceReference arg0) { }
+    
+    public synchronized Object onGet(Object arg0, String arg1, Object arg2) {
+        ServiceReference[] refs = getServiceReferences();
+        if (refs != null) {
+            // Immediate return.
+            if (isAggregate()) {
+                Object[] svc = (Object[]) Array.newInstance(getSpecification(), refs.length);
+                for (int i = 0; i < svc.length; i++) {
+                    svc[i] = getService(refs[i]);
+                }
+                return svc;
+            } else {
+                return getService(refs[0]);
+            }
+        } else {
+            // Begin to wait ...
+            long enter = System.currentTimeMillis();
+            boolean exhausted = false;
+            ServiceReference ref = null;
+            synchronized (this) {
+                while (getServiceReference() == null && ! exhausted) {
+                    try {
+                        wait(1);
+                    } catch (InterruptedException e) {
+                        // We was interrupted ....
+                    } finally {
+                        long end = System.currentTimeMillis(); 
+                        exhausted = (end - enter) > timeout;
+                    }
+                }
+            }
+            // Check 
+            if (exhausted) {
+                // Timeout, throw an exception
+                throw new RuntimeException("Service " + getSpecification().getName() + " unavailable : timeout");
+            } else {
+                ref = getServiceReference();
+                if (isAggregate()) {
+                    Object[] svc = (Object[]) Array.newInstance(getSpecification(), 1);
+                    svc[0] = ref;
+                    return svc[0];
+                } else {
+                    return getService(ref);
+                }
+            }
+        }
+    }
+
+    public void onSet(Object arg0, String arg1, Object arg2) { }
+
+}

Added: felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java (added)
+++ felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java Tue May  6 08:30:47 2008
@@ -0,0 +1,93 @@
+package org.apache.felix.ipojo.handler.temporal;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.PrimitiveHandler;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.FieldMetadata;
+import org.apache.felix.ipojo.parser.PojoMetadata;
+import org.apache.felix.ipojo.util.DependencyModel;
+import org.apache.felix.ipojo.util.DependencyStateListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+
+public class TemporalHandler extends PrimitiveHandler implements DependencyStateListener {
+    
+    private List/*<deps>*/ m_dependencies = new ArrayList(1);
+    
+    public static final String NAMESPACE = "org.apache.felix.ipojo.handler.temporal";
+
+    public void start() {
+        for (int i = 0; i < m_dependencies.size(); i++) {
+            ((TemporalDependency) m_dependencies.get(i)).start();
+        }
+    }
+    
+    public void stop() {
+        for (int i = 0; i < m_dependencies.size(); i++) {
+            ((TemporalDependency) m_dependencies.get(i)).stop();
+        }
+        m_dependencies.clear();
+    }
+
+    public void configure(Element meta, Dictionary dictionary) throws ConfigurationException {
+        PojoMetadata manipulation = getFactory().getPojoMetadata();
+        Element[] deps = meta.getElements("requires", NAMESPACE);
+        for(int i = 0; i < deps.length; i++) {
+            if(!deps[i].containsAttribute("field") || m_dependencies.contains(deps[i].getAttribute("field"))) {
+                error("One temporal dependency must be attached to a field or the field is already used");
+                return;
+            }
+            String field = deps[i].getAttribute("field");
+
+            FieldMetadata fieldmeta = manipulation.getField(field);
+            if (fieldmeta ==null) {
+                error("The field " + field + " does not exist in the class " + getInstanceManager().getClassName());
+                return;
+            }             
+                        
+            String fil = deps[i].getAttribute("filter");
+            Filter filter = null; 
+            if(fil != null) {
+                try {
+                    filter = getInstanceManager().getContext().createFilter(fil);
+                } catch (InvalidSyntaxException e) {
+                    error("Cannot create the field from " + fil + ": " + e.getMessage());
+                    return;
+                }
+            }
+            
+            boolean agg = false;
+            String aggregate = meta.getAttribute("aggregate"); 
+            if(aggregate != null) {
+                agg = aggregate.equalsIgnoreCase("true");
+            }
+
+            String spec = fieldmeta.getFieldType();
+            if (spec.endsWith("[]")) {
+                agg = true;
+                spec = spec.substring(0, spec.length() - 2);
+            }
+            
+            long timeout = 3000; // Default timeout.
+            if(deps[i].containsAttribute("timeout")) {
+                timeout = new Long(deps[i].getAttribute("timeout")).longValue();
+            }
+            
+            Class specification = DependencyModel.loadSpecification(spec, getInstanceManager().getContext());
+            TemporalDependency dep = new TemporalDependency(specification, field, agg, filter, getInstanceManager().getContext(), timeout, this);
+            m_dependencies.add(dep);
+            
+            getInstanceManager().register(fieldmeta, dep);
+        }        
+    }
+
+    public void invalidate(DependencyModel dependencymodel) {    }
+
+    public void validate(DependencyModel dependencymodel) {    }
+    
+
+}

Added: felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/resources/metadata.xml?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/resources/metadata.xml (added)
+++ felix/sandbox/clement/temporal/org.apache.felix.ipojo.handler.temporal/src/main/resources/metadata.xml Tue May  6 08:30:47 2008
@@ -0,0 +1,4 @@
+<ipojo>
+<handler classname="org.apache.felix.ipojo.handler.temporal.TemporalHandler" name="requires" namespace="org.apache.felix.ipojo.handler.temporal">
+</handler>	
+</ipojo>
\ No newline at end of file

Propchange: felix/sandbox/clement/temporal/tests.temporal.dependency/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue May  6 08:30:47 2008
@@ -0,0 +1,8 @@
+.classpath
+.project
+.settings
+maven-eclipse*
+bin*
+target*
+classes*
+.externalToolBuilders

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/pom.xml?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/pom.xml (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/pom.xml Tue May  6 08:30:47 2008
@@ -0,0 +1,101 @@
+<!--
+	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.
+-->
+<project>
+	<modelVersion>4.0.0</modelVersion>
+	<packaging>bundle</packaging>
+	<name>iPOJO Temporal Dependency Test Suite</name>
+	<artifactId>tests.core.annotations</artifactId>
+	<groupId>ipojo.tests</groupId>
+	<version>0.8.0-SNAPSHOT</version>
+	<dependencies>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo</artifactId>
+			<version>0.8.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.apache.felix.ipojo.metadata</artifactId>
+			<version>0.8.0-SNAPSHOT</version>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.felix</groupId>
+			<artifactId>org.osgi.core</artifactId>
+			<version>1.0.0</version>
+		</dependency>
+		<dependency>
+			<groupId>junit</groupId>
+			<artifactId>junit</artifactId>
+			<version>3.8.1</version>
+		</dependency>
+		<dependency>
+			<groupId>ipojo.examples</groupId>
+			<artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+			<version>0.8.0-SNAPSHOT</version>
+		</dependency>
+
+
+	</dependencies>
+	<build>
+		<plugins>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-compiler-plugin</artifactId>
+				<configuration>
+					<source>1.5</source>
+					<target>1.5</target>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-bundle-plugin</artifactId>
+				<version>1.4.0</version>
+				<extensions>true</extensions>
+				<configuration>
+					<instructions>
+						<Export-Package>
+							org.apache.felix.ipojo.test.scenarios.temporal.service
+						</Export-Package>
+						<Bundle-SymbolicName>
+							${pom.artifactId}
+						</Bundle-SymbolicName>
+						<Private-Package>
+							org.apache.felix.ipojo.test*
+						</Private-Package>
+						<Test-Suite>
+							org.apache.felix.ipojo.test.scenarios.temporal.TemporalTestSuite
+						</Test-Suite>
+					</instructions>
+				</configuration>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.felix</groupId>
+				<artifactId>maven-ipojo-plugin</artifactId>
+				<version>0.8.0-SNAPSHOT</version>
+				<executions>
+					<execution>
+						<goals>
+							<goal>ipojo-bundle</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>
+		</plugins>
+	</build>
+</project>

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/CheckServiceProvider.java Tue May  6 08:30:47 2008
@@ -0,0 +1,23 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+
+public class CheckServiceProvider implements CheckService {
+    
+    /**
+     * Temporal dependency.
+     */
+    private FooService fs;
+
+    public boolean check() {
+        return fs.foo();
+    }
+
+    public Properties getProps() {
+        return fs.fooProps();
+    }
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/FooProvider.java Tue May  6 08:30:47 2008
@@ -0,0 +1,37 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+
+public class FooProvider implements FooService {
+
+    public boolean foo() {
+       return true;
+    }
+
+    public Properties fooProps() {
+        return null;
+    }
+
+    public boolean getBoolean() {
+        return false;
+    }
+
+    public double getDouble() {
+        return 0;
+    }
+
+    public int getInt() {
+        return 0;
+    }
+
+    public long getLong() {
+        return 0;
+    }
+
+    public Boolean getObject() {
+        return null;
+    }
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/component/MultipleCheckServiceProvider.java Tue May  6 08:30:47 2008
@@ -0,0 +1,27 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+
+public class MultipleCheckServiceProvider implements CheckService {
+    
+    /**
+     * Temporal dependency.
+     */
+    private FooService[] fs;
+
+    public boolean check() {
+        boolean result = true;
+        for (int i = 0; i < fs.length; i++) {
+            result = result && fs[i].foo();
+        }
+        return result;
+    }
+
+    public Properties getProps() {
+        return fs[0].fooProps();
+    }
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayTest.java Tue May  6 08:30:47 2008
@@ -0,0 +1,208 @@
+package org.apache.felix.ipojo.test.scenarios.temporal;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class DelayTest extends OSGiTestCase {
+    
+   public void testDelay() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       long begin = System.currentTimeMillis();
+       DelayedProvider dp = new DelayedProvider(provider, 2000);
+       dp.start();
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 2", cs.check());
+       long end = System.currentTimeMillis();
+       
+       assertTrue("Assert delay", (end - begin) >= 2000);
+       
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 3", cs.check());
+       
+       provider.stop();
+       provider.dispose();
+       under.stop();
+       under.dispose();
+   }
+   
+   public void testTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       DelayedProvider dp = new DelayedProvider(provider, 5000);
+       dp.start();
+       cs = (CheckService) context.getService(ref_cs);
+       try {
+           cs.check();
+       } catch(RuntimeException e) {
+           // OK
+           dp.stop();
+           provider.stop();
+           provider.dispose();
+           under.stop();
+           under.dispose();
+           return;
+       }   
+       
+       fail("Timeout expected");
+   }
+   
+   public void testDelayTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       long begin = System.currentTimeMillis();
+       DelayedProvider dp = new DelayedProvider(provider, 2000);
+       dp.start();
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 2", cs.check());
+       long end = System.currentTimeMillis();
+       
+       assertTrue("Assert delay", (end - begin) >= 2000);
+       
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 3", cs.check());
+       
+       provider.stop();
+       provider.dispose();
+       under.stop();
+       under.dispose();
+   }
+   
+   public void testSetTimeout() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProviderTimeout", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the provider.
+       provider.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       DelayedProvider dp = new DelayedProvider(provider, 5000);
+       dp.start();
+       cs = (CheckService) context.getService(ref_cs);
+       try {
+           cs.check();
+       } catch(RuntimeException e) {
+           // OK
+           dp.stop();
+           provider.stop();
+           provider.dispose();
+           under.stop();
+           under.dispose();
+           return;
+       }   
+       
+       fail("Timeout expected");
+   }
+   
+   public void testDelayOnMultipleDependency() {
+       String prov = "provider";
+       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String prov2 = "provider2";
+       ComponentInstance provider2 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov2);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       // Stop the providers.
+       provider1.stop();
+       provider2.stop();
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 2", ref_cs);
+       long begin = System.currentTimeMillis();
+       DelayedProvider dp = new DelayedProvider(provider1, 2500);
+       DelayedProvider dp2 = new DelayedProvider(provider2, 1000);
+       dp.start();
+       dp2.start();
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 2", cs.check());
+       long end = System.currentTimeMillis();
+       assertTrue("Assert delay", (end - begin) >= 1000  && (end - begin) <= 2500);
+       dp.stop();
+       dp2.stop();
+       
+       ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability - 3", ref_cs);
+       cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation - 3", cs.check());
+       
+       provider1.stop();
+       provider2.stop();
+       under.stop();
+       under.dispose();
+   }
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/DelayedProvider.java Tue May  6 08:30:47 2008
@@ -0,0 +1,45 @@
+package org.apache.felix.ipojo.test.scenarios.temporal;
+
+import org.apache.felix.ipojo.ComponentInstance;
+
+public class DelayedProvider implements Runnable {
+    
+    ComponentInstance instance;
+    long delay = 5000;
+    Thread thread;
+    
+    public DelayedProvider(ComponentInstance ci) {
+        instance =ci;
+    }
+    
+    public DelayedProvider(ComponentInstance ci, long time) {
+        instance =ci;
+        delay = time;
+    }    
+    
+    public void start() {
+        thread = new Thread(this);
+        thread.start();
+    }
+    
+    public void stop() {
+        if (thread != null) {
+            thread.interrupt();
+        }
+    }
+
+    public void run() {
+            System.out.println("Start sleeping for " + delay);
+            try {
+                Thread.sleep(delay);
+            } catch (InterruptedException e) {
+                System.out.println("Interrupted ...");
+                return;
+            }
+            System.out.println("Wakeup");
+            thread = null;
+            instance.start();
+            System.out.println(instance.getInstanceName() + " started");
+    }
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/NoDelayTest.java Tue May  6 08:30:47 2008
@@ -0,0 +1,57 @@
+package org.apache.felix.ipojo.test.scenarios.temporal;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.temporal.service.FooService;
+import org.apache.felix.ipojo.test.scenarios.util.Utils;
+import org.osgi.framework.ServiceReference;
+
+public class NoDelayTest extends OSGiTestCase {
+    
+   public void testNoDelay() {
+       String prov = "provider";
+       ComponentInstance provider = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov);
+       String un = "under-1";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-CheckServiceProvider", un);
+       assertNotNull("Check creation", under);
+       assertNotNull("Check provider creation", prov);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       provider.stop();
+       provider.dispose();
+       under.stop();
+       under.dispose();
+   }
+   
+   public void testMultipleNoDelay() {
+       String prov1 = "provider-1";
+       ComponentInstance provider1 = Utils.getComponentInstanceByName(context, "TEMPORAL-FooProvider", prov1);
+       String un = "under-2";
+       ComponentInstance under = Utils.getComponentInstanceByName(context, "TEMPORAL-MultipleCheckServiceProvider", un);
+       
+       ServiceReference ref_fs = Utils.getServiceReferenceByName(context, FooService.class.getName(), prov1);
+       assertNotNull("Check foo availability", ref_fs);
+       
+       ServiceReference ref_cs = Utils.getServiceReferenceByName(context, CheckService.class.getName(), un);
+       assertNotNull("Check cs availability", ref_cs);
+       
+       CheckService cs = (CheckService) context.getService(ref_cs);
+       assertTrue("Check invocation", cs.check());
+       
+       provider1.stop();
+       provider1.dispose();
+       under.stop();
+       under.dispose();
+   }
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/TemporalTestSuite.java Tue May  6 08:30:47 2008
@@ -0,0 +1,37 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.felix.ipojo.junit4osgi.OSGiTestSuite;
+import org.osgi.framework.BundleContext;
+
+public class TemporalTestSuite extends TestSuite {
+
+    public static Test suite(BundleContext bc) {
+        OSGiTestSuite ots = new OSGiTestSuite("Temporal Dependency Test Suite", bc);
+        ots.addTestSuite(NoDelayTest.class);
+        ots.addTestSuite(DelayTest.class);
+        return ots;
+    }
+
+}
+

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/BarService.java Tue May  6 08:30:47 2008
@@ -0,0 +1,29 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal.service;
+
+import java.util.Properties;
+
+public interface BarService {
+	
+	public boolean bar();
+	
+	public Properties getProps();
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/CheckService.java Tue May  6 08:30:47 2008
@@ -0,0 +1,31 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal.service;
+
+import java.util.Properties;
+
+public interface CheckService {
+    
+    public static final String foo = "foo";
+	
+	public boolean check();
+	
+	public Properties getProps();
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ChildInterface.java Tue May  6 08:30:47 2008
@@ -0,0 +1,25 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal.service;
+
+public interface ChildInterface extends ParentInterface1, ParentInterface2 {
+    
+    public void processChild();
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/FooService.java Tue May  6 08:30:47 2008
@@ -0,0 +1,39 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal.service;
+
+import java.util.Properties;
+
+public interface FooService {
+
+	boolean foo();
+	
+	Properties fooProps();
+	
+	Boolean getObject();
+	
+	boolean getBoolean();
+	
+	int getInt();
+	
+	long getLong();
+	
+	double getDouble();
+	
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface1.java Tue May  6 08:30:47 2008
@@ -0,0 +1,25 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal.service;
+
+public interface ParentInterface1 extends ParentParentInterface {
+    
+    public void processParent1();
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentInterface2.java Tue May  6 08:30:47 2008
@@ -0,0 +1,25 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal.service;
+
+public interface ParentInterface2 {
+    
+    public void processParent2();
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/temporal/service/ParentParentInterface.java Tue May  6 08:30:47 2008
@@ -0,0 +1,25 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.temporal.service;
+
+public interface ParentParentInterface {
+    
+    public void processParentParent();
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/java/org/apache/felix/ipojo/test/scenarios/util/Utils.java Tue May  6 08:30:47 2008
@@ -0,0 +1,354 @@
+/* 
+ * 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.felix.ipojo.test.scenarios.util;
+
+import java.util.Dictionary;
+import java.util.Properties;
+
+import junit.framework.Assert;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.Factory;
+import org.apache.felix.ipojo.Handler;
+import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.ServiceContext;
+import org.apache.felix.ipojo.parser.ManifestMetadataParser;
+import org.apache.felix.ipojo.parser.ParseException;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ManagedServiceFactory;
+
+import org.apache.felix.ipojo.metadata.Element;
+
+public class Utils {
+    
+    public static Element getMetatadata(BundleContext bc, String component) {
+        String elem = (String) bc.getBundle().getHeaders().get("iPOJO-Components");
+        Assert.assertNotNull("iPOJO Components exists", elem);
+        try {
+            Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
+            Element[] childs = element.getElements("component");
+            for (int i = 0; i < childs.length; i++) {
+                String name = childs[i].getAttribute("name");
+                String clazz = childs[i].getAttribute("classname");
+                if (name != null && name.equalsIgnoreCase(component)) {
+                    return childs[i];
+                }
+                if (clazz.equalsIgnoreCase(component)) {
+                    return childs[i];
+                }
+            }
+            Assert.fail("Component " + component + " not found in " + bc.getBundle().getSymbolicName());
+        } catch (ParseException e) {
+            Assert.fail("Cannot parse the components from " + bc.getBundle().getSymbolicName() + ": " + e.getMessage());
+        }
+        
+        return null;
+        
+    }
+
+    public static Factory getFactoryByName(BundleContext bc, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+            if (refs == null) {
+                System.err.println("Cannot get the factory " + factoryName);
+                return null;
+            }
+            return ((Factory) bc.getService(refs[0]));
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+    }
+
+    public static HandlerFactory getHandlerFactoryByName(BundleContext bc, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName + ")");
+            if (refs == null) {
+                System.err.println("Cannot get the factory " + factoryName);
+                return null;
+            }
+            return (HandlerFactory) bc.getService(refs[0]);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+    }
+
+    public static ComponentInstance getComponentInstance(BundleContext bc, String factoryName, Dictionary configuration) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) {
+            System.err.println("Factory " + factoryName + " not found");
+            return null;
+        }
+
+        // if(fact.isAcceptable(configuration)) {
+        try {
+            return fact.createComponentInstance(configuration);
+        } catch (Exception e) {
+            e.printStackTrace();
+            Assert.fail("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+        // }
+        // else {
+        // System.err.println("Configuration not accepted by : " + factoryName);
+        // return null;
+        // }
+    }
+
+    public static ComponentInstance getComponentInstanceByName(BundleContext bc, String factoryName, String name) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) {
+            System.err.println("Factory " + factoryName + " not found");
+            return null;
+        }
+
+        try {
+            Properties props = new Properties();
+            props.put("name", name);
+            return fact.createComponentInstance(props);
+        } catch (Exception e) {
+            System.err.println("Cannot create the instance from " + factoryName + " : " + e.getMessage());
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    public static ServiceReference[] getServiceReferences(BundleContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    public static ServiceReference getServiceReference(BundleContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static ServiceReference getServiceReferenceByName(BundleContext bc, String itf, String name) {
+        ServiceReference[] refs = null;
+        String filter = null;
+        if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+    
+    public static ServiceReference getServiceReferenceByPID(BundleContext bc, String itf, String pid) {
+        ServiceReference[] refs = null;
+        String filter = "(" + "service.pid" + "=" + pid + ")";
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else if (refs.length == 1) {
+            return refs[0];
+        } else {
+            Assert.fail("A service lookup by PID returned several providers (" + refs.length + ")" + " for " + itf + " with " + pid);
+            return null;
+        }
+    }
+
+    public static Object getServiceObject(BundleContext bc, String itf, String filter) {
+        ServiceReference ref = getServiceReference(bc, itf, filter);
+        if (ref != null) {
+            return bc.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    public static Object[] getServiceObjects(BundleContext bc, String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = bc.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+
+//    public static ServiceContext getServiceContext(ComponentInstance ci) {
+//        if (ci instanceof CompositeManager) {
+//            return ((CompositeManager) ci).getServiceContext();
+//        } else {
+//            throw new RuntimeException("Cannot get the service context form an non composite instance");
+//        }
+//    }
+
+    public static Factory getFactoryByName(ServiceContext bc, String factoryName) {
+        ServiceReference[] refs;
+        try {
+            refs = bc.getServiceReferences(Factory.class.getName(), "(factory.name=" + factoryName + ")");
+            if (refs == null) { return null; }
+            return ((Factory) bc.getService(refs[0]));
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Cannot get the factory " + factoryName + " : " + e.getMessage());
+            return null;
+        }
+    }
+
+    public static ComponentInstance getComponentInstance(ServiceContext bc, String factoryName, Dictionary configuration) {
+        Factory fact = getFactoryByName(bc, factoryName);
+
+        if (fact == null) { return null; }
+
+        if (fact.isAcceptable(configuration)) {
+            try {
+                return fact.createComponentInstance(configuration);
+            } catch (Exception e) {
+                System.err.println(e.getMessage());
+                e.printStackTrace();
+                return null;
+            }
+        } else {
+            System.err.println("Configuration not accepted by : " + factoryName);
+            return null;
+        }
+    }
+
+    public static ServiceReference[] getServiceReferences(ServiceContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return new ServiceReference[0];
+        } else {
+            return refs;
+        }
+    }
+
+    public static ServiceReference getServiceReference(ServiceContext bc, String itf, String filter) {
+        ServiceReference[] refs = null;
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static ServiceReference getServiceReferenceByName(ServiceContext bc, String itf, String name) {
+        ServiceReference[] refs = null;
+        String filter = null;
+        if (itf.equals(Factory.class.getName()) || itf.equals(ManagedServiceFactory.class.getName())) {
+            filter = "(" + "factory.name" + "=" + name + ")";
+        } else {
+            filter = "(" + "instance.name" + "=" + name + ")";
+        }
+        try {
+            refs = bc.getServiceReferences(itf, filter);
+        } catch (InvalidSyntaxException e) {
+            System.err.println("Invalid Filter : " + filter);
+        }
+        if (refs == null) {
+            return null;
+        } else {
+            return refs[0];
+        }
+    }
+
+    public static Object getServiceObject(ServiceContext bc, String itf, String filter) {
+        ServiceReference ref = getServiceReference(bc, itf, filter);
+        if (ref != null) {
+            return bc.getService(ref);
+        } else {
+            return null;
+        }
+    }
+
+    public static Object[] getServiceObjects(ServiceContext bc, String itf, String filter) {
+        ServiceReference[] refs = getServiceReferences(bc, itf, filter);
+        if (refs != null) {
+            Object[] list = new Object[refs.length];
+            for (int i = 0; i < refs.length; i++) {
+                list[i] = bc.getService(refs[i]);
+            }
+            return list;
+        } else {
+            return new Object[0];
+        }
+    }
+    
+    public static boolean contains(String string, String[] array) {
+        for (int i = 0; array != null && i < array.length; i++) {
+            if (array[i] != null  && array[i].equals(string)) {
+                return true;
+            }
+        }
+        return false;
+    }
+    
+    public static boolean contains(int value, int[] array) {
+        for (int i = 0; array != null && i < array.length; i++) {
+            if (array[i] == value) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+}

Added: felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/resources/metadata.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/resources/metadata.xml?rev=653812&view=auto
==============================================================================
--- felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/resources/metadata.xml (added)
+++ felix/sandbox/clement/temporal/tests.temporal.dependency/src/main/resources/metadata.xml Tue May  6 08:30:47 2008
@@ -0,0 +1,20 @@
+<ipojo xmlns:temp="org.apache.felix.ipojo.handler.temporal">
+	<component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-CheckServiceProvider">
+		<temp:requires field="fs"/>
+		<provides/>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.test.scenarios.component.CheckServiceProvider" name="TEMPORAL-CheckServiceProviderTimeout">
+		<temp:requires field="fs" timeout="4000"/>
+		<provides/>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.test.scenarios.component.MultipleCheckServiceProvider" name="TEMPORAL-MultipleCheckServiceProvider">
+		<temp:requires field="fs" aggregate="true"/>
+		<provides/>
+	</component>
+	
+	<component classname="org.apache.felix.ipojo.test.scenarios.component.FooProvider" name="TEMPORAL-FooProvider">
+		<provides/>
+	</component>
+</ipojo>
\ No newline at end of file



Mime
View raw message