Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/argouml/configuration/ConfigurationFactory.java


1   // Copyright (c) 1996-2001 The Regents of the University of California. All
2   // Rights Reserved. Permission to use, copy, modify, and distribute this
3   // software and its documentation without fee, and without a written
4   // agreement is hereby granted, provided that the above copyright notice
5   // and this paragraph appear in all copies.  This software program and
6   // documentation are copyrighted by The Regents of the University of
7   // California. The software program and documentation are supplied "AS
8   // IS", without any accompanying services from The Regents. The Regents
9   // does not warrant that the operation of the program will be
10  // uninterrupted or error-free. The end-user understands that the program
11  // was developed for research purposes and is advised not to rely
12  // exclusively on the program for any reason.  IN NO EVENT SHALL THE
13  // UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
14  // SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
15  // ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
16  // THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
17  // SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
18  // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
20  // PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
21  // CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
22  // UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
23  
24  //
25  //  This code is originally from the open source UML editor argouml.
26  //  Information on argouml can be found at: http://argouml.tigris.org/
27  //
28  //  The original author is Thierry Lach  
29  //
30  //  Adopted by Matthieu Cormier on Fri June 27 2003.
31  
32  package org.argouml.configuration;
33  
34  import java.io.*;
35  import java.util.*;
36  import java.net.*;
37  
38  /** A factory object that provides configuration information.
39   * 
40   */
41  public class ConfigurationFactory
42  {
43    /** The only occurance of the configuration factory.
44     */
45    private static final ConfigurationFactory SINGLETON;
46  
47    /** The active configuration handler.
48     */
49    private static ConfigurationHandler _handler = new ConfigurationProperties();
50  
51    /** Private constructor to not allow instantiation.
52     */
53    private ConfigurationFactory() {
54       // Argo.log.debug("Constructor");
55    }
56  
57    /** Returns the instance of the singleton.
58     *
59     *  @return the only instance of the configuration factory.
60     */
61    public static final ConfigurationFactory getInstance()
62    {
63        return SINGLETON;
64    }
65  
66    /** Returns the customized configuration for the user.
67     *
68     *  @return a concrete class which extends ConfigurationHandler and
69     *  can be used to access and manipulate the configuration.
70     */
71    public ConfigurationHandler getConfigurationHandler() {
72        // needs-more-work:  Allow other configuration handlers.
73        return _handler;
74    }
75  
76      /**
77       * Initialize the factory singleton based on system
78       * property argo.ConfigurationFactory, or use the default
79       * if not set.
80       */
81      static {
82          String name = System.getProperty("argo.ConfigurationFactory");
83    ConfigurationFactory newFactory = null;
84    if (name != null) {
85              try {
86                  newFactory = (ConfigurationFactory)Class.forName(name).newInstance();
87              }
88        catch(Exception e) {
89            System.out.println ("Can't create configuration factory " +
90                                name + ", using default factory");
91              }
92    }
93    if (newFactory == null)
94      newFactory = new ConfigurationFactory();
95    SINGLETON = newFactory;
96      }
97  
98  } /* end class ConfigurationFactory */