Hi Todd,
The correct method to programatically deactivate a component is:
/**
* deactivate a particular component by name
*
*/
*public* *void* deactivate(String component) {
ComponentInstance c = (ComponentInstance)NXRuntime./getRuntime/()
.getComponentInstance(component);
*try* {
c.deactivate();
} *catch* (Exception e) {
//TODO clean this up
e.printStackTrace();
}
}
ComponentInstance is a proxy to the real Component object and it will
pass the correct runtime context to the component deactivate() method
(the same context used when activating the component)
In most cases your method will work too. Anyway you can have problems if
you want to retrieve resources using the context getResource methods if
the context is not the same as the one that loaded the component.
The RuntimeContext.undeploy() method un-deploy components deployed using
XML files.
So you need to pass as argument the URL or the path as a string of the
XML that loaded the component.
If you want to nundeploy a component loaded from the file having the
path "bundle" then your code is correct.
Undeploy means in fact unregistering the component.
You can also unregister components using the ComponentManager API. ( but
it is not recommended if the component was loaded from an XML file using
deploy(..))
ComponentManager mgr = NXRuntime.getRuntime().getComponentManager();
mgr.unregister(new ComponentName("myComponent"));
Using the ComponentManager API you can access low level details of
component registry and retrieve the registration info for your component.
The registration info is containing all you may want to know about a
component including extension points and contributed extensions.
See the interface RegistrationInfo for details.
Example:
ComponentManager mgr = NXRuntime.getRuntime().getComponentManager();
// get the registration info for my component
RegistrationInfo ri = mgr.getRegistrationInfo(new
ComponentName("myComponent"));
// get the extension points
ExtensionPoint[] xp = ri.getExtensionPoints();
// get contributed extensions
Extension[] xt = ri.getExtensions();
// get components I depend on
Set<ComponentName> requires = ri.getRequiredComponents();
// get the context for that component
RuntimeContext ctx = ri.getContext();
// get the component instance
ComponentInstance co = ri.getComponent();
.. and so on.
You can unregister an extension by calling
component.unregisterExtension(extension); on your component
where extension is an extension retrieved from the component
RegistrationInfo.
Anyway extensions are unregistered automatically when the component
which contributed them is unregistered (undeployed)
We are pleased to hear you are using NXRuntime. What exactly are you
using NXRuntime for?
Do not hesitate to ask if you have more questions or new feature requests.
Best regards,
Bogdan
Todd Nist wrote:
Hello,
I have use case that requires the ability to be able to deactivate and
or unregister bundles or individual extension points with out shutting
down the server. I have created an MBean for my service, but what
methods do I need to invoke to deactivate a particular extension /
component? Something like this:
/**
* deactivate a particular component by name
*
*/
*public* *void* deactivate(String component) {
Component c = (Component)NXRuntime./getRuntime/()
.getComponent(component);
*try* {
c.deactivate(NXRuntime./getRuntime/().getContext());
} *catch* (Exception e) {
//TODO clean this up
e.printStackTrace();
}
}
/**
* undeploy a specific bundle by name
*
*/
*public* *void* undeploy(String bundle) {
RuntimeContext context = NXRuntime./getRuntime/().getContext();
*try* {
context.undeploy(bundle);
} *catch* (Exception e) {
//*TODO* fix clean this up
e.printStackTrace();
}
}
I think the above would work ok, but how about extensions? How do I
get a list of extensions for a given component? I guess that I could
have the component provide a helper method of its extension points
since it is aware of them as they are activated, but I’m wondering if
there already a method available that provides this? Or is there a
better way to approach this?
Thanks in advance for you assistance.
Regards,
Todd
------------------------------------------------------------------------
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm