[israfil-micro commit] r50 - in trunk/israfil-micro-container/src: main/java/net/israfil/micro/container test/java/net/i...

0 views
Skip to first unread message

codesite...@google.com

unread,
Jul 29, 2008, 11:03:23 PM7/29/08
to israfil-...@googlegroups.com
Author: christianedwardgruber
Date: Tue Jul 29 20:02:14 2008
New Revision: 50

Added:
trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/AbstractStartable.java
trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/DefaultContainer.java
trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/Startable.java
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/LifecycleTest.java
Removed:
trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/DefaultAutoWiringAdaptableContainer.java
Modified:
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/AutoWiringAdaptableContainerTest.java
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/ContainerTest.java
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/MultiThreadedAutoWiringContainerTest.java

Log:
batched change (sadly). Add a startable interface and an abstract
impl. No tests yet - next step. Add a stub for the Lifecycle tests.
Also rename the long default container to DefaultContainer

Added: trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/AbstractStartable.java
==============================================================================
--- (empty file)
+++
trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/AbstractStartable.java
Tue Jul 29 20:02:14 2008
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2008 Israfil Consulting Services Corporation
+ * Copyright (c) 2008 Christian Edward Gruber
+ * All Rights Reserved
+ *
+ * This software is licensed under the Berkeley Standard Distribution license,
+ * (BSD license), as defined below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Israfil Consulting Services nor the names of
its contributors
+ * may be used to endorse or promote products derived from this
software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * $Id: Copyright.java 618 2008-04-14 14:03:03Z christianedwardgruber $
+ */
+package net.israfil.micro.container;
+
+/**
+ * A convenience implementation of Startable
+ */
+public abstract class AbstractStartable implements Startable {
+
+ private boolean started = false;
+
+ /**
+ * @see Startable.start();
+ */
+ public void start() {
+ this.started = true;
+ }
+
+ /**
+ * @see Startable.isRunning();
+ */
+ public boolean isRunning() { return started; }
+
+}

