1 23 24 package com.sun.enterprise.admin.server.core; 25 26 import java.util.List ; 27 import java.util.ArrayList ; 28 import java.util.Iterator ; 29 import java.util.logging.Level ; 30 import java.util.logging.Logger ; 31 import java.util.Properties ; 32 import java.util.Enumeration ; 33 34 import javax.management.ObjectName ; 35 import javax.management.Attribute ; 36 37 import com.sun.enterprise.admin.AdminContext; 38 import com.sun.enterprise.admin.event.AdminEvent; 39 import com.sun.enterprise.admin.event.AdminEventCache; 40 import com.sun.enterprise.admin.event.AdminEventMulticaster; 41 import com.sun.enterprise.admin.event.AdminEventResult; 42 import com.sun.enterprise.admin.event.ElementChangeHelper; 43 import com.sun.enterprise.admin.util.proxy.CallStack; 44 import com.sun.enterprise.admin.util.proxy.Call; 45 import com.sun.enterprise.admin.util.proxy.InterceptorImpl; 46 import com.sun.enterprise.admin.event.EventStack; 47 import com.sun.enterprise.admin.event.EventContext; 48 import com.sun.enterprise.config.ConfigContext; 49 import com.sun.enterprise.config.ConfigException; 50 import com.sun.enterprise.admin.event.ResourceDeployEvent; 51 import com.sun.enterprise.admin.event.BaseDeployEvent; 52 import com.sun.enterprise.security.SecurityContext; 53 import com.sun.enterprise.security.audit.AuditManager; 54 import com.sun.enterprise.security.audit.AuditManagerFactory; 55 56 import com.sun.enterprise.admin.event.pluggable.RestartEventHelper; 57 import com.sun.enterprise.server.pluggable.PluggableFeatureFactory; 58 import com.sun.enterprise.server.ApplicationServer; 59 import com.sun.enterprise.server.ServerContext; 60 import com.sun.enterprise.admin.event.pluggable.NotificationFactory; 61 62 63 66 public class AdminNotificationHelper { 67 68 private AdminContext _adminContext; 69 private Logger _logger; 70 71 public AdminNotificationHelper(AdminContext ctx) { 72 _adminContext = ctx; 73 if (_adminContext != null) { 74 _logger = _adminContext.getAdminLogger(); 75 } else { 76 _logger = Logger.getLogger("global"); 77 } 78 } 79 80 public void sendNotification() { 81 ConfigContext context = _adminContext.getAdminConfigContext(); 82 String instanceName = _adminContext.getServerName(); 83 AdminEventCache cache = 84 AdminEventCache.getInstance(instanceName); 85 cache.setAdminConfigContext(context); 86 ArrayList changeList = context.getConfigChangeList(); 87 context.resetConfigChangeList(); 88 ArrayList eventList = null; 89 if (changeList.size() <= 0) { 90 eventList = new ArrayList (); 91 } 94 else 95 { 96 cache.processConfigChangeList(changeList, false, false); 97 eventList = cache.getAndResetCachedEvents(); 98 99 try { 102 ElementChangeHelper elementHelper = new ElementChangeHelper(); AdminEvent[] elementChangeEvents = elementHelper.generateElementChangeEventsFromChangeList(instanceName, changeList, context); 104 if(elementChangeEvents!=null) 105 for(int i=0; i<elementChangeEvents.length; i++) 106 eventList.add(elementChangeEvents[i]); 107 } catch (Exception e) { 108 } 110 112 } 113 EventStack stack = EventContext.getEventStackFromThreadLocal(); 114 List newEventList = stack.getEvents(); 115 newEventList.addAll(eventList); 116 117 boolean requiresRestart = false; 118 119 Iterator iter = newEventList.iterator(); 120 while (iter.hasNext()) { 121 AdminEvent event = (AdminEvent)iter.next(); 122 if (_logger.isLoggable(Level.FINEST)) { 123 _logger.log(Level.FINEST, "mbean.event_sent", 124 event.getEventInfo()); 125 } else { 126 _logger.log(Level.INFO, "mbean.send_event", event.toString()); 127 } 128 AdminEventResult result=AdminEventMulticaster.multicastEvent(event); 129 _logger.log(Level.FINE, "mbean.event_res", result.getResultCode()); 130 _logger.log(Level.FINEST, "mbean.event_reply", 131 result.getAllMessagesAsString()); 132 if (!AdminEventResult.SUCCESS.equals(result.getResultCode())) { 133 requiresRestart = true; 134 cache.setRestartNeeded(true); 135 } 139 140 } 141 ServerContext svcCtx = ApplicationServer.getServerContext(); 142 PluggableFeatureFactory featureFactory = null; 143 if (svcCtx != null) { 144 featureFactory = svcCtx.getPluggableFeatureFactory(); 145 146 NotificationFactory nFactory = 148 featureFactory.getNotificationFactory(); 149 RestartEventHelper helper = nFactory.createRestartEventHelper(); 150 helper.setRestartRequiredForTarget(context, changeList); 151 152 } 153 stack.resetEvents(); 154 155 return; 156 } 157 158 } 159 | Popular Tags |