KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > dav > server > apm > APMFactory


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19
20 package org.openharmonise.dav.server.apm;
21
22 import org.openharmonise.rm.config.*;
23
24 /**
25  * Factory class which can return the singleton instance of the APM.
26  * The APM implementation to return is taken from the configuration
27  * property 'WEBDAV_APM'.
28  *
29  *
30  * @author Michael Bell
31  * @version $Revision: 1.1 $
32  *
33  */

34 public class APMFactory {
35
36
37     private static final String JavaDoc PNAME_WEBDAV_APM = "WEBDAV_APM";
38     private static AuxillaryProcessManager m_apm = null;
39
40     /**
41      *
42      */

43     private APMFactory() {
44         super();
45     }
46     
47     /**
48      * Returns singleton instance of APM
49      *
50      * @return
51      * @throws APMException
52      */

53     static public AuxillaryProcessManager getAPM() throws APMException {
54         
55         try {
56             if(m_apm == null) {
57             
58                 String JavaDoc sAuxillaryClass =
59                                     ConfigSettings
60                                         .getProperty(
61                                         PNAME_WEBDAV_APM);
62             
63                 if (sAuxillaryClass != null && sAuxillaryClass.length() > 0) {
64                     Class JavaDoc classAuxillary = Class.forName(sAuxillaryClass);
65                     m_apm =
66                         (AuxillaryProcessManager) classAuxillary.newInstance();
67                 }
68             }
69         } catch (ConfigException e) {
70             throw new APMException(e);
71         } catch (ClassNotFoundException JavaDoc e) {
72             throw new APMException(e);
73         } catch (InstantiationException JavaDoc e) {
74             throw new APMException(e);
75         } catch (IllegalAccessException JavaDoc e) {
76             throw new APMException(e);
77         }
78         
79         return m_apm;
80     }
81
82 }
83
Popular Tags