Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
This file is part of Niowire. Niowire is free software: you can redistribute it and/or modify it under the terms of the Lesser GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Niowire is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public License for more details. You should have received a copy of the Lesser GNU General Public License along with Niowire. If not, see <http://www.gnu.org/licenses/>.
 
 package io.niowire.inspection;
 
 import java.util.Map;

This is a simple Inspector which will timeout after a message has not been received for the amount of time that it was configured with

Author(s):
Trent Houliston
 
 public class TimeoutInspector implements NioInspector
 {
 
 	//Our context
 	private Context context = null;
 	private long lastMessage = System.currentTimeMillis();
 	private long timeout;
 	private boolean open = true;
 	private Map<String, ? extends Objectconfiguration;

We use the UID generator to generate our UID based on the remoteAddress socket

Returns:
the UID
 
 	public String getUid()
 	{
 		return UidGenerator.addressToUid(.getRemoteAddress());
 	}

We do nothing while inspecting, we just return whatever we are given

Parameters:
line the line we are inspecting (just returned)
Returns:
the line we were given
Throws:
NioAuthenticationException does not get thrown ever in this class
 
 	{
 		if (!)
 		{
 			throw new ClosedChannelException();
 		}
 		return line;
 	}

Returns if we should time out or not

Returns:
false
 
 	public boolean timeout()
 	{
 		//Timeout when the inspector is closed
 		return ! || (( > 0) && (System.currentTimeMillis() -  > ));
 	}

 
 	public void setContext(Context context)
 	{
 		this. = context;
 	}

 
 	public void configure(Map<String, ? extends Objectconfigurationthrows Exception
 	{
		 = ((Numberconfiguration.get("timeout")).longValue();
		this. = configuration;
	}

	public void close() throws IOException
	{
		 = false;
	}

	public Map<String, ? extends ObjectgetConfiguration()
	{
	}
New to GrepCode? Check out our FAQ X