1 24 25 package org.objectweb.cjdbc.common.monitor.backend; 26 27 import org.objectweb.cjdbc.common.exceptions.DataCollectorException; 28 import org.objectweb.cjdbc.common.monitor.AbstractDataCollector; 29 import org.objectweb.cjdbc.controller.backend.DatabaseBackend; 30 import org.objectweb.cjdbc.controller.core.Controller; 31 import org.objectweb.cjdbc.controller.monitoring.datacollector.DataCollector; 32 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase; 33 34 39 public abstract class AbstractBackendDataCollector 40 extends AbstractDataCollector 41 { 42 private String backendName; 43 private String virtualDatabaseName; 44 45 51 public AbstractBackendDataCollector(String backendName, 52 String virtualDatabaseName) 53 { 54 super(); 55 this.backendName = backendName; 56 this.virtualDatabaseName = virtualDatabaseName; 57 } 58 59 62 public long collectValue() throws DataCollectorException 63 { 64 try 65 { 66 VirtualDatabase vdb = ((Controller) controller) 67 .getVirtualDatabase(virtualDatabaseName); 68 DatabaseBackend db = vdb.getAndCheckBackend(backendName, 69 VirtualDatabase.NO_CHECK_BACKEND); 70 return this.getValue(db); 71 } 72 catch (Exception e) 73 { 74 throw new DataCollectorException(DataCollector.BACKEND_NOT_ACCESSIBLE); 75 } 76 } 77 78 84 public abstract long getValue(Object backend); 85 86 89 public String getTargetName() 90 { 91 return backendName; 92 } 93 } 94 | Popular Tags |