3.2.2.1. Forum Event LifeCycle

ForumEventLifeCycle enables you to listen to the lifecycle of a forum. By implementing ForumEventLifeCycle, you can be notified of new posts and replies, categories and topics. This installation will be injected when the data flow is called to save data.

Configuration plug-in

You can find the configuration file of this component at: integ-forum-social/src/main/resources/conf/portal/configuration.xml.

For example, to add a Forum to a space of the Social application and keep new activities of Forum (such as new posts and topics) updated to the activities of space, do as follows:


<external-component-plugins>
<target-component>org.exoplatform.forum.service.ForumService</target-component>
<component-plugin>
  <name>ForumEventListener</name>
  <set-method>addListenerPlugin</set-method>
  <type>org.exoplatform.forum.ext.impl.ForumSpaceActivityPublisher</type>
</component-plugin>
</external-component-plugins>

Tutorial

To use ForumEventLifeCycle class, do the following steps:

  1. Create a new class that extends ForumEventListener.

    For example: class ABCActivityPublisher

    public class ABCActivityPublisher extends ForumEventListener {
    
    ..............
    }
  2. Override functions in this created class. In each function, you can write anythings to meet your needs.

    public class ABCActivityPublisher extends ForumEventListener {
    
    
    public void saveCategory(Category category){
      ....
    }
    public void saveForum(Forum forum){
      ....
    }
    public void addTopic(Topic topic, String categoryId, String forumId)){
      ....
    }
    public void updateTopic(Topic topic, String categoryId, String forumId){
      ....
    }
    public void addPost(Post post, String categoryId, String forumId, String topicId){
      ....
    }
    public void updatePost(Post post, String categoryId, String forumId, String topicId){
      ....
    }
    }
    • The function saveCategory is called when a category is added and/or edited.

    • The function saveForum is called when a forum is added and/or edited.

    • The addTopic function is called when a topic is added.

    • The updateTopic function is called when a topic is updated.

    • The addPost function is called when a post is added.

    • The updatePost function is called when a post is updated.

  3. Add a new configuration to the configuration.xml file with the type that is the class created in the Step 1.

    
    <external-component-plugins>
    <target-component>org.exoplatform.forum.service.ForumService</target-component>
    <component-plugin>
      <name>ForumEventListener</name>
      <set-method>addListenerPlugin</set-method>
      <type>{package}.{class name}</type>
    <!-- example
    <type>org.exoplatform.forum.ext.impl.ABCActivityPublisher</type>
    -->
    </component-plugin>
    </external-component-plugins>
Copyright ©. All rights reserved. eXo Platform SAS
blog comments powered byDisqus