Author: jochen
Date: Sun Dec 14 19:14:55 2014
New Revision: 1645499
URL: http://svn.apache.org/r1645499
Log:
Initial site, Javadocs.
Added:
commons/sandbox/commons-inject/trunk/src/site/apt/lifecycle.apt
commons/sandbox/commons-inject/trunk/src/site/apt/loggerInjection.apt
commons/sandbox/commons-inject/trunk/src/site/fml/
commons/sandbox/commons-inject/trunk/src/site/fml/faq.fml
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/
- copied from r1645493,
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/impl/
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/util/
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/util/ExceptionsTest.java
(with props)
Removed:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/impl/
Modified:
commons/sandbox/commons-inject/trunk/pom.xml
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/CommonsLoggingLoggerModule.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/ILifecycleController.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IAnnotatedBindingBuilder.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IBinder.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/ILinkedBindingBuilder.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IModule.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IScopedBindingBuilder.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/Scopes.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBindingSet.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractInjector.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultInjector.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultLifecycleController.java
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/IInjectorAware.java
commons/sandbox/commons-inject/trunk/src/site/apt/index.apt
commons/sandbox/commons-inject/trunk/src/site/apt/using.apt
commons/sandbox/commons-inject/trunk/src/site/site.xml
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/InitializableObject.java
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/ListenerTest.java
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/Log4jLoggerModuleTest.java
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/SimpleInjectorTest.java
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TckTest.java
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TimeRecordingObject.java
Modified: commons/sandbox/commons-inject/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/pom.xml?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/pom.xml (original)
+++ commons/sandbox/commons-inject/trunk/pom.xml Sun Dec 14 19:14:55 2014
@@ -5,10 +5,16 @@
<artifactId>commons-sandbox-parent</artifactId>
<version>10</version>
</parent>
+ <groupId>org.apache.commons.inject</groupId>
<artifactId>commons-inject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>Apache Commons Inject</name>
<description>A JSR 330 compliant dependency injection
framework.</description>
+ <scm>
+
<connection>scm:svn:https://svn.apache.org/repos/asf/commons/sandbox/commons-inject/trunk/</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/commons/sandbox/commons-inject/trunk/</developerConnection>
+
<url>http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/</url>
+ </scm>
<build>
<pluginManagement>
<plugins>
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/CommonsLoggingLoggerModule.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/CommonsLoggingLoggerModule.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/CommonsLoggingLoggerModule.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/CommonsLoggingLoggerModule.java
Sun Dec 14 19:14:55 2014
@@ -19,7 +19,6 @@ package org.apache.commons.inject.api;
import org.apache.commons.inject.api.bind.IModule;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.logging.log4j.Logger;
/**
* A {@link IModule module}, which injects Commons Logging Loggers, aka
instances of
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/ILifecycleController.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/ILifecycleController.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/ILifecycleController.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/ILifecycleController.java
Sun Dec 14 19:14:55 2014
@@ -19,4 +19,6 @@ package org.apache.commons.inject.api;
public interface ILifecycleController extends ILifecycleListener {
boolean add(ILifecycleListener pListener);
boolean remove(ILifecycleListener pListener);
+ void start();
+ void shutdown();
}
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IAnnotatedBindingBuilder.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IAnnotatedBindingBuilder.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IAnnotatedBindingBuilder.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IAnnotatedBindingBuilder.java
Sun Dec 14 19:14:55 2014
@@ -18,7 +18,23 @@ package org.apache.commons.inject.api.bi
import java.lang.annotation.Annotation;
+/**
+ * A binding builder, which allows to specify annotations, or annotation
+ * types as constraints, depending on which POJO's may, or may not be
+ * injected.
+ */
public interface IAnnotatedBindingBuilder<T> extends ILinkedBindingBuilder<T> {
+ /**
+ * Specifies, that the binding can only be used for injection, if a
+ * field is annotated with an {@link Annotation}, that equals the
+ * given. In general, this means that the annotation type, and all
+ * attributes are equal.
+ * @see Annotation#equals(Object)
+ */
ILinkedBindingBuilder<T> annotatedWith(Annotation pAnnotation);
+ /**
+ * Specifies, that the binding can only be used for injection, if a
+ * field is annotated with an {@link Annotation} of the given type.
+ */
ILinkedBindingBuilder<T> annotatedWith(Class<? extends Annotation>
pAnnotation);
}
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IBinder.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IBinder.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IBinder.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IBinder.java
Sun Dec 14 19:14:55 2014
@@ -22,6 +22,11 @@ import org.apache.commons.inject.api.IIn
import org.apache.commons.inject.api.IKey;
import org.apache.commons.inject.api.IPoint;
+/**
+ * A {@link IBinder} is passed as an argument to modules. Modules use
+ * the binder to create {@link IBinding bindings}.
+ */
+
public interface IBinder {
public interface IInjectionParticipator {
List<IPoint<Object>> getPoints(IKey<?> pKey, Class<?> pType);
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/ILinkedBindingBuilder.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/ILinkedBindingBuilder.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/ILinkedBindingBuilder.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/ILinkedBindingBuilder.java
Sun Dec 14 19:14:55 2014
@@ -23,6 +23,10 @@ import org.apache.commons.inject.api.IPr
import com.google.inject.Provider;
+/**
+ * A binding builder, which allows to specify a bindings target: A
+ * target is the value, that gets injected, if the binding is applied.
+ */
public interface ILinkedBindingBuilder<T> extends IScopedBindingBuilder<T> {
void toInstance(T pInstance);
IScopedBindingBuilder<T> to(Class<? extends T> pImplClass);
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IModule.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IModule.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IModule.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IModule.java
Sun Dec 14 19:14:55 2014
@@ -16,6 +16,17 @@
*/
package org.apache.commons.inject.api.bind;
+import org.apache.commons.inject.api.IInjectorBuilder;
+
+
+/**
+ * A {@link IModule module} is created by the user in order to configure
+ * the {@link IInjector}.
+ */
public interface IModule {
+ /**
+ * Called by the {@link IInjectorBuilder} to create bindings, by using
+ * the given {@link IBinder binder}.
+ */
void configure(IBinder pBinder);
}
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IScopedBindingBuilder.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IScopedBindingBuilder.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IScopedBindingBuilder.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/IScopedBindingBuilder.java
Sun Dec 14 19:14:55 2014
@@ -16,6 +16,9 @@
*/
package org.apache.commons.inject.api.bind;
+/**
+ * A binding builder, which allows to specify a bindings scope.
+ */
public interface IScopedBindingBuilder<T> {
void scope(Scopes pScope);
void asEagerSingleton();
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/Scopes.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/Scopes.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/Scopes.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/api/bind/Scopes.java
Sun Dec 14 19:14:55 2014
@@ -16,8 +16,25 @@
*/
package org.apache.commons.inject.api.bind;
+/**
+ * List of the supported scopes.
+ */
public enum Scopes {
+ /**
+ * A binding with scope {@code PER_CALL} will create a new instance,
+ * whenever the binding is used to inject a value.
+ */
PER_CALL,
+ /**
+ * A binding with scope {@code EAGER_SINGLETON} will create a single
instance,
+ * which is injected whenever the binding is used to inject a value. The
+ * instance will be created immediately.
+ */
EAGER_SINGLETON,
+ /**
+ * A binding with scope {@code EAGER_SINGLETON} will create a single
instance,
+ * which is injected whenever the binding is used to inject a value. The
+ * instance will be created as soon as required.
+ */
LAZY_SINGLETON
}
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBaseProvider.java
Sun Dec 14 19:14:55 2014
@@ -20,10 +20,24 @@ import org.apache.commons.inject.api.IIn
import org.apache.commons.inject.api.IPoint;
import org.apache.commons.inject.api.IProvider;
+/**
+ * Abstract implementation of a base provider: In general, bindings are using
+ * a {@link AbstractScopedProvider scoped provider}, which controls the
bindings
+ * scope ({@code When} is the instance created?) The actual instantiation, and
+ * the injection of values, is delegated to the base provider. ({@code How} is
+ * the instance created?)
+ */
public abstract class AbstractBaseProvider<T> implements IProvider<T>,
IInjectorAware {
private final Class<T> type;
private final IPoint<T> point;
+ /**
+ * Creates a new base provider.
+ * @param pType The type of the instance, which is being created
+ * by the provider.
+ * @param pPoint The point, which is being used to inject values
+ * into the created instance.
+ */
protected AbstractBaseProvider(Class<T> pType, IPoint<T> pPoint) {
type = pType;
point = pPoint;
@@ -47,6 +61,4 @@ public abstract class AbstractBaseProvid
((IInjectorAware) point).init(pInjector);
}
}
-
-
}
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBindingSet.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBindingSet.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBindingSet.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractBindingSet.java
Sun Dec 14 19:14:55 2014
@@ -26,19 +26,31 @@ import org.apache.commons.inject.api.IBi
import org.apache.commons.inject.api.IKey;
import org.apache.commons.inject.api.Key;
+/**
+ * A set of bindings, which are being collected to create, or implement
+ * an {@link IInjector}.
+ */
public class AbstractBindingSet {
+ /**
+ * The internal map of bindings uses this key.
+ */
public static class MappedKey<T> extends Key<T> {
private final Class<? extends Annotation> annotationType;
- public MappedKey(Class<T> pType, String pName, Annotation[]
pAnnotations, Class<? extends Annotation> pAnnotationType) {
+ public MappedKey(Class<T> pType, String pName,
+ Annotation[] pAnnotations,
+ Class<? extends Annotation>
pAnnotationType) {
super(pType, pName, pAnnotations);
- annotationType = null;
+ annotationType = pAnnotationType;
}
public Class<? extends Annotation> getAnnotationType() {
return annotationType;
}
}
+ /**
+ * The internal map of bindings uses this value.
+ */
protected static class BindingAndKey<T> {
private IBinding<T> binding;
private final MappedKey<T> key;
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractInjector.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractInjector.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractInjector.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/AbstractInjector.java
Sun Dec 14 19:14:55 2014
@@ -22,6 +22,9 @@ import org.apache.commons.inject.api.IKe
import org.apache.commons.inject.api.Key;
import org.apache.commons.inject.api.NoSuchBindingException;
+/**
+ * Abstract implementation of an {@link IInjector injector}.
+ */
public abstract class AbstractInjector implements IInjector {
protected abstract <T> IBinding<T> getBinding(IKey<T> pKey);
protected abstract <T> IBinding<T> requireBinding(IKey<T> pKey);
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultInjector.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultInjector.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultInjector.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultInjector.java
Sun Dec 14 19:14:55 2014
@@ -17,6 +17,7 @@
package org.apache.commons.inject.impl;
import org.apache.commons.inject.api.IBinding;
+import org.apache.commons.inject.api.IInjector;
import org.apache.commons.inject.api.IKey;
import org.apache.commons.inject.api.IPoint;
import org.apache.commons.inject.api.IProvider;
@@ -25,6 +26,9 @@ import org.apache.commons.inject.impl.Ab
import org.apache.commons.inject.impl.AbstractBindingSet.ReducedKey;
import org.apache.commons.inject.impl.bind.DefaultBinding;
+/**
+ * Default implementation of an {@link IInjector injector}.
+ */
public class DefaultInjector extends AbstractInjector {
private final ImmutableBindingSet bindings;
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultLifecycleController.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultLifecycleController.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultLifecycleController.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/DefaultLifecycleController.java
Sun Dec 14 19:14:55 2014
@@ -24,35 +24,36 @@ import org.apache.commons.inject.api.ILi
import org.apache.commons.inject.util.Exceptions;
public class DefaultLifecycleController implements ILifecycleController {
- private static enum State {
- NOT_STARTED,
- STARTED,
- TERMINATED
- }
- private State state = State.NOT_STARTED;
+ private static final int NOT_STARTED = 0;
+ private static final int STARTED = 1;
+ private static final int TERMINATED = 2;
+
+ private int state = NOT_STARTED;
private List<ILifecycleListener> listeners = new
ArrayList<ILifecycleListener>();
+ private List<ILifecycleListener> initializedListeners = new
ArrayList<ILifecycleListener>();
@Override
public synchronized void start() {
- if (state == State.NOT_STARTED) {
+ if (state == NOT_STARTED) {
for (ILifecycleListener listener : listeners) {
try {
listener.start();
+ initializedListeners.add(listener);
} catch (Throwable t) {
throw Exceptions.show(t);
}
}
- state = State.STARTED;
+ state = STARTED;
}
}
@Override
public synchronized void shutdown() {
- if (state == State.STARTED) {
+ if (state == STARTED) {
Throwable th = null;
// Shutdown in reverse order.
- for (int i = listeners.size()-1; i >= 0; i--) {
- final ILifecycleListener listener =
listeners.get(i);
+ for (int i = initializedListeners.size()-1; i >= 0;
i--) {
+ final ILifecycleListener listener =
initializedListeners.get(i);
try {
listener.shutdown();
listeners.remove(i);
@@ -65,15 +66,16 @@ public class DefaultLifecycleController
throw Exceptions.show(th);
}
}
- state = State.TERMINATED;
+ state = TERMINATED;
}
}
@Override
public synchronized boolean add(ILifecycleListener pListener) {
- if (state == State.STARTED) {
+ if (state == STARTED) {
try {
pListener.start();
+ initializedListeners.add(pListener);
} catch (Throwable t) {
throw Exceptions.show(t);
}
@@ -83,8 +85,8 @@ public class DefaultLifecycleController
@Override
public synchronized boolean remove(ILifecycleListener pListener) {
- boolean result = listeners.remove(pListener);
- if (state == State.STARTED) {
+ boolean result = initializedListeners.remove(pListener);
+ if (state == TERMINATED && result) {
try {
pListener.shutdown();
} catch (Throwable t) {
@@ -92,6 +94,5 @@ public class DefaultLifecycleController
}
}
return result;
-
}
}
Modified:
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/IInjectorAware.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/IInjectorAware.java?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/IInjectorAware.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/main/java/org/apache/commons/inject/impl/IInjectorAware.java
Sun Dec 14 19:14:55 2014
@@ -18,6 +18,9 @@ package org.apache.commons.inject.impl;
import org.apache.commons.inject.api.IInjector;
+/** Interface of an object, which is being notified when the
+ * {@link IInjector injector} has been created.
+ */
public interface IInjectorAware {
void init(IInjector pInjector);
}
Modified: commons/sandbox/commons-inject/trunk/src/site/apt/index.apt
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/site/apt/index.apt?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/site/apt/index.apt (original)
+++ commons/sandbox/commons-inject/trunk/src/site/apt/index.apt Sun Dec 14
19:14:55 2014
@@ -18,19 +18,20 @@
Apache Commons Inject
---------------------
-Apache Commons Inject is an implementation of
{{{https://jcp.org/en/jsr/detail?id=330}JSR 330: Dependency Injection for
Java}}.
-In other words: It is yet another implementation of JSR 330, much like
-{{{https://code.google.com/p/google-guice/}Guice}},
-{{{http://www.mkyong.com/spring3/spring-3-and-jsr-330-inject-and-named-example/}Spring}},
-{{{http://square.github.io/dagger/}Dagger}}, and some minor others.
-
-Commons Inject mimicks Guice in most aspects. (For example, if you know the
Guice API,
-you will immediately understand the API of Commons Inject.) However, compared
to Guice,
-you will hopefully note the following differences:
-
-* Commons Inject is self contained. You don't need Guava, or similar helper
jar files.
-* Commons Inject is somewhat easier to use. In particular, you don't need to
bother so
- much about Generics. OTOH, there's no automatic distinction between
+ Apache Commons Inject is an implementation of
+ {{{https://jcp.org/en/jsr/detail?id=330}JSR 330: Dependency Injection for
Java}}.
+ In other words: It is yet another implementation of JSR 330, much like
+ {{{https://code.google.com/p/google-guice/}Guice}},
+
{{{http://www.mkyong.com/spring3/spring-3-and-jsr-330-inject-and-named-example/}Spring}},
+ {{{http://square.github.io/dagger/}Dagger}}, and some minor others.
+
+ Commons Inject mimicks Guice in most aspects. (For example, if you know the
Guice API,
+ you will immediately understand the API of Commons Inject.) However,
compared to Guice,
+ you will hopefully note the following differences:
+
+ * Commons Inject is self contained. You don't need Guava, or similar helper
jar files.
+ * Commons Inject is somewhat easier to use. In particular, you don't need to
bother so
+ much about Generics. OTOH, there's no automatic distinction between
------------------------------------
@Inject private List someList;
@@ -45,17 +46,17 @@ you will hopefully note the following di
@Inject @Named(value="foo") private List<Foo> fooList;
------------------------------------
-* Commons Inject is based on the standard Java reflection API <<only>>. As a
consequence, it
- should work on Android.
-* Commons Inject doesn't distinguish between production mode, and development
mode.
- OTOH, its startup time should be <<much>> faster than Guice in production
mode.
-* Commons Inject provides some extensions out of the box:
- * Support for an {{{./lifecycle.html}Application Lifecycle}}, including
support for
-
{{{http://docs.oracle.com/javaee/5/api/javax/annotation/PostConstruct.html}@PostConstruct}},
- and
{{{http://docs.oracle.com/javaee/5/api/javax/annotation/PreDestroy.html}@PreDestroy}}.
- This lifecycle support works with arbitrary objects, including eager, or
lazy
- singletons.
- * {{{./loggerInjection.html}Logger injection}} via Log4J, SLF4J, or Commons
Logging.
- (Adding support for other frameworks should be extremely easy.)
+ * Commons Inject is based on the standard Java reflection API <<only>>. As a
consequence, it
+ should work on Android.
+ * Commons Inject doesn't distinguish between production mode, and
development mode.
+ OTOH, its startup time should be <<much>> faster than Guice in production
mode.
+ * Commons Inject provides some extensions out of the box:
+ * Support for an {{{./lifecycle.html}Application Lifecycle}}, including
support for
+
{{{http://docs.oracle.com/javaee/5/api/javax/annotation/PostConstruct.html}@PostConstruct}},
+ and
{{{http://docs.oracle.com/javaee/5/api/javax/annotation/PreDestroy.html}@PreDestroy}}.
+ This lifecycle support works with arbitrary objects, including eager, or
lazy
+ singletons.
+ * {{{./loggerInjection.html}Logger injection}} via Log4J, SLF4J, or
Commons Logging.
+ (Adding support for other frameworks should be extremely easy.)
\ No newline at end of file
Added: commons/sandbox/commons-inject/trunk/src/site/apt/lifecycle.apt
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/site/apt/lifecycle.apt?rev=1645499&view=auto
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/site/apt/lifecycle.apt (added)
+++ commons/sandbox/commons-inject/trunk/src/site/apt/lifecycle.apt Sun Dec 14
19:14:55 2014
@@ -0,0 +1,82 @@
+~~
+~~ Licensed to the Apache Software Foundation (ASF) under one or more
+~~ contributor license agreements. See the NOTICE file distributed with
+~~ this work for additional information regarding copyright ownership.
+~~ The ASF licenses this file to You under the Apache License, Version 2.0
+~~ (the "License"); you may not use this file except in compliance with
+~~ the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing, software
+~~ distributed under the License is distributed on an "AS IS" BASIS,
+~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~~ See the License for the specific language governing permissions and
+~~ limitations under the License.
+~~
+ -----------------------------
+ Application Lifecycle Support
+ -----------------------------
+
+ Commons Inject provides limited application lifecycle support. More
specifically, you
+ can have your Pojo's initialized when the application starts and you can
also have them
+ perform a graceful shutdown hen the application terminates.
+
+ To achieve that, you must use the <<@PostConstruct>>, and <<@PreDestroy>>
annotations,
+ like this:
+
+-----------------------------
+public class MyBean
+ @Inject private ConnectionProvider connectionProvider;
+
+ @PostConstruct
+ public void init() throws SomeException {
+ // Perform initialization on this bean.
+ }
+
+ @PreDestroy
+ public void shutdown() throws OtherException {
+ // Release resources, etc...
+ }
+}
+------------------------------
+
+ The
{{{http://docs.oracle.com/javaee/6/tutorial/doc/gmgkd.html}specification}} of
<<@PostConstruct>>, and
+ <<@PreDestroy>> demands, that such methods must be public, non-static,
non-abstract, and must not expect
+ parameters. Of course, you need access to other beans, or the like, you can
have them injected via
+ @Inject. If there are multiple beans with @PostConstruct: For eager
singletons, the order of invocation depends on the order of
+ binding in the modules. Lazy singletons are initialized upon first use.
(Injection into another bean counts as
+ use.)
+
+ Beans with @PreDestroy, OTOH, are invoked in reverse order of initialization.
+
+ Two other things must be done to make use of <<@PostConstruct>>, and
<<@PreDestroy>>:
+
+ * The predefined
{{{./apidocs/org/apache/commons/inject/api/PostConstructModule.html}PostConstructModule}}
+ must be used when creating the injector. (This module <<must>> be the
first in your module list.)
+
+ * You must invoke the methods <<start()>> and <<shutdown()>> on the modules
+ {{{./apidocs/org/apache/commons/inject/api/ILifycycleController}lifecycle
controller}}
+
+ In other words, a typical application would look like this:
+
+--------------------------------
+public class MyApp {
+ public static void main() throws Exception {
+ final IModule postConstructModule = new PostConstructModule();
+ final IModule module1 = new MyModule1();
+ final IModule module2 = new MyModule2();
+ // Note: The PostConstructModule is first in the list.
+ final IInjctor injector = CommonsInject.build(postConstructModule,
module1, module2);
+ // A binding for the controller was created automatically by the
PostConstructModule.
+ final ILifecycleController controller =
injector.getInstance(ILifecycleController.class);
+ // Initialize the beans with @PostConstruct
+ controller.start();
+ // Do the real work here.
+ ...
+ // Terminate the beans with @PreDestroy
+ controller.shutdown();
+ }
+}
+--------------------------------
+
\ No newline at end of file
Added: commons/sandbox/commons-inject/trunk/src/site/apt/loggerInjection.apt
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/site/apt/loggerInjection.apt?rev=1645499&view=auto
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/site/apt/loggerInjection.apt
(added)
+++ commons/sandbox/commons-inject/trunk/src/site/apt/loggerInjection.apt Sun
Dec 14 19:14:55 2014
@@ -0,0 +1,92 @@
+~~
+~~ Licensed to the Apache Software Foundation (ASF) under one or more
+~~ contributor license agreements. See the NOTICE file distributed with
+~~ this work for additional information regarding copyright ownership.
+~~ The ASF licenses this file to You under the Apache License, Version 2.0
+~~ (the "License"); you may not use this file except in compliance with
+~~ the License. You may obtain a copy of the License at
+~~
+~~ http://www.apache.org/licenses/LICENSE-2.0
+~~
+~~ Unless required by applicable law or agreed to in writing, software
+~~ distributed under the License is distributed on an "AS IS" BASIS,
+~~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+~~ See the License for the specific language governing permissions and
+~~ limitations under the License.
+~~
+ -----------------------------
+ Application Lifecycle Support
+ -----------------------------
+
+ Every application needs logging. What's more: Every part of an application
+ needs logging. This applies, in particular, to components created by the
+ injector.
+
+ To perform logging, a component needs loggers. Obviously, one would like
+ to have these injected. And this is, what the logger modules can do for you.
+ Here's an example of a component with injected loggers:
+
+----------------------------------
+package com.foo.myapp;
+
+import org.apache.log4j.Logger;
+
+public class MyComponent {
+ @InjLogger private Logger log;
+
+ public void run() {
+ log.debug("run: ->");
+ // Do something here.
+ ...
+ log.debug("run: <-");
+ }
+----------------------------------
+
+ Three things should be noted at this point:
+* The example doesn't use the standard @Inject annotation, but a custom
annotation
+ @InjLogger, which is unsupported by any other JSR 330 implementation, apart
from
+ Commons Inject. (In most cases, one could extend the respective
implementation
+ to achieve the same purpose. For example, Guice explicitly supports {{{
+ https://github.com/google/guice/wiki/CustomInjections}custom annotations}}.
+* The injected logger will have the id "com.foo.myapp.MyComponent", same as the
+ class name, into which the logger is being injected. If you would like
another
+ id, use <<<@InjLogger(id="SomeOtherId")>>> instead.
+* The above example uses {{{http://logging.apache.org/log4j/1.2/}Log4J}} as a
logging
+ system. As a consequence, the proper module to use in the example below will
be the
+
{{{./apidocs/org/apache/commons/inject/api/Log4jLoggerModule.html}Log4jLoggerModule}}.
+ For other modules, you would need a different logger injection module.
Explicitly
+ supported are
{{{./apidocs/org/apache/commons/inject/api/Log4j2LoggerModule.html}
+ Log4j 2 (Log4j2LoggerModule)}},
{{{./apidocs/org/apache/commons/inject/api/Slf4JLoggerModule.html}
+ SLF4J 2 (Slf4JLoggerModule)}}, and
{{{./apidocs/org/apache/commons/inject/api/CommonsLoggingLoggerModule.html}
+ Commons Logging (CommonsLoggingLoggerModule)}}. (Adding support for others
would be
+ quite easy by deriving another subclass of
{{{./apidocs/org/apache/commons/inject/api/AbstractLoggerInjectingModule.html}
+ AbstractLoggerInjectingModule}}.
+
+ And here's how to apply the module:
+
+--------------------------------
+public class MyApp {
+ public static void main() throws Exception {
+ final IModule postConstructModule = new PostConstructModule();
+ final IModule loggerModule = new Log4jLoggerModule();
+ final IModule module1 = new MyModule1();
+ final IModule module2 = new MyModule2();
+ // Note: The PostConstructModule is first in the list.
+ final IInjctor injector = CommonsInject.build(postConstructModule,
+
loggerModule, module1, module2);
+ // A binding for the controller was created automatically by the
PostConstructModule.
+ final ILifecycleController controller =
injector.getInstance(ILifecycleController.class);
+ // Initialize the beans with @PostConstruct
+ controller.start();
+ // Do the real work here.
+ ...
+ // Terminate the beans with @PreDestroy
+ controller.shutdown();
+ }
+}
+--------------------------------
+
+ For obvious reasons, the logger module must precede you own, custom modules,
so that
+ these can benefit from the bindings created by the logger module. The
PostConstructModule
+ in the example isn't mandatory. However, if you do use the
PostConstructModule, it has
+ to go first.
Modified: commons/sandbox/commons-inject/trunk/src/site/apt/using.apt
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/site/apt/using.apt?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/site/apt/using.apt (original)
+++ commons/sandbox/commons-inject/trunk/src/site/apt/using.apt Sun Dec 14
19:14:55 2014
@@ -18,24 +18,24 @@
Using Commons Inject
--------------------
-To use Commons Inject, you have to create an
-{{{./apidocs/org/apache/commons/inject/api/IInjector.html}IInjector}}. The
purpose
-of the IInjector is the creation of POJO's, according to the rules you specify.
-The IInjector is the direct equivalent of the {{{}Guice Injector}}.
-
-To create an Injector, you must have some modules that provide the injectors
-configurtion. There are a few predefined modules:
-
-[[PostConstructModule]] The
{{{./apidocs/org/apache/commons/inject/api/PostConstructModule.html}
- PostConstruct module}} provides support for an application lifecycle: Your
POJO's
- may be initialized when the aplication starts. And there is also the
possibility
- for a shutdown. See {{{./lifecycle.html}this document}} for details.
-[[Log4jLoggerModule]] The
{{{./apidocs/org/apache/commons/inject/api/Log4jLoggerModule.html}
- Log4j Logger module}} allows to have Log4j Loggers injected into your POJO's.
- Details are described {{{./loggerInjection.html}here}}.
+ To use Commons Inject, you have to create an
+ {{{./apidocs/org/apache/commons/inject/api/IInjector.html}IInjector}}. The
purpose
+ of the IInjector is the creation of POJO's, according to the rules you
specify.
+ The IInjector is the direct equivalent of the {{{}Guice Injector}}.
+
+ To create an Injector, you must have some modules that provide the injectors
+ configurtion. There are a few predefined modules:
+
+ [[PostConstructModule]] The
{{{./apidocs/org/apache/commons/inject/api/PostConstructModule.html}
+ PostConstruct module}} provides support for an application lifecycle: Your
POJO's
+ may be initialized when the aplication starts. And there is also the
possibility
+ for a shutdown. See {{{./lifecycle.html}this document}} for details.
+ [[Log4jLoggerModule]] The
{{{./apidocs/org/apache/commons/inject/api/Log4jLoggerModule.html}
+ Log4j Logger module}} allows to have Log4j Loggers injected into your
POJO's.
+ Details are described {{{./loggerInjection.html}here}}.
-Of course, the predefined modules will never be sufficient. In practice, you
will also
-have custom modules like this:
+ Of course, the predefined modules will never be sufficient. In practice, you
will also
+ have custom modules like this:
----------------------------------------------
package com.foo.myapp;
@@ -54,8 +54,8 @@ public class MyModule implements IModule
}
----------------------------------------------
-Assuming that you have created your modules, and you wish to use one or more
-of the predefined module, then you can create an IInjector like this:
+ Assuming that you have created your modules, and you wish to use one or more
+ of the predefined module, then you can create an IInjector like this:
----------------------------------------------
import org.apache.commons.inject.api.CommonsInject;
@@ -68,7 +68,7 @@ public IInjector newInjector() {
return CommonsInject.build(module0, module1, module2);
----------------------------------------------
-That Injector can create POJO's for you, like this:
+ That Injector can create POJO's for you, like this:
----------------------------------------------
List<Foo> fooList = injector.requireInstance(List.class);
Added: commons/sandbox/commons-inject/trunk/src/site/fml/faq.fml
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/site/fml/faq.fml?rev=1645499&view=auto
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/site/fml/faq.fml (added)
+++ commons/sandbox/commons-inject/trunk/src/site/fml/faq.fml Sun Dec 14
19:14:55 2014
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<faqs xmlns="http://maven.apache.org/FML/1.0.1"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/FML/1.0.1
http://maven.apache.org/xsd/fml-1.0.1.xsd"
+ title="Frequently Asked Questions"
+ toplink="false">
+
+ <part id="general">
+ <title>General</title>
+
+ <faq id="whats-commons-inject">
+ <question>
+ What is Commons Inject?
+ </question>
+ <answer>
+ <p>Commons Inject is an implementation of
+ <a href="https://jcp.org/en/jsr/detail?id=330">JSR 330 (Dependency
Injection for Java)</a>.
+ Or, in other words: It is a dependency injection framework, like
+ <a href="https://github.com/google">Google Guice</a>, the
+ core part of the <a
href="http://projects.spring.io/spring-framework/">Spring Framework</a>,
+ <a href="http://square.github.io/dagger/">Dagger</a>, or several
others.</p>
+ </answer>
+ </faq>
+
+ <faq id="standard-compliance">
+ <question>
+ Does Commons Inject really comply to the JSR 330 standard?
+ </question>
+ <answer>
+ <p>Yes, it passes the JSR 330 TCK, with and without static
injection.</p>
+ <p>This means, if you have got an application, which is based on an
+ alternative implementation of JSR 330, then it should be really easy,
+ to port that application over to Commons Inject. In general, the only
+ obvious thing to do would be to rewrite the configuration part.
+ However, as Commons Injects configuration closely follows the
+ configuration concepts from Guice, that should be really easy.</p>
+ </answer>
+ </faq>
+
+ <faq id="comparison">
+ <question>
+ How does Commons Inject compare to other JSR 330 implementations?
+ </question>
+ <answer>
+ <p>The author of Commons Inject believes that the framework has the
+ following advantages over its competitors:</p>
+ <ul>
+ <li>It is very small, and lightweight. (As of this writing, it
contains
+ only 56 Java classes with 3833 lines of code, including test
sources. The
+ complete source distribution will have about only 1MB of data,
without
+ compression.</li>
+ <li>The emphasis is on usability, not strictness. For example,
there is
+ no need to derive subclasses of a key in order to bind generic
classes.
+ Or, you may use strings as names withput converting them to
annotations.
+ </li>
+ <li>With usability in mind again: It comes with meaningful
extensions
+ integrated. For example, there is a PostConstructModule, which
enables
+ initialization and resource cleanup for components. Likewise, you
can
+ have loggers, or properties injected into your beans.</li>
+ <li>Commons Inject is based on Java Reflection only. AFAIK, this
means
+ it would work on Android, too, unlike Guice.</li>
+ <li>It works standalone. The only jar file you need is
commons-inject-YOURVERSION.jar.
+ No additional stuff like Guava, AspectJ, Javassist, or whatever
required.</li>
+ </ul>
+ </answer>
+ </faq>
+
+ </part>
+
+ <part id="use">
+
+ <title>Using Commons Inject</title>
+
+ <faq id="how-install">
+ <question>
+ How do I install Commons Inject?
+ </question>
+ <answer>
+ <p>There is no need for a special installation. Just add the jar file
to
+ your project, like you would do with any other jar file. In the case of
+ Maven, you would simply declare a dependency like this:
+ </p>
+ <source>
+ <dependencies>
+ <!-- Other dependencies ... -->
+ <dependency>
+ <groupId>org.apache.commons.inject</groupId>
+ <artifactId>org.apache.commons.inject</artifactId>
+ <version>YOURVERSION</version>
+ <dependency/>
+ <dependencies/>
+ </source>
+ </answer>
+ </faq>
+
+ </part>
+
+</faqs>
\ No newline at end of file
Modified: commons/sandbox/commons-inject/trunk/src/site/site.xml
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/site/site.xml?rev=1645499&r1=1645498&r2=1645499&view=diff
==============================================================================
--- commons/sandbox/commons-inject/trunk/src/site/site.xml (original)
+++ commons/sandbox/commons-inject/trunk/src/site/site.xml Sun Dec 14 19:14:55
2014
@@ -17,7 +17,11 @@
-->
<project name="Commons Inject"
xmlns="http://maven.apache.org/DECORATION/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/DECORATION/1.1.0
http://maven.apache.org/xsd/decoration-1.1.0.xsd">
-
+ <skin>
+ <groupId>org.apache.maven.skins</groupId>
+ <artifactId>maven-fluido-skin</artifactId>
+ <version>1.3.1</version>
+ </skin>
<bannerRight>
<name>Commons Inject</name>
<src>/images/logo.png</src>
@@ -28,7 +32,7 @@
<menu name="Commons Inject">
<item name="Overview" href="/index.html" />
<item name="User guide" href="/using.html" />
- <item name="Lifecycle handling" href="/lifycycle.html" />
+ <item name="Lifecycle handling" href="/lifecycle.html" />
<item name="Logger injection" href="/loggerInjection.html" />
<item name="FAQ" href="/faq.html" />
<item name="Javadoc" href="/apidocs/index.html" />
Modified:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/InitializableObject.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/InitializableObject.java?rev=1645499&r1=1645493&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/InitializableObject.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/InitializableObject.java
Sun Dec 14 19:14:55 2014
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-package org.apache.commons.impl;
+package org.apache.commons.inject.impl;
import org.apache.commons.inject.api.ILifecycleListener;
import org.apache.commons.inject.api.InjLogger;
Modified:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/ListenerTest.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/ListenerTest.java?rev=1645499&r1=1645493&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/ListenerTest.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/ListenerTest.java
Sun Dec 14 19:14:55 2014
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-package org.apache.commons.impl;
+package org.apache.commons.inject.impl;
import java.util.ArrayList;
import java.util.List;
Modified:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/Log4jLoggerModuleTest.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/Log4jLoggerModuleTest.java?rev=1645499&r1=1645493&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/Log4jLoggerModuleTest.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/Log4jLoggerModuleTest.java
Sun Dec 14 19:14:55 2014
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-package org.apache.commons.impl;
+package org.apache.commons.inject.impl;
import java.util.ArrayList;
import java.util.List;
@@ -45,14 +45,12 @@ public class Log4jLoggerModuleTest {
@Override
public boolean requiresLayout() {
- // TODO Auto-generated method stub
return false;
}
@Override
public void close() {
- // TODO Auto-generated method stub
-
+ // Does nothing.
}
@Override
Modified:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/SimpleInjectorTest.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/SimpleInjectorTest.java?rev=1645499&r1=1645493&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/SimpleInjectorTest.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/SimpleInjectorTest.java
Sun Dec 14 19:14:55 2014
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-package org.apache.commons.impl;
+package org.apache.commons.inject.impl;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
Modified:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TckTest.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TckTest.java?rev=1645499&r1=1645493&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TckTest.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TckTest.java
Sun Dec 14 19:14:55 2014
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-package org.apache.commons.impl;
+package org.apache.commons.inject.impl;
import org.apache.commons.inject.api.CommonsInject;
import org.apache.commons.inject.api.IInjector;
Modified:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TimeRecordingObject.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TimeRecordingObject.java?rev=1645499&r1=1645493&r2=1645499&view=diff
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TimeRecordingObject.java
(original)
+++
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/impl/TimeRecordingObject.java
Sun Dec 14 19:14:55 2014
@@ -14,7 +14,7 @@
See the License for the specific language governing permissions and
limitations under the License.
*/
-package org.apache.commons.impl;
+package org.apache.commons.inject.impl;
public class TimeRecordingObject {
private final long timeOfCreation;
Added:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/util/ExceptionsTest.java
URL:
http://svn.apache.org/viewvc/commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/util/ExceptionsTest.java?rev=1645499&view=auto
==============================================================================
---
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/util/ExceptionsTest.java
(added)
+++
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/util/ExceptionsTest.java
Sun Dec 14 19:14:55 2014
@@ -0,0 +1,50 @@
+package org.apache.commons.inject.util;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.UndeclaredThrowableException;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class ExceptionsTest {
+ @Test
+ public void testShowRTE() {
+ final NullPointerException npe = new NullPointerException();
+ Throwable th = null;
+ try {
+ throw Exceptions.show(npe);
+ } catch (Throwable t) {
+ th = t;
+ }
+ Assert.assertNotNull(th);
+ Assert.assertSame(npe, th);
+ }
+
+ @Test
+ public void testShowError() {
+ final OutOfMemoryError oome = new OutOfMemoryError();
+ Throwable th = null;
+ try {
+ throw Exceptions.show(oome);
+ } catch (Throwable t) {
+ th = t;
+ }
+ Assert.assertNotNull(th);
+ Assert.assertSame(oome, th);
+ }
+
+ @Test
+ public void testShowThrowable() {
+ final Throwable t0 = new Throwable("Some throwable"){
+ };
+ Throwable th = null;
+ try {
+ throw Exceptions.show(t0);
+ } catch (UndeclaredThrowableException ute) {
+ th = ute.getCause();
+ }
+ Assert.assertNotNull(th);
+ Assert.assertSame(t0, th); }
+
+}
Propchange:
commons/sandbox/commons-inject/trunk/src/test/java/org/apache/commons/inject/util/ExceptionsTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain