summaryrefslogtreecommitdiff
path: root/java/src/CreationStrategy.java
blob: 787e0c22c24f39610f4bd39e5578dd4340884f4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*************************************************
 *
 * = PACKAGE
 *    ACE.Connection
 *
 * = FILENAME
 *    CreationStrategy.java
 *
 *@author Prashant Jain
 *
 *************************************************/
package ACE.Connection;

/**
 * <hr>
 * <h2>SYNOPSIS</h2>
 *<blockquote>
 * Defines the interface for specifying a creation strategy for a
 * <a href="ACE.Connection.SvcHandler.html#_top_"><tt>SvcHandler</tt></a> to the
 * <a href="ACE.Connection.StrategyAcceptor.html#_top_"><tt>StrategyAcceptor</tt></a>.
 *</blockquote>
 *
 * <p><b>DESCRIPTION</b><br>
 *<blockquote>
 *     The default behavior is to make a new SvcHandler.  However,
 *     subclasses can override this strategy to perform SvcHandler
 *     creation in any way that they like (such as creating subclass
 *     instances of SvcHandler, using a singleton, dynamically
 *     linking the handler, etc.).
 *</blockquote>
 *
 *@see SvcHandler,StrategyAcceptor,AcceptStrategy,ActivateStrategy
 */
public class CreationStrategy
{
  /**
   * Create an instance of Creation Strategy.
   *@param handlerFactory Svc Handler factory that is used to create
   * an instance of a Svc Handler
   */
  public CreationStrategy (Class handlerFactory)
  {
    this.handlerFactory_ = handlerFactory;
  }

  /**
   * Create a new SvcHandler. Note that subclasses should override
   * this method to provide a new creation strategy.
   *@return reference to a new instance of the SvcHandler (or subclass)
   *@exception InstantiationException Unable to instantiate.
   *@exception IllegalAccessException No handler factory available.
   */
  public SvcHandler makeSvcHandler () throws InstantiationException, 
    IllegalAccessException
    {
      // Create a new Svc_Handler
      return (SvcHandler) handlerFactory_.newInstance ();
    }

  private Class handlerFactory_;
}