Added: trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/DefaultContainer.java
==============================================================================
--- (empty file)
+++
trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/DefaultContainer.java
Tue Jul 29 20:02:14 2008
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2008 Israfil Consulting Services Corporation
+ * Copyright (c) 2008 Christian Edward Gruber
+ * All Rights Reserved
+ *
+ * This software is licensed under the Berkeley Standard Distribution license,
+ * (BSD license), as defined below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Israfil Consulting Services nor the names of
its contributors
+ * may be used to endorse or promote products derived from this
software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * $Id: Copyright.java 618 2008-04-14 14:03:03Z christianedwardgruber $
+ */
+package net.israfil.micro.container;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import net.israfil.micro.container.adapters.IndependentAutoWiringAdapter;
+import net.israfil.micro.container.error.ComponentAlreadyRegisteredError;
+import net.israfil.micro.container.error.CouldNotCreateComponentError;
+import net.israfil.micro.container.error.UnsatisfiedDependencyError;
+import net.israfil.micro.container.util.CyclicalReferenceDetectionUtil;
+import net.israfil.micro.container.util.NonDuplicateStack;
+
+
+/**
+ * A default implementation of AutoWiringAdaptableContainer, a Container
+ * that uses an AutoWiringAdapter to ensure that components can be
+ * created appropriately with their dependencies satisfied automatically.
+ *
+ * This adapter is intended for constructor injection, but relies on the
+ * adapter to perform such. No reflection is used by this class itself.
+ *
+ */
+public class DefaultContainer extends AbstractContainer implements
AutoWiringAdaptableContainer {
+
+ private Hashtable registry = new Hashtable();
+
+ private final boolean failEarly;
+
+ private boolean starting = false;
+
+ private final Object CREATION_MUTEX = new Object();
+
+ /**
+ * A default constructor that will throw errors regarding circular
+ * dependencies at registration time, throw missing dependency errors
+ * at wire-up (getComponent()) time, and has no parent.
+ *
+ * @param failEarly A boolean to indicate that this container should
detect missing or circular dependencies at start() time.
+ */
+ public DefaultContainer() {
+ super();
+ this.failEarly = false;
+ }
+
+ /**
+ * Construct this container such that it detects missing dependencies
+ * upon invocation of start(). Otherwise, it will fail at wire time,
+ * rather than at registration time. Circular references will give errors
+ * at registration time.
+ *
+ * @param failEarly A boolean to indicate that this container should
detect missing or circular dependencies at start() time.
+ */
+ public DefaultContainer(boolean failEarly) {
+ super();
+ this.failEarly = failEarly;
+ }
+
+ /**
+ * This method constructs a DefaultAutoWiringAdaptableContainer that
+ * has a parent container for backup resolution. The parent container
+ * can be of any type of Container.
+ *
+ * @param parent The parent container (optional)
+ */
+ public DefaultContainer(Container parent) {
+ super(parent);
+ this.failEarly = false;
+ }
+
+ /**
+ * Construct this container such that it detects missing dependencies
+ * upon invocation of start(). Otherwise, it will fail at wire time,
+ * rather than at registration time. Circular references will give errors
+ * at registration time. This method also provides for a parent container.
+ * The parent container can be of any type of Container.
+ *
+ * @param failEarly A boolean to indicate that this container should
detect missing or circular dependencies at start() time.
+ * @param parent The parent Container (optional)
+ */
+ public DefaultContainer(Container parent, boolean failEarly) {
+ super(parent);
+ this.failEarly = failEarly;
+ }
+
+ public synchronized void start() {
+ if (isRunning() || starting) return;
+ if (getParent() != null && !getParent().isRunning()) throw new
RuntimeException("Parent container is not started.");
+ this.starting = true;
+ if (failEarly) {
+ Enumeration i = registry.keys();
+ while (i.hasMoreElements()) {
+ // force get each component, forcing all wiring.
+ getComponent(i.nextElement());
+ }
+ }
+ super.start();
+ }
+
+ public void registerType(Object key, Class componentType) {
+ registerType(key,new IndependentAutoWiringAdapter(componentType));
+ }
+
+ public void registerType(Object key, AutoWiringAdapter
componentAdapter) {
+ if (this.isRunning()) throw new RuntimeException("Cannot register
when container is started.");
+ // FIXME: Figure out whether to support parent registry checking.
Probably can't do it.
+
+ if (registry.containsKey(key)) throw new
ComponentAlreadyRegisteredError("Component already registered for " + key);
+ detectCircularDependencies(key,componentAdapter);
+ registry.put(key, componentAdapter);
+ }
+
+ private void detectCircularDependencies(Object key,AutoWiringAdapter
componentAdapter) {
+ NonDuplicateStack nds = new NonDuplicateStack();
+ nds.push(key);
+
CyclicalReferenceDetectionUtil.detectCircularDependencies(this.registry,
nds, componentAdapter);
+ }
+
+ private Object wireObject(Object originalKey, AutoWiringAdapter
adapter) {
+ Object[] dependencies = adapter.dependencies();
+ Object[] parameters = new Object[dependencies.length];
+ for (int depn = 0; depn < dependencies.length; depn++ ) {
+ Object key = adapter.dependencies()[depn];
+ parameters[depn] = getComponent(key);
+ if (parameters[depn] == null) throw new
UnsatisfiedDependencyError("Could not materialize dependency for key "
+ key);
+ }
+ try {
+ return adapter.create(parameters);
+ } catch (IllegalAccessException e) {
+ throw new CouldNotCreateComponentError("Could not create
component " + originalKey + " of type " + adapter.getType(),e);
+ } catch (InstantiationException e) {
+ throw new CouldNotCreateComponentError("Could not create
component " + originalKey + " of type " + adapter.getType(),e);
+ }
+ }
+
+ public Object getComponent(Object key) {
+ Object component = super.getStoredComponent(key);
+ if (component == null && registry.containsKey(key)) {
+ synchronized (CREATION_MUTEX) {
+ if (component == null) { // in case following thread gets in just
after storage.
+ component = wireObject(key,(AutoWiringAdapter)registry.get(key));
+ if (component != null) store(key, component);
+ }
+ }
+ }
+ return component;
+ }
+
+}

Added: trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/Startable.java
==============================================================================
--- (empty file)
+++
trunk/israfil-micro-container/src/main/java/net/israfil/micro/container/Startable.java
Tue Jul 29 20:02:14 2008
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2008 Israfil Consulting Services Corporation
+ * Copyright (c) 2008 Christian Edward Gruber
+ * All Rights Reserved
+ *
+ * This software is licensed under the Berkeley Standard Distribution license,
+ * (BSD license), as defined below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Israfil Consulting Services nor the names of
its contributors
+ * may be used to endorse or promote products derived from this
software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * $Id: Copyright.java 618 2008-04-14 14:03:03Z christianedwardgruber $
+ */
+package net.israfil.micro.container;
+
+/**
+ * A simple interface that, if implemented, allows a component
+ * to participate in a startup phase of lifecycle.
+ */
+public interface Startable {
+
+ /**
+ * Begin the lifecycle of the component, after which it should be
+ * usable. This component should only act on its own startup
+ * lifecycle, and should assume that any components that are
+ * provided through dependency injection are already started
+ * before this command is executed.
+ */
+ public void start();
+
+ /**
+ * Returns true if the container has been started, and false if it has
+ * not been started.
+ */
+ public boolean isRunning();
+
+}

Modified: trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/AutoWiringAdaptableContainerTest.java
==============================================================================
---
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/AutoWiringAdaptableContainerTest.java (original)
+++
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/AutoWiringAdaptableContainerTest.java
Tue Jul 29 20:02:14 2008
@@ -34,8 +34,6 @@
package net.israfil.micro.container;


-import java.util.Hashtable;
-
import net.israfil.micro.container.adapters.AbstractAutoWiringAdapter;

import org.testng.Assert;
@@ -86,7 +84,7 @@
@testng.expected-exceptions
value
= "net.israfil.micro.container.error.UnsatisfiedDependencyError" */
public void testMissingDependencies() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer();
+ AutoWiringAdaptableContainer container = new DefaultContainer();
container.registerType(B.class,B.adapter);
container.start();
container.getComponent(B.class);
@@ -94,7 +92,7 @@

/** @testng.test */
public void testDelayedFailureWithMissingDependencies() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer();
+ AutoWiringAdaptableContainer container = new DefaultContainer();
container.registerType(B.class,B.adapter);
container.start();
}
@@ -103,14 +101,14 @@
@testng.expected-exceptions
value
= "net.israfil.micro.container.error.UnsatisfiedDependencyError" */
public void testMissingDependenciesFailingEarly() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer(true);
+ AutoWiringAdaptableContainer container = new DefaultContainer(true);
container.registerType(B.class,B.adapter);
container.start();
}

/** @testng.test */
public void testMissingDependenciesWiringEarly() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer(true);
+ AutoWiringAdaptableContainer container = new DefaultContainer(true);
container.registerType(A.class,A1.class);
container.registerType(B.class,B.adapter);
container.start();
@@ -121,7 +119,7 @@
@testng.expected-exceptions
value = "java.lang.RuntimeException" */
public void testRegistryFailureAfterStart() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer();
+ AutoWiringAdaptableContainer container = new DefaultContainer();
container.registerType(A.class,A1.class);
container.registerType(B.class,B.adapter);
container.start();
@@ -132,7 +130,7 @@
@testng.expected-exceptions
value
= "net.israfil.micro.container.error.CouldNotCreateComponentError" */
public void testIllegalAccessDuringConstruction() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer(true);
+ AutoWiringAdaptableContainer container = new DefaultContainer(true);
container.registerType(E.class,E.class);
container.start();
}
@@ -141,15 +139,15 @@
@testng.expected-exceptions
value
= "net.israfil.micro.container.error.CouldNotCreateComponentError" */
public void testInstantiationErrorDuringConstruction() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer(true);
+ AutoWiringAdaptableContainer container = new DefaultContainer(true);
container.registerType(A.class,A.class);
container.start();
}

