KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > monitor > WSMonitorLifeCycleFactory


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.admin.monitor;
24
25
26 /**
27  * This SPI mechanism allows loaders to call web services Management module to
28  * initialize web service endpoints for monitoring and management. JSR 77 and
29  * Monitoring MBeans are created at this time.
30  * <br>
31  */

32 public class WSMonitorLifeCycleFactory {
33
34     /**
35      * WSMonitorLifeCycleFactory is private. Only one sigleton object is available
36      * is available through getInstance method.
37      */

38     private WSMonitorLifeCycleFactory () {
39     }
40
41     /**
42      * Returns the WSMonitorLifeCycleFactory singleton.
43      *
44      * @return the WSMonitorLifeCycleFactory instance
45      */

46     public static WSMonitorLifeCycleFactory getInstance() {
47         return lcf;
48     }
49
50     /**
51      * Returns the WSLifeCycleProvider instance. If
52      * -Dwsmgmt.lifecycle.provider.classname is defined,that class is loaded and
53      * returned as the WSLifeCycle provider. If there is an error finding or
54      * loading the class, the default provider class is returned.
55      *
56      * @return WSMonitorLifeCycleProvider implementation
57      * @throws IllegalAccessException - if the class or its nullary constructor
58      * is not accessible.
59      * InstantiationException - if this Class represents an abstract
60      * class,an interface, an array class, a
61      * primitive type, or void; or if the class * has no nullary constructor; or if the
62      * instantiation fails for some other
63      * reason.
64      * ClassCastException - if the provider implementation specified
65      * by -D does not implement the com.sun.
66      * enterprise.admin.wsmgmt.repository.spi.
67      * RepositoryProvider interface.
68      * ClassNotFoundException - if the provider implementation specified * by -D does could not be found by the
69      * class loader.
70      */

71     public WSMonitorLifeCycleProvider getWSMonitorLifeCycleProvider()
72       throws InstantiationException JavaDoc, IllegalAccessException JavaDoc, ClassCastException JavaDoc,
73         ClassNotFoundException JavaDoc {
74        String JavaDoc implName = System.getProperty(WSMGMT_PROVIDER_NAME);
75        if ( implName == null ) {
76             Class JavaDoc repClass = Class.forName(WSMGMT_DEFAULT_PROVIDER);
77             Object JavaDoc o = repClass.newInstance();
78             return (WSMonitorLifeCycleProvider)o;
79        } else {
80             Class JavaDoc repClass = Class.forName(implName);
81             Object JavaDoc o = repClass.newInstance();
82             return (WSMonitorLifeCycleProvider)o;
83        }
84     }
85
86     /** Environment property name to customize Repository Provider */
87     public static final String JavaDoc WSMGMT_PROVIDER_NAME =
88         "wsmgmt.lifecycle.provider.classname";
89
90     public static final String JavaDoc WSMGMT_DEFAULT_PROVIDER =
91         "com.sun.enterprise.admin.wsmgmt.lifecycle.AppServWSMonitorLifeCycleProvider";
92
93     // PRIVATE VARS
94
static WSMonitorLifeCycleFactory lcf = new WSMonitorLifeCycleFactory();
95 }
96
Popular Tags