KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > server > CompiereCtrl


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2002 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.server;
15
16 import java.sql.*;
17
18 import org.jboss.system.ServiceMBeanSupport;
19
20 import org.compiere.*;
21 import org.compiere.util.*;
22
23 /**
24  * Compiere Controller & Status Info for Dialnostics only
25  *
26  * @author Jorg Janke
27  * @version $Id: CompiereCtrl.java,v 1.7 2003/10/04 03:59:00 jjanke Exp $
28  */

29 public class CompiereCtrl extends ServiceMBeanSupport
30     implements CompiereCtrlMBean
31 {
32
33     /**
34      * Cosntructor
35      */

36     public CompiereCtrl()
37     {
38     } // CompiereCtrl
39

40     /** DataSource Name */
41     private String JavaDoc m_dataSourceName;
42
43     /**
44      * Get Name
45      * @return Name
46      */

47     public String JavaDoc getName()
48     {
49         return NAME;
50     } // getName
51

52     /*************************************************************************/
53
54     /**
55      * Create Service
56      * @throws Exception
57      */

58     protected void createService() throws Exception JavaDoc
59     {
60         Ini.setClient (false);
61
62         // Set XML environment explicitly to standard 1.4.0 distribution
63
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
64             "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl"); // System Default
65
// "org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
66
System.setProperty("javax.xml.parsers.SAXParserFactory",
67             "org.apache.crimson.jaxp.SAXParserFactoryImpl"); // System Default
68
// "org.apache.xerces.jaxp.SAXParserFactoryImpl");
69

70     } // createService
71

72     /**
73      * Start Service
74      * @throws Exception
75      */

76     protected void startService() throws Exception JavaDoc
77     {
78         Compiere.startupServer(null);
79     } // startService
80

81     /**
82      * Stop Service
83      */

84     protected void stopService()
85     {
86     } // stopService
87

88     /**
89      * Destroy Service
90      */

91     protected void destroyService()
92     {
93     } // destroy Service
94

95     /*************************************************************************/
96
97     /**
98      * Get Compiere Home
99      * @return Compiere Home
100      */

101     public String JavaDoc getCompiereHome()
102     {
103         return Ini.getCompiereHome();
104     } // getCompiereHome
105

106     /**
107      * Get Compiere Summary
108      * @return Compiere Summary
109      */

110     public String JavaDoc getCompiereSummary()
111     {
112         return Compiere.getSummary();
113     } // getCompiereSummary
114

115     /**
116      * Get Database Summary
117      * @return Database Summary
118      */

119     public String JavaDoc getDatabaseSummary()
120     {
121         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
122         try
123         {
124             DatabaseMetaData dbmd = DB.getConnectionRW().getMetaData();
125             sb.append("Driver=").append(dbmd.getDriverName())
126                 .append(" Version: ").append(dbmd.getDriverVersion());
127             sb.append(" - Database=").append(dbmd.getDatabaseProductName())
128                 .append(" Version: ").append(dbmd.getDatabaseProductVersion());
129         }
130         catch (SQLException ex)
131         {
132             sb.append(ex);
133         }
134         return sb.toString();
135     } // getDatabaseSummary
136

137     /**
138      * Get DataSource Name
139      * @return DataSource Name
140      */

141     public String JavaDoc getDataSourceName()
142     {
143         return m_dataSourceName;
144     } // getDataSourceName
145

146     /**
147      * Set DataSource Name
148      * @param dataSourceName DataSource Name
149      */

150     public void setDataSourceName (String JavaDoc dataSourceName)
151     {
152         m_dataSourceName = dataSourceName;
153     } // setDataSourceName
154

155     /**
156      * Set Log Trace Level
157      * @param traceLevel trace level
158      */

159     public void setTraceLevel (int traceLevel)
160     {
161         Log.setTraceLevel(traceLevel);
162         Ini.setProperty(Ini.P_DEBUGLEVEL, traceLevel);
163         Ini.saveProperties(false);
164     } // setTraceLevel
165

166     /**
167      * Get Log Trace Level
168      * @return trace level
169      */

170     public int getTraceLevel ()
171     {
172         return Log.getTraceLevel();
173     } // getTraceLevel
174

175
176     /**
177      * Get Log Level Info
178      * @return log Level Info
179      */

180     public String JavaDoc getLogLevel()
181     {
182         org.apache.log4j.Logger root = org.apache.log4j.Logger.getRootLogger();
183         return "Effective=" + root.getEffectiveLevel() + ", Level=" + root.getLevel();
184     }
185
186     /*************************************************************************/
187
188     /**
189      * String Representation
190      * @return info
191      */

192     public String JavaDoc toString()
193     {
194         StringBuffer JavaDoc sb = new StringBuffer JavaDoc("Ctrl[");
195         sb.append("");
196         sb.append("]");
197         return sb.toString();
198     } // toString
199

200 } // Ctrl
201
Popular Tags