lundi 2 février 2015

Which Design Patterns for 'event'-driven notification service for Content in Java?

I am designing a Content Management System. At the minute I am dealing with documents



public Enum DocAction(){
DOCUMENTSUBMITTED,
DOCUMENTAPPROVED,
DOCUMENTREJECTED
}

public Enum NotificationType(){
EMAIL,
TEXT,
POPUP
}

public class Newspaper(){
private long id;
private map<DocAction,long> notifications;
private long EditorId
}

Public class Document(){
private long id;
private long newspaperId;
private long authorId
private String article
}

Public class Notification(){
private long id
private map<NotificationType,long> notifications
}


The rough outline of classes are above.


I want it to be on certain actions (document submitted, approved, rejected etc) a notification will be send out, depending which newspaper it was submitted to.


Then I can just go into the corresponding methods, such as 'saveDocument', check a key exists, and if it does then send the notification it is mapped to, to the editor/author.


I thought Enums was a good plan as could add or remove as many, and not all newspapers will want to use all. However I was informed this is a bad design, as e-nums are hard to manage, and will require alot of maintenance with redeploying etc.


I was wondering if there was a design pattern that was more suited to this design.


Key features:



  • Newspapers have notifications (may be of multiple types)

  • Notifcations need to be sent out when certain actions to sometimes the editor id, sometimes the author id

  • The number of events for each newspaper will vary.


Thanks for your help.


Aucun commentaire:

Enregistrer un commentaire