首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >wso2is:如何注册UMListenerServiceComponent?

wso2is:如何注册UMListenerServiceComponent?
EN

Stack Overflow用户
提问于 2014-03-21 16:41:39
回答 1查看 87关注 0票数 2

我想在IS管理控制台中重新分发事件。例如,如果我添加/更改/删除一个用户或某个角色,我希望将这些更新重新发送给其他使用者。到目前为止,我发现的唯一方法是UMListenerServiceComponent。看起来我可以定义自己的UserStoreManagerListener并在UMListenerServiceComponent注册它。

下面的示例来自https://svn.wso2.org/repos/wso2/branches/carbon/3.2.0/core/org.wso2.carbon.user.core/3.2.3/src/main/java/org/wso2/carbon/user/core/jdbc/JDBCUserStoreManager.java

在这种情况下,添加用户的操作是触发已注册的侦听器。

代码语言:javascript
复制
public void addUser(String userName, Object credential, String[] roleList,
        Map<String, String> claims, String profileName, boolean requirePasswordChange)
        throws UserStoreException {

    for (UserStoreManagerListener listener : UMListenerServiceComponent
            .getUserStoreManagerListeners()) {
        if (!listener.addUser(userName, credential, roleList, claims, profileName, this)) {
            return;
        }
    }
    // persist the user info. in the database.
    persistUser(userName, credential, roleList, claims, profileName, requirePasswordChange);

}

我的问题是如何实现和注册这类听众?还是有更简单的方法?提前感谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-06 15:28:29

问题解决了!

下载了身份管理器版本,用于wso2IS 4.6.0:http://svn.wso2.org/repos/wso2/carbon/platform/branches/turing/components/identity/org.wso2.carbon.identity.mgt/4.2.1,类IdentityMgtServiceComponent正在将IdentityMgtEventListener注册为Osgi上下文中的服务。

IdentityMgtServiceComponent:

代码语言:javascript
复制
protected void activate(ComponentContext context) {
        listener = new IdentityMgtEventListener();
        serviceRegistration = context.getBundleContext().registerService(
                UserOperationEventListener.class.getName(), listener, null);

最后,我复制了这个模式,并使用AbstractUserOperationEventListener扩展编写了自己的包,并通过包加载器类激活了它。

所有的前/后添加/删除操作都会被触发。

希望这能有所帮助

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22564528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档