Lines 36-41
Link Here
|
36 |
import org.apache.catalina.core.StandardContext; |
36 |
import org.apache.catalina.core.StandardContext; |
37 |
import org.apache.catalina.core.StandardEngine; |
37 |
import org.apache.catalina.core.StandardEngine; |
38 |
import org.apache.catalina.core.StandardHost; |
38 |
import org.apache.catalina.core.StandardHost; |
|
|
39 |
import org.apache.catalina.core.StandardServer; |
39 |
import org.apache.catalina.core.StandardService; |
40 |
import org.apache.catalina.core.StandardService; |
40 |
import org.apache.catalina.loader.WebappLoader; |
41 |
import org.apache.catalina.loader.WebappLoader; |
41 |
import org.apache.catalina.realm.DataSourceRealm; |
42 |
import org.apache.catalina.realm.DataSourceRealm; |
Lines 51-56
Link Here
|
51 |
import org.apache.catalina.valves.RemoteHostValve; |
52 |
import org.apache.catalina.valves.RemoteHostValve; |
52 |
import org.apache.catalina.valves.ValveBase; |
53 |
import org.apache.catalina.valves.ValveBase; |
53 |
import org.apache.tomcat.util.modeler.BaseModelMBean; |
54 |
import org.apache.tomcat.util.modeler.BaseModelMBean; |
|
|
55 |
import org.apache.tomcat.util.modeler.Registry; |
54 |
|
56 |
|
55 |
|
57 |
|
56 |
/** |
58 |
/** |
Lines 61-67
Link Here
|
61 |
* @version $Revision$ $Date$ |
63 |
* @version $Revision$ $Date$ |
62 |
*/ |
64 |
*/ |
63 |
|
65 |
|
64 |
public class MBeanFactory extends BaseModelMBean { |
66 |
public class MBeanFactory{ |
65 |
|
67 |
|
66 |
private static final org.apache.juli.logging.Log log = |
68 |
private static final org.apache.juli.logging.Log log = |
67 |
org.apache.juli.logging.LogFactory.getLog(MBeanFactory.class); |
69 |
org.apache.juli.logging.LogFactory.getLog(MBeanFactory.class); |
Lines 232-237
Link Here
|
232 |
|
234 |
|
233 |
} |
235 |
} |
234 |
|
236 |
|
|
|
237 |
private Server getServer(ObjectName oname) throws Exception{ |
238 |
Server server=null; |
239 |
|
240 |
if(container instanceof Service){ |
241 |
throw new Exception("Base container is a Service."); |
242 |
} else if(container instanceof Server){ |
243 |
server=(Server)this.container; |
244 |
} |
245 |
|
246 |
StandardServer standardServer=null; |
247 |
if(server instanceof StandardServer){ |
248 |
standardServer = (StandardServer)server; |
249 |
} |
250 |
|
251 |
if(oname != null && standardServer != null |
252 |
&& !oname.getDomain().equals(standardServer.getObjectName().getDomain())){ |
253 |
throw new Exception("Server with the domain is not found"); |
254 |
} |
255 |
|
256 |
return server; |
257 |
} |
258 |
|
259 |
/** |
260 |
* Creates a new StandardService. |
261 |
* |
262 |
* @param parent MBean Name of the associated parent component (Server) |
263 |
* @param name Name of this service |
264 |
* @param container Name of the associated container (Engine) instance with this service |
265 |
* @param domain Domain name for the container instance |
266 |
* @param defaultHost Name of the default host to be used in the Engine |
267 |
* @param baseDir Base directory value for Engine |
268 |
* |
269 |
* @exception Exception if an MBean cannot be created or registered |
270 |
*/ |
271 |
public String createStandardService(String parent, String name, |
272 |
String container, String domain, String defaultHost, String baseDir) throws Exception{ |
273 |
|
274 |
ObjectName pname = new ObjectName(parent); |
275 |
Server server=getServer(pname); |
276 |
StandardService service = new StandardService(); |
277 |
service.setName(name); |
278 |
|
279 |
ObjectName oname; |
280 |
if(domain != null){ |
281 |
oname=new ObjectName(domain + ":type=Service,serviceName="+name); |
282 |
}else{ |
283 |
oname=new ObjectName(pname.getDomain() + ":type=Service,serviceName="+name); |
284 |
} |
285 |
|
286 |
service.preRegister(Registry.getRegistry(null, null).getMBeanServer(), oname); |
287 |
Registry.getRegistry(null, null).registerComponent(service, oname, null); |
288 |
server.addService(service); |
289 |
|
290 |
return (oname.toString()); |
291 |
|
292 |
} |
293 |
|
294 |
/** |
295 |
* Creates a new StandardEngine. |
296 |
* |
297 |
* @param parent MBean Name of the associated parent component (Service) |
298 |
* @param name Name of this engine |
299 |
* @param domain Domain name for the container instance |
300 |
* @param defaultHost Name of the default host to be used in the Engine |
301 |
* @param baseDir Base directory value for Engine |
302 |
* |
303 |
* @exception Exception if an MBean cannot be created or registered |
304 |
*/ |
305 |
public String createStandardEngine(String parent, String name, String domain, |
306 |
String defaultHost, String baseDir) throws Exception{ |
307 |
|
308 |
StandardEngine engine = new StandardEngine(); |
309 |
engine.setName( name ); |
310 |
engine.setDomain(domain); |
311 |
engine.setDefaultHost(defaultHost); |
312 |
engine.setBaseDir(baseDir); |
313 |
|
314 |
ObjectName pname = new ObjectName(parent); |
315 |
Service service=getService(pname); |
316 |
service.setContainer(engine); |
317 |
|
318 |
return engine.getJmxName().toString(); |
319 |
|
320 |
} |
235 |
|
321 |
|
236 |
/** |
322 |
/** |
237 |
* Create a new AccessLoggerValve. |
323 |
* Create a new AccessLoggerValve. |
Lines 685-691
Link Here
|
685 |
|
771 |
|
686 |
} |
772 |
} |
687 |
|
773 |
|
688 |
|
774 |
|
689 |
/** |
775 |
/** |
690 |
* Create a new StandardManager. |
776 |
* Create a new StandardManager. |
691 |
* |
777 |
* |
Lines 777-783
Link Here
|
777 |
|
863 |
|
778 |
} |
864 |
} |
779 |
|
865 |
|
780 |
|
866 |
/** |
|
|
867 |
* Remove an existing Service. |
868 |
* |
869 |
* @param name MBean Name of the service to remove |
870 |
* |
871 |
* @exception Exception if a component cannot be removed |
872 |
*/ |
873 |
public void removeService(String name) throws Exception{ |
874 |
|
875 |
ObjectName oname = new ObjectName(name); |
876 |
Service service = getService(oname); |
877 |
Server server = service.getServer(); |
878 |
server.removeService(service); |
879 |
|
880 |
} |
881 |
|
781 |
/** |
882 |
/** |
782 |
* Remove an existing Connector. |
883 |
* Remove an existing Connector. |
783 |
* |
884 |
* |