1 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 29 public class CompiereCtrl extends ServiceMBeanSupport 30 implements CompiereCtrlMBean 31 { 32 33 36 public CompiereCtrl() 37 { 38 } 40 41 private String m_dataSourceName; 42 43 47 public String getName() 48 { 49 return NAME; 50 } 52 53 54 58 protected void createService() throws Exception 59 { 60 Ini.setClient (false); 61 62 System.setProperty("javax.xml.parsers.DocumentBuilderFactory", 64 "org.apache.crimson.jaxp.DocumentBuilderFactoryImpl"); System.setProperty("javax.xml.parsers.SAXParserFactory", 67 "org.apache.crimson.jaxp.SAXParserFactoryImpl"); 70 } 72 76 protected void startService() throws Exception 77 { 78 Compiere.startupServer(null); 79 } 81 84 protected void stopService() 85 { 86 } 88 91 protected void destroyService() 92 { 93 } 95 96 97 101 public String getCompiereHome() 102 { 103 return Ini.getCompiereHome(); 104 } 106 110 public String getCompiereSummary() 111 { 112 return Compiere.getSummary(); 113 } 115 119 public String getDatabaseSummary() 120 { 121 StringBuffer sb = new StringBuffer (); 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 } 137 141 public String getDataSourceName() 142 { 143 return m_dataSourceName; 144 } 146 150 public void setDataSourceName (String dataSourceName) 151 { 152 m_dataSourceName = dataSourceName; 153 } 155 159 public void setTraceLevel (int traceLevel) 160 { 161 Log.setTraceLevel(traceLevel); 162 Ini.setProperty(Ini.P_DEBUGLEVEL, traceLevel); 163 Ini.saveProperties(false); 164 } 166 170 public int getTraceLevel () 171 { 172 return Log.getTraceLevel(); 173 } 175 176 180 public String 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 192 public String toString() 193 { 194 StringBuffer sb = new StringBuffer ("Ctrl["); 195 sb.append(""); 196 sb.append("]"); 197 return sb.toString(); 198 } 200 } | Popular Tags |