2016-06-29 10 views
0

Ich mache Jira Plugin und ich muss Active Object verwenden. (Jira v7.1.8) Aber in der offiziellen Dokumentation ist veraltet. Es ist geschrieben mit Xml, aber wenn ich richtig verstanden habe, jetzt Atlassian Spring Scanner (ich v1.2.3 verwenden)Wie verwendet man aktive Objekte mit Annotation in Atlassian SDK

Nach diesem ein Handbuch https://bitbucket.org/atlassian/atlassian-spring-scanner/src/1.2.x/README.md?at=1.2.x&fileviewer=file-view-default nichts gelungen.

atlassian-plugin.xml

<atlassian-plugin key="${project.groupId}.${project.artifactId}" 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="dbplugin"/> 

    <web-resource key="my-resources"> 
     <dependency>com.atlassian.jira.jira-project-config-plugin:project-config-global</dependency> 
     <context>my-resources</context> 
    </web-resource> 
    <!----------- This is old xml version ------------------ 
     <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> 

<component key="dao-factory" class="com.lemon.dbplugin.DAO.DAOFactory"> 
      </component> 
    --------------------------------------------------------> 
     <ao key="ao-module"> 
      <entity>com.lemon.dbplugin.entity.StudentEntity</entity> 
     </ao> 



    <webwork1 key="actions" name="MyActions"> 
     <actions> 
      <action name="com.lemon.dbplugin.ActionAlpha" alias="action" roles-required="admin"> 
       <view name="success">/templates/success.vm</view> 
      </action> 
     </actions> 
    </webwork1> 

ActionAlpha

package com.lemon.dbplugin; 


import com.atlassian.jira.project.Project; 
import com.atlassian.jira.web.action.JiraWebActionSupport; 
import com.lemon.dbplugin.DAO.DAOFactory; 
import com.lemon.dbplugin.entity.StudentEntity; 
import com.lemon.dbplugin.logic.Student; 
import com.lemon.dbplugin.logic.StudentImpl; 
import org.apache.log4j.Logger; 
import webwork.action.ServletActionContext; 

public class ActionAlpha extends JiraWebActionSupport { 

private static final Logger log = Logger.getLogger(ActionAlpha.class); 
private Project project; 
private StudentEntity[] students; 

@Override 
public String execute() throws Exception { 
    log.debug("Entered in execute ActionAlpha"); 
    project = getSelectedProjectObject(); 
    getHttpRequest().setAttribute("com.atlassian.jira.projectconfig.util.ServletRequestProjectConfigRequestCache:project", project); 
    students = DAOFactory.getInstance().getStudentDAO().getStudents(); 
    log.debug("students :" + students); 
    return super.execute(); 
} 
public String doAdd() throws Exception { 
    log.debug("Entered in doAdd ActionAlpha"); 
    String name = getHttpRequest().getParameterValues("name")[0]; 
    Student student = new StudentImpl(name); 
    log.debug("student :" + student); 
    DAOFactory.getInstance().getStudentDAO().addStudent(student); 
    ServletActionContext.getResponse().sendRedirect("/secure/action.jspa"); 
    return NONE; 
} 

}

DAOFactory

package com.lemon.dbplugin.DAO; 


import com.atlassian.activeobjects.external.ActiveObjects; 
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; 
import com.lemon.dbplugin.DAO.Impl.StudentDAOImpl; 
import org.springframework.beans.factory.annotation.Autowired; 
import org.springframework.stereotype.Component; 


@Component 
public class DAOFactory { 
    private static StudentDAO studentDAO = null; 
    private static DAOFactory instance = null; 
@ComponentImport private static ActiveObjects ao; 

@Autowired 
public DAOFactory(@ComponentImport ActiveObjects ao) { 
    DAOFactory.ao = ao; 
} 
public static synchronized DAOFactory getInstance() { 
    if (instance == null) { 
     instance = new DAOFactory(ao); 
    } 
    return instance; 
} 
public StudentDAO getStudentDAO() { 
    if (studentDAO == null) { 
     studentDAO = new StudentDAOImpl(ao); 
    } 
    return studentDAO; 
} 

}

StudentDAOImpl

package com.lemon.dbplugin.DAO.Impl; 

