1 12 13 package org.ejtools.jmx.browser.model.service; 14 15 16 17 import java.beans.beancontext.BeanContextServices ; 18 19 import java.util.Iterator ; 20 21 import java.util.Vector ; 22 23 24 25 import org.apache.log4j.Logger; 26 27 import org.ejtools.beans.beancontext.CustomBeanContextServiceProvider; 28 29 import org.ejtools.jmx.browser.model.connector.LocalConnectionService; 30 31 import org.ejtools.util.service.Profile; 32 33 34 35 50 51 public class ConnectionServiceProvider extends CustomBeanContextServiceProvider 52 53 { 54 55 56 57 protected ConnectionService service = null; 58 59 60 61 private static Logger logger = Logger.getLogger(ConnectionServiceProvider.class); 62 63 64 65 66 67 68 69 public ConnectionServiceProvider() 70 71 { 72 73 this.setup(new LocalConnectionService()); 74 75 } 76 77 78 79 80 81 92 93 public ConnectionServiceProvider(Profile metadata) 94 95 { 96 97 99 String clazz = metadata.getProperty(ConnectionMetaData.CLASS_NAME); 100 101 if (clazz != null) 102 103 { 104 105 try 106 107 { 108 109 ConnectionService service = (ConnectionService) Thread.currentThread().getContextClassLoader().loadClass(clazz).newInstance(); 110 111 this.setup(service); 112 113 } 114 115 catch (ClassNotFoundException cnfe) 116 117 { 118 119 logger.error(cnfe.getMessage(), cnfe); 120 121 } 122 123 catch (IllegalAccessException iae) 124 125 { 126 127 logger.error(iae.getMessage(), iae); 128 129 } 130 131 catch (Exception e) 132 133 { 134 135 logger.error(e.getMessage(), e); 136 137 } 138 139 } 140 141 else 142 143 { 144 145 logger.error("Class provided is null"); 146 147 } 148 149 } 150 151 152 153 154 155 168 169 public Iterator getCurrentServiceSelectors(BeanContextServices bcs, java.lang.Class serviceClass) 170 171 { 172 173 return (new Vector ()).iterator(); 174 175 } 176 177 178 179 180 181 198 199 public Object getService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Class serviceClass, java.lang.Object serviceSelector) 200 201 { 202 203 return this.service; 204 205 } 206 207 208 209 210 211 224 225 public void releaseService(BeanContextServices bcs, java.lang.Object requestor, java.lang.Object service) { } 226 227 228 229 230 231 236 237 protected Class [] getServiceClass() 238 239 { 240 241 return new Class []{ConnectionService.class}; 242 243 } 244 245 246 247 248 249 258 259 private void setup(ConnectionService service) 260 261 { 262 263 this.service = service; 264 265 } 266 267 } 268 269 | Popular Tags |