/**
 * THINGS/THINGER 2009
 * Copyright Erich P Gatejen (c) 2001 through 2009  ALL RIGHTS RESERVED
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package things.thinger.service.proxy;

import java.net.Socket;

import things.common.WhoAmI;
import things.thinger.io.Logger;

/**
 * Context for a proxy session used by the service. 
 * <p>
 * <p>
 * @author Erich P. Gatejen
 * @version 1.0
 * <p>
 * <i>Version History</i>
 * <pre>EPG - Added by request.  This was part of a stand-alone lib for a while. - 10 DEC 08
 * </pre> 
 */
public class ProxyServiceContext extends ProxyContext {
	
	// ===================================================================================================
	// EXPOSED DATA

	
	// ===================================================================================================
	// INTERNAL DATA
	ProxyServiceThread thread;
	private ProxyService ownerService;
	private ProxyProcessor processor;
	
	// ===================================================================================================
	// METHODS
	
	/**
	 * Constructor.
	 * @param id
	 * @param session
	 * @param thread
	 * @param ownerService
	 * @param uplink
	 * @param downlink
	 * @param processor
	 * @param logger
	 * @throws Throwable
	 */
	public ProxyServiceContext(WhoAmI id, ProxySession session, ProxyServiceThread thread, ProxyService ownerService, Socket uplink, Socket downlink, ProxyProcessor processor, Logger logger) throws Throwable {
		super(id, session, uplink, downlink, logger);
		this.processor = processor;
		this.thread = thread;
		this.ownerService = ownerService;
	}

	// ===================================================================================================
	// ABSTRACT
	
	/**
	 * We are done with this context.  Let the service know we are done with this session.
	 */
	public void complete() {
		ownerService.complete(this);
	}
	
	/**
	 * Dispatch this context for processing.  The service 
	 */
	public void process() throws Throwable {
		processor.process(this);
	}
	
	// ==========================================================================================================
	// == PRIVATE AND INTERNAL

}