import com.atlassian.activeobjects.external.ActiveObjects; 
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport; 
import com.atlassian.sal.api.transaction.TransactionCallback; 
import com.lemon.dbplugin.DAO.StudentDAO; 
import com.lemon.dbplugin.entity.StudentEntity; 
import com.lemon.dbplugin.logic.Student; 
import org.apache.log4j.Logger; 
import org.springframework.beans.factory.annotation.Autowired; 

import java.util.Date; 


public class StudentDAOImpl implements StudentDAO { 


    private final ActiveObjects ao; 
    private static final Logger log = Logger.getLogger(StudentDAOImpl.class); 


    @Autowired 
    public StudentDAOImpl(@ComponentImport ActiveObjects ao) { 
     this.ao = ao; 
    } 

    @Override 
    public StudentEntity addStudent(final Student student) throws Exception { 
     log.debug("Entered to addStudents"); 
     log.debug("AO :" + ao); 
     return ao.executeInTransaction(new TransactionCallback<StudentEntity>() { 
      public StudentEntity doInTransaction() { 
       StudentEntity entity = ao.create(StudentEntity.class); 
       entity.setName(student.getName()); 
       entity.setCreated(new Date(System.currentTimeMillis())); 
       entity.save(); 
       return entity; 
      } 
     }); 
    } 

    public StudentEntity[] getStudents() throws Exception { 
     log.debug("Entered to getStudents"); 
     log.debug("ao: " + ao); 

     try { 
      return ao.executeInTransaction(new TransactionCallback<StudentEntity[]>() { 
       public StudentEntity[] doInTransaction() { 
        StudentEntity[] result = ao.find(StudentEntity.class); 
        if (result != null) { 
         return ao.find(StudentEntity.class); 
        } else { 
         return new StudentEntity[]{}; 
        } 
       } 
      }); 
     } 
     catch(NullPointerException e){ 
      return new StudentEntity[]{}; 
     } 
    } 
} 

Compilieren und Paket whithout Fehler. Aber wenn ich offen /jira/secure/action.jspa versuchen, in der Konsole bekomme ich dies:

