我想开始开发一个人群插件。该插件必须连接到AD搜索用户并获得AD的特定属性。所以我开始关注这个。我已经为我过去开发的JIRA插件安装了Atlassian-SDK。所以我用
创建了一个新的插件atlas-create-crowd-plugin
之后我删除了创建命令创建的类并将其复制到示例代码中,但这并没有起作用(编译问题)。所以我改变了pom.xml
<? xml version="1.0" encoding="UTF-8"?>
<project xmlns=http://maven.apache.org/POM/4.0.0
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<version>1.0-SNAPSHOT</version>
<organization>
<name>Example Company</name>
<url>http://www.example.com/</url>
</organization>
<name>event-listener-example</name>
<description>This is an event listener plugin for Atlassian Crowd.</description>
<packaging>atlassian-plugin</packaging>
<dependencies>
<dependency>
<groupId>com.atlassian.crowd</groupId>
<artifactId>crowd-events</artifactId>
<version>${crowd.version}</version>
<cope>provided</scope>
<dependency>
<dependency>
<groupId>com.atlassian.event</groupId>
<artifactId>atlassian-event</artifactId>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.atlassian.maven.plugins</groupId>
<artifactId>maven-crowd-plugin</artifactId>
<version>6.2.1</version>
<extensions>true</extensions>
<configuration>
<productVersion>${crowd.version}</productVersion>
<productDataVersion>${crowd.data.version}</productDataVersion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<configuration>
</plugin>
</plugins>
</build>
<properties>
<crowd.version>2.8.4</crowd.version>
<crowd.data.version>2.8.4</crowd.data.version>
<atlassian.plugin.key>${project.groupId}.${project.artifactId} </atlassian.plugin.key>
</properties>
</project>
在这里你可以看到我把它变成了一个小问题(版本,并添加了atlassian-event依赖)。
然后我更改了atlassian-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>
<resource type="i18n" name="i18n" location="kgSynchro" />
<listener name="User Created Listener" key="usercreatedlistener"
class="myPackage.NewUserEventListener">
<description>Will listen for user creation
events.</description>
</listener>
</atlassian-plugin>
最后我的班级:
package myPackage.events;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atlassian.crowd.event.user.UserCreatedEvent;
import com.atlassian.event.api.EventListener;
public class NewUserEventListener {
private final Logger log = LoggerFactory.getLogger (NewUserEventListener.class);
@EventListener public void printUserCreatedEvent(
UserCreatedEvent event) {
System.out.println("User " + event.getUser ().getDisplayName() + " has been created.");
log.error("new User is CREATED");
}
}
与示例相同,但我添加了Logger来记录方法的调用。
然后我用atlas-run启动了crod环境(也试过了atlas-debug),然后我去了User UI并尝试添加一个新用户。用户是正确创建的,但是在日志中没有出现关于我的方法的内容。我有很多错误:
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
但这种情况发生在evry页面上,我在人群中导航.....然后我认为这与我的方法从未被调用的事实无关。
每个人都有一些关于尝试找出问题的提示吗?
坦克提前了
答案 0 :(得分:0)
您的侦听器的路径是“myPackage.events.NewUserEventListener”。 将atlassian-plugin.xml侦听器部分更改为以下代码。
<listener name="User Created Listener" key="usercreatedlistener"
class="myPackage.events.NewUserEventListener">
<description>Will listen for user creation events.</description>
</listener>
此外,练习Java Naming Convention也很好。 希望这可以帮到你。
谢谢,
Vikash