summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-02-12 09:31:33 (EST)
committerStefan Liebig2008-02-12 09:31:33 (EST)
commitaebe78863e533e619ddc41a04294dc9adcd6591e (patch)
tree173f3a791ca89c37d7872f06e8e47347076b0983
parentbd77107d6cb34e53bdf22321c044d8db09462733 (diff)
downloadorg.eclipse.riena.old-aebe78863e533e619ddc41a04294dc9adcd6591e.zip
org.eclipse.riena.old-aebe78863e533e619ddc41a04294dc9adcd6591e.tar.gz
org.eclipse.riena.old-aebe78863e533e619ddc41a04294dc9adcd6591e.tar.bz2
uses new service injector
-rw-r--r--org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/Activator.java12
-rw-r--r--org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/ExceptionHandlerManagerDefault.java158
2 files changed, 86 insertions, 84 deletions
diff --git a/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/Activator.java b/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/Activator.java
index 510b1e3..4a8458e 100644
--- a/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/Activator.java
+++ b/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/Activator.java
@@ -14,7 +14,8 @@ import java.util.Hashtable;
import org.eclipse.riena.core.exception.IExceptionHandler;
import org.eclipse.riena.core.exception.IExceptionHandlerManager;
-import org.eclipse.riena.core.service.ServiceInjector;
+import org.eclipse.riena.core.service.Injector;
+import org.eclipse.riena.core.service.ServiceId;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
@@ -24,7 +25,7 @@ public class Activator implements BundleActivator {
private BundleContext context;
- private ServiceInjector handlerManagerInjector;
+ private Injector handlerManagerInjector;
private ServiceRegistration handlerManagerReg;
@@ -39,11 +40,8 @@ public class Activator implements BundleActivator {
private void registerExceptionHandlerManager() {
ExceptionHandlerManagerDefault handlerManager = new ExceptionHandlerManagerDefault();
String handlerId = IExceptionHandler.ID;
- String bindMethod = "addHandler";
- String unbindMethod = "removeHandler";
- handlerManagerInjector = new ServiceInjector(context, handlerId, handlerManager, bindMethod, unbindMethod);
- handlerManagerInjector.start();
+ handlerManagerInjector = new ServiceId(handlerId).injectInto(handlerManager).start(context);
Hashtable<String, String> properties = new Hashtable<String, String>(0);
handlerManagerReg = context.registerService(IExceptionHandlerManager.ID, handlerManager, properties);
@@ -79,7 +77,7 @@ public class Activator implements BundleActivator {
handlerManagerReg.unregister();
handlerManagerReg = null;
- handlerManagerInjector.dispose();
+ handlerManagerInjector.stop();
handlerManagerInjector = null;
}
}
diff --git a/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/ExceptionHandlerManagerDefault.java b/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/ExceptionHandlerManagerDefault.java
index 7779bf1..c4b0a1b 100644
--- a/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/ExceptionHandlerManagerDefault.java
+++ b/org.eclipse.riena.exceptionmanager/src/org/eclipse/riena/internal/exceptionmanager/ExceptionHandlerManagerDefault.java
@@ -22,90 +22,94 @@ import org.eclipse.riena.core.exception.IExceptionHandlerManager;
*/
public class ExceptionHandlerManagerDefault implements IExceptionHandlerManager {
- private List<IExceptionHandler> handlers;
+ private List<IExceptionHandler> handlers;
- public ExceptionHandlerManagerDefault() {
- handlers = new ArrayList<IExceptionHandler>();
- }
+ public ExceptionHandlerManagerDefault() {
+ handlers = new ArrayList<IExceptionHandler>();
+ }
- public void addHandler(IExceptionHandler handler) {
- handlers = sort(handlers, handler);
- }
+ public void bind(IExceptionHandler handler) {
+ handlers = sort(handlers, handler);
+ }
- private List<IExceptionHandler> sort(List<IExceptionHandler> existsHandler, IExceptionHandler handler) {
- List<TopologicalNode<IExceptionHandler>> nodes = new ArrayList<TopologicalNode<IExceptionHandler>>(existsHandler.size() + 1);
- TopologicalNode<IExceptionHandler> node = new TopologicalNode<IExceptionHandler>(handler.getName(), handler.getBefore(), handler);
- nodes.add(node);
- for (IExceptionHandler nextHandler : existsHandler) {
- node = new TopologicalNode<IExceptionHandler>(nextHandler.getName(), nextHandler.getBefore(), nextHandler);
- nodes.add(node);
- }
- return TopologicalSort.sort(nodes);
- }
+ public void unbind(IExceptionHandler handler) {
+ handlers.remove(handler);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable)
- */
- public Action handleCaught(Throwable t) {
- return handleCaught(t, null, null);
- }
+ private List<IExceptionHandler> sort(List<IExceptionHandler> existsHandler, IExceptionHandler handler) {
+ List<TopologicalNode<IExceptionHandler>> nodes = new ArrayList<TopologicalNode<IExceptionHandler>>(
+ existsHandler.size() + 1);
+ TopologicalNode<IExceptionHandler> node = new TopologicalNode<IExceptionHandler>(handler.getName(), handler
+ .getBefore(), handler);
+ nodes.add(node);
+ for (IExceptionHandler nextHandler : existsHandler) {
+ node = new TopologicalNode<IExceptionHandler>(nextHandler.getName(), nextHandler.getBefore(), nextHandler);
+ nodes.add(node);
+ }
+ return TopologicalSort.sort(nodes);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable,
- * org.eclipse.equinox.log.Logger)
- */
- public Action handleCaught(Throwable t, Logger logger) {
- return handleCaught(t, null, logger);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable)
+ */
+ public Action handleCaught(Throwable t) {
+ return handleCaught(t, null, null);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable, java.lang.String)
- */
- public Action handleCaught(Throwable t, String msg) {
- return handleCaught(t, msg, null);
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable,
+ * org.eclipse.equinox.log.Logger)
+ */
+ public Action handleCaught(Throwable t, Logger logger) {
+ return handleCaught(t, null, logger);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable, java.lang.String,
- * org.eclipse.equinox.log.Logger)
- */
- public Action handleCaught(Throwable t, String msg, Logger logger) {
- Action action = Action.NotHandled;
- for (IExceptionHandler handler : handlers) {
- action = handler.handleCaught(t, msg, logger);
- if (action != Action.NotHandled) {
- break;
- }
- }
- return action;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable,
+ * java.lang.String)
+ */
+ public Action handleCaught(Throwable t, String msg) {
+ return handleCaught(t, msg, null);
+ }
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleUncaught(java.lang.Throwable,
- * java.lang.Object, org.eclipse.equinox.log.Logger)
- */
- public Action handleUncaught(Throwable t, String msg, Logger logger) {
- Action action = Action.NotHandled;
- for (IExceptionHandler handler : handlers) {
- action = handler.handleUncaught(t, msg, logger);
- if (action != Action.NotHandled) {
- break;
- }
- }
- return action;
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleCaught(java.lang.Throwable,
+ * java.lang.String, org.eclipse.equinox.log.Logger)
+ */
+ public Action handleCaught(Throwable t, String msg, Logger logger) {
+ Action action = Action.NotHandled;
+ for (IExceptionHandler handler : handlers) {
+ action = handler.handleCaught(t, msg, logger);
+ if (action != Action.NotHandled) {
+ break;
+ }
+ }
+ return action;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.core.exception.IExceptionHandlerManager#handleUncaught(java.lang.Throwable,
+ * java.lang.Object, org.eclipse.equinox.log.Logger)
+ */
+ public Action handleUncaught(Throwable t, String msg, Logger logger) {
+ Action action = Action.NotHandled;
+ for (IExceptionHandler handler : handlers) {
+ action = handler.handleUncaught(t, msg, logger);
+ if (action != Action.NotHandled) {
+ break;
+ }
+ }
+ return action;
+ }
- public void removeHandler(IExceptionHandler handler) {
- handlers.remove(handler);
- }
} \ No newline at end of file