Additional log on plug-in self-registration and failures.
Whenever a new class is self-registered from a plug-in additional INFO message is displayed with class name and listener / exported interface. Additionally when a Listener fails to get created from injection into a DynamicSet, an error is logged allowing the plug-in developer to understand what was the problem. Without this patch, you may see your plus-in loading correctly but then the listeners being discarded silently and you would spend a lot of time figuring out where the problem was. Change-Id: Ief3d3c5a3012136f73296a3afa5c85c22fc38bb7
This commit is contained in:
@@ -47,6 +47,11 @@ limitations under the License.
|
||||
<groupId>org.apache.tomcat</groupId>
|
||||
<artifactId>servlet-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@@ -25,6 +25,9 @@ import com.google.inject.name.Named;
|
||||
import com.google.inject.util.Providers;
|
||||
import com.google.inject.util.Types;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
@@ -39,6 +42,7 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
* registrations to decide between singleton and non-singleton members.
|
||||
*/
|
||||
public class DynamicSet<T> implements Iterable<T> {
|
||||
private static final Logger log = LoggerFactory.getLogger(DynamicSet.class);
|
||||
/**
|
||||
* Declare a singleton {@code DynamicSet<T>} with a binder.
|
||||
* <p>
|
||||
@@ -147,7 +151,8 @@ public class DynamicSet<T> implements Iterable<T> {
|
||||
try {
|
||||
next = p.get();
|
||||
} catch (RuntimeException e) {
|
||||
// TODO Log failed member of DynamicSet.
|
||||
log.error("Cannot get iterated object from provider " + p
|
||||
+ ": object discared", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -192,10 +192,12 @@ class AutoRegisterModules {
|
||||
|
||||
if (is("org.apache.sshd.server.Command", clazz)) {
|
||||
if (sshGen != null) {
|
||||
PluginLoader.log.info("Exporting " + clazz + " as SSH Command");
|
||||
sshGen.export(export, clazz);
|
||||
}
|
||||
} else if (is("javax.servlet.http.HttpServlet", clazz)) {
|
||||
if (httpGen != null) {
|
||||
PluginLoader.log.info("Exporting " + clazz + " as HTTP Servlet");
|
||||
httpGen.export(export, clazz);
|
||||
listen(clazz, clazz);
|
||||
}
|
||||
@@ -247,6 +249,7 @@ class AutoRegisterModules {
|
||||
TypeLiteral<?> tl = TypeLiteral.get(type);
|
||||
if (env.hasDynamicSet(tl)) {
|
||||
sysSingletons.add(clazz);
|
||||
PluginLoader.log.info("Registering " + clazz + " to listener " + tl);
|
||||
sysListen.put(tl, clazz);
|
||||
} else if (env.hasDynamicMap(tl)) {
|
||||
if (clazz.getAnnotation(Export.class) == null) {
|
||||
@@ -255,6 +258,7 @@ class AutoRegisterModules {
|
||||
clazz.getName(), rawType.getName()));
|
||||
}
|
||||
sysSingletons.add(clazz);
|
||||
PluginLoader.log.info("Registering " + clazz + " to listener " + tl);
|
||||
sysListen.put(tl, clazz);
|
||||
} else {
|
||||
throw new InvalidPluginException(String.format(
|
||||
|
Reference in New Issue
Block a user