de.fhg.igd.semoa.web
Class HttpInGate

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended byde.fhg.igd.semoa.web.HttpInGate
All Implemented Interfaces:
AgentGateway, AgentGateway.In, Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class HttpInGate
extends javax.servlet.http.HttpServlet
implements AgentGateway.In

TO DO: the clean up process, the documentation, agents passed in a file.

Version:
"$Id: HttpInGate.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Roger Hartmann
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class de.fhg.igd.semoa.server.AgentGateway
AgentGateway.In, AgentGateway.Out
 
Field Summary
static int BUF_SIZE
          The buffer size.
private static String[] DEPEND_
          The dependencies to other objects in the global Environment.
private  boolean enabled_
          Enable/disable the gate.
private  InGate ingate_
          The private reference to the ingate.
private  long lastFetch_
          The time of the last fetch of the ingate.
private  Object lock_
          The lock object that is needed when getting the ingate.
static long MAX_SIZE
          The maximum size of an Agent in bytes (initial value).
private  long maxSize_
          The maximum size of an agent (current value).
static String MIME_TYPE
          The mimetype that an agent has to be that it is accepted by the ingate.
static String PROTOCOL
          The protocol name.
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
HttpInGate()
          Creates a new instance.
 
Method Summary
protected  Ticket createTicket(javax.servlet.http.HttpServletRequest request)
          Creates a return ticket.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Writes a simple page that allows the user to send an agent via web browser.
 void doPost(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          This method receives agents from the Outgate.
protected  InGate getInGate()
          Returns a reference to the ingate.
 long getMaximumSize()
          Returns the maximum size an agent is allowed to be.
 String getServletInfo()
           
 boolean isEnabled()
           
 URL localURL()
          Returns the URL of this server or null if it cannot be retrieved.
 String protocol()
           
 void setEnabled(boolean on)
          Enables and disables this gateway temporarily.
 void setMaximumSize(long size)
          Sets the maximum size of an acceptable agent.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIME_TYPE

public static final String MIME_TYPE
The mimetype that an agent has to be that it is accepted by the ingate.

See Also:
Constant Field Values

MAX_SIZE

public static final long MAX_SIZE
The maximum size of an Agent in bytes (initial value).

See Also:
Constant Field Values

BUF_SIZE

public static final int BUF_SIZE
The buffer size.

See Also:
Constant Field Values

PROTOCOL

public static final String PROTOCOL
The protocol name.

See Also:
Constant Field Values

DEPEND_

private static final String[] DEPEND_
The dependencies to other objects in the global Environment.


lastFetch_

private long lastFetch_
The time of the last fetch of the ingate.


ingate_

private InGate ingate_
The private reference to the ingate.


maxSize_

private long maxSize_
The maximum size of an agent (current value).


lock_

private Object lock_
The lock object that is needed when getting the ingate.


enabled_

private boolean enabled_
Enable/disable the gate.

Constructor Detail

HttpInGate

public HttpInGate()
Creates a new instance.

Method Detail

getMaximumSize

public long getMaximumSize()
Returns the maximum size an agent is allowed to be.

Specified by:
getMaximumSize in interface AgentGateway.In
Returns:
the maximum size an agent may be to be accepted.

setMaximumSize

public void setMaximumSize(long size)
Sets the maximum size of an acceptable agent.

Specified by:
setMaximumSize in interface AgentGateway.In
Parameters:
size - the new size.

localURL

public URL localURL()
Returns the URL of this server or null if it cannot be retrieved.

Specified by:
localURL in interface AgentGateway.In
Returns:
the local URL

setEnabled

public void setEnabled(boolean on)
Enables and disables this gateway temporarily.

Specified by:
setEnabled in interface AgentGateway
Parameters:
on - true if the gateway shall be enabled and false otherwise.

isEnabled

public boolean isEnabled()
Specified by:
isEnabled in interface AgentGateway
Returns:
true if this gateway is enabled.

protocol

public String protocol()
Specified by:
protocol in interface AgentGateway
Returns:
The lower case IN protocol name of the protocol supported by the gateway.

getInGate

protected InGate getInGate()
Returns a reference to the ingate. This is a convenience method which only re-fetches the ingate reference if it changed since the last fetch (which is not likely to happen anyway).

Returns:
The reference to the ingate.

createTicket

protected Ticket createTicket(javax.servlet.http.HttpServletRequest request)
Creates a return ticket.

FIX ME: port

Parameters:
request - the HttpServletRequest passed to the servlet.
Returns:
the ticket.

doGet

public void doGet(javax.servlet.http.HttpServletRequest req,
                  javax.servlet.http.HttpServletResponse res)
           throws javax.servlet.ServletException,
                  IOException
Writes a simple page that allows the user to send an agent via web browser.

Throws:
javax.servlet.ServletException
IOException

doPost

public void doPost(javax.servlet.http.HttpServletRequest req,
                   javax.servlet.http.HttpServletResponse res)
            throws javax.servlet.ServletException,
                   IOException
This method receives agents from the Outgate.

Throws:
javax.servlet.ServletException
IOException

getServletInfo

public String getServletInfo()
Specified by:
getServletInfo in interface javax.servlet.Servlet


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.