[INFO] [talledLocalContainer] 2016-06-30 09:38:15,837 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.OsgiServiceUtilsImpl] Registering service [email protected] with interface net.java.ao.schema.TableNameConverter and properties {com.atlassian.plugin.key=com.lemon.dbplugin.dbplugin} 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,839 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.OsgiServiceUtilsImpl] Registering service com.atlassian.[email protected]3cf99a08 with interface com.atlassian.activeobjects.config.ActiveObjectsConfiguration and properties {com.atlassian.plugin.key=com.lemon.dbplugin.dbplugin} 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,845 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] onPluginModuleEnabledEvent storing unattached <ao> configuration module for [com.lemon.dbplugin.dbplugin] 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,875 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.ActiveObjectsServiceFactory] onPluginEnabledEvent attaching unbound <ao> to [com.lemon.dbplugin.dbplugin] 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] init bundle [com.lemon.dbplugin.dbplugin] 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] loading new AO promise for JiraTenantImpl{id='system'} 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] setAoConfiguration [com.lemon.dbplugin.dbplugin] 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,876 http-nio-2990-exec-8 DEBUG admin 578x129x1 bnt30i 10.0.0.120 /rest/plugins/1.0/com.lemon.dbplugin.dbplugin-key [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] got ActiveObjectsConfiguration 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,877 active-objects-init-JiraTenantImpl{id='system'}-0 DEBUG admin  [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] creating ActiveObjects 
[INFO] [talledLocalContainer] 2016-06-30 09:38:15,905 active-objects-init-JiraTenantImpl{id='system'}-0 DEBUG admin  [c.a.activeobjects.osgi.TenantAwareActiveObjects] bundle [com.lemon.dbplugin.dbplugin] created ActiveObjects 
[INFO] [talledLocalContainer] 2016-06-30 09:38:53,798 http-nio-2990-exec-12 ERROR admin 578x184x1 bnt30i 10.0.0.120 /secure/action.jspa [c.a.j.config.webwork.JiraActionFactory] Error autowiring Action 'com.lemon.dbplugin.ActionAlpha'. 
[INFO] [talledLocalContainer] java.lang.NullPointerException 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.JiraActionFactory$JiraPluginActionFactory.getActionImpl(JiraActionFactory.java:389) 
[INFO] [talledLocalContainer] at webwork.action.factory.PrefixActionFactoryProxy.getActionImpl(PrefixActionFactoryProxy.java:99) 
[INFO] [talledLocalContainer] at webwork.action.factory.JspActionFactoryProxy.getActionImpl(JspActionFactoryProxy.java:59) 
[INFO] [talledLocalContainer] at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60) 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.LookupAliasActionFactoryProxy.getActionImpl(LookupAliasActionFactoryProxy.java:61) 
[INFO] [talledLocalContainer] at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60) 
[INFO] [talledLocalContainer] at webwork.action.factory.ContextActionFactoryProxy.getActionImpl(ContextActionFactoryProxy.java:36) 
[INFO] [talledLocalContainer] at webwork.action.factory.PrepareActionFactoryProxy.getActionImpl(PrepareActionFactoryProxy.java:37) 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.JiraActionFactory$SafeParameterSettingActionFactoryProxy.getActionImpl(JiraActionFactory.java:147) 
[INFO] [talledLocalContainer] at webwork.action.factory.ChainingActionFactoryProxy.getActionImpl(ChainingActionFactoryProxy.java:53) 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.JiraActionFactory.getActionImpl(JiraActionFactory.java:301) 
[INFO] [talledLocalContainer] ... 2 filtered 
[INFO] [talledLocalContainer] at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
[INFO] [talledLocalContainer] ... 55 filtered 
[INFO] [talledLocalContainer] at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59) 
[INFO] [talledLocalContainer] ... 27 filtered 
[INFO] [talledLocalContainer] at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59) 
[INFO] [talledLocalContainer] ... 38 filtered 
[INFO] [talledLocalContainer] at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70) 
[INFO] [talledLocalContainer] ... 38 filtered 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:169) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.util.scala.ScalaJavaInterOp$1.apply(ScalaJavaInterOp.java:25) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil$.outOfCustomerContext(CustomerContextUtil.scala:48) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil.outOfCustomerContext(CustomerContextUtil.scala) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.outOfCustomerContext(CustomerContextServiceImpl.java:24) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.outOfCustomerContext(CustomerContextSettingFilter.java:164) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:120) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:112) 
[INFO] [talledLocalContainer] ... 55 filtered 
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
[INFO] [talledLocalContainer] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
[INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:745) 
[INFO] [talledLocalContainer] 2016-06-30 09:38:53,801 http-nio-2990-exec-12 ERROR admin 578x184x1 bnt30i 10.0.0.120 /secure/action.jspa [c.a.j.web.dispatcher.JiraWebworkActionDispatcher] Exception thrown from action 'action', returning 404 
[INFO] [talledLocalContainer] java.lang.NullPointerException 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.JiraActionFactory$JiraPluginActionFactory.getActionImpl(JiraActionFactory.java:389) 
[INFO] [talledLocalContainer] at webwork.action.factory.PrefixActionFactoryProxy.getActionImpl(PrefixActionFactoryProxy.java:99) 
[INFO] [talledLocalContainer] at webwork.action.factory.JspActionFactoryProxy.getActionImpl(JspActionFactoryProxy.java:59) 
[INFO] [talledLocalContainer] at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60) 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.LookupAliasActionFactoryProxy.getActionImpl(LookupAliasActionFactoryProxy.java:61) 
[INFO] [talledLocalContainer] at webwork.action.factory.CommandActionFactoryProxy.getActionImpl(CommandActionFactoryProxy.java:60) 
[INFO] [talledLocalContainer] at webwork.action.factory.ContextActionFactoryProxy.getActionImpl(ContextActionFactoryProxy.java:36) 
[INFO] [talledLocalContainer] at webwork.action.factory.PrepareActionFactoryProxy.getActionImpl(PrepareActionFactoryProxy.java:37) 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.JiraActionFactory$SafeParameterSettingActionFactoryProxy.getActionImpl(JiraActionFactory.java:147) 
[INFO] [talledLocalContainer] at webwork.action.factory.ChainingActionFactoryProxy.getActionImpl(ChainingActionFactoryProxy.java:53) 
[INFO] [talledLocalContainer] at com.atlassian.jira.config.webwork.JiraActionFactory.getActionImpl(JiraActionFactory.java:301) 
[INFO] [talledLocalContainer] ... 2 filtered 
[INFO] [talledLocalContainer] at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) 
[INFO] [talledLocalContainer] ... 55 filtered 
[INFO] [talledLocalContainer] at com.atlassian.greenhopper.jira.filters.ClassicBoardRouter.doFilter(ClassicBoardRouter.java:59) 
[INFO] [talledLocalContainer] ... 27 filtered 
[INFO] [talledLocalContainer] at com.atlassian.labs.httpservice.resource.ResourceFilter.doFilter(ResourceFilter.java:59) 
[INFO] [talledLocalContainer] ... 38 filtered 
[INFO] [talledLocalContainer] at com.atlassian.jira.security.JiraSecurityFilter.doFilter(JiraSecurityFilter.java:70) 
[INFO] [talledLocalContainer] ... 38 filtered 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.lambda$invokeFilterChain$0(CustomerContextSettingFilter.java:169) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.util.scala.ScalaJavaInterOp$1.apply(ScalaJavaInterOp.java:25) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil$.outOfCustomerContext(CustomerContextUtil.scala:48) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.utils.context.CustomerContextUtil.outOfCustomerContext(CustomerContextUtil.scala) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.utils.context.CustomerContextServiceImpl.outOfCustomerContext(CustomerContextServiceImpl.java:24) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.outOfCustomerContext(CustomerContextSettingFilter.java:164) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilterImpl(CustomerContextSettingFilter.java:120) 
[INFO] [talledLocalContainer] at com.atlassian.servicedesk.internal.web.CustomerContextSettingFilter.doFilter(CustomerContextSettingFilter.java:112) 
[INFO] [talledLocalContainer] ... 55 filtered 
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 
[INFO] [talledLocalContainer] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 
[INFO] [talledLocalContainer] at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 
[INFO] [talledLocalContainer] at java.lang.Thread.run(Thread.java:745) 

