Active objects 0.24, confluence 5.1.4

XXX XXX November 13, 2013

I am wondering why dependency injection with setter for ActiveObjects is not working and why I can't retrieve it via the ComponentManager. I made a test with the constructor it is working. For the other confluence component (like PageManager and so on) I don't have any proble.

Here is the relevant part of my atlassian-plugin.xml:

<!-- Servlets -->
	<servlet name="DocumentFormServlet" key="DocumentFormServlet"
		class="com.arhs.jaspers.confluence.plugin.servlet.document.DocumentUploadServlet">
		<description>A servlet to create new documents</description>
		<url-pattern>/createDocument</url-pattern>
	</servlet>

	<!-- Active objects -->
	<component-import key="ao" name="Active Objects service"
		interface="com.atlassian.activeobjects.external.ActiveObjects">
		<description>Component to access Active Objects functionality from the
			plugin</description>
	</component-import>

	<ao key="ao-module">
		<description>The module configuring the Active Objects service used by
			this plugin
		</description>
		<entity>com.arhs.jaspers.confluence.plugin.model.Category</entity>
		<entity>com.arhs.jaspers.confluence.plugin.model.Document</entity>
		<entity>com.arhs.jaspers.confluence.plugin.model.Rating</entity>
		<entity>com.arhs.jaspers.confluence.plugin.model.Keyword</entity>
	</ao>

	<!-- Support for transaction -->
	<component key="tx-processor" name="Transactional Annotation Processor"
		class="com.atlassian.activeobjects.external.TransactionalAnnotationProcessor">
		<decription>Processes @Transactional annotations.</decription>
	</component>

Here is the relevant part of my java code:

public class DocumentUploadServlet extends HttpServlet{

     public ActiveObjects ao;

     public void initAo(){
        //Throw component not found exception
        ao = ContainerManager.getComponent("ao",ActiveObjects.class);
     }
     
     //Never called
     public setAo(ActiveObjects ao){
          this.ao = ao;
     }

}

Anybody has an idea why I have suchn an error?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
jhinch _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 13, 2013

ContainerManager only works for components exposed by the host application. ActiveObjects is exposed by another plugin so that won't work. You need to use contructor injection instead of setter injection to get access to the ActiveObjects component

XXX XXX November 13, 2013
Thanks very clear answer :-)
TAGS
AUG Leaders

Atlassian Community Events