1 23 24 package com.sun.enterprise.admin.mbeans; 25 26 import com.sun.logging.LogDomains; 27 import com.sun.enterprise.config.ConfigContext; 28 import com.sun.enterprise.config.ConfigException; 29 import com.sun.enterprise.admin.config.BaseConfigMBean; 30 import com.sun.enterprise.util.i18n.StringManager; 31 32 import com.sun.enterprise.admin.servermgmt.InstanceException; 33 import com.sun.enterprise.admin.event.AdminEventResult; 34 import com.sun.enterprise.admin.event.AdminEvent; 35 import com.sun.enterprise.admin.event.AdminEventMulticaster; 36 import com.sun.enterprise.admin.event.EjbTimerEvent; 37 38 import com.sun.enterprise.server.ApplicationServer; 39 import com.sun.enterprise.server.ServerContext; 40 41 import java.util.logging.Logger ; 42 import java.util.logging.Level ; 43 44 51 public class EJBTimerManagementMBean 52 extends BaseConfigMBean 53 implements com.sun.enterprise.admin.mbeanapi.IEJBTimerManagementMBean 54 { 55 56 public EJBTimerManagementMBean() 57 { 58 super(); 59 } 60 61 private Logger getLogger() 62 { 63 if (_logger == null) { 64 _logger = Logger.getLogger(LogDomains.ADMIN_LOGGER); 65 } 66 return _logger; 67 } 68 69 79 public String [] listTimers(String target) 80 throws ConfigException, InstanceException { 81 82 fine("Entering list Timers"); 83 String server = getServerName(); 84 85 fine("List Timers: Sending Notification to server" + server); 86 87 String [] resStr = sendListTimerEvent(server, new String [] {server}); 88 fine("RESULT: " + resStr); 89 if(resStr == null || resStr.length == 0) { 90 resStr = new String [] {"There are no Ejb Timers."}; 91 } 92 resStr[0] = server + ": " + resStr[0]; 93 return resStr; 94 } 95 96 protected String [] sendListTimerEvent(String server, String [] allServers) { 97 AdminEvent event = new EjbTimerEvent(server, 98 EjbTimerEvent.ACTION_LISTTIMERS, 99 server, 100 allServers); 101 102 event.setTargetDestination(server); 103 AdminEventResult res = forwardEvent(event); 104 105 return (String []) res.getAttribute(server, 106 EjbTimerEvent.EJB_TIMER_CALL_RESULT_ATTRNAME); 107 } 108 109 protected AdminEventResult forwardEvent(AdminEvent e) { 110 111 AdminEventResult result = null; 112 result = AdminEventMulticaster.multicastEvent(e); 113 return result; 114 } 115 116 private void fine(String s) { 117 getLogger().log(Level.INFO, s); } 119 120 121 private String getServerName() { 122 return ApplicationServer.getServerContext().getInstanceName(); 123 } 124 126 private static final StringManager _strMgr = 127 StringManager.getManager(EJBTimerManagementMBean.class); 128 private static Logger _logger; 129 } 131 | Popular Tags |