KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > management > Controller


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Jeff Mesnil.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.controller.management;
23
24 import java.io.IOException JavaDoc;
25 import java.rmi.RemoteException JavaDoc;
26 import java.util.List JavaDoc;
27
28 import javax.management.NotCompliantMBeanException JavaDoc;
29
30 import org.continuent.sequoia.common.exceptions.ControllerException;
31 import org.continuent.sequoia.common.i18n.Translate;
32 import org.continuent.sequoia.common.jmx.mbeans.ControllerMBean;
33 import org.continuent.sequoia.common.log.Trace;
34 import org.continuent.sequoia.controller.jmx.AbstractStandardMBean;
35
36 /**
37  * This class defines the management interface of a Controller
38  *
39  * @author <a HREF="mailto:jeff@emicnetworks.com">Jeff Mesnil</a>
40  * @version 1.0
41  */

42 public class Controller extends AbstractStandardMBean
43     implements
44       ControllerMBean
45 {
46
47   private org.continuent.sequoia.controller.core.Controller controller;
48   static Trace endUserLogger = Trace
49                                                                               .getLogger("org.continuent.sequoia.enduser");
50
51   /**
52    * Creates a new <code>Controller</code> object based on a
53    * <code>managedController</code>
54    *
55    * @param managedController the controller to manage
56    * @throws NotCompliantMBeanException if this instance is not a compliant
57    * MBean
58    */

59   public Controller(
60       org.continuent.sequoia.controller.core.Controller managedController)
61       throws NotCompliantMBeanException JavaDoc
62   {
63     super(ControllerMBean.class);
64     this.controller = managedController;
65   }
66
67   /**
68    * @see org.continuent.sequoia.controller.jmx.AbstractStandardMBean#getAssociatedString()
69    */

70   public String JavaDoc getAssociatedString()
71   {
72     return "controller"; //$NON-NLS-1$
73
}
74
75   /**
76    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#addVirtualDatabases(java.lang.String)
77    */

78   public void addVirtualDatabases(String JavaDoc xml) throws ControllerException
79   {
80     try
81     {
82       endUserLogger.info(Translate.get("controller.add.virtualdatabases"));
83       controller.addVirtualDatabases(xml);
84       endUserLogger.info(Translate.get("controller.virtualdatabases.added"));
85     }
86     catch (ControllerException ex)
87     {
88       endUserLogger.error(ex.getMessage());
89       throw ex;
90     }
91   }
92
93   /**
94    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#getVirtualDatabaseNames()
95    */

96   public List JavaDoc getVirtualDatabaseNames()
97   {
98     return controller.getVirtualDatabaseNames();
99   }
100
101   /**
102    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#addDriver(byte[])
103    */

104   public void addDriver(byte[] bytes) throws Exception JavaDoc
105   {
106     try
107     {
108       controller.addDriver(bytes);
109     }
110     catch (ControllerException e)
111     {
112       throw e;
113     }
114   }
115
116   /**
117    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#saveConfiguration()
118    */

119   public String JavaDoc saveConfiguration() throws Exception JavaDoc
120   {
121     String JavaDoc msg = controller.saveConfiguration();
122     endUserLogger.info(msg);
123     return msg;
124   }
125
126   /**
127    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#shutdown()
128    */

129   public void shutdown() throws ControllerException
130   {
131     try
132     {
133       endUserLogger.info(Translate.get("controller.shutdown", this
134           .getControllerName()));
135       controller.shutdown();
136       endUserLogger.info(Translate.get("controller.shutdown.completed", this
137           .getControllerName()));
138     }
139     catch (ControllerException ex)
140     {
141       endUserLogger.error(ex.getMessage());
142       throw ex;
143     }
144   }
145
146   /**
147    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#getBacklogSize()
148    */

149   public int getBacklogSize()
150   {
151     return controller.getBacklogSize();
152   }
153
154   /**
155    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#getControllerName()
156    */

157   public String JavaDoc getControllerName()
158   {
159     return controller.getControllerName();
160   }
161
162   /**
163    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#getJmxName()
164    */

165   public String JavaDoc getJmxName()
166   {
167     return controller.getJmxName();
168   }
169
170   /**
171    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#getPortNumber()
172    */

173   public int getPortNumber()
174   {
175     return controller.getJdbcPortNumber();
176   }
177
178   /**
179    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#getVersionNumber()
180    */

181   public String JavaDoc getVersionNumber() throws RemoteException JavaDoc
182   {
183     return controller.getVersionNumber();
184   }
185
186   /**
187    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#getXml()
188    */

189   public String JavaDoc getXml()
190   {
191     return controller.getXml();
192   }
193
194   /**
195    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#isShuttingDown()
196    */

197   public boolean isShuttingDown()
198   {
199     return controller.isShuttingDown();
200   }
201
202   /**
203    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#setBacklogSize(int)
204    */

205   public void setBacklogSize(int size)
206   {
207     controller.setBacklogSize(size);
208   }
209
210   /**
211    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#refreshLogConfiguration()
212    */

213   public void refreshLogConfiguration() throws ControllerException
214   {
215     try
216     {
217       controller.refreshLogConfiguration();
218       endUserLogger.info(Translate.get("controller.refresh.log.success"));
219     }
220     catch (ControllerException ex)
221     {
222       endUserLogger.error(ex.getMessage());
223       throw ex;
224     }
225   }
226
227   /**
228    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#updateLogConfigurationFile(java.lang.String)
229    */

230   public void updateLogConfigurationFile(String JavaDoc newConfiguration)
231       throws IOException JavaDoc, ControllerException
232   {
233     try
234     {
235       controller.updateLogConfigurationFile(newConfiguration);
236       endUserLogger.info(Translate.get("controller.update.log.success"));
237     }
238     catch (ControllerException ex)
239     {
240       endUserLogger.error(ex.getMessage());
241       throw ex;
242     }
243     catch (IOException JavaDoc ioex)
244     {
245       endUserLogger.error(ioex.getMessage());
246       throw ioex;
247     }
248   }
249
250   /**
251    * @see org.continuent.sequoia.common.jmx.mbeans.ControllerMBean#viewLogConfigurationFile()
252    */

253   public String JavaDoc viewLogConfigurationFile() throws IOException JavaDoc
254   {
255     return controller.viewLogConfigurationFile();
256   }
257 }
258
Popular Tags