Yes, you can. To add a GBean, fill out a GBeanData and then do
something like this:
Kernel kernel = ... (injected)
ObjectName mine = (creator object name, normally injected)
ObjectName oName = (new GBean object name)
GBeanData data = ...
EditableConfigurationManager mgr =
ConfigurationUtil.getEditableConfigurationManager(kernel);
if(mgr != null) {
try {
ObjectName config = Util.getConfiguration(kernel, mine);
mgr.addGBeanToConfiguration(Configuration.getConfigurationID(config),
data, true);
return (...)
kernel.getProxyManager().createProxy(oName, SomeInterface.class);
} catch (InvalidConfigException e) {
log.error("Should never happen", e);
} catch (URISyntaxException e) {
log.error("Should never happen", e);
} finally {
ConfigurationUtil.releaseConfigurationManager(kernel, mgr);
}
} else {
log.warn("The ConfigurationManager in the kernel does not
allow changes at runtime");
}
return null;
I haven't looked at removing recently, but I know it's possible.
Thanks,
Aaron
On 3/21/06, Hiram Chirino <[EMAIL PROTECTED]> wrote:
> Hi Dain,
>
> Is possible to dynamicaly register/unregister a GBean in the kernel?
> Last time I checked, that was not really possible, but I'm hoping
> things have changed since then?
>
> --
> Regards,
> Hiram
>