You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ma...@apache.org on 2014/02/07 16:52:39 UTC

svn commit: r1565694 - in /felix/sandbox/marrs/dependencymanager-prototype/dm: src/dm/Component.java src/dm/Dependency.java src/dm/Event.java src/dm/State.java test/test/ComponentTest.java test/test/ConcurrencyTest.java

Author: marrs
Date: Fri Feb  7 15:52:38 2014
New Revision: 1565694

URL: http://svn.apache.org/r1565694
Log:
Added some comments, renamed the test cases.

Modified:
    felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Component.java
    felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Dependency.java
    felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Event.java
    felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/State.java
    felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java
    felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ConcurrencyTest.java

Modified: felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Component.java
URL: http://svn.apache.org/viewvc/felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Component.java?rev=1565694&r1=1565693&r2=1565694&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Component.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Component.java Fri Feb  7 15:52:38 2014
@@ -4,15 +4,24 @@ import java.util.List;
 
 import dm.impl.SerialExecutor;
 
+/**
+ * A component. Has dependencies. 
+ */
 public interface Component {
-	void add(Dependency d);
-	void remove(Dependency d);
-	SerialExecutor getExecutor();
-	void start();
-	void stop();
-	void handleChange();
-	boolean isAvailable();
-	void add(ComponentStateListener l);
-	void remove(ComponentStateListener l);
-	List<Dependency> getDependencies();
+	public SerialExecutor getExecutor(); // shared between a component and its dependencies
+
+	public void add(Dependency d);
+	public void remove(Dependency d);
+
+	public void start();
+	public void stop();
+	
+	public void handleChange();
+	
+	public boolean isAvailable();
+	
+	public void add(ComponentStateListener l);
+	public void remove(ComponentStateListener l);
+
+	public List<Dependency> getDependencies(); // for testing only...
 }

Modified: felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Dependency.java
URL: http://svn.apache.org/viewvc/felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Dependency.java?rev=1565694&r1=1565693&r2=1565694&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Dependency.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Dependency.java Fri Feb  7 15:52:38 2014
@@ -1,13 +1,17 @@
 package dm;
 
+/**
+ * A dependency. Can be added to a single component. Can be available, or not.
+ */
 public interface Dependency {
+	public void add(Component component);
+	public void remove(Component component);
+
 	public void changed(final Event e);
 
-	void add(Component component);
-	void start();
-	void stop();
+	public void start();
+	public void stop();
 
 	public boolean isAvailable();
 
-	public void remove(Component component);
 }

Modified: felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Event.java
URL: http://svn.apache.org/viewvc/felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Event.java?rev=1565694&r1=1565693&r2=1565694&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Event.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/Event.java Fri Feb  7 15:52:38 2014
@@ -1,7 +1,12 @@
 package dm;
 
+/** 
+ * 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 {
 
+	/* for now, events are simple and only record availability of the dependency */
 	boolean isAvailable();
 
 }

Modified: felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/State.java
URL: http://svn.apache.org/viewvc/felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/State.java?rev=1565694&r1=1565693&r2=1565694&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/State.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/src/dm/State.java Fri Feb  7 15:52:38 2014
@@ -1,7 +1,11 @@
 package dm;
 
+/**
+ * Abstraction for the state of a component. Immutable object. Again for now, a component can
+ * have only two states: available and unavailable.
+ */
 public class State {
-	private boolean m_available;
+	private final boolean m_available;
 
 	public State(boolean available) {
 		m_available = available;

Modified: felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java?rev=1565694&r1=1565693&r2=1565694&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ComponentTest.java Fri Feb  7 15:52:38 2014
@@ -13,7 +13,7 @@ import dm.impl.EventImpl;
 
 public class ComponentTest {
 	@Test
-	public void createComponent() {
+	public void createStartAndStopComponent() {
 		Component c = new ComponentImpl();
 		Assert.assertEquals(false, c.isAvailable());
 		c.start();
@@ -22,7 +22,7 @@ public class ComponentTest {
 		Assert.assertEquals(false, c.isAvailable());
 	}
 	@Test
-	public void createComponentDep1() {
+	public void createComponentAddDependencyAndStartComponent() {
 		Component c = new ComponentImpl();
 		Dependency d = new DependencyImpl();
 		c.add(d);
@@ -32,7 +32,7 @@ public class ComponentTest {
 		c.remove(d);
 	}
 	@Test
-	public void createComponentDep2() {
+	public void createComponentStartItAndAddDependency() {
 		Component c = new ComponentImpl();
 		Dependency d = new DependencyImpl();
 		c.start();
@@ -44,7 +44,7 @@ public class ComponentTest {
 		c.stop();
 	}
 	@Test
-	public void createComponentDep3() {
+	public void createComponentStartItAddDependencyAndMakeDependencyAvailable() {
 		Component c = new ComponentImpl();
 		Dependency d = new DependencyImpl();
 		c.start();
@@ -60,7 +60,7 @@ public class ComponentTest {
 		Assert.assertEquals(false, c.isAvailable());
 	}
 	@Test
-	public void createComponentDep4() {
+	public void createComponentStartItAddDependencyAndListenerMakeDependencyAvailableAndUnavailableImmediately() {
 		Component c = new ComponentImpl();
 		final Dependency d = new DependencyImpl();
 		ComponentStateListener l = new ComponentStateListener() {
@@ -83,7 +83,7 @@ public class ComponentTest {
 		Assert.assertEquals(false, c.isAvailable());
 	}
 	@Test
-	public void createComponentDep5() {
+	public void createComponentAddTwoDependenciesMakeBothAvailableAndUnavailable() {
 		Component c = new ComponentImpl();
 		Dependency d1 = new DependencyImpl();
 		Dependency d2 = new DependencyImpl();

Modified: felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ConcurrencyTest.java
URL: http://svn.apache.org/viewvc/felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ConcurrencyTest.java?rev=1565694&r1=1565693&r2=1565694&view=diff
==============================================================================
--- felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ConcurrencyTest.java (original)
+++ felix/sandbox/marrs/dependencymanager-prototype/dm/test/test/ConcurrencyTest.java Fri Feb  7 15:52:38 2014
@@ -15,7 +15,7 @@ import dm.impl.EventImpl;
 
 public class ConcurrencyTest {
 	@Test
-	public void createComponentDep4() {
+	public void createComponentAddDependencyAndListenerAndAddAnotherDependencyInAParallelThread() {
 		final Semaphore s = new Semaphore(0);
 		final Component c = new ComponentImpl();
 		final Dependency d = new DependencyImpl();