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.hazelcast;
  
 
Sends processed device events out on Hazelcast topics for further processing.

Author(s):
Derek
 
 public class HazelcastEventProcessor extends OutboundEventProcessor {

Static logger instance
 
 	private static Logger LOGGER = Logger.getLogger(HazelcastEventProcessor.class);

Common Hazelcast configuration
 
Topic for device measurements
 
Topic for device locations
 
Topic for device alerts
 
Topic for device command invocations
 
Topic for device command responses
 
Used for marshaling command invocations
 
 			true);
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.server.lifecycle.ILifecycleComponent#start()
 	 */
 	public void start() throws SiteWhereException {
 		if (getConfiguration() == null) {
 			throw new SiteWhereException("No Hazelcast configuration provided.");
 		}
 		this. =
 		this. =
 	}
 
 	/*
 	 * (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 {
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.rest.model.device.event.processor.OutboundEventProcessor#onMeasurements
	 * (com.sitewhere.spi.device.event.IDeviceMeasurements)
	 */
	public void onMeasurements(IDeviceMeasurements measurementsthrows SiteWhereException {
		DeviceMeasurements marshaled = DeviceMeasurements.copy(measurements);
		.debug("Published measurements event to Hazelcast (id=" + measurements.getId() + ")");
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.rest.model.device.event.processor.OutboundEventProcessor#onLocation
	 * (com.sitewhere.spi.device.event.IDeviceLocation)
	 */
	public void onLocation(IDeviceLocation locationthrows SiteWhereException {
		DeviceLocation marshaled = DeviceLocation.copy(location);
		.debug("Published location event to Hazelcast (id=" + location.getId() + ")");
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.rest.model.device.event.processor.OutboundEventProcessor#onAlert(
	 * com.sitewhere.spi.device.event.IDeviceAlert)
	 */
	public void onAlert(IDeviceAlert alertthrows SiteWhereException {
		DeviceAlert marshaled = DeviceAlert.copy(alert);
		.publish(marshaled);
		.debug("Published alert event to Hazelcast (id=" + alert.getId() + ")");
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.rest.model.device.event.processor.OutboundEventProcessor#
	 * onCommandInvocation(com.sitewhere.spi.device.event.IDeviceCommandInvocation)
	 */
		.debug("Published command invocation event to Hazelcast (id=" + invocation.getId() + ")");
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.rest.model.device.event.processor.OutboundEventProcessor#
	 * onCommandResponse(com.sitewhere.spi.device.event.IDeviceCommandResponse)
	 */
	public void onCommandResponse(IDeviceCommandResponse responsethrows SiteWhereException {
		DeviceCommandResponse marshaled = DeviceCommandResponse.copy(response);
		.debug("Published command response event to Hazelcast (id=" + response.getId() + ")");
	}
	}
	public void setConfiguration(SiteWhereHazelcastConfiguration configuration) {
		this. = configuration;
	}
New to GrepCode? Check out our FAQ X