Jira Service and ActiveObjects problem

jordan blanc-poujol June 25, 2014

Hello,

I create a service and I need to use an activeObject to add in my database some informations.

My Service :

public class TestService extends AbstractService {

	public JiraHome jiraHome;
	public ActiveObjects ao;

	public TestService(JiraHome jiraHome,ActiveObjects ao) {
		this.jiraHome = jiraHome;
		this.ao = ao;
	}

	@Override
	public void run() {
		AddDataFromCsv adfc = new AddDataFromCsv(jiraHome, ao);
		adfc.addBD();

	}

	@Override
	public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException {
		return getObjectConfiguration("TESTSERVICE",
				"services/com/atlassian/tutorial/helloworld/testservice.xml",
				null);
	}

}
The class AddDataFromCsv works fine.

When itry to add my service in jira i have an error and i don't understand what it means :

com.atlassian.tutorial.helloworld.TestService has unsatisfied dependency 'interface com.atlassian.activeobjects.external.ActiveObjects' for constructor 'public com.atlassian.tutorial.helloworld.TestService(com.atlassian.jira.config.util.JiraHome,com.atlassian.activeobjects.external.ActiveObjects)' from org.picocontainer.DefaultPicoContainer@20d535de:1<[Immutable]:com.atlassian.jira.component.CachingMutablePicoContainer@56c4e51e.


Thanks.

5 answers

1 vote
Sergey Temchenko
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 9, 2016

I've just run into the same problem. After few attempts i got solution.

Import ao in atlassian-plugin.xml

<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>

 

Use setter to init ao within the service.

package com.togethernetworks.plugins.services.kpi;
import com.atlassian.activeobjects.external.ActiveObjects;
import com.atlassian.configurable.ObjectConfiguration;
import com.atlassian.configurable.ObjectConfigurationException;
import com.atlassian.jira.service.AbstractService;
import com.opensymphony.module.propertyset.PropertySet;
import java.util.Date;

public class KpiService extends AbstractService
{
	private final static String SERVICE_ID = "someservice";
	private final static String SERVICE_CONF = "services/kpi/kpiservice.xml";
	private ActiveObjects activeObjects;
	private String parseDate;
	
	public void setActiveObjects(ActiveObjects activeObjects)
	{
		this.activeObjects = activeObjects;
	}
	
	@Override
	public void run()
	{
		System.out.println("Running service!!" + this.parseDate);
	}
	
	public void init(PropertySet props) throws ObjectConfigurationException
	{
		super.init(props);
		
		if (this.hasProperty("test")) {
			
			this.parseDate = this.getProperty("test");
			
		}
	}
	@Override
	public ObjectConfiguration getObjectConfiguration() throws ObjectConfigurationException
	{
		return this.getObjectConfiguration(
			KpiService.SERVICE_ID,
			KpiService.SERVICE_CONF,
			null
		);
	}
}
0 votes
Daniel Wester
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2014

Create your own service and do all of the active object interaction in there. Then import that service into your Service class. Or use SAL's Job functionality.

0 votes
jordan blanc-poujol June 25, 2014

Thanks for you answer but what can you propose to me for update my database every hour ? I thought services are the best solution to do this.

0 votes
jordan blanc-poujol June 25, 2014

Thanks for you answer but what can you propose to me for update my database every hour ? I thought services were the best solution to do this.

0 votes
Timothy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 25, 2014

Not a solution but ActiveObjects and services do not mix well.

Suggest an answer

Log in or Sign up to answer