001 package de.deepamehta.storage.neo4j; 002 003 import de.deepamehta.core.storage.spi.DeepaMehtaStorage; 004 005 import org.osgi.framework.BundleActivator; 006 import org.osgi.framework.BundleContext; 007 008 import java.util.logging.Logger; 009 010 011 012 public class Neo4jStorageActivator implements BundleActivator { 013 014 // ------------------------------------------------------------------------------------------------------- Constants 015 016 private static final String DATABASE_PATH = System.getProperty("dm4.database.path"); 017 018 // ---------------------------------------------------------------------------------------------- Instance Variables 019 020 private DeepaMehtaStorage storage; 021 022 private final Logger logger = Logger.getLogger(getClass().getName()); 023 024 // -------------------------------------------------------------------------------------------------- Public Methods 025 026 027 028 // ************************************** 029 // *** BundleActivator Implementation *** 030 // ************************************** 031 032 033 034 @Override 035 public void start(BundleContext context) { 036 try { 037 logger.info("========== Starting \"DeepaMehta 4 Storage - Neo4j\" =========="); 038 storage = new Neo4jStorage(DATABASE_PATH); 039 // 040 logger.info("Registering DeepaMehta 4 storage service - Neo4j - at OSGi framework"); 041 context.registerService(DeepaMehtaStorage.class.getName(), storage, null); 042 } catch (Exception e) { 043 logger.severe("Starting \"DeepaMehta 4 Storage - Neo4j\" failed:"); 044 e.printStackTrace(); 045 // Note: we don't throw through the OSGi container here. It would not print out the stacktrace. 046 // File Install would retry to start the bundle endlessly. 047 } 048 } 049 050 @Override 051 public void stop(BundleContext context) { 052 try { 053 logger.info("========== Stopping \"DeepaMehta 4 Storage - Neo4j\" =========="); 054 if (storage != null) { 055 storage.shutdown(); 056 } 057 } catch (Exception e) { 058 logger.severe("Stopping \"DeepaMehta 4 Storage - Neo4j\" failed:"); 059 e.printStackTrace(); 060 // Note: we don't throw through the OSGi container here. It would not print out the stacktrace. 061 } 062 } 063 }