How do I autowire a component?

Most of the time, you don't have to. All plugins will have their 'primary' objects (The macro in a macro plugin, the XWork actions in an XWork plugin, the RPC handler in an RPC plugin and so on...) autowired.

If you want to write an arbitrary object that is autowired, but that is not any particular plugin type itself, write a Component Plugin Module. The added advantage of this is that Confluence will then autowire other plugins with the component you have just written.

If, however, you find you need to autowire an arbitrary object with Spring components, use bucket.util.ContainerManager

bucket.container.ContainerManager.autowireComponent(myObject);

Where myObject is the object instance that you wish to be autowired.