KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hero > util > BonitaConfig


1 package hero.util;
2
3 /**
4 *
5 * Bonita
6 * Copyright (C) 1999 Bull S.A.
7 * Bull 68 route de versailles 78434 Louveciennes Cedex France
8 * Further information: bonita@objectweb.org
9 *
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or any later version.
14 *
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
23 * USA
24 *
25 *
26 --------------------------------------------------------------------------
27 * $Id: BonitaConfig.java,v 1.3 2005/03/18 14:55:05 mvaldes Exp $
28 *
29 --------------------------------------------------------------------------
30 */

31
32 import java.util.List JavaDoc;
33
34 import javax.management.MBeanServer JavaDoc;
35 import javax.management.MBeanServerFactory JavaDoc;
36 import javax.management.ObjectName JavaDoc;
37
38 public class BonitaConfig {
39     
40     private ObjectName JavaDoc config;
41     private MBeanServer JavaDoc server;
42     private static BonitaConfig bc = null; // Singleton pattern
43

44     public BonitaConfig() throws HeroException{
45         try{
46             config = new ObjectName JavaDoc("jonas:type=service,name=BonitaConfigService");
47             List JavaDoc list = MBeanServerFactory.findMBeanServer(null);
48             server = (MBeanServer JavaDoc) list.iterator().next();
49         } catch (Exception JavaDoc e) {e.printStackTrace();
50             throw new HeroException(e.getMessage());
51         }
52     }
53     
54     public static BonitaConfig getInstance() throws HeroException{
55         if ( bc == null) {
56             bc = new BonitaConfig();
57         }
58         return bc;
59     }
60         
61     public boolean getProcessJMS(String JavaDoc projectName) throws HeroException
62     {
63         /*try {
64             Boolean value =(Boolean) server.invoke(config, "getProcessJMS", new Object[] { projectName},
65                     new String[] {"".getClass().getName()});
66             return value.booleanValue();
67         } catch (Exception e) {
68             throw new HeroException(e.getMessage());
69         }*/

70         return true;
71     }
72     
73     public boolean getProcessLog(String JavaDoc projectName) throws HeroException
74     {
75         /*try {
76             Boolean value =(Boolean) server.invoke(config, "getProcessLog", new Object[] { projectName},
77                     new String[] {"".getClass().getName()});
78             return value.booleanValue();
79         } catch (Exception e) {
80             throw new HeroException(e.getMessage());
81         }*/

82         return true;
83     }
84     
85     public boolean getProcessTrace(String JavaDoc projectName) throws HeroException
86     {
87         /*try {
88             Boolean value =(Boolean) server.invoke(config, "getProcessTrace", new Object[] { projectName},
89                     new String[] {"".getClass().getName()});
90             return value.booleanValue();
91         } catch (Exception e) {
92             throw new HeroException(e.getMessage());
93         }*/

94         return true;
95     }
96     
97     public String JavaDoc getPocessLogLevel(String JavaDoc projectName) throws HeroException
98     {
99         /*try {
100             String value =(String) server.invoke(config, "getProcessLogLevel", new Object[] { projectName},
101                     new String[] {"".getClass().getName()});
102             return value;
103         } catch (Exception e) {
104             throw new HeroException(e.getMessage());
105         }*/

106         return hero.interfaces.Constants.DEBUG;
107     }
108     
109     public String JavaDoc getPocessTraceLevel(String JavaDoc projectName) throws HeroException
110     {
111         /*try {
112             String value =(String) server.invoke(config, "getProcessTraceLevel", new Object[] { projectName},
113                     new String[] {"".getClass().getName()});
114             return value;
115         } catch (Exception e) {
116             throw new HeroException(e.getMessage());
117         }*/

118         return hero.interfaces.Constants.DEBUG;
119     }
120     
121     public String JavaDoc getPocessHistoric(String JavaDoc projectName) throws HeroException
122     {
123         /*try {
124             String value =(String) server.invoke(config, "getProcessHistoric", new Object[] { projectName},
125                     new String[] {"".getClass().getName()});
126             return value;
127         } catch (Exception e) {
128             throw new HeroException(e.getMessage());
129         }*/

130         return hero.interfaces.Constants.TRANSFER;
131     }
132     
133     public void updateJMS(boolean jms) throws HeroException
134     {
135         try {
136             server.invoke(config, "updateJMS", new Object JavaDoc[] {new Boolean JavaDoc(jms)},new String JavaDoc[] {"boolean"});
137         } catch (Exception JavaDoc e) {
138             throw new HeroException(e.getMessage());
139         }
140     }
141     
142 }
Popular Tags