1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
;
15 import java
.util
.HashSet
;
18 import org
.eclipse
.linuxtools
.lttng
.TraceDebug
;
19 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.state
.StateEventToHandlerFactory
;
25 public class EventProcessorProxy
{
26 // ========================================================================
28 // =======================================================================
29 private static EventProcessorProxy instance
= null;
30 private final Set
<AbsEventToHandlerResolver
> processingFactories
= new HashSet
<AbsEventToHandlerResolver
>();
33 // ========================================================================
35 // =======================================================================
36 public EventProcessorProxy() {
37 // Manual creation of State update factory
38 addEventProcessorFactory(StateEventToHandlerFactory
.getInstance());
41 // ========================================================================
43 // =======================================================================
45 * @return the processingFactories
47 public Set
<AbsEventToHandlerResolver
> getProcessingFactories() {
48 return processingFactories
;
52 * Returns this singleton
56 public static EventProcessorProxy
getInstance() {
57 if (instance
== null) {
58 instance
= new EventProcessorProxy();
65 * Register a factory of event handler methods, each factory provides a map
66 * to Before and After state update handlers
68 * @param handlersFactory
70 public void addEventProcessorFactory(
71 AbsEventToHandlerResolver handlersFactory
) {
72 if (handlersFactory
!= null) {
73 //only add the listener if not already included
74 if (!processingFactories
.contains(handlersFactory
)) {
75 processingFactories
.add(handlersFactory
);
79 .debug("An attempt to register a null factory has been detected");
84 * Remove a factory previously added with addEventProcessorFactory
86 * @param handlersFactory
88 public void removeEventProcessorFactory(
89 IEventToHandlerResolver handlersFactory
) {
90 if (handlersFactory
!= null) {
91 processingFactories
.remove(handlersFactory
);