public class ToShortMessage extends ShortMessage {
public String getFilterMessageBody() { this.shortMessageState.setHasRead(true, this); return messageBody; }
}
public class ShortMessageState extends Observable{
.....
public void setHasRead(boolean hasRead, ShortMessage shortMessage) { this.shortMessage = shortMessage; if ((hasRead) && (!this.hasRead)){ this.hasRead = hasRead; setChanged();//出发 notifyObservers(this); }else this.hasRead = hasRead; }
} public class ShortMessageRepository implements Observer{ .... public void update(Observable obj,Object arg){ logger.debug(" Observable update "); ShortMessageState shortMessageState = (ShortMessageState)obj; try { this.shortMessageDao.updateShortMessate(shortMessageState.getShortMessage()); } catch (Exception e) { e.printStackTrace(); } }
}
|