Sorry für die dumme Frage, was mache ich falsch?

+0

Sie schrieben hilft nur, dass „nichts gelungen“, aber Sie brauchen, um über genau viel präziser zu sein, was nicht funktioniert, oder wie Sie Ihre vorhandenen Code fehlgeschlagen. –

+0

@ScottDudley Ich habe ein Protokoll von der Konsole hinzugefügt, wenn ich versuche, $ servername/jira/secure/action.jspa zu öffnen. Kompilieren und Verpacken erfolgt fehlerfrei. –

Antwort

0

Nach wochenlanger Suche im Internet und vielen Versuchen habe ich endlich das offizielle Active Objects Tutorial bekommen, um mit der neuesten Version von Jira (7.1.2) und spring-scanner 2.0 zu arbeiten.

Sie können die vollständige Codebeispiel auf GitHub finden, aber hier ist der Kern von ihm:

Erklären Sie Ihre depenencies richtig

<!-- Active Objects --> 
    <dependency> 
     <groupId>com.atlassian.activeobjects</groupId> 
     <artifactId>activeobjects-plugin</artifactId> 
     <version>${ao.version}</version> 
     <scope>provided</scope> 
    </dependency> 
    <!-- SAL, the Active Objects plugin uses SAL's API for transactions --> 
    <dependency> 
     <groupId>com.atlassian.sal</groupId> 
     <artifactId>sal-api</artifactId> 
     <version>${sal.version}</version> 
     <scope>provided</scope> 
    </dependency> 
    <!-- Dependency Injection --> 
    <dependency> 
     <groupId>org.springframework</groupId> 
     <artifactId>spring-context</artifactId> 
     <version>${spring.version}</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>com.atlassian.plugin</groupId> 
     <artifactId>atlassian-spring-scanner-annotation</artifactId> 
     <version>${atlassian.spring.scanner.version}</version> 
     <scope>provided</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-simple</artifactId> 
     <version>${slf4j.version}</version> 
     <scope>compile</scope> 
    </dependency> 

Konfigurieren der Federscanner

