Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) SiteWhere, LLC. All rights reserved. http://www.sitewhere.com
   *
   * The software in this package is published under the terms of the CPAL v1.0
   * license, a copy of which has been included with this distribution in the
   * LICENSE.txt file.
   */
  package com.sitewhere.device.event.processor;
  
 import java.util.List;
 
 
Default implementation of com.sitewhere.spi.device.event.processor.IOutboundEventProcessorChain interface.

Author(s):
Derek
 
 public class DefaultOutboundEventProcessorChain extends LifecycleComponent implements
Static logger instance
 
 	private static Logger LOGGER = Logger.getLogger(DefaultOutboundEventProcessorChain.class);

Indicates whether processing is enabled
 
 	private boolean processingEnabled = false;

List of event processors
 
 
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.server.lifecycle.ILifecycleComponent#start()
 	 */
 	public void start() throws SiteWhereException {
 		for (IOutboundEventProcessor processor : getProcessors()) {
 			startNestedComponent(processorfalse);
 		}
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.server.lifecycle.ILifecycleComponent#getLogger()
 	 */
 	public Logger getLogger() {
 		return ;
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.server.lifecycle.ILifecycleComponent#stop()
 	 */
 	public void stop() throws SiteWhereException {
 		for (IOutboundEventProcessor processor : getProcessors()) {
 			processor.lifecycleStop();
 		}
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.device.event.processor.IOutboundEventProcessorChain#
 	 * setProcessingEnabled(boolean)
 	 */
 	public void setProcessingEnabled(boolean enabled) {
 		this. = enabled;
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.device.event.processor.IOutboundEventProcessorChain#
 	 * isProcessingEnabled()
	 */
	public boolean isProcessingEnabled() {
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.event.processor.IOutboundEventProcessor#onMeasurements
	 * (com.sitewhere.spi.device.event.IDeviceMeasurements)
	 */
	public void onMeasurements(IDeviceMeasurements measurementsthrows SiteWhereException {
			for (IOutboundEventProcessor processor : getProcessors()) {
				try {
					if (processor.getLifecycleStatus() == .) {
						processor.onMeasurements(measurements);
else {
						logSkipped(processor);
					}
catch (SiteWhereException e) {
				}
			}
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.event.processor.IOutboundEventProcessor#onLocation(com
	 * .sitewhere.spi.device.event.IDeviceLocation)
	 */
	public void onLocation(IDeviceLocation locationthrows SiteWhereException {
			for (IOutboundEventProcessor processor : getProcessors()) {
				try {
					if (processor.getLifecycleStatus() == .) {
						processor.onLocation(location);
else {
						logSkipped(processor);
					}
catch (SiteWhereException e) {
				}
			}
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.event.processor.IOutboundEventProcessor#onAlert(com.sitewhere
	 * .spi.device.event.IDeviceAlert)
	 */
	public void onAlert(IDeviceAlert alertthrows SiteWhereException {
			for (IOutboundEventProcessor processor : getProcessors()) {
				try {
					if (processor.getLifecycleStatus() == .) {
						processor.onAlert(alert);
else {
						logSkipped(processor);
					}
catch (SiteWhereException e) {
				}
			}
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.event.processor.IOutboundEventProcessor#onCommandInvocation
	 * (com.sitewhere.spi.device.event.IDeviceCommandInvocation)
	 */
			for (IOutboundEventProcessor processor : getProcessors()) {
				try {
					if (processor.getLifecycleStatus() == .) {
						processor.onCommandInvocation(invocation);
else {
						logSkipped(processor);
					}
catch (SiteWhereException e) {
				}
			}
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.event.processor.IOutboundEventProcessor#onCommandResponse
	 * (com.sitewhere.spi.device.event.IDeviceCommandResponse)
	 */
	public void onCommandResponse(IDeviceCommandResponse responsethrows SiteWhereException {
			for (IOutboundEventProcessor processor : getProcessors()) {
				try {
					if (processor.getLifecycleStatus() == .) {
						processor.onCommandResponse(response);
else {
						logSkipped(processor);
					}
catch (SiteWhereException e) {
				}
			}
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.event.processor.IOutboundEventProcessor#onBatchOperation
	 * (com.sitewhere.spi.device.batch.IBatchOperation)
	 */
	public void onBatchOperation(IBatchOperation operationthrows SiteWhereException {
			for (IOutboundEventProcessor processor : getProcessors()) {
				try {
					if (processor.getLifecycleStatus() == .) {
						processor.onBatchOperation(operation);
else {
						logSkipped(processor);
					}
catch (SiteWhereException e) {
				}
			}
		}
	}

Output log message indicating a processor was skipped.

Parameters:
processor
	protected void logSkipped(IOutboundEventProcessor processor) {
				"Skipping event processor " + processor.getComponentName() + " because its state is '"
processor.getLifecycleStatus() + "'");
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.event.processor.IOutboundEventProcessorChain#getProcessors
	 * ()
	 */
		return ;
	}
	public void setProcessors(List<IOutboundEventProcessorprocessors) {
		this. = processors;
	}
New to GrepCode? Check out our FAQ X