Issue #1580 - Refactor events framework so EventBus is available from CAVE or EDEX.

Change-Id: If8d9c18108ca244b044b1ddc5a80e9e5de623c7a

Former-commit-id: 06ddb6cce7 [formerly 1b1d00f8a9] [formerly 06ddb6cce7 [formerly 1b1d00f8a9] [formerly 36909dd6c0 [formerly 1d3f9e0d5b32f96fc4eff47f040d5eb159a38d3c]]]
Former-commit-id: 36909dd6c0
Former-commit-id: cd52a94032 [formerly 4400265394]
Former-commit-id: 0cb979038b
This commit is contained in:
Mike Duff 2013-02-05 13:15:46 -06:00
parent 53c04aac63
commit 28e854de25
38 changed files with 596 additions and 226 deletions

View file

@ -187,7 +187,6 @@
install-size="0"
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.common.dataplugin.maps"
@ -246,4 +245,10 @@
version="0.0.0"
unpack="false"/>
<plugin
id="com.raytheon.uf.viz.event"
download-size="0"
install-size="0"
version="0.0.0"/>
</feature>

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View file

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.raytheon.uf.viz.event</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,8 @@
#Tue Feb 05 09:52:42 CST 2013
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.6

View file

@ -0,0 +1,13 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Event
Bundle-SymbolicName: com.raytheon.uf.viz.event
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: com.raytheon.uf.viz.event.Activator
Bundle-Vendor: RAYTHEON
Require-Bundle: org.eclipse.core.runtime,
com.raytheon.uf.common.event;bundle-version="1.0.0",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
com.raytheon.uf.common.status;bundle-version="1.12.1174"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy

View file

@ -0,0 +1 @@
com.raytheon.uf.viz.event.CaveEventBusHandler

View file

@ -0,0 +1,4 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.

View file

@ -0,0 +1,80 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.viz.event;
import com.raytheon.uf.common.event.Event;
import com.raytheon.uf.common.event.EventPublishRequest;
import com.raytheon.uf.common.event.IEventBusHandler;
import com.raytheon.uf.common.serialization.comm.RequestRouter;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
/**
* Cave implementation of the {@link IEventBusHandler}
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 5, 2013 1580 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class CaveEventBusHandler implements IEventBusHandler {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(CaveEventBusHandler.class);
/**
* {@inheritDoc}
*/
@Override
public void publish(Event event) {
EventPublishRequest request = new EventPublishRequest(event);
try {
RequestRouter.route(request);
} catch (Exception e) {
statusHandler.handle(Priority.PROBLEM, "Error sending Event", e);
}
}
/**
* {@inheritDoc}
*/
@Override
public void register(Object subscriber) {
throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*/
@Override
public void unregister(Object subscriber) {
throw new UnsupportedOperationException();
}
}

View file

@ -8,5 +8,7 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Require-Bundle: com.raytheon.uf.common.serialization;bundle-version="1.12.1174",
com.raytheon.uf.common.serialization.comm;bundle-version="1.12.1174",
javax.persistence;bundle-version="1.0.0",
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174"
com.raytheon.uf.common.dataplugin;bundle-version="1.12.1174",
com.google.guava;bundle-version="1.0.0",
com.raytheon.uf.common.status;bundle-version="1.12.1174"
Export-Package: com.raytheon.uf.common.event

View file

@ -0,0 +1,69 @@
package com.raytheon.uf.common.event;
import java.util.ServiceLoader;
/**
* The EventBus.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 11, 2012 1261 djohnson Add SW history, create constants for fields,
* add unregister.
* Dec 11, 2012 1407 djohnson Separate the creation of the Google EventBus from the wrapper class.
* Feb 05, 2013 1580 mpduff Moved to common, use IEventBusHandler.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public final class EventBus {
private static final IEventBusHandler handler;
static {
handler = ServiceLoader.<IEventBusHandler> load(IEventBusHandler.class)
.iterator().next();
}
private EventBus() {
}
/**
* Register with the EventBus.
*
* @param subscriber
* The subscriber to register
*/
public static void register(Object subscriber) {
handler.register(subscriber);
}
/**
* Unregister from the EventBus.
*
* @param subscriber
* The subscriber to unregister
*/
public static void unregister(Object subscriber) {
handler.unregister(subscriber);
}
/**
* Publish the event.
*
* @param event
* The event to publish
*/
public static void publish(Event event) {
if (event == null) {
throw new IllegalArgumentException("Cannot publish a null event");
}
handler.publish(event);
}
}

View file

@ -0,0 +1,78 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.event;
import com.raytheon.uf.common.serialization.annotations.DynamicSerialize;
import com.raytheon.uf.common.serialization.annotations.DynamicSerializeElement;
import com.raytheon.uf.common.serialization.comm.IServerRequest;
/**
* Publish event request.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 5, 2013 1580 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
@DynamicSerialize
public class EventPublishRequest implements IServerRequest {
@DynamicSerializeElement
private Event event;
/**
* Default Constructor.
*/
public EventPublishRequest() {
}
/**
* Convenience constructor.
*
* @param event
* The event to publish
*/
public EventPublishRequest(Event event) {
this.event = event;
}
/**
* @param event
* the event to set
*/
public void setEvent(Event event) {
this.event = event;
}
/**
* @return the event
*/
public Event getEvent() {
return event;
}
}

