You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by pd...@apache.org on 2014/02/26 00:28:11 UTC
svn commit: r1571864 [1/5] - in
/felix/sandbox/pderop/dependencymanager-prototype: ./ cnf/ cnf/bin/
cnf/buildrepo/ cnf/buildrepo/biz.aQute.junit/
cnf/buildrepo/biz.aQute.launcher/ cnf/buildrepo/ee.foundation/
cnf/buildrepo/ee.minimum/ cnf/buildrepo/jun...
Author: pderop
Date: Tue Feb 25 23:28:08 2014
New Revision: 1571864
URL: http://svn.apache.org/r1571864
Log:
temporarily committed my current work in my own sandbox
Added:
felix/sandbox/pderop/dependencymanager-prototype/
felix/sandbox/pderop/dependencymanager-prototype/cnf/
felix/sandbox/pderop/dependencymanager-prototype/cnf/.classpath (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/.gitignore
felix/sandbox/pderop/dependencymanager-prototype/cnf/.project (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/bin/
felix/sandbox/pderop/dependencymanager-prototype/cnf/bin/.gitignore
felix/sandbox/pderop/dependencymanager-prototype/cnf/build-template.xml (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/build.bnd
felix/sandbox/pderop/dependencymanager-prototype/cnf/build.properties
felix/sandbox/pderop/dependencymanager-prototype/cnf/build.xml (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/README.txt
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.junit/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.junit/biz.aQute.junit-latest.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.launcher/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.launcher/biz.aQute.launcher-latest.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.foundation/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.foundation/ee.foundation-1.1.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.1.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/junit.osgi/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/junit.osgi/junit.osgi-3.8.2.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.1.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.1.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.3.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.0.1.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.1.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.2.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.1.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-5.0.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/
felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.junit/
felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.junit/biz.aQute.junit-1.2.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.launcher/
felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.launcher/biz.aQute.launcher-1.3.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/
felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/pluginpaths.bnd
felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/repositories.bnd
felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/
felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/
felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.bnd/
felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.bnd/biz.aQute.bnd-2.2.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.repository/
felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.repository/biz.aQute.repository-2.1.0.jar (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/
felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml (with props)
felix/sandbox/pderop/dependencymanager-prototype/cnf/src/
felix/sandbox/pderop/dependencymanager-prototype/cnf/src/.gitignore
felix/sandbox/pderop/dependencymanager-prototype/dm/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/.classpath (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm.it/.gitignore
felix/sandbox/pderop/dependencymanager-prototype/dm.it/.project (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm.it/.settings/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/.settings/org.eclipse.jdt.core.prefs
felix/sandbox/pderop/dependencymanager-prototype/dm.it/bin/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/bnd.bnd
felix/sandbox/pderop/dependencymanager-prototype/dm.it/build.xml (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm.it/generated/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/
felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/Ensure.java
felix/sandbox/pderop/dependencymanager-prototype/dm/.classpath (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm/.gitignore
felix/sandbox/pderop/dependencymanager-prototype/dm/.project (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm/.settings/
felix/sandbox/pderop/dependencymanager-prototype/dm/.settings/bndtools.core.prefs
felix/sandbox/pderop/dependencymanager-prototype/dm/bin/
felix/sandbox/pderop/dependencymanager-prototype/dm/bnd.bnd
felix/sandbox/pderop/dependencymanager-prototype/dm/build.xml (with props)
felix/sandbox/pderop/dependencymanager-prototype/dm/design.txt
felix/sandbox/pderop/dependencymanager-prototype/dm/generated/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/.gitignore
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Component.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ComponentStateListener.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Dependency.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/DependencyManager.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ServiceDependency.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentContext.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentState.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/DependencyContext.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/Event.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ConfigurationDependencyImpl.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DefaultNullObject.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/DependencyImpl.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/EventImpl.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/InvocationUtil.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/Logger.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/SerialExecutor.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ServiceDependencyImpl.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ServiceEventImpl.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ServiceUtil.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AbstractFactoryFilterIndex.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AdapterFilterIndex.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/AspectFilterIndex.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/BundleContextInterceptor.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/BundleContextInterceptorBase.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/FilterIndexBundleContext.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/ServiceRegistryCache.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/multiproperty/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/multiproperty/Filter.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/multiproperty/MultiPropertyFilterIndex.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/index/multiproperty/Property.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/packageinfo
felix/sandbox/pderop/dependencymanager-prototype/dm/src/tracker/
felix/sandbox/pderop/dependencymanager-prototype/dm/src/tracker/AbstractTracked.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/tracker/BundleTracker.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/tracker/BundleTrackerCustomizer.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/tracker/ServiceTracker.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/tracker/ServiceTrackerCustomizer.java
felix/sandbox/pderop/dependencymanager-prototype/dm/src/tracker/packageinfo
felix/sandbox/pderop/dependencymanager-prototype/dm/test/
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ComponentTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ConcurrencyTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ConfigurationTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/Ensure.java
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/SerialExecutorTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/ServiceRaceTest.java
felix/sandbox/pderop/dependencymanager-prototype/dm/test/test/TestBase.java
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/.classpath
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/.classpath?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/.classpath
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/.gitignore?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/cnf/.gitignore (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/cnf/.gitignore Tue Feb 25 23:28:08 2014
@@ -0,0 +1,2 @@
+/bin/
+/cache/
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/.project
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/.project?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/.project
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/bin/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/bin/.gitignore?rev=1571864&view=auto
==============================================================================
(empty)
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/build-template.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/build-template.xml?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/build-template.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/build.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/build.bnd?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/cnf/build.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/cnf/build.bnd Tue Feb 25 23:28:08 2014
@@ -0,0 +1,50 @@
+########################
+## BND BUILD SETTINGS ##
+########################
+
+
+## Global defaults are loaded from the bnd library (as shown below), place your
+## specific settings here. Additional settings are inherited from ext/*.bnd and
+## they will be overridden by anything you specify in this file.
+
+## General Options
+#project.dependson: ${p-dependson;:}
+#project.bootclasspath: ${p-bootclasspath;:}
+#project.buildpath: ${p-buildpath;:}
+#project.sourcepath: ${p-sourcepath;:}
+#project.allsourcepath: ${p-allsourcepath;:}
+#project.output: ${p-output}
+#project.testpath: ${p-testpath;:}
+
+#-verbose: true
+#project: ${basedir}
+#src: src
+#bin: bin
+#target-dir: generated
+#target: ${project}/${target-dir}
+#build: ${workspace}/cnf
+#p: ${basename;${project}}
+#project.name: ${p}
+#plugin-dir: ${build}/plugins
+
+## Java Compiler Options
+#java: java
+#javac: javac
+#javac.source: 1.5
+#javac.target: 1.5
+#javac.debug: on
+
+## Bnd Options
+#-sources: true
+#-sourcepath: ${project}/src
+
+
+## Properties from ext/*.bnd can be referenced in order to extend them. For
+## example, to add one additional plugin to the list defined in
+## ext/repositories.bnd:
+# -plugin: ${ext.repositories.-plugin}, org.example.MyPlugin
+
+
+## If you use git, you might want to uncomment the following lines:
+# Git-Descriptor: ${system-allow-fail;git describe --dirty --always}
+# Git-SHA: ${system-allow-fail;git rev-list -1 HEAD}
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/build.properties
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/build.properties?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/cnf/build.properties (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/cnf/build.properties Tue Feb 25 23:28:08 2014
@@ -0,0 +1,3 @@
+# This file is used to bootstrap the bnd ANT Task definition found in build-template.xml
+
+bnd.location=plugins/biz.aQute.bnd/biz.aQute.bnd-2.2.0.jar
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/build.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/build.xml?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/build.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/README.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/README.txt?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/README.txt (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/README.txt Tue Feb 25 23:28:08 2014
@@ -0,0 +1,6 @@
+WARNING
+=======
+
+This directory contains JAR file dependencies that are intended ONLY FOR BUILT-TIME usage.
+None are intended to be deployed as bundles into a running OSGi Framework, and indeed they may cause
+unexpected errors if they are used at runtime.
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.junit/biz.aQute.junit-latest.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.junit/biz.aQute.junit-latest.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.junit/biz.aQute.junit-latest.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.launcher/biz.aQute.launcher-latest.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.launcher/biz.aQute.launcher-latest.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/biz.aQute.launcher/biz.aQute.launcher-latest.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.foundation/ee.foundation-1.1.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.foundation/ee.foundation-1.1.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.foundation/ee.foundation-1.1.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.1.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.1.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/ee.minimum/ee.minimum-1.2.1.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/junit.osgi/junit.osgi-3.8.2.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/junit.osgi/junit.osgi-3.8.2.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/junit.osgi/junit.osgi-3.8.2.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.1.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.1.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.foundation/org.osgi.ee.foundation-1.0.1.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.1.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.1.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.1.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.3.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.3.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/org.osgi.ee.minimum/org.osgi.ee.minimum-1.1.3.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.0.1.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.0.1.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.0.1.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.1.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.1.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.1.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.2.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.2.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.2.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.1.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.1.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-4.3.1.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-5.0.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-5.0.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/buildrepo/osgi.core/osgi.core-5.0.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.junit/biz.aQute.junit-1.2.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.junit/biz.aQute.junit-1.2.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.junit/biz.aQute.junit-1.2.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.launcher/biz.aQute.launcher-1.3.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.launcher/biz.aQute.launcher-1.3.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/cache/biz.aQute.launcher/biz.aQute.launcher-1.3.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/pluginpaths.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/pluginpaths.bnd?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/pluginpaths.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/pluginpaths.bnd Tue Feb 25 23:28:08 2014
@@ -0,0 +1 @@
+-pluginpath: ${plugin-dir}/biz.aQute.repository/biz.aQute.repository-2.1.0.jar
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/repositories.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/repositories.bnd?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/repositories.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/cnf/ext/repositories.bnd Tue Feb 25 23:28:08 2014
@@ -0,0 +1,7 @@
+-plugin:\
+ aQute.bnd.deployer.repository.LocalIndexedRepo; name=Release; local=${workspace}/cnf/releaserepo;pretty=true,\
+ aQute.bnd.deployer.repository.LocalIndexedRepo; name=Local; local=${workspace}/cnf/localrepo;pretty=true,\
+ aQute.bnd.deployer.repository.FixedIndexedRepo; name=Bndtools Hub; locations=https://github.com/bndtools/bundle-hub/raw/master/index.xml.gz,\
+ aQute.lib.deployer.FileRepo; name=Build; location=${workspace}/cnf/buildrepo
+
+-releaserepo: Release
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/localrepo/index.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.bnd/biz.aQute.bnd-2.2.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.bnd/biz.aQute.bnd-2.2.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.bnd/biz.aQute.bnd-2.2.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.repository/biz.aQute.repository-2.1.0.jar
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.repository/biz.aQute.repository-2.1.0.jar?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/plugins/biz.aQute.repository/biz.aQute.repository-2.1.0.jar
------------------------------------------------------------------------------
svn:mime-type = application/zip
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/cnf/releaserepo/index.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/cnf/src/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/cnf/src/.gitignore?rev=1571864&view=auto
==============================================================================
(empty)
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/.classpath
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/.classpath?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm.it/.classpath
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/.gitignore?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.it/.gitignore (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.it/.gitignore Tue Feb 25 23:28:08 2014
@@ -0,0 +1,2 @@
+/bin/
+/generated/
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/.project
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/.project?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm.it/.project
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/.settings/org.eclipse.jdt.core.prefs?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.it/.settings/org.eclipse.jdt.core.prefs (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.it/.settings/org.eclipse.jdt.core.prefs Tue Feb 25 23:28:08 2014
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.7
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/bnd.bnd?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.it/bnd.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.it/bnd.bnd Tue Feb 25 23:28:08 2014
@@ -0,0 +1,20 @@
+Test-Cases: \
+ ${classes;CONCRETE;EXTENDS;junit.framework.TestCase}
+-runbundles: \
+ org.mockito.mockito-all,\
+ dm;version=latest,\
+ org.apache.felix.configadmin;version=1.6.0
+Private-Package: \
+ dm.it
+-runee:JavaSE-1.6
+-runvm:-ea
+-runfw:org.apache.felix.framework
+-buildpath: \
+ osgi.core;version='[4.2,5)',\
+ osgi.cmpn,\
+ org.mockito.mockito-all,\
+ junit.osgi;version=3.8,\
+ dm;version=latest
+Bundle-Version:0.0.0.${tstamp}
+-runsystempackages: \
+ sun.reflect
\ No newline at end of file
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/build.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/build.xml?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm.it/build.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/ComponentTest.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,70 @@
+package dm.it;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceRegistration;
+
+import dm.Component;
+import dm.DependencyManager;
+
+public class ComponentTest extends TestCase {
+ private final Ensure m_ensure = new Ensure();
+ private final BundleContext m_context = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
+
+ public void testSimple() throws Exception {
+ DependencyManager dm = new DependencyManager(m_context);
+ Component consumer = dm.createComponent();
+ consumer
+ .setImplementation(new Consumer())
+ .add(dm.createServiceDependency()
+ .setService(Provider.class)
+ .setRequired(true)
+ .setCallbacks("add", "remove"))
+ .add(dm.createServiceDependency()
+ .setService(Provider.class)
+ .setRequired(true)
+ .setAutoConfig("m_autoConfiguredProvider"));
+ ServiceRegistration sr = m_context.registerService(Provider.class.getName(), new ProviderImpl(), null);
+ dm.add(consumer);
+ m_ensure.waitForStep(2, 5000);
+ sr.unregister();
+ m_ensure.waitForStep(5, 5000);
+ }
+
+ public static interface Provider {
+ }
+
+ public class ProviderImpl implements Provider {}
+
+ public class Consumer {
+ Provider m_provider;
+ Provider m_autoConfiguredProvider;
+
+ void add(Provider provider) {
+ Assert.assertNotNull(provider);
+ m_provider = provider;
+ m_ensure.step(1);
+ }
+
+ void start() {
+ Assert.assertNotNull(m_autoConfiguredProvider);
+ m_ensure.step(2);
+ }
+
+ void stop() {
+ m_ensure.step(3);
+ }
+
+ void destroy() {
+ m_ensure.step(4);
+ }
+
+ void remove(Provider provider) {
+ Assert.assertEquals(m_provider, provider);
+ m_ensure.step(5);
+ }
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/Ensure.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/Ensure.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/Ensure.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm.it/src/dm/it/Ensure.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,154 @@
+package dm.it;
+
+import java.io.PrintStream;
+
+import junit.framework.Assert;
+
+/**
+ * Helper class to make sure that steps in a test happen in the correct order. Instantiate
+ * this class and subsequently invoke <code>step(nr)</code> with steps starting at 1. You
+ * can also have threads wait until you arrive at a certain step.
+ */
+public class Ensure {
+ private final boolean DEBUG;
+ private static long INSTANCE = 0;
+ private static final int RESOLUTION = 100;
+ private static PrintStream STREAM = System.out;
+ int step = 0;
+ private Throwable m_throwable;
+
+ public Ensure() {
+ this(true);
+ }
+
+ public Ensure(boolean debug) {
+ DEBUG = debug;
+ if (DEBUG) {
+ INSTANCE++;
+ }
+ }
+
+ public void setStream(PrintStream output) {
+ STREAM = output;
+ }
+
+ /**
+ * Mark this point as step <code>nr</code>.
+ *
+ * @param nr the step we are in
+ */
+ public synchronized void step(int nr) {
+ step++;
+ Assert.assertEquals(nr, step);
+ if (DEBUG) {
+ String info = getLineInfo(3);
+ STREAM.println("[Ensure " + INSTANCE + "] step " + step + " [" + currentThread() + "] " + info);
+ }
+ notifyAll();
+ }
+
+ private String getLineInfo(int depth) {
+ StackTraceElement[] trace = Thread.currentThread().getStackTrace();
+ String info = trace[depth].getClassName() + "." + trace[depth].getMethodName() + ":" + trace[depth].getLineNumber();
+ return info;
+ }
+
+ /**
+ * Mark this point as the next step.
+ */
+ public synchronized void step() {
+ step++;
+ if (DEBUG) {
+ String info = getLineInfo(3);
+ STREAM.println("[Ensure " + INSTANCE + "] next step " + step + " [" + currentThread() + "] " + info);
+ }
+ notifyAll();
+ }
+
+ /**
+ * Wait until we arrive at least at step <code>nr</code> in the process, or fail if that
+ * takes more than <code>timeout</code> milliseconds. If you invoke wait on a thread,
+ * you are effectively assuming some other thread will invoke the <code>step(nr)</code>
+ * method.
+ *
+ * @param nr the step to wait for
+ * @param timeout the number of milliseconds to wait
+ */
+ public synchronized void waitForStep(int nr, int timeout) {
+ final int initialTimeout = timeout;
+ if (DEBUG) {
+ String info = getLineInfo(3);
+ STREAM.println("[Ensure " + INSTANCE + "] waiting for step " + nr + " [" + currentThread() + "] " + info);
+ }
+ while (step < nr && timeout > 0) {
+ try {
+ wait(RESOLUTION);
+ timeout -= RESOLUTION;
+ }
+ catch (InterruptedException e) {}
+ }
+ if (step < nr) {
+ throw new IllegalStateException("Timed out waiting for " + initialTimeout + " ms for step " + nr + ", we are still at step " + step);
+ }
+ if (DEBUG) {
+ String info = getLineInfo(3);
+ STREAM.println("[Ensure " + INSTANCE + "] arrived at step " + nr + " [" + currentThread() + "] " + info);
+ }
+ }
+
+ private String currentThread() {
+ Thread thread = Thread.currentThread();
+ return thread.getId() + " " + thread.getName();
+ }
+
+ public static Runnable createRunnableStep(final Ensure ensure, final int nr) {
+ return new Runnable() { public void run() { ensure.step(nr); }};
+ }
+
+ public synchronized void steps(Steps steps) {
+ steps.next(this);
+ }
+
+ /**
+ * Helper class for naming a list of step numbers. If used with the steps(Steps) method
+ * you can define at which steps in time this point should be passed. That means you can
+ * check methods that will get invoked multiple times during a test.
+ */
+ public static class Steps {
+ private final int[] m_steps;
+ private int m_stepIndex;
+
+ /**
+ * Create a list of steps and initialize the step counter to zero.
+ */
+ public Steps(int... steps) {
+ m_steps = steps;
+ m_stepIndex = 0;
+ }
+
+ /**
+ * Ensure we're at the right step. Will throw an index out of bounds exception if we enter this step more often than defined.
+ */
+ public void next(Ensure ensure) {
+ ensure.step(m_steps[m_stepIndex++]);
+ }
+ }
+
+ /**
+ * Saves a thrown exception that occurred in a different thread. You can only save one exception
+ * at a time this way.
+ */
+ public synchronized void throwable(Throwable throwable) {
+ m_throwable = throwable;
+ }
+
+ /**
+ * Throws a <code>Throwable</code> if one occurred in a different thread and that thread saved it
+ * using the <code>throwable()</code> method.
+ */
+ public synchronized void ensure() throws Throwable {
+ if (m_throwable != null) {
+ throw m_throwable;
+ }
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/.classpath
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/.classpath?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm/.classpath
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/.gitignore?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/.gitignore (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/.gitignore Tue Feb 25 23:28:08 2014
@@ -0,0 +1,2 @@
+/bin/
+/generated/
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/.project
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/.project?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm/.project
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/.settings/bndtools.core.prefs
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/.settings/bndtools.core.prefs?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/.settings/bndtools.core.prefs (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/.settings/bndtools.core.prefs Tue Feb 25 23:28:08 2014
@@ -0,0 +1,3 @@
+compileErrorAction=skip
+eclipse.preferences.version=1
+eclipseClasspath=expose
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/bnd.bnd
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/bnd.bnd?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/bnd.bnd (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/bnd.bnd Tue Feb 25 23:28:08 2014
@@ -0,0 +1,11 @@
+-buildpath: \
+ osgi.cmpn,\
+ osgi.core;version=4.2
+Private-Package: \
+ dm.impl,\
+ dm.context,\
+ dm.impl.index,\
+ dm.impl.index.multiproperty
+Export-Package: \
+ dm,\
+ tracker
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/build.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/build.xml?rev=1571864&view=auto
==============================================================================
Binary file - no diff available.
Propchange: felix/sandbox/pderop/dependencymanager-prototype/dm/build.xml
------------------------------------------------------------------------------
svn:mime-type = application/xml
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/design.txt
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/design.txt?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/design.txt (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/design.txt Tue Feb 25 23:28:08 2014
@@ -0,0 +1,22 @@
+7 feb 2014 (marrs & uiterlix):
+
+This prototype demonstrates the new concurrency principles that form the basis for the DM:
+
+ * All external events that influence the state of dependencies are recorded and given
+ to the serial executor of the component. We record whatever data comes in, so when the
+ actual job is run by the serial executor, we still have access to the original data
+ without having to access other sources whose state might have changed since.
+ * The serial executor of a component will execute a job immediately if it is being called
+ by the thread that is already executing jobs.
+ * If the serial executor of a component had not yet started a job, it will queue and start
+ it on the current thread.
+ * If the serial executor gets invoked from a different thread than the one currently
+ executing jobs, the job will be put at the end of the queue. As mentioned before, any
+ data associated with the event will also be recorded so it is available when the job
+ executes.
+ * State in the component and dependency can only be modified via the serial executor
+ thread. This means we don't need explicit synchronization anywhere.
+
+
+
+
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/.gitignore
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/.gitignore?rev=1571864&view=auto
==============================================================================
(empty)
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Component.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Component.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Component.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Component.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,13 @@
+package dm;
+
+
+/**
+ * A component. Has dependencies.
+ */
+public interface Component {
+ public Component setImplementation(Object implementation);
+ public Component add(Dependency d);
+ public Component remove(Dependency d);
+ public Component add(ComponentStateListener l);
+ public Component remove(ComponentStateListener l);
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ComponentStateListener.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ComponentStateListener.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ComponentStateListener.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ComponentStateListener.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,7 @@
+package dm;
+
+import dm.context.ComponentState;
+
+public interface ComponentStateListener {
+ public void changed(ComponentState state);
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Dependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Dependency.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Dependency.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/Dependency.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,13 @@
+package dm;
+
+
+/**
+ * A dependency. Can be added to a single component. Can be available, or not.
+ */
+public interface Dependency {
+ public Dependency setCallbacks(String add, String remove);
+ public Dependency setCallbacks(String add, String change, String remove);
+ public Dependency setRequired(boolean required);
+ public Dependency setAutoConfig(boolean autoConfig);
+ public Dependency setAutoConfig(String instanceName);
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/DependencyManager.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/DependencyManager.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/DependencyManager.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/DependencyManager.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,177 @@
+/*
+ * 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 dm;
+
+import java.lang.ref.WeakReference;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.FrameworkUtil;
+
+import dm.context.ComponentContext;
+import dm.impl.ComponentImpl;
+import dm.impl.ConfigurationDependencyImpl;
+import dm.impl.Logger;
+import dm.impl.ServiceDependencyImpl;
+import dm.impl.index.AdapterFilterIndex;
+import dm.impl.index.AspectFilterIndex;
+import dm.impl.index.ServiceRegistryCache;
+import dm.impl.index.multiproperty.MultiPropertyFilterIndex;
+
+/**
+ * The dependency manager manages all components and their dependencies. Using
+ * this API you can declare all components and their dependencies. Under normal
+ * circumstances, you get passed an instance of this class through the
+ * <code>DependencyActivatorBase</code> subclass you use as your
+ * <code>BundleActivator</code>, but it is also possible to create your
+ * own instance.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class DependencyManager {
+ public static final String ASPECT = "org.apache.felix.dependencymanager.aspect";
+ public static final String SERVICEREGISTRY_CACHE_INDICES = "org.apache.felix.dependencymanager.filterindex";
+ public static final String METHOD_CACHE_SIZE = "org.apache.felix.dependencymanager.methodcache";
+ private final BundleContext m_context;
+ private final Logger m_logger;
+ private final List<Component> m_components = new CopyOnWriteArrayList<>();
+
+ // service registry cache
+ private static ServiceRegistryCache m_serviceRegistryCache;
+ private static final Set /* WeakReference<DependencyManager> */ m_dependencyManagers = new HashSet();
+ static {
+ String index = System.getProperty(SERVICEREGISTRY_CACHE_INDICES);
+ if (index != null) {
+ Bundle bundle = FrameworkUtil.getBundle(DependencyManager.class);
+ try {
+ if (bundle.getState() != Bundle.ACTIVE) {
+ bundle.start();
+ }
+ BundleContext bundleContext = bundle.getBundleContext();
+
+ m_serviceRegistryCache = new ServiceRegistryCache(bundleContext);
+ m_serviceRegistryCache.open(); // TODO close it somewhere
+ String[] props = index.split(";");
+ for (int i = 0; i < props.length; i++) {
+ if (props[i].equals("*aspect*")) {
+ m_serviceRegistryCache.addFilterIndex(new AspectFilterIndex());
+ }
+ else if (props[i].equals("*adapter*")) {
+ m_serviceRegistryCache.addFilterIndex(new AdapterFilterIndex());
+ }
+ else {
+ m_serviceRegistryCache.addFilterIndex(new MultiPropertyFilterIndex(props[i]));
+ }
+ }
+ }
+ catch (BundleException e) {
+ // if we cannot start ourselves, we cannot use the indices
+ // TODO we might want to warn people about this
+ }
+ }
+ }
+
+ public DependencyManager(BundleContext context) {
+ this(context, new Logger(context));
+ }
+
+ DependencyManager(BundleContext context, Logger logger) {
+ m_context = createContext(context);
+ m_logger = logger;
+ synchronized (m_dependencyManagers) {
+ m_dependencyManagers.add(new WeakReference(this));
+ }
+ }
+
+ public static List getDependencyManagers() {
+ List /* DependencyManager */ result = new ArrayList();
+ synchronized (m_dependencyManagers) {
+ Iterator iterator = m_dependencyManagers.iterator();
+ while (iterator.hasNext()) {
+ WeakReference reference = (WeakReference) iterator.next();
+ DependencyManager manager = (DependencyManager) reference.get();
+ if (manager != null) {
+ try {
+ manager.getBundleContext().getBundle();
+ result.add(manager);
+ continue;
+ }
+ catch (IllegalStateException e) {
+ }
+ }
+ iterator.remove();
+ }
+ }
+ return result;
+ }
+
+ public BundleContext getBundleContext() {
+ return m_context;
+ }
+
+ public void add(Component service) {
+ m_components.add(service);
+ ((ComponentContext) service).start();
+ }
+
+ public void remove(Component service) {
+ ((ComponentContext) service).stop();
+ m_components.remove(service);
+ }
+
+ public Component createComponent() {
+ return new ComponentImpl(m_context, this, m_logger);
+ }
+
+ public ServiceDependency createServiceDependency() {
+ return new ServiceDependencyImpl(m_context, m_logger);
+ }
+
+ public ConfigurationDependencyImpl createConfigurationDependency() {
+ return new ConfigurationDependencyImpl(); // TODO pass context and logger in the constructor
+ }
+
+ public List getComponents() {
+ return m_components;
+ }
+
+ public void clear() {
+ for (Component component : m_components) {
+ remove(component);
+ }
+ m_components.clear();
+ }
+
+ private BundleContext createContext(BundleContext context) {
+ if (m_serviceRegistryCache != null) {
+ return m_serviceRegistryCache.createBundleContextInterceptor(context);
+ }
+ else {
+ return context;
+ }
+ }
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/FilterIndex.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,47 @@
+/*
+ * 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 dm;
+
+import java.util.List;
+
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceEvent;
+import org.osgi.framework.ServiceListener;
+
+/**
+ * A filter index is an interface you can implement to create your own, optimized index for specific filter expressions.
+ *
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public interface FilterIndex {
+ /** Opens this filter index. */
+ public void open(BundleContext context);
+ /** Closes this filter index. */
+ public void close();
+ /** Determines if the combination of class and filter is applicable for this filter index. */
+ public boolean isApplicable(String clazz, String filter);
+ /** Returns all service references that match the specified class and filter. */
+ public List /* <ServiceReference> */ getAllServiceReferences(String clazz, String filter);
+ /** Invoked whenever a service event occurs. */
+ public void serviceChanged(ServiceEvent event);
+ /** Adds a service listener to this filter index. */
+ public void addServiceListener(ServiceListener listener, String filter);
+ /** Removes a service listener from this filter index. If the listener is not present in the filter index, this method does nothing. */
+ public void removeServiceListener(ServiceListener listener);
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ServiceDependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ServiceDependency.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ServiceDependency.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/ServiceDependency.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,11 @@
+package dm;
+
+import org.osgi.framework.ServiceReference;
+
+public interface ServiceDependency extends Dependency {
+ public ServiceDependency setService(Class serviceName);
+ public ServiceDependency setService(Class serviceName, String serviceFilter);
+ public ServiceDependency setService(String serviceFilter);
+ public ServiceDependency setService(Class serviceName, ServiceReference serviceReference);
+ public ServiceDependency setDefaultImplementation(Object implementation);
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentContext.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentContext.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentContext.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentContext.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,16 @@
+package dm.context;
+
+import java.util.List;
+
+import dm.impl.SerialExecutor;
+
+public interface ComponentContext {
+ public SerialExecutor getExecutor(); // shared between a component and its dependencies
+ public void start();
+ public void stop();
+ public boolean isAvailable();
+ public void handleChange();
+ public List<DependencyContext> getDependencies(); // for testing only...
+ public void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures, Object[][] parameters);
+ public Object[] getInstances();
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentState.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentState.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentState.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/ComponentState.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,8 @@
+package dm.context;
+
+public enum ComponentState {
+ INACTIVE,
+ WAITING_FOR_REQUIRED,
+ INSTANTIATED_AND_WAITING_FOR_REQUIRED,
+ TRACKING_OPTIONAL
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/DependencyContext.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/DependencyContext.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/DependencyContext.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/DependencyContext.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,32 @@
+package dm.context;
+
+
+public interface DependencyContext {
+ public void invokeAdd();
+ public void invokeRemove();
+ /** Whenever the dependency changes state, this method is invoked with the Event containing the new state information. */
+ public void add(final Event e);
+ public void change(final Event e);
+ public void remove(final Event e);
+ public void add(ComponentContext component);
+ public void remove(ComponentContext component);
+ /** Invoked by the component when the dependency should start working. */
+ public void start();
+ /** Invoked by the component when the dependency should stop working. */
+ public void stop();
+
+ public boolean isAvailable();
+
+ public boolean isRequired();
+
+ public boolean isInstanceBound();
+ public void setInstanceBound(boolean instanceBound);
+
+ /** Does this dependency need the component instances to determine if the dependency is available or not */
+ public boolean needsInstance();
+
+ public Class getAutoConfigType();
+ public Object getAutoConfigInstance();
+ public boolean isAutoConfig();
+ public String getAutoConfigName();
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/Event.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/Event.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/Event.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/context/Event.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,8 @@
+package dm.context;
+
+/**
+ * An event holds all data that belongs to some external event as it comes in via
+ * the 'changed' callback of a dependency.
+ */
+public interface Event {
+}
Added: felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java?rev=1571864&view=auto
==============================================================================
--- felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java (added)
+++ felix/sandbox/pderop/dependencymanager-prototype/dm/src/dm/impl/ComponentImpl.java Tue Feb 25 23:28:08 2014
@@ -0,0 +1,439 @@
+package dm.impl;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Proxy;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import org.osgi.framework.BundleContext;
+
+import dm.Component;
+import dm.ComponentStateListener;
+import dm.Dependency;
+import dm.DependencyManager;
+import dm.context.ComponentContext;
+import dm.context.ComponentState;
+import dm.context.DependencyContext;
+
+public class ComponentImpl implements Component, ComponentContext {
+ private static final Class[] VOID = new Class[] {};
+ private final SerialExecutor m_executor = new SerialExecutor(new Logger(null));
+ private ComponentState m_state = ComponentState.INACTIVE;
+ private final List<DependencyContext> m_dependencies = new CopyOnWriteArrayList<>();
+ private final List<ComponentStateListener> m_listeners = new CopyOnWriteArrayList<>();
+ private boolean m_isStarted;
+ private final Logger m_logger;
+ private final BundleContext m_context;
+ private final DependencyManager m_manager;
+ private final Object SYNC = new Object();
+ private Object m_componentDefinition;
+ private Object m_componentInstance;
+
+ public ComponentImpl() {
+ this(null, null, new Logger(null));
+ }
+
+ public ComponentImpl(BundleContext context, DependencyManager manager, Logger logger) {
+ m_context = context;
+ m_manager = manager;
+ m_logger = logger;
+ }
+
+ public SerialExecutor getExecutor() {
+ return m_executor;
+ }
+
+ @Override
+ public Component add(final Dependency d) {
+ getExecutor().execute(new Runnable() {
+ @Override
+ public void run() {
+ DependencyContext dc = (DependencyContext) d;
+ m_dependencies.add(dc);
+ dc.add(ComponentImpl.this);
+ if (!(m_state == ComponentState.INACTIVE)) {
+ dc.setInstanceBound(true);
+ dc.start();
+ }
+ handleChange();
+ }
+ });
+ return this;
+ }
+
+ @Override
+ public Component remove(final Dependency d) {
+ getExecutor().execute(new Runnable() {
+ @Override
+ public void run() {
+ DependencyContext dc = (DependencyContext) d;
+ if (!(m_state == ComponentState.INACTIVE)) {
+ dc.stop();
+ }
+ m_dependencies.remove(d);
+ dc.remove(ComponentImpl.this);
+ handleChange();
+ }
+ });
+ return this;
+ }
+
+ public void start() {
+ getExecutor().execute(new Runnable() {
+ @Override
+ public void run() {
+ m_isStarted = true;
+ handleChange();
+ }
+ });
+
+ }
+
+ public void stop() {
+ getExecutor().execute(new Runnable() {
+ @Override
+ public void run() {
+ m_isStarted = false;
+ handleChange();
+ }
+ });
+ }
+
+ @Override
+ public void handleChange() {
+ ComponentState oldState;
+ ComponentState newState;
+ do {
+ oldState = m_state;
+ newState = calculateNewState(oldState);
+ m_state = newState;
+ }
+ while (performTransition(oldState, newState));
+ }
+
+ /** Based on the current state, calculate the new state. */
+ private ComponentState calculateNewState(ComponentState currentState) {
+ if (currentState == ComponentState.INACTIVE) {
+ if (m_isStarted) {
+ return ComponentState.WAITING_FOR_REQUIRED;
+ }
+ }
+ if (currentState == ComponentState.WAITING_FOR_REQUIRED) {
+ if (!m_isStarted) {
+ return ComponentState.INACTIVE;
+ }
+ if (allRequiredAvailable()) {
+ return ComponentState.INSTANTIATED_AND_WAITING_FOR_REQUIRED;
+ }
+ }
+ if (currentState == ComponentState.INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
+ if (m_isStarted && allRequiredAvailable()) {
+ if (allInstanceBoundAvailable()) {
+ return ComponentState.TRACKING_OPTIONAL;
+ }
+ return currentState;
+ }
+ return ComponentState.WAITING_FOR_REQUIRED;
+ }
+ if (currentState == ComponentState.TRACKING_OPTIONAL) {
+ if (m_isStarted && allRequiredAvailable() && allInstanceBoundAvailable()) {
+ return currentState;
+ }
+ return ComponentState.INSTANTIATED_AND_WAITING_FOR_REQUIRED;
+ }
+ return currentState;
+ }
+
+ private boolean allRequiredAvailable() {
+ boolean available = true;
+ for (DependencyContext d : m_dependencies) {
+ if (d.isRequired() && !d.isInstanceBound()) {
+ if (!d.isAvailable()) {
+ available = false;
+ break;
+ }
+ }
+ }
+ return available;
+ }
+
+ private boolean allInstanceBoundAvailable() {
+ boolean available = true;
+ for (DependencyContext d : m_dependencies) {
+ if (d.isRequired() && d.isInstanceBound()) {
+ if (!d.isAvailable()) {
+ available = false;
+ break;
+ }
+ }
+ }
+ return available;
+ }
+
+ private boolean someDependenciesNeedInstance() {
+ for (DependencyContext d : m_dependencies) {
+ if (d.needsInstance()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /** Perform all the actions associated with state transitions. Returns true if a transition was performed. */
+ private boolean performTransition(ComponentState oldState, ComponentState newState) {
+// System.out.println("transition from " + oldState + " to " + newState);
+ if (oldState == ComponentState.INACTIVE && newState == ComponentState.WAITING_FOR_REQUIRED) {
+ for (DependencyContext d : m_dependencies) {
+ if (d.needsInstance()) {
+ instantiateComponent();
+ }
+ d.start();
+ }
+ notifyListeners(newState);
+ return true;
+ }
+ if (oldState == ComponentState.WAITING_FOR_REQUIRED && newState == ComponentState.INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
+ instantiateComponent();
+ invokeAddRequiredDependencies();
+ invokeAutoConfigDependencies();
+ invoke("init" /* TODO make callbacks configurable */ );
+ notifyListeners(newState);
+ return true;
+ }
+ if (oldState == ComponentState.INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == ComponentState.TRACKING_OPTIONAL) {
+ invokeAddRequiredInstanceBoundDependencies();
+ invokeAutoConfigInstanceBoundDependencies();
+ invoke("start");
+ invokeAddOptionalDependencies();
+ notifyListeners(newState);
+ return true;
+ }
+ if (oldState == ComponentState.TRACKING_OPTIONAL && newState == ComponentState.INSTANTIATED_AND_WAITING_FOR_REQUIRED) {
+ invoke("stop");
+ invokeRemoveInstanceBoundDependencies();
+ notifyListeners(newState);
+ return true;
+ }
+ if (oldState == ComponentState.INSTANTIATED_AND_WAITING_FOR_REQUIRED && newState == ComponentState.WAITING_FOR_REQUIRED) {
+ invoke("destroy");
+ invokeRemoveRequiredDependencies();
+ notifyListeners(newState);
+ if (! someDependenciesNeedInstance()) {
+ destroyComponent();
+ }
+ return true;
+ }
+ if (oldState == ComponentState.WAITING_FOR_REQUIRED && newState == ComponentState.INACTIVE) {
+ for (DependencyContext d : m_dependencies) {
+ d.stop();
+ }
+ destroyComponent();
+ notifyListeners(newState);
+ return true;
+ }
+ return false;
+ }
+
+ private void instantiateComponent() {
+ // TODO add more complex factory instantiations of one or more components in a composition here
+ if (m_componentInstance == null) {
+ if (m_componentDefinition instanceof Class) {
+ try {
+ m_componentInstance = createInstance((Class) m_componentDefinition);
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ else {
+ m_componentInstance = m_componentDefinition;
+ }
+ }
+ }
+
+ private void destroyComponent() {
+ m_componentInstance = null;
+ }
+
+ private void invokeAddRequiredDependencies() {
+ for (DependencyContext d : m_dependencies) {
+ if (d.isRequired() && !d.isInstanceBound()) {
+ d.invokeAdd();
+ }
+ }
+ }
+
+ private void invokeAutoConfigDependencies() {
+ for (DependencyContext d : m_dependencies) {
+ if (d.isAutoConfig() && !d.isInstanceBound()) {
+ configureImplementation(d.getAutoConfigType(), d.getAutoConfigInstance(), d.getAutoConfigName());
+ }
+ }
+ }
+
+ private void invokeAutoConfigInstanceBoundDependencies() {
+ for (DependencyContext d : m_dependencies) {
+ if (d.isAutoConfig() && d.isInstanceBound()) {
+ configureImplementation(d.getAutoConfigType(), d.getAutoConfigInstance(), d.getAutoConfigName());
+ }
+ }
+ }
+
+ private void invokeAddRequiredInstanceBoundDependencies() {
+ for (DependencyContext d : m_dependencies) {
+ if (d.isRequired() && d.isInstanceBound()) {
+ d.invokeAdd();
+ }
+ }
+ }
+
+ private void invokeAddOptionalDependencies() {
+ for (DependencyContext d : m_dependencies) {
+ if (! d.isRequired()) {
+ d.invokeAdd();
+ }
+ }
+ }
+
+ private void invokeRemoveRequiredDependencies() {
+ for (DependencyContext d : m_dependencies) {
+ if (!d.isInstanceBound()) {
+ d.invokeRemove();
+ }
+ }
+ }
+
+ private void invokeRemoveInstanceBoundDependencies() {
+ for (DependencyContext d : m_dependencies) {
+ if (d.isInstanceBound()) {
+ d.invokeRemove();
+ }
+ }
+ }
+
+ private void invoke(String name) {
+// System.out.println("invoke " + name);
+ if (name != null) {
+ // if a callback instance was specified, look for the method there, if not,
+ // ask the service for its composition instances
+
+ invokeCallbackMethod(getInstances(), name,
+ new Class[][] {{ Component.class }, {}},
+ new Object[][] {{ this }, {}});
+ }
+ }
+
+ public Object[] getInstances() {
+ // TODO
+// Object[] instances = m_callbackInstance != null ? new Object[] { m_callbackInstance } : getCompositionInstances();
+ return new Object[] { m_componentInstance };
+ }
+
+ public void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures, Object[][] parameters) {
+ for (int i = 0; i < instances.length; i++) {
+ try {
+ InvocationUtil.invokeCallbackMethod(instances[i], methodName, signatures, parameters);
+ }
+ catch (NoSuchMethodException e) {
+ // if the method does not exist, ignore it
+ }
+ catch (InvocationTargetException e) {
+ // the method itself threw an exception, log that
+ //m_logger.log(Logger.LOG_ERROR, "Invocation of '" + methodName + "' failed.", e.getCause());
+ }
+ catch (Exception e) {
+ //m_logger.log(Logger.LOG_ERROR, "Could not invoke '" + methodName + "'.", e);
+ }
+ }
+ }
+
+ private Object createInstance(Class clazz) throws SecurityException, NoSuchMethodException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
+ Constructor constructor = clazz.getConstructor(VOID);
+ constructor.setAccessible(true);
+ return constructor.newInstance(null);
+ }
+
+ private void notifyListeners(ComponentState state) {
+ for (ComponentStateListener l : m_listeners) {
+ l.changed(state);
+ }
+ }
+
+ private void notifyListener(ComponentStateListener l, ComponentState state) {
+ l.changed(state);
+ }
+
+ public boolean isAvailable() {
+ return m_state == ComponentState.TRACKING_OPTIONAL;
+ }
+
+ @Override
+ public Component add(final ComponentStateListener l) {
+ m_listeners.add(l);
+ return this;
+ }
+
+ @Override
+ public Component remove(ComponentStateListener l) {
+ m_listeners.remove(l);
+ return this;
+ }
+
+ @Override
+ public List<DependencyContext> getDependencies() {
+ return m_dependencies;
+ }
+
+ @Override
+ public Component setImplementation(Object implementation) {
+ m_componentDefinition = implementation;
+ return this;
+ }
+
+ /**
+ * Configure a field in the service implementation. The service implementation
+ * is searched for fields that have the same type as the class that was specified
+ * and for each of these fields, the specified instance is filled in.
+ *
+ * @param clazz the class to search for
+ * @param instance the instance to fill in
+ * @param instanceName the name of the instance to fill in, or <code>null</code> if not used
+ */
+ private void configureImplementation(Class clazz, Object instance, String instanceName) {
+ Object[] instances = getInstances();
+ if (instances != null && instance != null && clazz != null) {
+ for (int i = 0; i < instances.length; i++) {
+ Object serviceInstance = instances[i];
+ Class serviceClazz = serviceInstance.getClass();
+ if (Proxy.isProxyClass(serviceClazz)) {
+ serviceInstance = Proxy.getInvocationHandler(serviceInstance);
+ serviceClazz = serviceInstance.getClass();
+ }
+ while (serviceClazz != null) {
+ Field[] fields = serviceClazz.getDeclaredFields();
+ for (int j = 0; j < fields.length; j++) {
+ Field field = fields[j];
+ Class type = field.getType();
+ if ((instanceName == null && type.equals(clazz))
+ || (instanceName != null && field.getName().equals(instanceName) && type.isAssignableFrom(clazz))) {
+ try {
+ field.setAccessible(true);
+ // synchronized makes sure the field is actually written to immediately
+ synchronized (SYNC) {
+ field.set(serviceInstance, instance);
+ }
+ }
+ catch (Exception e) {
+ m_logger.log(Logger.LOG_ERROR, "Could not set field " + field, e);
+ return;
+ }
+ }
+ }
+ serviceClazz = serviceClazz.getSuperclass();
+ }
+ }
+ }
+ }
+}