1 22 package org.jboss.mx.persistence; 23 24 import java.io.File ; 25 import java.io.FileInputStream ; 26 import java.io.FileOutputStream ; 27 import java.io.IOException ; 28 import java.io.ObjectInputStream ; 29 import java.io.ObjectOutputStream ; 30 import javax.management.MBeanInfo ; 31 32 import org.jboss.logging.Logger; 33 34 import java.io.FileNotFoundException ; 35 36 41 public class MBeanInfoOdb 42 { 43 protected Logger fLogger; 44 45 47 public MBeanInfoOdb() 48 { 49 super(); 50 } 51 52 54 protected void store(MBeanInfo metadata, File location) throws IOException 55 { 56 location.createNewFile(); 57 FileOutputStream fos = new FileOutputStream (location); 58 ObjectOutputStream oos = new ObjectOutputStream (fos); 59 oos.writeObject(metadata); 60 } 61 62 protected MBeanInfo load(File location) 63 throws IOException , FileNotFoundException , ClassNotFoundException 64 { 65 logger().info("Loading mbean info from location: " + location.getAbsolutePath()); 66 FileInputStream fis = new FileInputStream (location); 67 ObjectInputStream ois = new ObjectInputStream (fis); 68 MBeanInfo obj = (MBeanInfo ) ois.readObject(); 69 ois.close(); 70 return obj; 71 } 72 73 protected Logger logger() 74 { 75 if (fLogger == null) 76 { 77 fLogger = Logger.getLogger("" + getClass().getName()); 78 } 79 return fLogger; 80 } 81 } 82 83 | Popular Tags |