[dependency-shot] r390 committed - Format code

0 views
Skip to first unread message

depende...@googlecode.com

unread,
Mar 17, 2011, 3:40:20 PM3/17/11
to depende...@googlegroups.com
Revision: 390
Author: mathieu.ancelin
Date: Thu Mar 17 12:21:25 2011
Log: Format code
http://code.google.com/p/dependency-shot/source/detail?r=390

Modified:

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/DependencyShot.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/event/AutoEvent.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/event/EventImpl.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/graph/Binder.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/graph/Binding.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/InjectorImpl.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/CircularConstructorHandler.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/ConstructorHandler.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/FieldsHandler.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/scope/RequestScope.java

/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/spi/DSServiceLoader.java

=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/DependencyShot.java
Thu Mar 17 12:19:02 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/DependencyShot.java
Thu Mar 17 12:21:25 2011
@@ -19,6 +19,7 @@

import cx.ath.mancel01.dependencyshot.api.DSBinder;
import cx.ath.mancel01.dependencyshot.api.Stage;
+import cx.ath.mancel01.dependencyshot.exceptions.ExceptionManager;
import cx.ath.mancel01.dependencyshot.graph.Binder;
import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
import cx.ath.mancel01.dependencyshot.injection.InjectorBuilder;
@@ -137,8 +138,9 @@
return handler;
}
}
- throw new RuntimeException("Can't find a specific configuration
handler for : "
- + confHandler.getSimpleName());
+ ExceptionManager.makeException("Can't find a specific
configuration handler for : "
+ + confHandler.getSimpleName()).throwManaged();
+ throw new RuntimeException(); // should never append
}

