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.provisioning;
  
 
Default implementation of com.sitewhere.spi.device.provisioning.ICommandDestination.

Parameters:
<T>
Author(s):
Derek
 
 public class CommandDestination<T, P> extends LifecycleComponent implements ICommandDestination<T, P> {

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

Unique destination id
 
 	private String destinationId;

Configured command execution encoder
 
Configured command delivery parameter extractor
 
Configured command delivery provider
 
 
 	public CommandDestination() {
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see
 	 * com.sitewhere.spi.device.provisioning.ICommandDestination#deliverCommand(com.sitewhere
 	 * .spi.device.command.IDeviceCommandExecution,
 	 * com.sitewhere.spi.device.IDeviceNestingContext,
 	 * com.sitewhere.spi.device.IDeviceAssignment)
 	 */
 	public void deliverCommand(IDeviceCommandExecution executionIDeviceNestingContext nesting,
 			IDeviceAssignment assignmentthrows SiteWhereException {
 		T encoded = getCommandExecutionEncoder().encode(executionnestingassignment);
 		P params =
 						execution);
 		getCommandDeliveryProvider().deliver(nestingassignmentexecutionencodedparams);
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see
 	 * com.sitewhere.spi.device.provisioning.ICommandDestination#deliverSystemCommand(
 	 * com.sitewhere.spi.device.command.ISystemCommand,
 	 * com.sitewhere.spi.device.IDeviceNestingContext,
 	 * com.sitewhere.spi.device.IDeviceAssignment)
 	 */
 	public void deliverSystemCommand(ISystemCommand commandIDeviceNestingContext nesting,
 			IDeviceAssignment assignmentthrows SiteWhereException {
 		T encoded = getCommandExecutionEncoder().encodeSystemCommand(commandnestingassignment);
 		P params =
 		getCommandDeliveryProvider().deliverSystemCommand(nestingassignmentencodedparams);
 	}
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see com.sitewhere.spi.server.lifecycle.ILifecycleComponent#start()
 	 */
 	public void start() throws SiteWhereException {
 		.info("Starting command destination '" + getDestinationId() + "'.");
 
 		// Start command execution encoder.
 		if (getCommandExecutionEncoder() == null) {
			throw new SiteWhereException("No command execution encoder configured for destination.");
		}
		// Start command execution encoder.
			throw new SiteWhereException(
					"No command delivery parameter extractor configured for destination.");
		}
		// Start command delivery provider.
		if (getCommandDeliveryProvider() == null) {
			throw new SiteWhereException("No command delivery provider configured for destination.");
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.server.lifecycle.LifecycleComponent#getComponentName()
	 */
		return "Command Destination (" + getDestinationId() + ")";
	}
	/*
	 * (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("Stopping command destination '" + getDestinationId() + "'.");
		// Stop command execution encoder.
		if (getCommandExecutionEncoder() != null) {
		}
		// Stop command delivery provider.
		if (getCommandDeliveryProvider() != null) {
		}
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.spi.device.provisioning.ICommandDestination#getDestinationId()
	 */
	}
	public void setDestinationId(String destinationId) {
		this. = destinationId;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.provisioning.ICommandDestination#getCommandExecutionEncoder
	 * ()
	 */
	}
	public void setCommandExecutionEncoder(ICommandExecutionEncoder<T> commandExecutionEncoder) {
		this. = commandExecutionEncoder;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see com.sitewhere.spi.device.provisioning.ICommandDestination#
	 * getCommandDeliveryParameterExtractor()
	 */
	}
			ICommandDeliveryParameterExtractor<P> commandDeliveryParameterExtractor) {
		this. = commandDeliveryParameterExtractor;
	}
	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.sitewhere.spi.device.provisioning.ICommandDestination#getCommandDeliveryProvider
	 * ()
	 */
	}
	public void setCommandDeliveryProvider(ICommandDeliveryProvider<T, P> commandDeliveryProvider) {
		this. = commandDeliveryProvider;
	}
New to GrepCode? Check out our FAQ X