Community
Participate
Working Groups
Provide abstract OSGiActivator.WithConfig
/** * @author Eike Stepper * @since 3.1 */ public static abstract class WithConfig extends OSGiActivator { public WithConfig(OMBundle bundle) { super(bundle); } @Override protected final void doStart() throws Exception { FileInputStream fis = null; try { File configFile = OM.BUNDLE.getConfigFile(); if (configFile.exists()) { fis = new FileInputStream(configFile); ObjectInputStream ois = new ObjectInputStream(fis); Object config = ois.readObject(); IOUtil.close(ois); doStartWithConfig(config); } } catch (Exception ex) { getOMBundle().logger().error(ex); } finally { IOUtil.close(fis); } } @Override protected final void doStop() throws Exception { FileOutputStream fos = null; try { Object config = doStopWithConfig(); File configFile = OM.BUNDLE.getConfigFile(); fos = new FileOutputStream(configFile); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(config); IOUtil.close(oos); } catch (Exception ex) { getOMBundle().logger().error(ex); } finally { IOUtil.close(fos); } } protected abstract void doStartWithConfig(Object config) throws Exception; protected abstract Object doStopWithConfig() throws Exception; }
Committed to HEAD
Available in R20110608-1407