/** @testng.test */
public void testAutowiringWithDependencyInParentContainer() {
- AutoWiringAdaptableContainer parent = new DefaultAutoWiringAdaptableContainer(true);
- AutoWiringAdaptableContainer child = new DefaultAutoWiringAdaptableContainer(parent,true);
+ AutoWiringAdaptableContainer parent = new DefaultContainer(true);
+ AutoWiringAdaptableContainer child = new DefaultContainer(parent,true);
parent.registerType(A.class,A1.class);
child.registerType(B.class,B.adapter);
parent.start();
@@ -203,7 +201,7 @@
protected E() {}
}

- public static class TestableAutoWiringAdaptableContainer extends
DefaultAutoWiringAdaptableContainer {
+ public static class TestableAutoWiringAdaptableContainer extends
DefaultContainer {
public boolean isStored(Object key) {
return super.isStored(key);
}

Modified: trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/ContainerTest.java
==============================================================================
---
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/ContainerTest.java (original)
+++
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/ContainerTest.java
Tue Jul 29 20:02:14 2008
@@ -33,8 +33,6 @@
*/
package net.israfil.micro.container;

-import java.util.Hashtable;
-
import org.testng.Assert;

public class ContainerTest {

Added: trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/LifecycleTest.java
==============================================================================
--- (empty file)
+++
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/LifecycleTest.java
Tue Jul 29 20:02:14 2008
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2008 Israfil Consulting Services Corporation
+ * Copyright (c) 2008 Christian Edward Gruber
+ * All Rights Reserved
+ *
+ * This software is licensed under the Berkeley Standard Distribution license,
+ * (BSD license), as defined below:
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
notice, this
+ * list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above
copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ * 3. Neither the name of Israfil Consulting Services nor the names of
its contributors
+ * may be used to endorse or promote products derived from this
software without
+ * specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY
+ * OF SUCH DAMAGE.
+ *
+ * $Id: Copyright.java 618 2008-04-14 14:03:03Z christianedwardgruber $
+ */
+package net.israfil.micro.container;
+
+import net.israfil.micro.container.adapters.AbstractAutoWiringAdapter;
+
+import org.testng.Assert;
+
+
+public class LifecycleTest {
+
+ DefaultContainer container = null;
+
+ /** @testng.before-method alwaysRun = "true" */
+ public void setUp() {
+
+ }
+
+ /** @testng.after-method alwaysRun = "true" */
+ public void tearDown() {
+ container = null;
+ }
+
+
+ /** @testng.test */
+ public void testMissingDependenciesWiringEarly() {
+ AutoWiringAdaptableContainer container = new DefaultContainer(true);
+ container.registerType(A.class,A1.class);
+ container.registerType(B.class,B.adapter);
+ container.start();
+ Assert.assertNotNull(container.getComponent(B.class));
+ }
+
+ public static interface A {
+ }
+ public static class A1 extends AbstractStartable implements A {
+ public void start() { super.start(); }
+ }
+ public static class B {
+ private final A a;
+ public B(A a) {
+ if (a==null) throw new IllegalArgumentException("B cannot support
null constructor arguments.");
+ this.a = a;
+ }
+ public static final AutoWiringAdapter adapter = new AbstractAutoWiringAdapter(
+ B.class,
+ new Object[] {A.class}
+ ) {
+ public Object create(Object[] param) throws IllegalAccessException,
InstantiationException {
+ return new B((A)param[0]);
+ }
+ };
+ }
+ public static class C extends AbstractStartable implements Startable{
+ private final A a;
+ public C(A a) {
+ if (a==null) throw new IllegalArgumentException("C cannot support
null constructor arguments.");
+ this.a = a;
+ }
+ public void start() { super.start(); }
+ }
+
+}

Modified: trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/MultiThreadedAutoWiringContainerTest.java
==============================================================================
---
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/MultiThreadedAutoWiringContainerTest.java (original)
+++
trunk/israfil-micro-container/src/test/java/net/israfil/micro/container/MultiThreadedAutoWiringContainerTest.java
Tue Jul 29 20:02:14 2008
@@ -33,8 +33,6 @@
*/
package net.israfil.micro.container;

-import java.util.Hashtable;
-
import net.israfil.micro.container.adapters.AbstractAutoWiringAdapter;

import org.testng.Assert;
@@ -57,7 +55,7 @@

/** @testng.test */
public void testMissingDependenciesWiringEarly() {
- AutoWiringAdaptableContainer container = new DefaultAutoWiringAdaptableContainer(true);
+ AutoWiringAdaptableContainer container = new DefaultContainer(true);
container.registerType(A.class,A1.class);
container.registerType(B.class,B.adapter);
container.start();
@@ -110,7 +108,7 @@
protected E() {}
}

- public static class TestableAutoWiringAdaptableContainer extends
DefaultAutoWiringAdaptableContainer {
+ public static class TestableAutoWiringAdaptableContainer extends
DefaultContainer {
public boolean isStored(Object key) {
return super.isStored(key);
}

Reply all
Reply to author
Forward
0 new messages