|
Confluence Docs 3.0 : How do I get a reference to a component?
This page last changed on Jan 24, 2006 by jnolen.
Cannot resolve external resource into attachment. How do I get a reference to a component?Confluence's component system is powered by Spring, but we've done a lot of nice things to make it easier for developers to get their hands on a component at any time. Autowired ObjectsIf your object is being autowired (for example another plugin module or an XWork action), the easiest way to access a component is to add a basic Java setter method. For example, if you need a SpaceManager simply add the following setter method. This setter will be called when the object is created.
public void setSpaceManager(SpaceManager spaceManager)
{
this.spaceManager = spaceManager;
}
Non-autowired ObjectsIf your object is not being autowired, you may need to retrieve the component explicitly. This is done via the ContainerManager like so:
SpaceManager spaceManager = (SpaceManager) ContainerManager.getComponent("spaceManager");
|
| Document generated by Confluence on Nov 05, 2009 23:34 |