<build> 
    <plugins> 
     <plugin> 
      <groupId>com.atlassian.maven.plugins</groupId> 
      <artifactId>maven-jira-plugin</artifactId> 
      <version>${amps.version}</version> 
      <extensions>true</extensions> 
      <configuration> 
       <productVersion>${jira.version}</productVersion> 
       <productDataVersion>${jira.version}</productDataVersion> 
       <enableQuickReload>true</enableQuickReload> 
       <enableFastdev>false</enableFastdev> 
       <instructions> 
        <Atlassian-Plugin-Key>${atlassian.plugin.key}</Atlassian-Plugin-Key> 
        <!-- Add package to export here --> 
        <Export-Package>com.atlassian.tutorial.ao.todo.api,</Export-Package> 
        <!-- Add package import here --> 
        <Import-Package> 
         org.springframework.osgi.*;resolution:="optional", 
         org.eclipse.gemini.blueprint.*;resolution:="optional", 
         * 
        </Import-Package> 
        <!-- Ensure plugin is spring powered --> 
        <Spring-Context>*</Spring-Context> 
       </instructions> 
      </configuration> 
     </plugin> 

     <plugin> 
      <groupId>com.atlassian.plugin</groupId> 
      <artifactId>atlassian-spring-scanner-maven-plugin</artifactId> 
      <version>${atlassian.spring.scanner.version}</version> 
      <executions> 
       <execution> 
        <goals> 
         <goal>atlassian-spring-scanner</goal> 
        </goals> 
        <phase>process-classes</phase> 
       </execution> 
      </executions> 
      <configuration> 
       <verbose>false</verbose> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

Eigenschaften

<properties> 
    <!-- 
    This key is used to keep the consistency between the key in atlassian-plugin.xml 
    and the key to generate bundle. 
    --> 
    <atlassian.plugin.key>${project.groupId}.${project.artifactId}</atlassian.plugin.key> 
    <jira.version>7.2.1</jira.version> 
    <!-- 
    For correct versions to use with your Atlassian product see target folder, i.e. 
    /target/container/tomcat8x/cargo-jira-home/webapps/jira/WEB-INF/lib 
    --> 
    <amps.version>6.2.4</amps.version> 
    <ao.version>1.0.0</ao.version> 
    <sal.version>2.6.0</sal.version> 
    <slf4j.version>1.7.9</slf4j.version> 
    <testkit.version>6.3.11</testkit.version> 
    <plugin.testrunner.version>1.2.3</plugin.testrunner.version> 
    <spring.version>4.1.6.RELEASE</spring.version> 
    <!-- See https://bitbucket.org/atlassian/atlassian-spring-scanner --> 
    <atlassian.spring.scanner.version>1.2.6</atlassian.spring.scanner.version> 
    <!--Determined by JEE compliant container--> 
    <servlet.version>3.1.0</servlet.version> 
</properties> 

** Frühling Context ** Sie müssen auch Feder konfigurieren mit einem /resources/META-INF/spring/plugin-context.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:atlassian-scanner="http://www.atlassian.com/schema/atlassian-scanner/2" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
    http://www.atlassian.com/schema/atlassian-scanner/2 
    http://www.atlassian.com/schema/atlassian-scanner/2/atlassian-scanner.xsd"> 
<atlassian-scanner:scan-indexes autowire="constructor" /> 
</beans> 

Java Beans

Dann können Sie @Component benutzen, um Ihre Java-Klasse markieren für Abhängigkeitsspritze.

Da wir autowire="constructor" in unserem plugin-context.xml setzen, brauchen wir nicht @Autowired oder @Inject Anmerkungen für Konstruktor Injektion mehr.

Ihre eigenen Bohnen automatisch injiziert werden, haben externe Bohnen Markt sein mit @ComponentImport:

@Component 
public final class TodoServlet extends HttpServlet { 
    private final TodoService todoService; 
    private final UserManager userManager; 

    public TodoServlet(TodoService todoService, @ComponentImport UserManager userManager) { 
    this.todoService = todoService; 
    this.userManager = userManager; 
} 

Daher können Sie Aktiv Objekte importieren wie folgt:

public TodoServiceImpl(@ComponentImport ActiveObjects ao) { 
    this.ao = ao; 
} 

Achten Sie darauf, nicht zu tun alles mit ao im Konstruktor, seit es nicht fertig Jet!

Hoffnung, die