Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * **************************************************************************
- * GOVERNMENT PURPOSE RIGHTS
- *
- * Contract No: FA8731-08-C-0002.
- * Contractor Name: Accenture/Gestalt, LLC
- * Contractor Address: 680 American Ave
- * Suite 302
- * King of Prussia, PA 19406
- * Expiration Date: 6 August 2011
- *
- * The Government's rights to use, modify, reproduce, release, perform, display,
- * or disclose this software are restricted by paragraph (b)(2) of the Rights in
- * Noncommercial Computer Software and Noncommercial Computer Software Documentation
- * clause contained in the above identified contract. No restrictions apply after the
- * expiration date shown above. Any reproduction of the software or portions thereof
- * marked with this legend must also reproduce the markings.
- *
- * DISTRIBUTION STATEMENT D. Distribution authorized to the Department of Defense and
- * U.S. DoD contractors only (Software Documentation) (13 Dec 2004). Other requests
- * shall be referred to (GIGSG/ES).
- * **************************************************************************
- */
- import org.osgi.framework.*
- import org.apache.felix.framework.Felix
- import org.apache.felix.framework.util.FelixConstants
- import org.apache.felix.framework.cache.BundleCache
- import org.apache.felix.framework.util.StringMap
- import org.apache.felix.main.AutoActivator
- import java.util.Map
- import org.springframework.context.ApplicationContext
- import com.accenture.netcds.*
- import org.codehaus.groovy.grails.commons.ConfigurationHolder
- import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
- class BootStrap {
- // Values retrieved from Config.groovy
- def BUNDLE_LOCATION = ConfigurationHolder.config.dds.bundle.location
- def INTERP_LOCATION = ConfigurationHolder.config.dds.lib.location
- //JLG def LISTENER_DIR = ConfigurationHolder.config.dds.listener.dir
- def cachedir = File.createTempFile("felix.tmp", null);
- def init = { servletContext ->
- log.debug "BUNDLE_LOCATION: " + BUNDLE_LOCATION
- log.debug "INTERP_LOCATION: " + INTERP_LOCATION
- //JLG log.debug "LISTENER_DIR: " + LISTENER_DIR
- cachedir.delete()
- def configMap = new StringMap(false)
- configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true")
- configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
- "org.osgi.util.tracker; version=1.3.2," +
- "javax.swing.border;," +
- "javax.swing.event;," +
- "javax.swing.table;," +
- "javax.swing.tree;," +
- "javax.naming;," +
- "javax.naming.spi;," +
- "javax.net;," +
- "javax.net.ssl;," +
- "javax.sql;," +
- "javax.swing;," +
- "javax.xml.parsers;," +
- "javax.xml.namespace;," +
- "javax.xml.xpath;," +
- "javax.servlet.http;," +
- "javax.servlet;," +
- "org.w3c.dom;," +
- "org.xml.sax;," +
- "org.xml.sax.helpers;," +
- "net.sf.json;," +
- "org.osgi.framework; version=1.4.0," +
- "org.osgi.service.packageadmin; version=1.2.0," +
- "org.osgi.service.startlevel; version=1.1.0," +
- "org.osgi.service.url; version=1.0.0,");
- def bundles =
- this.getClass().getClassLoader().getResource(INTERP_LOCATION + "interpreter-api-0.1.0-SNAPSHOT.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(INTERP_LOCATION + "all_numeric-interpreter-0.1.0-SNAPSHOT.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(INTERP_LOCATION + "single_series-interpreter-0.1.0-SNAPSHOT.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(INTERP_LOCATION + "mapping-interpreter-0.1.0-SNAPSHOT.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(INTERP_LOCATION + "com.springsource.org.hsqldb-1.8.0.9.jar").toString() + " " +
- // this.getClass().getClassLoader().getResource(INTERP_LOCATION + "pax-loggin-api-1.1.0.jar").toString() + " " +
- // this.getClass().getClassLoader().getResource(INTERP_LOCATION + "pax-loggin-service-1.1.0.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(INTERP_LOCATION + "org.apache.felix.shell-1.0.2.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.apache.felix.scr-1.0.7-SNAPSHOT.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.osgi.compendium-1.3.0-SNAPSHOT.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.apache.felix.http.jetty-0.9.0-SNAPSHOT.jar").toString() + " " +
- this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.apache.felix.webconsole-1.2.1-SNAPSHOT.jar").toString() + " " +
- //JLG this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.modulefusion.dirinstaller.jar").toString()
- configMap.put(AutoActivator.AUTO_START_PROP + ".1", bundles)
- configMap.put(FelixConstants.LOG_LEVEL_PROP, "1")
- configMap.put("org.osgi.service.http.port", "9999")
- //JLG configMap.put("dirinstaller.dir", LISTENER_DIR)
- configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, cachedir.getAbsolutePath())
- // Create list to hold custom framework activators.
- List list = new ArrayList()
- // Add activator to process auto-start/install properties.
- list.add(new AutoActivator(configMap))
- // Add our own activator.
- //list.add(this);
- try
- {
- // Now create an instance of the framework.
- Felix felix = new Felix(configMap, list)
- felix.start();
- log.debug("Started Felix!")
- ApplicationContext ctx = servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)
- InterpreterServiceInf service = (InterpreterServiceInf) ctx.getBean("interpreterService")
- if (service.setBundleContext(felix.getBundleContext())) {
- log.debug("GRAILS SERVICE LOADED: " + service.getName())
- }
- }
- catch (Exception ex)
- {
- System.err.println("Could not create framework: " + ex)
- ex.printStackTrace()
- System.exit(-1)
- }
- }
- def destroy = {
- deleteFileOrDir(cachedir);
- log.info("Removing BundleCache")
- }
- /**
- * Utility method used to delete the profile directory when run as
- * a stand-alone application.
- * @param file The file to recursively delete.
- **/
- private void deleteFileOrDir(File file) {
- if (file.isDirectory())
- {
- File[] childs = file.listFiles()
- for (int i = 0;i < childs.length;i++)
- {
- deleteFileOrDir(childs[i])
- }
- }
- file.delete()
- }
- }
Add Comment
Please, Sign In to add comment