1 23 24 29 30 package com.sun.enterprise.admin.mbeans; 31 32 import com.sun.enterprise.admin.servermgmt.InstanceException; 33 import com.sun.enterprise.config.ConfigException; 34 35 import com.sun.enterprise.util.i18n.StringManagerBase; 36 37 import java.util.logging.Logger ; 38 import java.util.logging.Level ; 39 40 44 public class ExceptionHandler { 45 46 private Logger _logger; 47 48 49 53 public ExceptionHandler(Logger logger) { 54 _logger = logger; 55 } 56 57 protected Logger getLogger() 58 { 59 return _logger; 60 } 61 62 public InstanceException handleInstanceException(Exception ex, String messageId, String arg) 63 { 64 return handleInstanceException(ex, messageId, new String [] {arg}); 65 } 66 67 75 public InstanceException handleInstanceException(Exception ex, String messageId, String [] args) 76 { 77 InstanceException result = null; 78 Level level = Level.FINE; 79 if (ex instanceof InstanceException) { 80 result = (InstanceException)ex; 81 } else if (ex instanceof ConfigException) { 82 result = new InstanceException(ex); 83 } else { 84 level = Level.WARNING; 85 result = new InstanceException(ex); 86 } 87 StringManagerBase sm = StringManagerBase.getStringManager(getLogger().getResourceBundleName()); 88 getLogger().log(level, sm.getString(messageId, args), ex); 89 return result; 90 } 91 92 public ConfigException handleConfigException(Exception ex, String messageId, String arg) 93 { 94 return handleConfigException(ex, messageId, new String [] {arg}); 95 } 96 97 105 public ConfigException handleConfigException(Exception ex, String messageId, String [] args) 106 { 107 ConfigException result = null; 108 Level level = Level.FINE; 109 if (ex instanceof ConfigException) { 110 result = (ConfigException)ex; 111 } else { 112 level = Level.WARNING; 113 result = new ConfigException(ex); 114 } 115 StringManagerBase sm = StringManagerBase.getStringManager(getLogger().getResourceBundleName()); 116 getLogger().log(level, sm.getString(messageId, args), ex); 117 return result; 118 } 119 } 120 | Popular Tags |