I get the typical no such bean exception when injecting an AO object… all classes are in the same package!!
I use this dependency
<dependency>
<groupId>com.atlassian.activeobjects</groupId>
<artifactId>activeobjects-plugin</artifactId>
<version>5.2.0</version>
<scope>provided</scope>
</dependency>
This is my Servlet class
@Scanned
public class MyServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String TEMPLATE = "home.vm";
private final String user;
Map<String, Object> context;
private SearchService searchService;
private TemplateRenderer templateRenderer;
private final UserManager userManager;
private final CustomFieldManager customFieldManager;
private final WorklogManager worklogManager;
private final IssueLinkManager issueLinkManager;
private final LoginUriProvider loginUriProvider;
private final PageBuilderService pageBuilderService;
private BookedHoursTransactions bookedHoursTransactions;
private final I18nResolver i18nResolver;
@Inject
public MyServlet(@ComponentImport SearchService searchService, @ComponentImport TemplateRenderer templateRenderer,
@ComponentImport UserManager userManager, @ComponentImport CustomFieldManager customFieldManager, @ComponentImport WorklogManager worklogManager
, @ComponentImport IssueLinkManager issueLinkManager, @ComponentImport LoginUriProvider loginUriProvider,
@ComponentImport PageBuilderService pageBuilderService, @ComponentImport I18nResolver i18nResolver, @ComponentImport BookedHoursTransactions bookedHoursTransactions) {
super();
this.searchService = searchService;
this.templateRenderer = templateRenderer;
this.userManager = userManager;
this.customFieldManager = customFieldManager;
this.worklogManager = worklogManager;
this.issueLinkManager = issueLinkManager;
this.loginUriProvider = loginUriProvider;
this.pageBuilderService = pageBuilderService;
this.i18nResolver = i18nResolver;
this.user = userManager.getRemoteUser().getUsername();
this.bookedHoursTransactions = bookedHoursTransactions;
}
Here the Interface
@Transactional
public interface BookedHoursTransactions {
public BookedHours add(String clientId, int yearOfIssue, double spentHours, double spentTransferedHours, double transferedHours, LocalDate deadlineDate, int bookedHours, double availableHours, double remainingHours, double expiredHours);
public void updateBookedHours(String projectKey, int newValue);
public void updateFeatures(String projectKey, double transferedHours, double spentTransferedHours, double availableHours, double remainingHours, double expiredHours);
public void updateDeadlineDate(String projectKey, LocalDate deadlineDate);
public void updateAvailableHours(String projectKey, double availableHours);
public void updateRemainingHours(String projectKey, double remainingHours);
public void updateSpentHours(String projectKey, double spentHours);
public List<BookedHours> all();
}
Here the implementation
@Scanned
@Named
public class BookedHoursTransactionsImpl implements BookedHoursTransactions {
private ActiveObjects ao;
private TransactionTemplate transactionTemplate;
public BookedHoursTransactionsImpl(@ComponentImport ActiveObjects ao, @ComponentImport TransactionTemplate transactionTemplate) {
this.ao = ao;
this.transactionTemplate = transactionTemplate;
}
//methods
}
Here the plugin.xml
atlassian-plugin key="${atlassian.plugin.key}"
name="${project.name}" plugins-version="2">
<plugin-info>
<description>${project.description}</description>
<version>${project.version}</version>
<vendor name="${project.organization.name}"
url="${project.organization.url}" />
<param name="plugin-icon">images/pluginIcon.png</param>
<param name="plugin-logo">images/pluginLogo.png</param>
</plugin-info>
<!-- add our i18n resource -->
<resource type="i18n" name="i18n" location="xx" />
<!-- add our web resources -->
<web-resource key="xx-resources"
name="xx Web Resources">
<dependency>com.atlassian.auiplugin:ajs</dependency>
<resource type="download" name="xx.css"
location="/css/xx.css" />
<resource type="download" name="xx.js"
location="/js/xx.js" />
<resource type="download" name="images/" location="/images" />
<context>xx</context>
</web-resource>
<!-- publish our component -->
<servlet name="myplugin" class="xxx.MyPlugin"
key="xx">
<url-pattern>/xx</url-pattern>
</servlet>
<web-section key="xx-section" name="xx Section"
location="xx-section" weight="10" />
<web-item key="xx_link" name="Link to xxServlet"
section="system.top.navigation.bar" weight="47">
<label>xx</label>
<link linkId="xx_link">/xx</link>
</web-item>
<ao key="ao-module">
<description>The module configuring the Active Objects service used by
this plugin</description>
<entity>xx.BookedHours</entity>
</ao>
</atlassian-plugin>
don’t think it’s necessary but my Entity class
ublic interface BookedHours extends Entity {
public String getClientId();
public void setClientId(String clientId);
public int getYearOfIssue();
public void setYearOfIssue(int yearOfIssue);
public LocalDate getDeadlineDate();
public void setDeadlineDate(LocalDate deadlineDate);
public int getBookedHours();
public void setBookedHours(int bookedHours);
public double getSpentHours();
public void setSpentHours(double spentHours);
public double getTransferedHours();
public void setTransferedHours(double transferedHours);
public double getSpentTransferedHours();
public void setSpentTransferedHours(double spentTransferedHours);
public double getAvailableHours();
public void setAvailableHours(double availableHours);
public double getRemainingHours();
public void setRemainingHours(double remainingHours);
public double getExpiredHours();
public void setExpiredHours(double expiredHours);
}