View Javadoc

1   /*
2    * @(#) Handler.java Mar 2, 2004
3    * 
4    * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
5    * Delft, the Netherlands. All rights reserved.
6    * 
7    * See for project information <a href="http://www.simulation.tudelft.nl/">
8    * www.simulation.tudelft.nl </a>.
9    * 
10   * The source code and binary code of this software is proprietary information
11   * of Delft University of Technology.
12   */
13  
14  package nl.tudelft.simulation.content;
15  
16  import java.io.Serializable;
17  import java.rmi.RemoteException;
18  
19  import nl.tudelft.simulation.actor.ActorInterface;
20  import nl.tudelft.simulation.jstats.streams.StreamInterface;
21  import nl.tudelft.simulation.logger.Logger;
22  
23  /***
24   * An abstract definition of a handler, providing a default stream and a
25   * constructor method. <br>
26   * <br>
27   * Copyright (c) 2003-2005 Delft University of Technology, Jaffalaan 5, 2628 BX
28   * Delft, the Netherlands. All rights reserved.
29   * 
30   * See for project information <a href="http://www.simulation.tudelft.nl/">
31   * www.simulation.tudelft.nl </a>.
32   * 
33   * The source code and binary code of this software is proprietary information
34   * of Delft University of Technology.
35   * 
36   * @author <a href="http://www.tbm.tudelft.nl/webstaf/peterja/index.htm">Peter
37   *         Jacobs </a>, <a
38   *         href="mailto:s.p.a.vanhouten@tbm.tudelft.nl">Stijn-Pieter van Houten
39   *         </a>, <a
40   *         href="http://www.tbm.tudelft.nl/webstaf/alexandv/index.htm">Alexander
41   *         Verbraeck </a>
42   * @version $$Revision: 1.3 $$ $$Date: 2005/04/08 11:29:12 $$
43   */
44  public abstract class Handler implements HandlerInterface
45  {
46  	/*** the serial version uid */
47  	private static final long serialVersionUID = 12L;
48  
49  	/*** the owner of this handler */
50  	protected ActorInterface owner = null;
51  
52  	/*** the default stream to use for the time delays */
53  	protected StreamInterface stream = null;
54  
55  	/***
56  	 * constructs a new Handler
57  	 * 
58  	 * @param owner the owner of this handler
59  	 */
60  	public Handler(final ActorInterface owner)
61  	{
62  		super();
63  		this.owner = owner;
64  		try
65  		{
66  			this.stream = owner.getSimulator().getReplication().getStream(
67  					"default");
68  		} catch (RemoteException exception)
69  		{
70  			Logger.severe(this, "<init>", exception);
71  		}
72  	}
73  
74  	/***
75  	 * @return Returns the default stream.
76  	 */
77  	public StreamInterface getStream()
78  	{
79  		return this.stream;
80  	}
81  
82  	/***
83  	 * @see nl.tudelft.simulation.content.HandlerInterface#handleContent(java.io.Serializable)
84  	 */
85  	public abstract boolean handleContent(final Serializable content);
86  }