You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@composer.apache.org by ha...@apache.org on 2008/01/21 06:41:50 UTC
svn commit: r613775 [2/15] - in /incubator/composer: ./ core/ core/src/
core/src/java/ core/src/java/org/ core/src/java/org/apache/
core/src/java/org/apache/composer/ core/src/java/org/apache/composer/core/
core/src/java/org/apache/composer/core/adapte...
Added: incubator/composer/core/apache-composer-core.iml
URL: http://svn.apache.org/viewvc/incubator/composer/core/apache-composer-core.iml?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/apache-composer-core.iml (added)
+++ incubator/composer/core/apache-composer-core.iml Sun Jan 20 22:41:26 2008
@@ -0,0 +1,293 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module relativePaths="true" type="JAVA_MODULE" version="4">
+ <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="false">
+ <output url="file://$MODULE_DIR$/target/classes" />
+ <exclude-output />
+ <output-test url="file://$MODULE_DIR$/target/test-classes" />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="module-library" exported="">
+ <library name="com.thoughtworks.paranamer:paranamer:1.1">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/com/thoughtworks/paranamer/paranamer/1.1/paranamer-1.1.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/com/thoughtworks/paranamer/paranamer/1.1/paranamer-1.1-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/com/thoughtworks/paranamer/paranamer/1.1/paranamer-1.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library name="com.thoughtworks.xstream:xstream:1.2.2">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library name="junit:junit-dep:4.4">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/junit/junit-dep/4.4/junit-dep-4.4.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/junit/junit-dep/4.4/junit-dep-4.4-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/junit/junit-dep/4.4/junit-dep-4.4-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library name="org.hamcrest:hamcrest-core:1.1">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library name="org.hamcrest:hamcrest-library:1.1">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/org/hamcrest/hamcrest-library/1.1/hamcrest-library-1.1-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library name="org.jmock:jmock-junit4:2.4.0">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/org/jmock/jmock-junit4/2.4.0/jmock-junit4-2.4.0.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/org/jmock/jmock-junit4/2.4.0/jmock-junit4-2.4.0-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/org/jmock/jmock-junit4/2.4.0/jmock-junit4-2.4.0-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library name="org.jmock:jmock:2.4.0">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/org/jmock/jmock/2.4.0/jmock-2.4.0.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/org/jmock/jmock/2.4.0/jmock-2.4.0-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/org/jmock/jmock/2.4.0/jmock-2.4.0-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntry type="module-library" exported="">
+ <library name="xpp3:xpp3_min:1.1.3.4.O">
+ <CLASSES>
+ <root url="jar://$M2_REPOSITORY$/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar!/" />
+ </CLASSES>
+ <JAVADOC>
+ <root url="jar://$M2_REPOSITORY$/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O-javadoc.jar!/" />
+ </JAVADOC>
+ <SOURCES>
+ <root url="jar://$M2_REPOSITORY$/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O-sources.jar!/" />
+ </SOURCES>
+ </library>
+ </orderEntry>
+ <orderEntryProperties />
+ </component>
+ <component name="copyright">
+ <Base>
+ <setting name="state" value="2" />
+ </Base>
+ <LanguageOptions name="$TEMPLATE$">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Apache Composer Organization. All rights reserved. ------------------------------------------------------------------------- The software in this package is published under the terms of the BSD style license a copy of which has been included with this distribution in the LICENSE.txt file. " />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="4" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="CSS">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="HTML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JAVA">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JSP">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="JavaScript">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="Properties">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ <LanguageOptions name="XML">
+ <option name="templateOptions">
+ <value>
+ <option name="block" value="true" />
+ <option name="separateBefore" value="false" />
+ <option name="separateAfter" value="false" />
+ <option name="prefixLines" value="true" />
+ <option name="lenBefore" value="80" />
+ <option name="lenAfter" value="80" />
+ <option name="box" value="false" />
+ <option name="filler" value=" " />
+ </value>
+ </option>
+ <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." />
+ <option name="keyword" value="Copyright" />
+ <option name="fileTypeOverride" value="2" />
+ <option name="relativeBefore" value="true" />
+ <option name="addBlankAfter" value="true" />
+ <option name="fileLocation" value="1" />
+ <option name="useAlternate" value="false" />
+ </LanguageOptions>
+ </component>
+</module>
+
Added: incubator/composer/core/pom.xml
URL: http://svn.apache.org/viewvc/incubator/composer/core/pom.xml?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/pom.xml (added)
+++ incubator/composer/core/pom.xml Sun Jan 20 22:41:26 2008
@@ -0,0 +1,63 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.composer</groupId>
+ <artifactId>apache-composer-parent</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>apache-composer-core</artifactId>
+ <name>Apache Composer Core</name>
+ <packaging>jar</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>com.thoughtworks.paranamer</groupId>
+ <artifactId>paranamer</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>com.thoughtworks.paranamer</groupId>
+ <artifactId>paranamer-maven-plugin</artifactId>
+ <configuration>
+ <sourceDirectory>src/test</sourceDirectory>
+ <outputDirectory>target/test-classes</outputDirectory>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>test</phase>
+ <id>generate</id>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-shade-plugin</artifactId>
+ <version>1.0-alpha-15</version>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>shade</goal>
+ </goals>
+ <configuration>
+ <shadedArtifactId>picocontainer</shadedArtifactId>
+ <artifactSet />
+ <relocations>
+ <relocation>
+ <pattern>com.thoughtworks.paranamer</pattern>
+ <shadedPattern>org.apache.composer.core.paranamer</shadedPattern>
+ </relocation>
+ </relocations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
Added: incubator/composer/core/src/java/org/apache/composer/core/Behavior.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/Behavior.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/Behavior.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/Behavior.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by Paul Hammant *
+ *****************************************************************************/
+
+package org.apache.composer.core;
+
+/**
+ * Behaviors modify the components created by a Injector with additional behaviors
+ *
+ * @author Paul Hammant
+ * @author Jörg Schaible
+ * @author Mauro Talevi
+ * @see LifecycleStrategy
+ */
+public interface Behavior<T> extends ComponentAdapter<T> {
+
+ /**
+ * Invoke the "start" method on the component.
+ * @param container the container to "start" the component
+ */
+ void start(Container container);
+
+ /**
+ * Invoke the "stop" method on the component.
+ * @param container the container to "stop" the component
+ */
+ void stop(Container container);
+
+ /**
+ * Invoke the "dispose" method on the component.
+ * @param container the container to "dispose" the component
+ */
+ void dispose(Container container);
+
+ /**
+ * Test if a component honors a lifecycle.
+ * @return <code>true</code> if the component has a lifecycle
+ */
+ boolean componentHasLifecycle();
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/BehaviorFactory.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/BehaviorFactory.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/BehaviorFactory.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/BehaviorFactory.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,27 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import java.util.Properties;
+
+/**
+ * Extends ComponentFactory to provide factory methods for Behaviors
+ *
+ * @author Paul Hammant
+ * @author Mauro Talevi
+ */
+public interface BehaviorFactory extends ComponentFactory {
+
+ ComponentFactory wrap(ComponentFactory delegate);
+
+ <T> ComponentAdapter<T> addComponentAdapter(ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy,
+ Properties componentProperties, ComponentAdapter<T> adapter);
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/BindKey.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/BindKey.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/BindKey.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/BindKey.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Committers. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by Joerg Schaibe *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+
+/** @author Paul Hammant */
+public class BindKey<T> implements Serializable {
+ /**
+ * Serialization UUID.
+ */
+ private static final long serialVersionUID = 563408828534240087L;
+
+ private final Class<T> type;
+ private final Class<? extends Annotation> annotation;
+
+ public BindKey(Class<T> type, Class<? extends Annotation> annotation) {
+ this.type = type;
+ this.annotation = annotation;
+ }
+
+ public Class<T> getType() {
+ return type;
+ }
+
+ public Class<? extends Annotation> getAnnotation() {
+ return annotation;
+ }
+
+ public String toString() {
+ return type.getName() + ":" + annotation.getName();
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ BindKey<?> bindKey = (BindKey<?>)o;
+
+ if (!annotation.equals(bindKey.annotation)) return false;
+ if (!type.equals(bindKey.type)) return false;
+
+ return true;
+ }
+
+ public int hashCode() {
+ int result;
+ result = type.hashCode();
+ result = 31 * result + annotation.hashCode();
+ return result;
+ }
+
+ public static <T> BindKey<T> bindKey(Class<T> type, Class<? extends Annotation> annotation) {
+ return new BindKey<T>(type, annotation);
+ }
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/Characteristics.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/Characteristics.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/Characteristics.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/Characteristics.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,87 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import java.util.Properties;
+
+/**
+ * Collection of immutable properties, holding behaviour characteristics.
+ *
+ * @author Paul Hammant
+ */
+public final class Characteristics {
+
+ private static final String _INJECTION = "injection";
+ private static final String _NONE = "none";
+ private static final String _CONSTRUCTOR = "constructor";
+ private static final String _METHOD = "method";
+ private static final String _SETTER = "setter";
+ private static final String _CACHE = "cache";
+ private static final String _JMX = "jmx";
+ private static final String _SYNCHRONIZING = "synchronizing";
+ private static final String _LOCKING = "locking";
+ private static final String _HIDE_IMPL = "hide-impl";
+ private static final String _PROPERTY_APPLYING = "property-applying";
+ private static final String _AUTOMATIC = "automatic";
+ private static final String _USE_NAMES = "use-parameter-names";
+
+ private static final String FALSE = "false";
+ private static final String TRUE = "true";
+
+ public static final Properties CDI = immutable(_INJECTION, _CONSTRUCTOR);
+
+ public static final Properties SDI = immutable(_INJECTION, _SETTER);
+
+ public static final Properties METHOD_INJECTION = immutable(_INJECTION, _METHOD);
+
+ public static final Properties NO_CACHE = immutable(_CACHE, FALSE);
+
+ public static final Properties CACHE = immutable(_CACHE, TRUE);
+
+ public static final Properties NO_JMX = immutable(_JMX, FALSE);
+
+ public static final Properties SYNCHRONIZE = immutable(_SYNCHRONIZING, TRUE);
+
+ public static final Properties LOCK = immutable(_LOCKING, TRUE);
+
+ public static final Properties SINGLE = CACHE;
+
+ public static final Properties HIDE_IMPL = immutable(_HIDE_IMPL, TRUE);
+
+ public static final Properties NO_HIDE_IMPL = immutable(_HIDE_IMPL, FALSE);
+
+ public static final Properties NONE = immutable(_NONE, "");
+
+ public static final Properties PROPERTY_APPLYING = immutable(_PROPERTY_APPLYING, TRUE);
+
+ public static final Properties AUTOMATIC = immutable(_AUTOMATIC, TRUE);
+
+ public static final Properties USE_NAMES = immutable(_USE_NAMES, TRUE);
+
+ private static Properties immutable(String name, String value) {
+ return new ImmutableProperties(name, value);
+ }
+
+ public static class ImmutableProperties extends Properties {
+
+ public ImmutableProperties(String name, String value) {
+ super.setProperty(name, value);
+ }
+
+ public Object remove(Object o) {
+ throw new UnsupportedOperationException();
+ }
+
+ public synchronized Object setProperty(String string, String string1) {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ClassNotFoundException.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ClassNotFoundException.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ClassNotFoundException.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ClassNotFoundException.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,17 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+public class ClassNotFoundException extends ComposerException {
+
+ public ClassNotFoundException(final String className, final java.lang.ClassNotFoundException cnfe) {
+ super("Class '" + className + "' not found", cnfe);
+ }
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ComponentAdapter.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ComponentAdapter.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ComponentAdapter.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ComponentAdapter.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,76 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+/**
+ * A component adapter is responsible for providing a specific component
+ * instance of type <T>. An instance of an implementation of this interface is
+ * used inside a {@link Container} for every registered component or
+ * instance. Each <code>ComponentAdapter</code> instance has to have a key
+ * which is unique within that container. The key itself is either a class type
+ * (normally an interface) or an identifier.
+ *
+ * @author Jon Tirsén
+ * @author Paul Hammant
+ * @author Aslak Hellesøy
+ */
+public interface ComponentAdapter<T> {
+
+ /**
+ * Retrieve the key associated with the component.
+ *
+ * @return the component's key. Should either be a class type (normally an interface) or an identifier that is
+ * unique (within the scope of the current PicoContainer).
+ */
+ Object getComponentKey();
+
+ /**
+ * Retrieve the class of the component.
+ *
+ * @return the component's implementation class. Should normally be a concrete class (ie, a class that can be
+ * instantiated).
+ */
+ Class<T> getComponentImplementation();
+
+ /**
+ * Retrieve the component instance. This method will usually create a new instance each time it is called, but that
+ * is not required. For example, {@link org.apache.composer.core.behaviors.Cached} will always return the
+ * same instance.
+ *
+ * @param container the {@link Container}, that is used to resolve any possible dependencies of the instance.
+ * @return the component instance.
+ * @throws CompositionException if the component has dependencies which could not be resolved, or
+ * instantiation of the component lead to an ambigous situation within the
+ * container.
+ */
+ T getComponentInstance(Container container) throws CompositionException;
+
+ /**
+ * Verify that all dependencies for this adapter can be satisifed. Normally, the adapter should verify this by
+ * checking that the associated PicoContainer contains all the needed dependnecies.
+ *
+ * @param container the {@link Container}, that is used to resolve any possible dependencies of the instance.
+ * @throws CompositionException if one or more dependencies cannot be resolved.
+ */
+ void verify(Container container) throws CompositionException;
+
+ /**
+ * Accepts a visitor for this ComponentAdapter. The method is normally called by visiting a {@link Container}, that
+ * cascades the visitor also down to all its ComponentAdapter instances.
+ *
+ * @param visitor the visitor.
+ */
+ void accept(ContainerVisitor visitor);
+
+ ComponentAdapter<T> getDelegate();
+
+ <U extends ComponentAdapter> U findAdapterOfType(Class<U> componentAdapterType);
+
+ String getDescriptor();
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ComponentFactory.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ComponentFactory.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ComponentFactory.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ComponentFactory.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,69 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import org.apache.composer.core.ComponentAdapter;
+import org.apache.composer.core.Parameter;
+import org.apache.composer.core.CompositionException;
+import org.apache.composer.core.ComponentMonitor;
+import org.apache.composer.core.LifecycleStrategy;
+
+import java.util.Properties;
+
+/**
+ * <p/>
+ * A component factory is responsible for creating
+ * {@link ComponentAdapter} component adapters. The main use of the component factory is
+ * inside {@link DefaultContainer#DefaultContainer(ComponentFactory)}, where it can
+ * be used to customize the default component adapter that is used when none is specified
+ * explicitly.
+ * </p>
+ *
+ * @author Paul Hammant
+ * @author Mauro Talevi
+ * @author Jon Tirsén
+ */
+public interface ComponentFactory {
+
+ /**
+ * Create a new component adapter based on the specified arguments.
+ *
+ * @param componentMonitor the component monitor
+ * @param lifecycleStrategy te lifecycle strategy
+ * @param componentProperties the component properties
+ * @param componentKey the key to be associated with this adapter. This
+ * value should be returned from a call to
+ * {@link ComponentAdapter#getComponentKey()} on the created
+ * adapter.
+ * @param componentImplementation the implementation class to be associated
+ * with this adapter. This value should be returned from a call
+ * to {@link ComponentAdapter#getComponentImplementation()} on
+ * the created adapter. Should not be null.
+ * @param parameters additional parameters to use by the component adapter
+ * in constructing component instances. These may be used, for
+ * example, to make decisions about the arguments passed into the
+ * component constructor. These should be considered hints; they
+ * may be ignored by some implementations. May be null, and may
+ * be of zero length.
+ * @return a new component adapter based on the specified arguments. Should
+ * not return null.
+ * @throws CompositionException if the creation of the component adapter
+ * results in a {@link CompositionException}.
+ * @return The component adapter
+ */
+ <T> ComponentAdapter<T> createComponentAdapter(ComponentMonitor componentMonitor,
+ LifecycleStrategy lifecycleStrategy,
+ Properties componentProperties,
+ Object componentKey,
+ Class<T> componentImplementation,
+ Parameter... parameters) throws CompositionException;
+
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitor.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitor.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitor.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitor.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,126 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by Paul Hammant & Obie Fernandez & Aslak *
+ *****************************************************************************/
+
+package org.apache.composer.core;
+
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Member;
+import java.lang.reflect.Method;
+
+/**
+ * A component monitor is responsible for monitoring the component instantiation
+ * and method invocation.
+ *
+ * @author Paul Hammant
+ * @author Obie Fernandez
+ * @author Aslak Hellesøy
+ * @author Mauro Talevi
+ */
+public interface ComponentMonitor {
+
+ /**
+ * Event thrown as the component is being instantiated using the given constructor
+ *
+ * @param container
+ * @param componentAdapter
+ * @param constructor the Constructor used to instantiate the addComponent @return the constructor to use in instantiation (nearly always the same one as passed in)
+ */
+ <T> Constructor<T> instantiating(Container container, ComponentAdapter<T> componentAdapter,
+ Constructor<T> constructor
+ );
+
+ /**
+ * Event thrown after the component has been instantiated using the given constructor.
+ * This should be called for both Constructor and Setter DI.
+ *
+ * @param container
+ * @param componentAdapter
+ * @param constructor the Constructor used to instantiate the addComponent
+ * @param instantiated the component that was instantiated by PicoContainer
+ * @param injected the components during instantiation.
+ * @param duration the duration in milliseconds of the instantiation
+ */
+
+ <T> void instantiated(Container container, ComponentAdapter<T> componentAdapter,
+ Constructor<T> constructor,
+ Object instantiated,
+ Object[] injected,
+ long duration);
+
+ /**
+ * Event thrown if the component instantiation failed using the given constructor
+ *
+ * @param container
+ * @param componentAdapter
+ * @param constructor the Constructor used to instantiate the addComponent
+ * @param cause the Exception detailing the cause of the failure
+ */
+ <T> void instantiationFailed(Container container,
+ ComponentAdapter<T> componentAdapter,
+ Constructor<T> constructor,
+ Exception cause);
+
+ /**
+ * Event thrown as the component method is being invoked on the given instance
+ *
+ * @param container
+ * @param componentAdapter
+ * @param member
+ * @param instance the component instance
+ */
+ void invoking(Container container, ComponentAdapter<?> componentAdapter, Member member, Object instance);
+
+ /**
+ * Event thrown after the component method has been invoked on the given instance
+ *
+ * @param container
+ * @param componentAdapter
+ * @param method the Method invoked on the component instance
+ * @param instance the component instance
+ * @param duration the duration in millis of the invocation
+ */
+ void invoked(Container container,
+ ComponentAdapter<?> componentAdapter,
+ Method method,
+ Object instance,
+ long duration);
+
+ /**
+ * Event thrown if the component method invocation failed on the given instance
+ *
+ * @param member
+ * @param instance the component instance
+ * @param cause the Exception detailing the cause of the failure
+ */
+ void invocationFailed(Member member, Object instance, Exception cause);
+
+ /**
+ * Event thrown if a lifecycle method invocation - start, stop or dispose -
+ * failed on the given instance
+ *
+ * @param container
+ * @param componentAdapter
+ * @param method the lifecycle Method invoked on the component instance
+ * @param instance the component instance
+ * @param cause the RuntimeException detailing the cause of the failure
+ */
+ void lifecycleInvocationFailed(MutableContainer container,
+ ComponentAdapter<?> componentAdapter, Method method,
+ Object instance,
+ RuntimeException cause);
+
+
+ /**
+ *
+ * @param container
+ * @param componentKey
+ */
+ Object noComponentFound(MutableContainer container, Object componentKey);
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitorStrategy.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitorStrategy.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitorStrategy.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ComponentMonitorStrategy.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,40 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ *****************************************************************************/
+
+package org.apache.composer.core;
+
+
+/**
+ * <p>
+ * Interface responsible for changing monitoring strategy.
+ * It may be implemented by {@link Container containers} and
+ * single {@link org.apache.composer.core.ComponentAdapter component adapters}.
+ * The choice of supporting the monitor strategy is left to the
+ * implementers of the container and adapters.
+ * </p>
+ *
+ * @author Paul Hammant
+ * @author Joerg Schaible
+ * @author Mauro Talevi
+ */
+public interface ComponentMonitorStrategy {
+
+ /**
+ * Changes the component monitor used
+ * @param monitor the new ComponentMonitor to use
+ */
+ void changeMonitor(ComponentMonitor monitor);
+
+ /**
+ * Returns the monitor currently used
+ * @return The ComponentMonitor currently used
+ */
+ ComponentMonitor currentMonitor();
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ComposerException.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ComposerException.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ComposerException.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ComposerException.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,61 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import java.io.PrintStream;
+import java.io.PrintWriter;
+
+/**
+ * Superclass for all Exceptions in PicoContainer. You can use this if you want to catch all exceptions thrown by
+ * PicoContainer. Be aware that some parts of the PicoContainer API will also throw {@link NullPointerException} when
+ * <code>null</code> values are provided for method arguments, and this is not allowed.
+ *
+ * @author Paul Hammant
+ * @author Aslak Hellesøy
+ */
+public abstract class ComposerException extends RuntimeException {
+
+ /**
+ * Construct a new exception with no cause and no detail message. Note modern JVMs may still track the exception
+ * that caused this one.
+ */
+ protected ComposerException() {
+ }
+
+ /**
+ * Construct a new exception with no cause and the specified detail message. Note modern JVMs may still track the
+ * exception that caused this one.
+ *
+ * @param message the message detailing the exception.
+ */
+ protected ComposerException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Construct a new exception with the specified cause and no detail message.
+ *
+ * @param cause the exception that caused this one.
+ */
+ protected ComposerException(final Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Construct a new exception with the specified cause and the specified detail message.
+ *
+ * @param message the message detailing the exception.
+ * @param cause the exception that caused this one.
+ */
+ protected ComposerException(final String message, final Throwable cause) {
+ super(message,cause);
+ }
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ComposerVerificationException.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ComposerVerificationException.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ComposerVerificationException.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ComposerVerificationException.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,63 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * Subclass of {@link ComposerException} that is thrown when a {@link Container} hierarchy
+ * cannot be verified. A failing verification is caused by ambuigities or missing dependencies
+ * between the registered components and their parameters. This exception is designed as a
+ * collector for all Exceptions occurring at the verification of the complete container
+ * hierarchy. The verification is normally done with the
+ * {@link org.apache.composer.core.visitors.VerifyingVisitor}, that will throw this exception.
+ */
+public class ComposerVerificationException extends ComposerException {
+ /**
+ * Serialization UUID.
+ */
+ private static final long serialVersionUID = -9008292036585394986L;
+
+ /**
+ * The exceptions that caused this one.
+ */
+ private final List<Throwable> nestedExceptions = new ArrayList<Throwable>();
+
+ /**
+ * Construct a new exception with a list of exceptions that caused this one.
+ *
+ * @param nestedExceptions the exceptions that caused this one.
+ */
+ public ComposerVerificationException(final List<? extends Throwable> nestedExceptions) {
+ this.nestedExceptions.addAll(nestedExceptions);
+ }
+
+ /**
+ * Retrieve the list of exceptions that caused this one.
+ *
+ * @return the list of exceptions that caused this one.
+ */
+ public List<Throwable> getNestedExceptions() {
+ return nestedExceptions;
+ }
+
+ /**
+ * Return a string listing of all the messages associated with the exceptions that caused
+ * this one.
+ *
+ * @return a string listing of all the messages associated with the exceptions that caused
+ * this one.
+ */
+ public String getMessage() {
+ return nestedExceptions.toString();
+ }
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/CompositionException.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/CompositionException.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/CompositionException.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/CompositionException.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Idea by Rachel Davies, Original code by Aslak Hellesoy and Paul Hammant *
+ *****************************************************************************/
+
+package org.apache.composer.core;
+
+/**
+ * Subclass of {@link ComposerException} that is thrown when there is:
+ * - a problem initializing the container
+ * - a cyclic dependency between components occurs.
+ * - problem adding a component
+ * - a request for a component that is ambiguous.
+ *
+ */
+public class CompositionException extends ComposerException {
+
+ /**
+ * Construct a new exception with no cause and the specified detail message. Note modern JVMs may still track the
+ * exception that caused this one.
+ *
+ * @param message the message detailing the exception.
+ */
+ public CompositionException(final String message) {
+ super(message);
+ }
+
+ /**
+ * Construct a new exception with the specified cause and no detail message.
+ *
+ * @param cause the exception that caused this one.
+ */
+ public CompositionException(final Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Construct a new exception with the specified cause and the specified detail message.
+ *
+ * @param message the message detailing the exception.
+ * @param cause the exception that caused this one.
+ */
+ public CompositionException(final String message, final Throwable cause) {
+ super(message, cause);
+ }
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/Container.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/Container.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/Container.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/Container.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,130 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import java.util.Collection;
+import java.util.List;
+import java.lang.annotation.Annotation;
+
+
+/**
+ * This is the core interface for PicoContainer. It is used to retrieve component instances from the container; it only
+ * has accessor methods (in addition to the {@link #accept(ContainerVisitor)} method). In order to register components in a
+ * PicoContainer, use a {@link MutableContainer}, such as {@link DefaultContainer}.
+ *
+ * @author Paul Hammant
+ * @author Aslak Hellesøy
+ * @author Jon Tirsén
+ * @see <a href="package-summary.html#package_description">See package description for basic overview how to use
+ * PicoContainer.</a>
+ */
+public interface Container {
+
+ /**
+ * Retrieve a component instance registered with a specific key or type. If a component cannot be found in this container,
+ * the parent container (if one exists) will be searched.
+ *
+ * @param componentKeyOrType the key or Type that the component was registered with.
+ * @return an instantiated component, or <code>null</code> if no component has been registered for the specified
+ * key.
+ */
+ Object getComponent(Object componentKeyOrType);
+
+ /**
+ * Retrieve a component keyed by the component type.
+ * @param <T> the type of the component.
+ * @param componentType the type of the component
+ * @return the typed resulting object instance or null if the object does not exist.
+ */
+ <T> T getComponent(Class<T> componentType);
+
+ <T> T getComponent(Class<T> componentType, Class<? extends Annotation> binding);
+
+ /**
+ * Retrieve all the registered component instances in the container, (not including those in the parent container).
+ * The components are returned in their order of instantiation, which depends on the dependency order between them.
+ *
+ * @return all the components.
+ * @throws ComposerException if the instantiation of the component fails
+ */
+ List<Object> getComponents();
+
+ /**
+ * Retrieve the parent container of this container.
+ *
+ * @return a {@link Container} instance, or <code>null</code> if this container does not have a parent.
+ */
+ Container getParent();
+
+ /**
+ * Find a component adapter associated with the specified key. If a component adapter cannot be found in this
+ * container, the parent container (if one exists) will be searched.
+ *
+ * @param componentKey the key that the component was registered with.
+ * @return the component adapter associated with this key, or <code>null</code> if no component has been
+ * registered for the specified key.
+ */
+ ComponentAdapter<?> getComponentAdapter(Object componentKey);
+
+ /**
+ * Find a component adapter associated with the specified type. If a component adapter cannot be found in this
+ * container, the parent container (if one exists) will be searched.
+ *
+ * @param componentType the type of the component.
+ * @return the component adapter associated with this class, or <code>null</code> if no component has been
+ * registered for the specified key.
+ * @param componentNameBinding
+ */
+
+ <T> ComponentAdapter<T> getComponentAdapter(Class<T> componentType, NameBinding componentNameBinding);
+
+ <T> ComponentAdapter<T> getComponentAdapter(Class<T> componentType, Class<? extends Annotation> binding);
+
+ /**
+ * Retrieve all the component adapters inside this container. The component adapters from the parent container are
+ * not returned.
+ *
+ * @return a collection containing all the {@link ComponentAdapter}s inside this container. The collection will not
+ * be modifiable.
+ * @see #getComponentAdapters(Class) a variant of this method which returns the component adapters inside this
+ * container that are associated with the specified type.
+ */
+ Collection<ComponentAdapter<?>> getComponentAdapters();
+
+ /**
+ * Retrieve all component adapters inside this container that are associated with the specified type. The addComponent
+ * adapters from the parent container are not returned.
+ *
+ * @param componentType the type of the components.
+ * @return a collection containing all the {@link ComponentAdapter}s inside this container that are associated with
+ * the specified type. Changes to this collection will not be reflected in the container itself.
+ */
+ <T> List<ComponentAdapter<T>> getComponentAdapters(Class<T> componentType);
+
+ <T> List<ComponentAdapter<T>> getComponentAdapters(Class<T> componentType, Class<? extends Annotation> binding);
+
+ /**
+ * Returns a List of components of a certain componentType. The list is ordered by instantiation order, starting
+ * with the components instantiated first at the beginning.
+ *
+ * @param componentType the searched type.
+ * @return a List of components.
+ * @throws ComposerException if the instantiation of a component fails
+ */
+ <T> List<T> getComponents(Class<T> componentType);
+
+ /**
+ * Accepts a visitor that should visit the child containers, component adapters and component instances.
+ *
+ * @param visitor the visitor
+ */
+ void accept(ContainerVisitor visitor);
+
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ContainerBuilder.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ContainerBuilder.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ContainerBuilder.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ContainerBuilder.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,239 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ * *
+ * Original code by *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+import static org.apache.composer.core.behaviors.Behaviors.caching;
+import static org.apache.composer.core.behaviors.Behaviors.implementationHiding;
+import org.apache.composer.core.behaviors.PropertyApplying;
+import org.apache.composer.core.behaviors.Synchronizing;
+import org.apache.composer.core.behaviors.Locking;
+import org.apache.composer.core.behaviors.Automating;
+import org.apache.composer.core.injectors.MethodInjection;
+import org.apache.composer.core.containers.EmptyContainer;
+import org.apache.composer.core.containers.TransientContainer;
+import static org.apache.composer.core.injectors.Injectors.CDI;
+import static org.apache.composer.core.injectors.Injectors.annotatedMethodDI;
+import static org.apache.composer.core.injectors.Injectors.annotatedFieldDI;
+import static org.apache.composer.core.injectors.Injectors.SDI;
+import static org.apache.composer.core.injectors.Injectors.adaptiveDI;
+import org.apache.composer.core.lifecycle.NullLifecycleStrategy;
+import org.apache.composer.core.lifecycle.ReflectionLifecycleStrategy;
+import org.apache.composer.core.lifecycle.StartableLifecycleStrategy;
+import org.apache.composer.core.monitors.ConsoleComponentMonitor;
+import org.apache.composer.core.monitors.NullComponentMonitor;
+
+import java.util.ArrayList;
+import java.util.Stack;
+import java.util.List;
+
+/**
+ * Helps assembles the myriad items available to a picocontainer.
+ * <p>Simple Example:</p>
+ * <pre>
+ * MutablePicoContainer mpc = new PicoBuilder()
+ * .withCaching()
+ * .withLifecycle()
+ * .build();
+ * </pre>
+ * @author Paul Hammant
+ */
+public class ContainerBuilder {
+
+ private Container parentContainer;
+ private Class<? extends MutableContainer> mpcClass = DefaultContainer.class;
+ private ComponentMonitor componentMonitor;
+ private List<Object> containerComps = new ArrayList<Object>();
+
+ public ContainerBuilder(Container parentContainer, InjectionFactory injectionType) {
+ this.injectionType = injectionType;
+ if (parentContainer != null) {
+ this.parentContainer = parentContainer;
+ } else {
+ this.parentContainer = new EmptyContainer();
+ }
+ }
+
+ public ContainerBuilder(Container parentContainer) {
+ this(parentContainer, adaptiveDI());
+ }
+
+ public ContainerBuilder(InjectionFactory injectionType) {
+ this(new EmptyContainer(), injectionType);
+ }
+
+ public ContainerBuilder() {
+ this(new EmptyContainer(), adaptiveDI());
+ }
+
+ private final Stack<Object> componentFactories = new Stack<Object>();
+
+ private InjectionFactory injectionType;
+
+ private Class<? extends ComponentMonitor> componentMonitorClass = NullComponentMonitor.class;
+ private Class<? extends LifecycleStrategy> lifecycleStrategyClass = NullLifecycleStrategy.class;
+
+ public ContainerBuilder withLifecycle() {
+ lifecycleStrategyClass = StartableLifecycleStrategy.class;
+ return this;
+ }
+
+ public ContainerBuilder withReflectionLifecycle() {
+ lifecycleStrategyClass = ReflectionLifecycleStrategy.class;
+ return this;
+ }
+
+ public ContainerBuilder withConsoleMonitor() {
+ componentMonitorClass = ConsoleComponentMonitor.class;
+ return this;
+ }
+
+ public ContainerBuilder withMonitor(Class<? extends ComponentMonitor> cmClass) {
+ if (cmClass == null) {
+ throw new NullPointerException("monitor class cannot be null");
+ }
+ if (!ComponentMonitor.class.isAssignableFrom(cmClass)) {
+ throw new ClassCastException(cmClass.getName() + " is not a " + ComponentMonitor.class.getName());
+
+ }
+ componentMonitorClass = cmClass;
+ componentMonitor = null;
+ return this;
+ }
+
+ public MutableContainer build() {
+
+ DefaultContainer temp = new TransientContainer();
+ temp.addComponent(Container.class, parentContainer);
+
+ for (Object containerComp : containerComps) {
+ temp.addComponent(containerComp);
+ }
+
+ ComponentFactory lastCaf = injectionType;
+ while (!componentFactories.empty()) {
+ Object componentFactory = componentFactories.pop();
+ DefaultContainer temp2 = new TransientContainer(temp);
+ temp2.addComponent("componentFactory", componentFactory);
+ if (lastCaf != null) {
+ temp2.addComponent(ComponentFactory.class, lastCaf);
+ }
+ ComponentFactory penultimateCaf = lastCaf;
+ lastCaf = (ComponentFactory) temp2.getComponent("componentFactory");
+ if (lastCaf instanceof BehaviorFactory) {
+ ((BehaviorFactory) lastCaf).wrap(penultimateCaf);
+ }
+ }
+
+ temp.addComponent(ComponentFactory.class, lastCaf);
+ if (componentMonitorClass == null) {
+ temp.addComponent(ComponentMonitor.class, componentMonitor);
+ } else {
+ temp.addComponent(ComponentMonitor.class, componentMonitorClass);
+ }
+ temp.addComponent(LifecycleStrategy.class, lifecycleStrategyClass);
+ temp.addComponent("mpc", mpcClass);
+
+
+ return (MutableContainer) temp.getComponent("mpc");
+ }
+
+ public ContainerBuilder withHiddenImplementations() {
+ componentFactories.push(implementationHiding());
+ return this;
+ }
+
+ public ContainerBuilder withSetterInjection() {
+ injectionType = SDI();
+ return this;
+ }
+
+ public ContainerBuilder withAnnotatedMethodInjection() {
+ injectionType = annotatedMethodDI();
+ return this;
+ }
+
+
+ public ContainerBuilder withAnnotatedFieldInjection() {
+ injectionType = annotatedFieldDI();
+ return this;
+ }
+
+
+ public ContainerBuilder withConstructorInjection() {
+ injectionType = CDI();
+ return this;
+ }
+
+ public ContainerBuilder withCaching() {
+ componentFactories.push(caching());
+ return this;
+ }
+
+ public ContainerBuilder withComponentFactory(ComponentFactory componentFactory) {
+ if (componentFactory == null) {
+ throw new NullPointerException("CAF cannot be null");
+ }
+ componentFactories.push(componentFactory);
+ return this;
+ }
+
+ public ContainerBuilder withSynchronizing() {
+ componentFactories.push(Synchronizing.class);
+ return this;
+ }
+
+ public ContainerBuilder withLocking() {
+ componentFactories.push(Locking.class);
+ return this;
+ }
+
+ public ContainerBuilder withBehaviors(BehaviorFactory... factories) {
+ for (ComponentFactory componentFactory : factories) {
+ componentFactories.push(componentFactory);
+ }
+ return this;
+ }
+
+ public ContainerBuilder implementedBy(Class<? extends MutableContainer> containerClass) {
+ mpcClass = containerClass;
+ return this;
+ }
+
+ public ContainerBuilder withMonitor(ComponentMonitor componentMonitor) {
+ this.componentMonitor = componentMonitor;
+ componentMonitorClass = null;
+ return this;
+ }
+
+ public ContainerBuilder withComponentFactory(Class<? extends ComponentFactory> componentFactoryClass) {
+ componentFactories.push(componentFactoryClass);
+ return this;
+ }
+
+ public ContainerBuilder withCustomContainerComponent(Object containerDependency) {
+ containerComps.add(containerDependency);
+ return this;
+ }
+
+ public ContainerBuilder withPropertyApplier() {
+ componentFactories.push(PropertyApplying.class);
+ return this;
+ }
+
+ public ContainerBuilder withAutomatic() {
+ componentFactories.push(Automating.class);
+ return this;
+ }
+
+ public ContainerBuilder withMethodInjection() {
+ componentFactories.push(new MethodInjection());
+ return this;
+ }
+}
Added: incubator/composer/core/src/java/org/apache/composer/core/ContainerVisitor.java
URL: http://svn.apache.org/viewvc/incubator/composer/core/src/java/org/apache/composer/core/ContainerVisitor.java?rev=613775&view=auto
==============================================================================
--- incubator/composer/core/src/java/org/apache/composer/core/ContainerVisitor.java (added)
+++ incubator/composer/core/src/java/org/apache/composer/core/ContainerVisitor.java Sun Jan 20 22:41:26 2008
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Copyright (C) PicoContainer Organization. All rights reserved. *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file. *
+ *****************************************************************************/
+package org.apache.composer.core;
+
+/**
+ * Interface realizing a visitor pattern for {@link Container} as described in the GoF.
+ * The visitor should visit the container, its children, all registered {@link ComponentAdapter}
+ * instances and all instantiated components.
+ *
+ * @author Aslak Hellesøy
+ * @author Jörg Schaible
+ */
+public interface ContainerVisitor {
+ /**
+ * Entry point for the PicoVisitor traversal. The given node is the first object, that is
+ * asked for acceptance. Only objects of type {@link Container}, {@link ComponentAdapter},
+ * or {@link Parameter} are valid.
+ *
+ * @param node the start node of the traversal.
+ * @return a visitor-specific value.
+ * @throws IllegalArgumentException in case of an argument of invalid type.
+ */
+ Object traverse(Object node);
+
+ /**
+ * Visit a {@link Container} that has to accept the visitor.
+ *
+ * @param pico the visited container.
+ */
+
+ void visitContainer(Container pico);
+ /**
+ * Visit a {@link ComponentAdapter} that has to accept the visitor.
+ *
+ * @param componentAdapter the visited ComponentAdapter.
+ */
+
+ void visitComponentAdapter(ComponentAdapter componentAdapter);
+ /**
+ * Visit a {@link Parameter} that has to accept the visitor.
+ *
+ * @param parameter the visited Parameter.
+ */
+ void visitParameter(Parameter parameter);
+}