1 23 24 package com.sun.enterprise.admin.selfmanagement.event; 25 26 import javax.management.Notification ; 27 import javax.management.NotificationBroadcasterSupport ; 28 import javax.management.MBeanNotificationInfo ; 29 import com.sun.enterprise.server.ServerContext; 30 31 32 33 37 public class LifeCycleImpl extends NotificationBroadcasterSupport implements LifeCycleImplMBean { 38 39 public LifeCycleImpl() { 40 DeclarativeLifecycleEventService.setLifeCycleImpl(this); 41 } 42 43 46 private long sequenceNumber = 0; 47 48 49 public void onReady(ServerContext sc) { 50 long seqno; 51 synchronized (this) { 52 seqno = sequenceNumber++; 53 } 54 Notification n = new Notification (LifeCycleEvent.READY_EVENT, this, seqno, "Ready!!!"); 56 sendNotification(n); 57 58 } 59 60 public void onShutdown() { 61 long seqno; 62 synchronized (this) { 63 seqno = sequenceNumber++; 64 } 65 Notification n = new Notification (LifeCycleEvent.SHUTDOWN_EVENT, this, seqno, "Shutting Down!!!"); 67 sendNotification(n); 68 69 } 70 71 public void onTermination() { 72 long seqno; 73 synchronized (this) { 74 seqno = sequenceNumber++; 75 } 76 Notification n = new Notification (LifeCycleEvent.TERMINATION_EVENT, this, seqno, "Terminated!!!"); 78 sendNotification(n); 79 80 } 81 82 83 public MBeanNotificationInfo [] getNotificationInfo() { 84 return notifsInfo; 85 } 86 87 private static final String [] types = { 88 LifeCycleEvent.READY_EVENT, 89 LifeCycleEvent.SHUTDOWN_EVENT, 90 LifeCycleEvent.TERMINATION_EVENT 91 }; 92 93 94 private static final MBeanNotificationInfo [] notifsInfo = { 95 new MBeanNotificationInfo ( 96 types, 97 "javax.management.Notification", 98 "Notifications sent by the LifeCycleImpl MBean") 99 }; 100 101 102 } 103 | Popular Tags |