View file

@ -0,0 +1,65 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.common.event;
/**
* IEventBusHandler interface.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 5, 2013 1580 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public interface IEventBusHandler {
/**
* Publishes events for all subscribers to receive
*
* @param event
* the event
*/
void publish(Event event);
/**
* Register an object with the event bus.
*
* @param subscriber
* the subscriber to register
*/
void register(Object subscriber);
/**
* Unregister an object with the event bus.
*
* @param subscriber
* the object subscribed to the event buss
*/
void unregister(Object subscriber);
}

View file

@ -30,6 +30,7 @@ import com.raytheon.edex.urifilter.URIFilter;
import com.raytheon.edex.urifilter.URIGenerateMessage;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.dataplugin.PluginException;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.monitor.cpg.MonitorStateConfigurationManager;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.stats.ProcessEvent;
@ -42,7 +43,6 @@ import com.raytheon.uf.edex.core.EdexException;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.database.plugin.PluginDao;
import com.raytheon.uf.edex.event.EventBus;
/**
* CompositeProductGenerator
@ -57,7 +57,8 @@ import com.raytheon.uf.edex.event.EventBus;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* 02/07/2009 1981 dhladky Initial Creation.
* 30NOV2012 1372 dhladky Added statistics
* 30NOV2012 1372 dhladky Added statistics.
* 02/05/2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -107,8 +108,6 @@ public abstract class CompositeProductGenerator implements
protected String routeId = null;
protected static final EventBus eventBus = EventBus.getInstance();
public CompositeProductGenerator(String name, String compositeProductType) {
this(name, compositeProductType, null);
}
@ -463,7 +462,7 @@ public abstract class CompositeProductGenerator implements
// error occurred and statement logged incorrectly
if ((processEvent.getProcessingLatency() > 0)
&& (processEvent.getProcessingTime() > 0)) {
eventBus.publish(processEvent);
EventBus.publish(processEvent);
}
}
}

View file

@ -41,6 +41,7 @@ import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.Time;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.registry.event.InsertRegistryEvent;
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
import com.raytheon.uf.common.registry.handler.IRegistryObjectHandler;
@ -76,7 +77,6 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.RetrievalStatus;
import com.raytheon.uf.edex.datadelivery.bandwidth.retrieval.SubscriptionRetrievalFulfilled;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthDaoUtil;
import com.raytheon.uf.edex.datadelivery.bandwidth.util.BandwidthUtil;
import com.raytheon.uf.edex.event.EventBus;
/**
* Abstract {@link IBandwidthManager} implementation which provides core
@ -99,6 +99,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Jan 25, 2013 1528 djohnson Compare priorities as primitive ints.
* Jan 28, 2013 1530 djohnson Unschedule all allocations for a subscription that does not fully schedule.
* Jan 30, 2013 1501 djohnson Fix broken calculations for determining required latency.
* Feb 05, 2013 1580 mpduff EventBus refactor.
* </pre>
*
* @author dhladky
@ -137,7 +138,7 @@ abstract class BandwidthManager extends
this.retrievalManager = retrievalManager;
this.bandwidthDaoUtil = bandwidthDaoUtil;
EventBus.getInstance().register(this);
EventBus.register(this);
BandwidthEventBus.register(this);
// Start a MaintenanceTask
@ -1520,7 +1521,7 @@ abstract class BandwidthManager extends
*/
@VisibleForTesting
void shutdown() {
EventBus.getInstance().unregister(this);
EventBus.unregister(this);
BandwidthEventBus.unregister(this);
retrievalManager.shutdown();
scheduler.shutdownNow();

View file

@ -8,6 +8,7 @@ import java.util.TreeMap;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.time.util.TimeUtil;
@ -16,7 +17,6 @@ import com.raytheon.uf.edex.datadelivery.bandwidth.dao.IBandwidthDao;
import com.raytheon.uf.edex.datadelivery.bandwidth.dao.SubscriptionRetrieval;
import com.raytheon.uf.edex.datadelivery.bandwidth.notification.BandwidthEventBus;
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
import com.raytheon.uf.edex.event.EventBus;
/**
*
@ -31,6 +31,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Oct 11, 2012 0726 djohnson Add SW history, check for bandwidth enabled,
* change the event listener type.
* Oct 26, 2012 1286 djohnson Return list of unscheduled allocations.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -59,7 +60,7 @@ public class RetrievalManager {
this.bandwidthDao = bandwidthDao;
this.notifier = notifier;
EventBus.getInstance().register(this);
EventBus.register(this);
}
public Map<Network, RetrievalPlan> getRetrievalPlans() {
@ -207,7 +208,7 @@ public class RetrievalManager {
* Shutdown the retrieval manager.
*/
public void shutdown() {
EventBus.getInstance().unregister(this);
EventBus.unregister(this);
// From this point forward, only return a poison pill for this retrieval
// manager, which will cause threads attempting to receive bandwidth
// allocations to die

View file

@ -14,6 +14,7 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionBundle;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
@ -32,7 +33,6 @@ import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
import com.raytheon.uf.edex.event.EventBus;
/**
* Class used to process SubscriptionRetrieval BandwidthAllocations.
@ -46,6 +46,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Oct 10, 2012 0726 djohnson Add generics, constants, defaultPriority.
* Nov 26, 2012 dhladky Override default ingest routes based on plugin
* Jan 30, 2013 1543 djohnson Should not implement IRetrievalHandler.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -114,7 +115,7 @@ public class SubscriptionRetrievalAgent extends
// retrievals were generated we have to send it manually
RetrievalManagerNotifyEvent retrievalManagerNotifyEvent = new RetrievalManagerNotifyEvent();
retrievalManagerNotifyEvent.setId(Long.toString(retrieval.getId()));
EventBus.getInstance().publish(retrievalManagerNotifyEvent);
EventBus.publish(retrievalManagerNotifyEvent);
}
}

View file

@ -4,8 +4,8 @@ import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.datadelivery.event.INotifiableEvent;
import com.raytheon.uf.common.datadelivery.event.notification.NotificationRecord;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.registry.event.RemoveRegistryEvent;
import com.raytheon.uf.edex.event.EventBus;
/**
*
@ -25,6 +25,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Jul 06, 2012 740 djohnson Fix bug that assumes {@link RemoveRegistryEvent}s will only be received by
* the method with it as a parameter (i.e. superclass parameter methods receive it too).
* Dec 07, 2012 1104 djohnson Changed to use INotifiableEvent for events with notifications.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -33,8 +34,6 @@ import com.raytheon.uf.edex.event.EventBus;
*/
public class NotificationHandler extends AbstractHandler {
private static EventBus eventBus = EventBus.getInstance();
private String endpoint;
/**
@ -42,7 +41,7 @@ public class NotificationHandler extends AbstractHandler {
* DataDeliveryEventBus
*/
public NotificationHandler() {
eventBus.register(this);
EventBus.register(this);
}
/**
@ -51,7 +50,7 @@ public class NotificationHandler extends AbstractHandler {
*/
public NotificationHandler(String endpoint) {
this.endpoint = endpoint;
eventBus.register(this);
EventBus.register(this);
}
/**

View file

@ -17,6 +17,7 @@ import com.raytheon.uf.common.datadelivery.registry.Provider;
import com.raytheon.uf.common.datadelivery.registry.Utils;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.IProviderHandler;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.localization.IPathManager;
import com.raytheon.uf.common.localization.LocalizationContext;
import com.raytheon.uf.common.localization.LocalizationContext.LocalizationLevel;
@ -43,7 +44,6 @@ import com.raytheon.uf.edex.datadelivery.retrieval.LinkStore;
import com.raytheon.uf.edex.datadelivery.retrieval.ProviderCollectionLinkStore;
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceFactory;
import com.raytheon.uf.edex.datadelivery.retrieval.ServiceTypeFactory;
import com.raytheon.uf.edex.event.EventBus;
/**
* Harvest MetaData
@ -60,6 +60,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Sept 12,2012 1038 dhladky Reconfigured config.
* Oct 03, 2012 1241 djohnson Use registry handler.
* Nov 09, 2012 1263 dhladky Changed to Site Level
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -209,8 +210,7 @@ public class CrawlMetaDataHandler {
List<Throwable> errors = communicationStrategy.getErrors();
for (Throwable throwable : errors) {
EventBus.getInstance().publish(
new HarvesterEvent(throwable.getMessage()));
EventBus.publish(new HarvesterEvent(throwable.getMessage()));
}
}

View file

@ -27,10 +27,10 @@ import com.raytheon.uf.common.datadelivery.retrieval.util.DataSizeUtils;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
import com.raytheon.uf.edex.event.EventBus;
/**
* Performs processing on the retrieved plugin data objects, and then sends an
@ -43,6 +43,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 01, 2013 1543 djohnson Initial creation
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -55,8 +56,6 @@ public class NotifyOfPluginDataObjectsDecorator implements
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(NotifyOfPluginDataObjectsDecorator.class);
private static final EventBus EVENT_BUS = EventBus.getInstance();
private final IRetrievalPluginDataObjectsProcessor retrievedDataProcessor;
public NotifyOfPluginDataObjectsDecorator(
@ -103,7 +102,7 @@ public class NotifyOfPluginDataObjectsDecorator implements
event.setNumRecords(value.length);
event.setBytes(DataSizeUtils.calculateSize(attXML, serviceType));
EVENT_BUS.publish(event);
EventBus.publish(event);
}
}
}

View file

@ -18,6 +18,7 @@ import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval;
import com.raytheon.uf.common.datadelivery.retrieval.xml.Retrieval.SubscriptionType;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
@ -26,7 +27,6 @@ import com.raytheon.uf.edex.database.DataAccessLayerException;
import com.raytheon.uf.edex.datadelivery.retrieval.RetrievalManagerNotifyEvent;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
import com.raytheon.uf.edex.event.EventBus;
/**
*
@ -41,6 +41,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Aug 9, 2012 1022 djohnson No longer extends Thread, simplify {@link SubscriptionDelay}.
* Oct 10, 2012 0726 djohnson Use the subRetrievalKey for notifying the retrieval manager.
* Nov 25, 2012 1268 dhladky Added additional fields to process subscription tracking
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -70,8 +71,7 @@ public class SubscriptionNotifyTask implements Runnable {
SubscriptionDelay(String subName, String owner, String plugin,
SubscriptionType subscriptionType, Network network,
String provider,
Long subRetrievalKey, long delayedUntilMillis) {
String provider, Long subRetrievalKey, long delayedUntilMillis) {
this.subName = subName;
this.owner = owner;
this.plugin = plugin;
@ -172,8 +172,6 @@ public class SubscriptionNotifyTask implements Runnable {
private static final IUFStatusHandler statusHandler = UFStatus
.getHandler(SubscriptionNotifyTask.class);
private static final EventBus eventBus = EventBus.getInstance();
/**
* Creates a SubscriptionDelay delayed for 11 seconds.
*
@ -189,10 +187,9 @@ public class SubscriptionNotifyTask implements Runnable {
// 11 seconds from start time
return new SubscriptionDelay(record.getId().getSubscriptionName(),
record.getOwner(), record.getPlugin(),
record
.getSubscriptionType(), record.getNetwork(),
record.getProvider(),
record.getSubRetrievalKey(), startTime + 11000);
record.getSubscriptionType(), record.getNetwork(),
record.getProvider(), record.getSubRetrievalKey(),
startTime + 11000);
}
// set written to by other threads
@ -317,8 +314,8 @@ public class SubscriptionNotifyTask implements Runnable {
} else {
event.setNumFailed(numFailed);
}
eventBus.publish(event);
eventBus.publish(retrievalManagerNotifyEvent);
EventBus.publish(event);
EventBus.publish(retrievalManagerNotifyEvent);
dao.removeSubscription(subToCheck.subName);
}

View file

@ -24,6 +24,7 @@ import java.util.HashMap;
import com.raytheon.uf.common.datadelivery.retrieval.xml.RetrievalAttribute;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
@ -34,7 +35,6 @@ import com.raytheon.uf.edex.datadelivery.retrieval.interfaces.IRetrievalResponse
import com.raytheon.uf.edex.datadelivery.retrieval.response.OpenDAPTranslator;
import com.raytheon.uf.edex.datadelivery.retrieval.response.RetrievalResponse;
import com.raytheon.uf.edex.datadelivery.retrieval.util.ConnectionUtil;
import com.raytheon.uf.edex.event.EventBus;
import dods.dap.DConnect;
import dods.dap.DataDDS;
@ -50,6 +50,7 @@ import dods.dap.DataDDS;
* Jan 07, 2011 dhladky Initial creation
* Jun 28, 2012 819 djohnson Use utility class for DConnect.
* Jul 25, 2012 955 djohnson Make package-private.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -63,8 +64,7 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
.getHandler(OpenDAPRetrievalAdapter.class);
@Override
public OpenDAPRequestBuilder createRequestMessage(
RetrievalAttribute attXML) {
public OpenDAPRequestBuilder createRequestMessage(RetrievalAttribute attXML) {
OpenDAPRequestBuilder reqBuilder = new OpenDAPRequestBuilder(this,
attXML);
@ -82,7 +82,7 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
data = connect.getData(null);
} catch (Exception e) {
statusHandler.handle(Priority.ERROR, e.getLocalizedMessage(), e);
EventBus.getInstance().publish(new RetrievalEvent(e.getMessage()));
EventBus.publish(new RetrievalEvent(e.getMessage()));
}
RetrievalResponse pr = new RetrievalResponse(request.getAttribute());
@ -90,6 +90,7 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
return pr;
}
@Override
public HashMap<String, PluginDataObject[]> processResponse(
IRetrievalResponse response) throws TranslationException {
@ -103,23 +104,21 @@ class OpenDAPRetrievalAdapter extends RetrievalAdapter {
"Unable to instantiate a required class!", e);
}
if (response.getPayLoad() != null
&& response.getPayLoad().length > 0) {
for (Object obj : response.getPayLoad()) {
PluginDataObject[] pdos = null;
if (response.getPayLoad() != null && response.getPayLoad().length > 0) {
for (Object obj : response.getPayLoad()) {
PluginDataObject[] pdos = null;
if (obj instanceof DataDDS) {
pdos = translator.asPluginDataObjects((DataDDS) obj);
}
if (obj instanceof DataDDS) {
pdos = translator.asPluginDataObjects((DataDDS) obj);
}
if (pdos != null && pdos.length > 0) {
String pluginName = pdos[0].getPluginName();
// TODO Need to check if pluginName already exists
map.put(pluginName, pdos);
}
if (pdos != null && pdos.length > 0) {
String pluginName = pdos[0].getPluginName();
// TODO Need to check if pluginName already exists
map.put(pluginName, pdos);
}
}
}
return map;
}

View file

@ -21,9 +21,9 @@ package com.raytheon.uf.edex.datadelivery.service.verify;
import com.raytheon.uf.common.datadelivery.event.INotifiableEvent;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationAction;
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationResponse;
import com.raytheon.uf.edex.event.EventBus;
/**
* Implementation of {@link IVerificationAction} that sends an
@ -37,14 +37,14 @@ import com.raytheon.uf.edex.event.EventBus;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 07, 2012 1104 djohnson Initial creation
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
class NotifyFailedVerification implements
IVerificationAction {
class NotifyFailedVerification implements IVerificationAction {
/**
* {@inheritDoc}
@ -52,9 +52,8 @@ class NotifyFailedVerification implements
@Override
public void verificationPerformed(Subscription subscription,
IVerificationResponse response) {
EventBus.getInstance().publish(
new SubscriptionVerificationFailedEvent(subscription, response
.getNotificationMessage()));
EventBus.publish(new SubscriptionVerificationFailedEvent(subscription,
response.getNotificationMessage()));
}
}

View file

@ -28,12 +28,12 @@ import com.raytheon.uf.common.datadelivery.registry.DataDeliveryRegistryObjectTy
import com.raytheon.uf.common.datadelivery.registry.DataSet;
import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.registry.event.InsertRegistryEvent;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.edex.event.EventBus;
/**
* Performs subscription integrity verification.
@ -45,6 +45,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 7, 2012 1104 djohnson Initial creation
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -155,7 +156,7 @@ public class SubscriptionIntegrityVerifier {
verificationStrategy, successfulVerificationActions,
failedVerificationActions);
EventBus.getInstance().register(verifier);
EventBus.register(verifier);
return verifier;
}

View file

@ -29,11 +29,11 @@ import org.apache.camel.Header;
import org.apache.camel.Headers;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.stats.ProcessEvent;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.status.UFStatus.Priority;
import com.raytheon.uf.edex.event.EventBus;
/**
* Provides logging and deletion services for camel
@ -44,6 +44,7 @@ import com.raytheon.uf.edex.event.EventBus;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 1, 2008 chammack Initial creation
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -55,8 +56,6 @@ public class ProcessUtil {
protected static final IUFStatusHandler handler = UFStatus
.getNamedHandler("Ingest");
protected static final EventBus eventBus = EventBus.getInstance();
protected transient final static ThreadLocal<DecimalFormat> FORMAT = new ThreadLocal<DecimalFormat>() {
@Override
@ -166,7 +165,7 @@ public class ProcessUtil {
// error occurred and statement logged incorrectly
if ((processEvent.getProcessingLatency() > 0)
&& (processEvent.getProcessingTime() > 0)) {
eventBus.publish(processEvent);
EventBus.publish(processEvent);
}
// Make sure we have something to log.

View file

@ -0,0 +1 @@
com.raytheon.uf.edex.event.EdexEventBusHandler

View file

@ -6,4 +6,6 @@
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="logHandler" class="com.raytheon.uf.edex.event.handler.LogHandler"/>
<bean id="statsPublishHandler" class="com.raytheon.uf.edex.event.handler.StatsHandler"/>
</beans>

View file

@ -0,0 +1,86 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.event;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.uf.common.event.Event;
import com.raytheon.uf.common.event.IEventBusHandler;
/**
* EDEX implementation of {@link IEventBusHandler}
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 5, 2013 1580 mpduff Initial creation.
*
* </pre>
*
* @author mpduff
* @version 1.0
*/
public class EdexEventBusHandler implements IEventBusHandler {
@VisibleForTesting
EdexEventBusHandler(GoogleEventBusFactory eventBusFactory) {
this.googleEventBus = eventBusFactory.getEventBus();
}
/**
* The actual Google EventBus being wrapped.
*/
private final com.google.common.eventbus.EventBus googleEventBus;
/**
* Constructor.
*/
public EdexEventBusHandler() {
this(new AsynchronousEventBusFactory());
}
/**
* {@inheritDoc}
*/
@Override
public void publish(Event event) {
this.googleEventBus.post(event);
}
/**
* {@inheritDoc}
*/
@Override
public void register(Object subscriber) {
this.googleEventBus.register(subscriber);
}
/**
* {@inheritDoc}
*/
@Override
public void unregister(Object subscriber) {
this.googleEventBus.unregister(subscriber);
}
}

View file

@ -1,94 +0,0 @@
package com.raytheon.uf.edex.event;
import com.google.common.annotations.VisibleForTesting;
import com.raytheon.uf.common.event.Event;
/**
*
* The EventBus.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Oct 11, 2012 1261 djohnson Add SW history, create constants for fields,
* add unregister.
* Dec 11, 2012 1407 djohnson Separate the creation of the Google EventBus from the wrapper class.
*
* </pre>
*
* @author djohnson
* @version 1.0
*/
public class EventBus {
@VisibleForTesting
static GoogleEventBusFactory eventBusFactory = new AsynchronousEventBusFactory();
/**
* Holder class which allows safe, concurrent, and on-demand creation of the
* EventBus. It also enforces the singleton contract.
*/
private static class EventBusHolder {
private static com.google.common.eventbus.EventBus eventBus = eventBusFactory
.getEventBus();
private static final EventBus instance = new EventBus(eventBus);
}
/**
* Returns the singleton instance of the data delivery event bus
*
* @return the singleton instance
*/
public static EventBus getInstance() {
return EventBusHolder.instance;
}
/**
* The actual Google EventBus being wrapped.
*/
private final com.google.common.eventbus.EventBus googleEventBus;
/**
* Constructor that accepts a Google EventBus.
*
* @param eventBus
* the Google EventBus
*/
private EventBus(com.google.common.eventbus.EventBus eventBus) {
this.googleEventBus = eventBus;
}
/**
* Register an object with the event bus.
*
* @param subscriber
* the subscriber to register
*/
public void register(Object subscriber) {
this.googleEventBus.register(subscriber);
}
/**
* Publishes events for all subscribers to receive
*
* @param event
* the event
*/
public void publish(Event event) {
this.googleEventBus.post(event);
}
/**
* Unregister an object with the event bus.
*
* @param subscriber
* the object subscribed to the event buss
*/
public void unregister(Object subscriber) {
this.googleEventBus.unregister(subscriber);
}
}

View file

@ -0,0 +1,53 @@
/**
* This software was developed and / or modified by Raytheon Company,
* pursuant to Contract DG133W-05-CQ-1067 with the US Government.
*
* U.S. EXPORT CONTROLLED TECHNICAL DATA
* This software product contains export-restricted data whose
* export/transfer/disclosure is restricted by U.S. law. Dissemination
* to non-U.S. persons whether in the United States or abroad requires
* an export license or other authorization.
*
* Contractor Name: Raytheon Company
* Contractor Address: 6825 Pine Street, Suite 340
* Mail Stop B8
* Omaha, NE 68106
* 402.291.0100
*
* See the AWIPS II Master Rights File ("Master Rights File.pdf") for
* further licensing information.
**/
package com.raytheon.uf.edex.event.handler;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.event.EventPublishRequest;
import com.raytheon.uf.common.serialization.comm.IRequestHandler;
/**
* Stats handler bean.
*
* <pre>
*
* SOFTWARE HISTORY
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Feb 5, 2013 1580 mpduff Initial creation.
*
* </pre>
*
* @author mpduffT
* @version 1.0
*/
public class EventPublishHandler implements
IRequestHandler<EventPublishRequest> {
@Override
public Object handleRequest(EventPublishRequest request) throws Exception {
EventBus.publish(request.getEvent());
return null;
}
}

View file

@ -6,7 +6,7 @@ import org.apache.commons.logging.LogFactory;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.event.Event;
import com.raytheon.uf.edex.event.EventBus;
import com.raytheon.uf.common.event.EventBus;
/**
*
@ -20,6 +20,7 @@ import com.raytheon.uf.edex.event.EventBus;
* ------------ ---------- ----------- --------------------------
* Mar 1, 2012 jsanchez Initial creation
* Nov 5, 2012 #1305 bgonzale Added log level Event logging.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -30,13 +31,11 @@ public class LogHandler {
private final Log logger;
private static EventBus eventBus = EventBus.getInstance();
/**
* Creates a new object
*/
public LogHandler() {
eventBus.register(this);
EventBus.register(this);
logger = LogFactory.getLog("Event");
}

View file

@ -26,10 +26,10 @@ import org.hibernate.HibernateException;
import org.hibernate.Transaction;
import com.raytheon.uf.common.event.Event;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.common.util.session.SessionContext;
import com.raytheon.uf.edex.event.EventBus;
import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectTypeDao;
/**
@ -43,6 +43,7 @@ import com.raytheon.uf.edex.registry.ebxml.dao.RegistryObjectTypeDao;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Sep 26, 2012 1187 djohnson Moved in from {@link RegistrySessionManager}.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -81,9 +82,8 @@ public class RegistrySessionContext implements SessionContext {
// Now that the Objects are persisted in the database, send
// the notifications to the other components that might be
// looking for them.
EventBus eventBus = EventBus.getInstance();
for (Event event : events) {
eventBus.publish(event);
EventBus.publish(event);
}
statusHandler
@ -110,8 +110,7 @@ public class RegistrySessionContext implements SessionContext {
* @throws IllegalStateException
* If an attempt is made to add an event to an inactive Session.
*/
public void postEvent(Event event)
throws IllegalStateException {
public void postEvent(Event event) throws IllegalStateException {
if (!transaction.isActive()) {
throw new IllegalStateException(
"Attempt to add event to an inactive transaction.");

View file

@ -27,6 +27,7 @@ import java.util.Set;
import com.google.common.eventbus.AllowConcurrentEvents;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.event.Event;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.serialization.SerializationException;
import com.raytheon.uf.common.serialization.SerializationUtil;
import com.raytheon.uf.common.stats.StatsRecord;
@ -36,7 +37,6 @@ import com.raytheon.uf.common.status.IUFStatusHandler;
import com.raytheon.uf.common.status.UFStatus;
import com.raytheon.uf.edex.database.dao.CoreDao;
import com.raytheon.uf.edex.database.dao.DaoConfig;
import com.raytheon.uf.edex.event.EventBus;
import com.raytheon.uf.edex.stats.util.ConfigLoader;
/**
@ -50,6 +50,7 @@ import com.raytheon.uf.edex.stats.util.ConfigLoader;
* ------------ ---------- ----------- --------------------------
* Aug 21, 2012 jsanchez Removed instance variable of event bus.
* Nov 07, 2012 1317 mpduff Updated config files.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -85,7 +86,7 @@ public class StatsHandler {
*/
public StatsHandler() throws Exception {
loadEventValidTypes();
EventBus.getInstance().register(this);
EventBus.register(this);
}
/**

View file

@ -0,0 +1 @@
com.raytheon.uf.edex.event.TestEventBusHandler

View file

@ -22,7 +22,6 @@ package com.raytheon.uf.edex.datadelivery.bandwidth.notification;
import org.junit.Ignore;
import com.google.common.eventbus.EventBus;
import com.raytheon.uf.edex.event.EventBusTest;
/**
* Test {@link BandwidthEventBus}.
@ -34,6 +33,7 @@ import com.raytheon.uf.edex.event.EventBusTest;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 11, 2012 djohnson Initial creation
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -48,8 +48,6 @@ public class BandwidthEventBusTest {
*/
public static void initSynchronous() {
// Need the normal event bus synchronous as well
EventBusTest.initSynchronous();
BandwidthEventBus.eventBusFactory = new BandwidthEventBusFactory() {
@Override
public EventBus getSubscriptionBus() {

View file

@ -27,11 +27,9 @@ import java.util.Collections;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import org.junit.BeforeClass;
import org.junit.Test;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
import com.raytheon.uf.edex.event.EventBusTest;
/**
* Test {@link RetrievalHandler}.
@ -46,6 +44,7 @@ import com.raytheon.uf.edex.event.EventBusTest;
* Aug 09. 2012 1022 djohnson Changes to RetrievalHandler.
* Nov 19, 2012 1166 djohnson Clean up JAXB representation of registry objects.
* Jan 30, 2013 1543 djohnson RetrievalTask now requires a Network.
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -71,11 +70,6 @@ public class RetrievalHandlerTest {
executorService, mockDao, Arrays.asList(retrievalTask),
subNotifyTask);
@BeforeClass
public static void classSetUp() {
EventBusTest.initSynchronous();
}
@Test
public void testAllRunningRetrievalsAreResetToPendingOnConstruction() {
verify(mockDao).resetRunningRetrievalsToPending();

View file

@ -30,13 +30,13 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.google.common.eventbus.Subscribe;
import com.raytheon.uf.common.datadelivery.event.retrieval.DataRetrievalEvent;
import com.raytheon.uf.common.datadelivery.registry.Network;
import com.raytheon.uf.common.dataplugin.PluginDataObject;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.localization.PathManagerFactoryTest;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.serialization.SerializationException;
@ -45,8 +45,6 @@ import com.raytheon.uf.edex.database.dao.DatabaseUtil;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalDao;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord;
import com.raytheon.uf.edex.datadelivery.retrieval.db.RetrievalRequestRecord.State;
import com.raytheon.uf.edex.event.EventBus;
import com.raytheon.uf.edex.event.EventBusTest;
/**
* Test {@link RetrievalTask}.
@ -103,11 +101,6 @@ public class RetrievalTaskTest {
private final List<DataRetrievalEvent> eventsReceived = new ArrayList<DataRetrievalEvent>();
@BeforeClass
public static void classSetUp() {
EventBusTest.initSynchronous();
}
@Before
public void setUp() throws RegistryHandlerException {
DatabaseUtil.start();
@ -118,7 +111,7 @@ public class RetrievalTaskTest {
dao = new RetrievalDao();
EventBus.getInstance().register(this);
EventBus.register(this);
}
@After

View file

@ -32,7 +32,6 @@ import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import com.raytheon.uf.common.datadelivery.registry.DataDeliveryRegistryObjectTypes;
@ -42,14 +41,13 @@ import com.raytheon.uf.common.datadelivery.registry.Subscription;
import com.raytheon.uf.common.datadelivery.registry.SubscriptionFixture;
import com.raytheon.uf.common.datadelivery.registry.handlers.DataDeliveryHandlers;
import com.raytheon.uf.common.datadelivery.registry.handlers.ISubscriptionHandler;
import com.raytheon.uf.common.event.EventBus;
import com.raytheon.uf.common.registry.event.InsertRegistryEvent;
import com.raytheon.uf.common.registry.handler.RegistryHandlerException;
import com.raytheon.uf.common.registry.handler.RegistryObjectHandlersUtil;
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationAction;
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationResponse;
import com.raytheon.uf.edex.datadelivery.service.verify.SubscriptionIntegrityVerifier.IVerificationStrategy;
import com.raytheon.uf.edex.event.EventBus;
import com.raytheon.uf.edex.event.EventBusTest;
/**
* Test {@link SubscriptionIntegrityVerifier}.
@ -61,6 +59,7 @@ import com.raytheon.uf.edex.event.EventBusTest;
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 07, 2012 1104 djohnson Initial creation
* Feb 05, 2013 1580 mpduff EventBus refactor.
*
* </pre>
*
@ -101,13 +100,6 @@ public class SubscriptionIntegrityVerifierTest {
private final InsertRegistryEvent dataSetUpdateEvent = new InsertRegistryEvent(
"someId", "someLid", DataDeliveryRegistryObjectTypes.DATASET);
private final EventBus eventBus = EventBus.getInstance();
@BeforeClass
public static void classSetUp() {
EventBusTest.initSynchronous();
}
@Before
public void setUp() throws RegistryHandlerException {
whenRegistryEventIdLookedUpReturnDataSet();
@ -115,14 +107,14 @@ public class SubscriptionIntegrityVerifierTest {
@After
public void tearDown() {
eventBus.unregister(verifier);
EventBus.unregister(verifier);
}
@Test
public void testSubscriptionsForDataSetAreRetrieved()
throws RegistryHandlerException {
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifySubscriptionsAreRetrievedForDataSet();
}
@ -135,7 +127,7 @@ public class SubscriptionIntegrityVerifierTest {
whenSubscriptionIsVerifiedItSucceeds(sub1);
whenSubscriptionIsVerifiedItSucceeds(sub2);
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifyEachSubscriptionIsVerifiedAgainstDataSet();
}
@ -149,7 +141,7 @@ public class SubscriptionIntegrityVerifierTest {
// sub2 is already invalid, should not be verified
sub2.setValid(false);
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifySubscriptionIsNotVerifiedAgainstDataSet(sub2);
}
@ -162,7 +154,7 @@ public class SubscriptionIntegrityVerifierTest {
whenSubscriptionIsVerifiedItSucceeds(sub1);
whenSubscriptionIsVerifiedItFails(sub2);
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifyFailedVerificationActionInvoked(sub2);
}
@ -174,8 +166,7 @@ public class SubscriptionIntegrityVerifierTest {
whenSubscriptionsAreRetrievedForDataSetReturnTwo();
whenSubscriptionIsVerifiedItSucceeds(sub1);
whenSubscriptionIsVerifiedItFails(sub2);
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifyFailedVerificationActionNotInvoked(sub1);
}
@ -188,7 +179,7 @@ public class SubscriptionIntegrityVerifierTest {
whenSubscriptionIsVerifiedItSucceeds(sub1);
whenSubscriptionIsVerifiedItFails(sub2);
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifySuccessfulVerificationActionNotInvoked(sub2);
}
@ -201,7 +192,7 @@ public class SubscriptionIntegrityVerifierTest {
whenSubscriptionIsVerifiedItSucceeds(sub1);
whenSubscriptionIsVerifiedItFails(sub2);
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifySuccessfulVerificationActionInvoked(sub1);
}
@ -212,7 +203,7 @@ public class SubscriptionIntegrityVerifierTest {
whenSubscriptionsAreRetrievedForDataSetThrowException();
eventBus.publish(dataSetUpdateEvent);
EventBus.publish(dataSetUpdateEvent);
verifySuccessfulVerificationActionNotInvoked(sub1);
verifySuccessfulVerificationActionNotInvoked(sub2);

View file

@ -19,10 +19,8 @@
**/
package com.raytheon.uf.edex.event;
import org.junit.Ignore;
/**
* Test {@link EventBus}.
* Test event bus handler.
*
* <pre>
*
@ -30,19 +28,15 @@ import org.junit.Ignore;
*
* Date Ticket# Engineer Description
* ------------ ---------- ----------- --------------------------
* Dec 10, 2012 1104 djohnson Initial creation
* Feb 5, 2013 1580 mpduff Initial creation
*
* </pre>
*
* @author djohnson
* @author mpduff
* @version 1.0
*/
@Ignore
public class EventBusTest {
/**
* Creates a synchronous Google EventBus.
*/
public class TestEventBusHandler extends EdexEventBusHandler {
private static class SynchronousEventBusFactory implements
GoogleEventBusFactory {
@Override
@ -52,10 +46,7 @@ public class EventBusTest {
}
}
/**
* Overrides the {@link EventBus} instance to be a synchronous version, useful for unit testing.
*/
public static void initSynchronous() {
EventBus.eventBusFactory = new SynchronousEventBusFactory();
public TestEventBusHandler() {
super(new SynchronousEventBusFactory());
}
}