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.communication;
  
 
 
Implementation of com.sitewhere.spi.device.communication.IOutboundCommandRouter that assumes a single com.sitewhere.spi.device.communication.ICommandDestination is available and delivers commands to it.

Author(s):
Derek
 
 public class SingleChoiceCommandRouter extends OutboundCommandRouter {

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

Destinations that will deliver all commands
 
 	private ICommandDestination<?, ?> destination;
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see
 	 * com.sitewhere.spi.device.communication.IOutboundCommandRouter#routeCommand(com.
 	 * sitewhere.spi.device.command.IDeviceCommandExecution,
 	 * com.sitewhere.spi.device.IDeviceNestingContext,
 	 * com.sitewhere.spi.device.IDeviceAssignment)
 	 */
 	public void routeCommand(IDeviceCommandExecution executionIDeviceNestingContext nesting,
 			IDeviceAssignment assignmentthrows SiteWhereException {
 		.deliverCommand(executionnestingassignment);
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see
 	 * com.sitewhere.spi.device.communication.IOutboundCommandRouter#routeSystemCommand
 	 * (com.sitewhere.spi.device.command.ISystemCommand,
 	 * com.sitewhere.spi.device.IDeviceNestingContext,
 	 * com.sitewhere.spi.device.IDeviceAssignment)
 	 */
 	public void routeSystemCommand(ISystemCommand commandIDeviceNestingContext nesting,
 			IDeviceAssignment assignmentthrows SiteWhereException {
 		.deliverSystemCommand(commandnestingassignment);
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.server.lifecycle.ILifecycleComponent#start()
 	 */
 	public void start() throws SiteWhereException {
 		.info("Starting single choice command router...");
 		if (getDestinations().size() != 1) {
 			throw new SiteWhereException("Expected exactly one destination for command routing but found "
 					+ getDestinations().size() + ".");
 		}
 		this. = it.next();
 	}
 
 	/*
 	 * (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 {
 		.info("Stopped single choice command router.");
	}
New to GrepCode? Check out our FAQ X