KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SOFA > SOFAnode > Util > BehaviorProtocolCheckerFactory


1 /* $Id: BehaviorProtocolCheckerFactory.java,v 1.2 2004/09/10 14:16:48 hnetynka Exp $ */
2 package SOFA.SOFAnode.Util;
3
4 /**
5  * A factory for getting a checker implementing interface for behavior protocol conformance checker.
6  *
7  * @author Stanislav Visnovsky, modified by Petr Hnetynka
8  * @version 2.0.0
9  * @see BehaviorProtocolChecker
10 */

11
12 public class BehaviorProtocolCheckerFactory {
13
14 /**
15   * Creates and returns an implementation of BehaviorProtocolChecker intarface.
16   * The <em>className</em> parameter specifies the name of the class that implements
17   * BehaviorProtocolChecker interface. If the specified checker cannot be created or
18   * the parameter is <em>null</em>, an instance of the default implementation is returned.
19   *
20   * @param className class name of the protocol checker
21   * @return protocol checker instance
22   */

23   public static BehaviorProtocolChecker getChecker(String JavaDoc className) {
24     if (className == null)
25       return new checker();
26     Class JavaDoc cl = null;
27     try {
28       cl = BehaviorProtocolCheckerFactory.class.forName(className);
29     } catch (ClassNotFoundException JavaDoc e) {
30       return new checker();
31     }
32     BehaviorProtocolChecker ret = null;
33     try {
34       ret = (BehaviorProtocolChecker) cl.newInstance();
35     } catch (Exception JavaDoc e) {
36       return new checker();
37     }
38     return ret;
39   }
40 }
41
Popular Tags