/**
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/event/AutoEvent.java
Sat Mar 12 14:15:30 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/event/AutoEvent.java
Thu Mar 17 12:21:25 2011
@@ -51,16 +51,20 @@

public void fire() {
if (manager == null) {
- ExceptionManager.makeException("You should inject the event in
order to call fire on it.").throwManaged();
- throw new RuntimeException("You should inject the event in
order to call fire on it.");
+ ExceptionManager
+ .makeException("You should inject the event in order
to call fire on it.")
+ .throwManaged();
+ throw new RuntimeException();
}
manager.fireEvent(this);
}

public void fireAsync() {
if (manager == null) {
- ExceptionManager.makeException("You should inject the event in
order to call fire on it.").throwManaged();
- throw new RuntimeException("You should inject the event in
order to call fire on it.");
+ ExceptionManager
+ .makeException("You should inject the event in order
to call fire on it.")
+ .throwManaged();
+ throw new RuntimeException();
}
manager.fireAsyncEvent(this);
}
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/event/EventImpl.java
Sat Mar 12 14:15:30 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/event/EventImpl.java
Thu Mar 17 12:21:25 2011
@@ -35,8 +35,10 @@
@Override
public void fire(T event) {
if (manager == null) {
- ExceptionManager.makeException("You should inject the event in
order to call fire on it.").throwManaged();
- throw new DSException("You should inject the event in order to
call fire on it.");
+ ExceptionManager
+ .makeException("You should inject the event in order
to call fire on it.")
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
manager.fireEvent(event);
}
@@ -44,8 +46,10 @@
@Override
public void fireAsync(T event) {
if (manager == null) {
- ExceptionManager.makeException("You should inject the event in
order to call fire on it.").throwManaged();
- throw new DSException("You should inject the event in order to
call fire on it.");
+ ExceptionManager
+ .makeException("You should inject the event in order
to call fire on it.")
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
manager.fireAsyncEvent(event);
}
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/graph/Binder.java
Sat Mar 12 14:15:30 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/graph/Binder.java
Thu Mar 17 12:21:25 2011
@@ -110,8 +110,10 @@
}
Binding<?> old = bindings.put(binding, binding);
if (old != null) {
- ExceptionManager.makeException(IllegalArgumentException.class,
binding + " overwrites " + old).throwManaged();
- throw new IllegalArgumentException(binding + " overwrites " +
old);
+ ExceptionManager
+ .makeException(IllegalArgumentException.class, binding
+ " overwrites " + old)
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
}

=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/graph/Binding.java
Thu Mar 17 12:20:34 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/graph/Binding.java
Thu Mar 17 12:21:25 2011
@@ -31,7 +31,6 @@
import cx.ath.mancel01.dependencyshot.spi.InstanceHandler;
import cx.ath.mancel01.dependencyshot.util.ReflectionUtil;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.util.Map;
import javax.inject.Named;
@@ -132,7 +131,10 @@
this.from = (Class<T>) params.get(DslConstants.FROM);
this.to = (Class<T>) params.get(DslConstants.FROM);
} else {
- throw new DSIllegalStateException("A binding must contains
a 'from' class.");
+ ExceptionManager
+ .makeException(DSIllegalStateException.class, "A
binding must contains a 'from' class.")
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
if (params.containsKey(DslConstants.TO)) {
this.to = (Class<? extends T>) params.get(DslConstants.TO);
@@ -255,17 +257,16 @@
new
ScopeInvocationHandler(injector.getScopeHandler(scope),
from, to, point, injector);
result = (T) ReflectionUtil.getProxyFor(scopeHandler,
from);
- //Proxy.newProxyInstance(
-
//Thread.currentThread().getContextClassLoader(),
- //new Class[]{from}, scopeHandler);
} else {
result = (T)
injector.getScopeHandler(scope).getScopedInstance(from, to, point,
injector);
}
} else {
-
ExceptionManager.makeException(DSIllegalStateException.class, "The scope "
+ scopedInstanceStore.getClass().getSimpleName()
- + " is invalid. Can't perform
injection.").throwManaged();
- throw new DSIllegalStateException("The scope " +
scopedInstanceStore.getClass().getSimpleName()
- + " is invalid. Can't perform injection.");
+ ExceptionManager
+ .makeException(DSIllegalStateException.class,
+ "The scope " +
scopedInstanceStore.getClass().getSimpleName()
+ + " is invalid. Can't perform injection.")
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
} else {
result = (T) injector.createInstance(to);
@@ -281,9 +282,13 @@
}
}
if (!nullable) {
-
ExceptionManager.makeException(NullInjectionException.class,
- "Could not get a " + to + ". Can't inject object
with null value. For that use @Nullable annotation.").throwManaged();
- throw new NullInjectionException("Could not get a " + to
+ ". Can't inject object with null value. For that use @Nullable
annotation.");
+ ExceptionManager
+ .makeException(NullInjectionException.class,
+ "Could not get a "
+ + to
+ + ". Can't inject object with null value. For
that use @Nullable annotation.")
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
}
if (!nullable) {
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/InjectorImpl.java
Thu Mar 17 12:20:34 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/InjectorImpl.java
Thu Mar 17 12:21:25 2011
@@ -48,7 +48,6 @@
import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Proxy;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
@@ -158,8 +157,10 @@
Logger.getLogger(InjectorImpl.class.getName()).
log(Level.SEVERE, "Ooops, no bindings
presents, "
+ "can't inject your app ...");
- ExceptionManager.makeException("No bindings
loaded").throwManaged();
- throw new DSException("No bindings loaded");
+ ExceptionManager
+ .makeException("No bindings loaded")
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
}
}
@@ -324,9 +325,11 @@
if (b != null) {
return b;
}
- ExceptionManager.makeException(IllegalStateException.class,
- "No binding for " + c + " and " +
annotation).throwManaged();
- throw new IllegalStateException("No binding for " + c + "
and " + annotation);
+ ExceptionManager
+ .makeException(IllegalStateException.class,
+ "No binding for " + c + " and " + annotation)
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
//throw new IllegalStateException("No binding for " + c + " and "
+ annotation);
}
@@ -418,14 +421,13 @@
proxy.setClazz(c);

proxy.setCircularConstructorArgumentsInstances(circularConstructorArgumentsInstances);
T instance = (T) ReflectionUtil.getProxyFor(proxy,
actualFromClass);
- //Proxy.newProxyInstance(
-
//Thread.currentThread().getContextClassLoader(),
- //new Class[]{actualFromClass}, proxy);
instanciatedClasses.put(c, instance);
}
if (!actualFromClass.isInterface() &&
instanciatedClasses.get(c) == null) {
- ExceptionManager.makeException("Can't proxy
circular dependencies without interface.").throwManaged();
- throw new DSException("Can't proxy circular
dependencies without interface.");
+ ExceptionManager
+ .makeException("Can't proxy circular
dependencies without interface.")
+ .throwManaged();
+ throw new RuntimeException(); // should never
append
}
try {
Object result = (T) instanciatedClasses.get(c);
@@ -446,10 +448,11 @@
circularClasses.remove(c);
}
} else {
-
ExceptionManager.makeException(DSCyclicDependencyDetectedException.class,
- "Circular dependency detected on " +
c.getName()).throwManaged();
- throw new DSCyclicDependencyDetectedException(
- "Circular dependency detected on " +
c.getName());
+ ExceptionManager
+ .makeException(DSCyclicDependencyDetectedException.class,
+ "Circular dependency detected on " +
c.getName())
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
}
}
@@ -505,8 +508,10 @@
if (e instanceof ExceptionManagedException) {
ExceptionManager.makeException(e).throwManaged();
}
- ExceptionManager.makeException("Could not inject static
members for " + c, e).throwManaged();
- throw new DSException("Could not inject static members for " +
c, e);
+ ExceptionManager
+ .makeException("Could not inject static members for "
+ c, e)
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
eventManager.fireAsyncEvent(stop);
}
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/CircularConstructorHandler.java
Thu Mar 17 12:21:00 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/CircularConstructorHandler.java
Thu Mar 17 12:21:25 2011
@@ -90,7 +90,9 @@
}
}
}
- ExceptionManager.makeException("Could not find @Inject constructor
for " + c).throwManaged();
- throw new DSException("Could not find @Inject constructor for " +
c);
+ ExceptionManager
+ .makeException("Could not find @Inject constructor for " +
c)
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
}
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/ConstructorHandler.java
Thu Mar 17 12:21:00 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/ConstructorHandler.java
Thu Mar 17 12:21:25 2011
@@ -91,7 +91,9 @@
}
}
}
- ExceptionManager.makeException("Could not find @Inject constructor
for " + c).throwManaged();
- throw new DSException("Could not find @Inject constructor for " +
c);
+ ExceptionManager
+ .makeException("Could not find @Inject constructor for " +
c)
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
}
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/FieldsHandler.java
Thu Mar 17 12:21:00 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/injection/handlers/FieldsHandler.java
Thu Mar 17 12:21:25 2011
@@ -17,10 +17,12 @@
package cx.ath.mancel01.dependencyshot.injection.handlers;

import cx.ath.mancel01.dependencyshot.exceptions.DSIllegalStateException;
+import cx.ath.mancel01.dependencyshot.exceptions.ExceptionManager;
import cx.ath.mancel01.dependencyshot.injection.InjectorImpl;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
+import java.util.logging.ErrorManager;
import java.util.logging.Logger;
import javax.inject.Inject;

@@ -61,7 +63,10 @@
&& (staticInjection ==
Modifier.isStatic(field.getModifiers()))) {
// check if the field is not final
if (Modifier.isFinal(field.getModifiers())) {
- throw new DSIllegalStateException("Cannot inject final
field: " + field);
+ ExceptionManager
+ .makeException("Cannot inject final field")
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
Class<?> type = field.getType();
Type genericType = field.getGenericType();
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/scope/RequestScope.java
Thu Mar 17 12:20:34 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/scope/RequestScope.java
Thu Mar 17 12:21:25 2011
@@ -23,7 +23,6 @@
import cx.ath.mancel01.dependencyshot.util.ReflectionUtil;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
=======================================
---
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/spi/DSServiceLoader.java
Thu Mar 17 12:20:34 2011
+++
/trunk/dependency-shot-core/src/main/java/cx/ath/mancel01/dependencyshot/spi/DSServiceLoader.java
Thu Mar 17 12:21:25 2011
@@ -53,14 +53,15 @@
return new DSServiceLoader(interf, loadFromServices(interf));
} catch (Exception ex) {
logger.log(Level.SEVERE, null, ex);
- ExceptionManager.makeException("Error while loading
services : ", ex).throwManaged();
- throw new DSException("Error while loading services : ", ex);
+ ExceptionManager
+ .makeException("Error while loading services : ", ex)
+ .throwManaged();
+ throw new RuntimeException(); // should never append
}
}

private static <T> Collection<T> loadFromServices(Class<T> interf)
throws Exception {
ClassLoader classLoader = DSServiceLoader.class.getClassLoader();
- //Thread.currentThread().getContextClassLoader();
Enumeration<URL> e = classLoader.getResources("META-INF/services/"
+ interf.getName());
Collection<T> services = new ArrayList<T>();
while (e.hasMoreElements()) {

Reply all
Reply to author
Forward
0 new messages