Committed the initial version of the dependency manager.
Added a "pom.xml" but since I'm fairly new at maven, this was copied from other examples.
Changed the package name to o.a.f.dependencymanager.
Modified a couple of classes so the code compiles with Java 1.4 (but we want to go for the minimum execution environment ultimately).
git-svn-id: https://svn.apache.org/repos/asf/incubator/felix/trunk@388822 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java b/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java
new file mode 100644
index 0000000..97a0866
--- /dev/null
+++ b/org.apache.felix.dependencymanager/src/main/java/org/apache/felix/dependencymanager/Dependency.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2006 The Apache Software Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.felix.dependencymanager;
+
+/**
+ * Generic dependency for a service. A dependency can be required or not.
+ * A dependency will be activated by the service it belongs to. The service
+ * will call the <code>start(Service service)</code> and
+ * <code>stop(Service service)</code> methods.
+ *
+ * After it has been started, a dependency must callback
+ * the associated service's <code>dependencyAvailable()</code> and
+ * <code>dependencyUnavailable()</code>
+ * methods. State changes of the dependency itself may only be made as long as
+ * the dependency is not 'active', meaning it is associated with a running service.
+ *
+ * @author Marcel Offermans
+ */
+public interface Dependency {
+ /**
+ * Returns <code>true</code> if this a required dependency. Required dependencies
+ * are dependencies that must be available before the service can be activated.
+ *
+ * @return <code>true</code> if the dependency is required
+ */
+ public boolean isRequired();
+
+ /**
+ * Returns <code>true</code> if the dependency is available.
+ *
+ * @return <code>true</code> if the dependency is available
+ */
+ public boolean isAvailable();
+
+ /**
+ * Starts tracking the dependency. This activates some implementation
+ * specific mechanism to do the actual tracking. If the tracking discovers
+ * that the dependency becomes available, it should call
+ * <code>dependencyAvailable()</code> on the service.
+ *
+ * @param service the service that is associated with this dependency
+ */
+ public void start(Service service);
+
+ /**
+ * Stops tracking the dependency. This deactivates the tracking. If the
+ * dependency was available, the tracker should call
+ * <code>dependencyUnavaible()</code> before stopping itself to ensure
+ * that dependencies that aren't "active" are unavailable.
+ */
+ public void stop(Service service);
+}