在 Geronimo 中管理 Apache Pluto
2010-03-30 00:00:00 来源:WEB开发网在为 ConfigService 组件创建了标准 Geronimo GBean 后,必须由 Geronimo 内核装入和启动它。您可以使用 org.apache.geronimo.kernel.KernelRegistry 类的 getSingleKernel 方法检索 Geronimo 内核。
通过对内核的引用,可以使用 GBeanData 实例描述 GBean。该 GBean 随后被内核装入和启动,如清单 3 中所示:
清单 3. 使用 GBeanManager 装入和启动 GBean
public class GBeanManager
{
public static void loadAndStartGBean(Class gBeanCls,
GBeanInfo gBeanInfo,
String serviceType)
{
java.net.URI gBeanURI =
java.net.URI.create("devworks/" + gBeanCls.getName() + "/1.0.0/?service="
+ serviceType);
org.apache.geronimo.gbean.AbstractName abstractName =
new org.apache.geronimo.gbean.AbstractName(gBeanURI);
org.apache.geronimo.gbean.GBeanData gBeanData =
new org.apache.geronimo.gbean.GBeanData(abstractName, gBeanInfo);
System.out.println("Loaded gBeanData for class: " + gBeanCls.getName());
org.apache.geronimo.kernel.Kernel geronimoKernel =
org.apache.geronimo.kernel.KernelRegistry.getSingleKernel();
System.out.println("Found kernel: " + geronimoKernel.getKernelName());
ClassLoader clsLoader = Thread.currentThread().getContextClassLoader();
try
{
geronimoKernel.loadGBean(gBeanData, clsLoader);
System.out.println("Loaded gBean: " + gBeanCls.getName());
}
catch (GBeanAlreadyExistsException e)
{
System.out.println("GBean [" + gBeanCls.getName() + "] already loaded");
}
try
{
geronimoKernel.startGBean(gBeanCls);
System.out.println("Started gBean: " + gBeanCls.getName());
}
catch (GBeanNotFoundException e)
{
System.err.println("GBean [" + gBeanCls.getName() + "] not found");
}
}
public static void stopAndUnloadGBean(Class gBeanCls)
{
org.apache.geronimo.kernel.Kernel geronimoKernel =
org.apache.geronimo.kernel.KernelRegistry.getSingleKernel();
System.out.println("Found kernel: " + geronimoKernel.getKernelName());
try
{
geronimoKernel.stopGBean(gBeanCls);
System.out.println("Stopped gBean: " + gBeanCls.getName());
}
catch (GBeanNotFoundException e)
{
System.err.println("GBean [" + gBeanCls.getName() + "] not found");
return;
}
try
{
geronimoKernel.unloadGBean(gBeanCls);
System.out.println("Unloaded gBean: " + gBeanCls.getName());
}
catch (GBeanNotFoundException e)
{
System.err.println("GBean [" + gBeanCls.getName() + "] not found");
return;
}
}
public static Object getGBean(Class gBeanCls)
throws GBeanNotFoundException
{
org.apache.geronimo.kernel.Kernel geronimoKernel =
org.apache.geronimo.kernel.KernelRegistry.getSingleKernel();
System.out.println("Found kernel: " + geronimoKernel.getKernelName());
return geronimoKernel.getGBean(gBeanCls);
}
}
- ››apache设置域名绑定 以及绑定不起作用的排查
- ››apache rewrite将指定URL转向指定的几个服务器
- ››apache配置文件httpd.comf部分参数说明
- ››Apache+Mysql+PHP+phpMyAdmin+Mac OS X 10.7 Lion...
- ››管理/var/spool/clientmqueue/下的大文件
- ››apache+tomcat负载均衡_项目实例
- ››apache mysql php 源码编译使用
- ››Apache添加mod_aspdotnet.so支持ASP.NET配置指南
- ››Apache中改变php.ini的路径
- ››Apache2.2与Tomcat6整合及虚拟主机配置
- ››Apache+php+mysql在windows下的安装与配置图解
- ››Apache+Subversion完美结合,CentOS下实现版本控制...
更多精彩
赞助商链接