3.4.6.4. Write an ActivityProcessor

Social lets you pre-process an activity before it is returned by the ActivityManager. To do this, you simply need to implement the interface ActivityProcessor:



/**
 * An activity processor is responsible to pre-process an activity before it is returned by the {@link ActivityManager}
 */
public interface ActivityProcessor {
  /**
   * Process an activity
   * @param activity the activity. It can be modified
   */
  void processActivity(Activity activity);
  /**
   * Priority of this processor.
   * All activity processors will be executed in ascending priority order
   * @return
   */
  int getPriority();
}

For example, the following shows you how to implement a SmileyProcessor that will replace text smileys by icons:



public class SmileyProcessor implements ActivityProcessor {
  String smiley =  "<img src='/images/smiley.gif'/>";
  public void processActivity(Activity activity) {
    String title = activity.getTitle();
     activity.setTitle(title.replaceAll(":-\)", smiley));
  }
  public int getPriority() {
    return 100;
  }
}
Copyright ©2012. All rights reserved. eXo Platform SAS