Guest User

Untitled

a guest
Feb 20th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.44 KB | None | 0 0
  1. /*
  2. * **************************************************************************
  3. * GOVERNMENT PURPOSE RIGHTS
  4. *
  5. * Contract No: FA8731-08-C-0002.
  6. * Contractor Name: Accenture/Gestalt, LLC
  7. * Contractor Address: 680 American Ave
  8. * Suite 302
  9. * King of Prussia, PA 19406
  10. * Expiration Date: 6 August 2011
  11. *
  12. * The Government's rights to use, modify, reproduce, release, perform, display,
  13. * or disclose this software are restricted by paragraph (b)(2) of the Rights in
  14. * Noncommercial Computer Software and Noncommercial Computer Software Documentation
  15. * clause contained in the above identified contract. No restrictions apply after the
  16. * expiration date shown above. Any reproduction of the software or portions thereof
  17. * marked with this legend must also reproduce the markings.
  18. *
  19. * DISTRIBUTION STATEMENT D. Distribution authorized to the Department of Defense and
  20. * U.S. DoD contractors only (Software Documentation) (13 Dec 2004). Other requests
  21. * shall be referred to (GIGSG/ES).
  22. * **************************************************************************
  23. */
  24. import org.osgi.framework.*
  25. import org.apache.felix.framework.Felix
  26. import org.apache.felix.framework.util.FelixConstants
  27. import org.apache.felix.framework.cache.BundleCache
  28. import org.apache.felix.framework.util.StringMap
  29. import org.apache.felix.main.AutoActivator
  30.  
  31. import java.util.Map
  32.  
  33. import org.springframework.context.ApplicationContext
  34.  
  35. import com.accenture.netcds.*
  36. import org.codehaus.groovy.grails.commons.ConfigurationHolder
  37. import org.codehaus.groovy.grails.web.servlet.GrailsApplicationAttributes
  38.  
  39. class BootStrap {
  40.  
  41. // Values retrieved from Config.groovy
  42. def BUNDLE_LOCATION = ConfigurationHolder.config.dds.bundle.location
  43. def INTERP_LOCATION = ConfigurationHolder.config.dds.lib.location
  44. //JLG def LISTENER_DIR = ConfigurationHolder.config.dds.listener.dir
  45.  
  46. def cachedir = File.createTempFile("felix.tmp", null);
  47. def init = { servletContext ->
  48.  
  49.  
  50. log.debug "BUNDLE_LOCATION: " + BUNDLE_LOCATION
  51. log.debug "INTERP_LOCATION: " + INTERP_LOCATION
  52. //JLG log.debug "LISTENER_DIR: " + LISTENER_DIR
  53. cachedir.delete()
  54.  
  55. def configMap = new StringMap(false)
  56.  
  57. configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true")
  58.  
  59. configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
  60. "org.osgi.util.tracker; version=1.3.2," +
  61. "javax.swing.border;," +
  62. "javax.swing.event;," +
  63. "javax.swing.table;," +
  64. "javax.swing.tree;," +
  65. "javax.naming;," +
  66. "javax.naming.spi;," +
  67. "javax.net;," +
  68. "javax.net.ssl;," +
  69. "javax.sql;," +
  70. "javax.swing;," +
  71. "javax.xml.parsers;," +
  72. "javax.xml.namespace;," +
  73. "javax.xml.xpath;," +
  74. "javax.servlet.http;," +
  75. "javax.servlet;," +
  76. "org.w3c.dom;," +
  77. "org.xml.sax;," +
  78. "org.xml.sax.helpers;," +
  79. "net.sf.json;," +
  80. "org.osgi.framework; version=1.4.0," +
  81. "org.osgi.service.packageadmin; version=1.2.0," +
  82. "org.osgi.service.startlevel; version=1.1.0," +
  83. "org.osgi.service.url; version=1.0.0,");
  84.  
  85. def bundles =
  86. this.getClass().getClassLoader().getResource(INTERP_LOCATION + "interpreter-api-0.1.0-SNAPSHOT.jar").toString() + " " +
  87. this.getClass().getClassLoader().getResource(INTERP_LOCATION + "all_numeric-interpreter-0.1.0-SNAPSHOT.jar").toString() + " " +
  88. this.getClass().getClassLoader().getResource(INTERP_LOCATION + "single_series-interpreter-0.1.0-SNAPSHOT.jar").toString() + " " +
  89. this.getClass().getClassLoader().getResource(INTERP_LOCATION + "mapping-interpreter-0.1.0-SNAPSHOT.jar").toString() + " " +
  90. this.getClass().getClassLoader().getResource(INTERP_LOCATION + "com.springsource.org.hsqldb-1.8.0.9.jar").toString() + " " +
  91. // this.getClass().getClassLoader().getResource(INTERP_LOCATION + "pax-loggin-api-1.1.0.jar").toString() + " " +
  92. // this.getClass().getClassLoader().getResource(INTERP_LOCATION + "pax-loggin-service-1.1.0.jar").toString() + " " +
  93. this.getClass().getClassLoader().getResource(INTERP_LOCATION + "org.apache.felix.shell-1.0.2.jar").toString() + " " +
  94. this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.apache.felix.scr-1.0.7-SNAPSHOT.jar").toString() + " " +
  95. this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.osgi.compendium-1.3.0-SNAPSHOT.jar").toString() + " " +
  96. this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.apache.felix.http.jetty-0.9.0-SNAPSHOT.jar").toString() + " " +
  97. this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.apache.felix.webconsole-1.2.1-SNAPSHOT.jar").toString() + " " +
  98. //JLG this.getClass().getClassLoader().getResource(BUNDLE_LOCATION + "org.modulefusion.dirinstaller.jar").toString()
  99. configMap.put(AutoActivator.AUTO_START_PROP + ".1", bundles)
  100.  
  101. configMap.put(FelixConstants.LOG_LEVEL_PROP, "1")
  102. configMap.put("org.osgi.service.http.port", "9999")
  103. //JLG configMap.put("dirinstaller.dir", LISTENER_DIR)
  104. configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, cachedir.getAbsolutePath())
  105. // Create list to hold custom framework activators.
  106. List list = new ArrayList()
  107. // Add activator to process auto-start/install properties.
  108. list.add(new AutoActivator(configMap))
  109. // Add our own activator.
  110. //list.add(this);
  111.  
  112. try
  113. {
  114. // Now create an instance of the framework.
  115. Felix felix = new Felix(configMap, list)
  116. felix.start();
  117. log.debug("Started Felix!")
  118.  
  119. ApplicationContext ctx = servletContext.getAttribute(GrailsApplicationAttributes.APPLICATION_CONTEXT)
  120.  
  121. InterpreterServiceInf service = (InterpreterServiceInf) ctx.getBean("interpreterService")
  122. if (service.setBundleContext(felix.getBundleContext())) {
  123. log.debug("GRAILS SERVICE LOADED: " + service.getName())
  124. }
  125.  
  126. }
  127. catch (Exception ex)
  128. {
  129. System.err.println("Could not create framework: " + ex)
  130. ex.printStackTrace()
  131. System.exit(-1)
  132. }
  133. }
  134.  
  135. def destroy = {
  136. deleteFileOrDir(cachedir);
  137. log.info("Removing BundleCache")
  138. }
  139.  
  140. /**
  141. * Utility method used to delete the profile directory when run as
  142. * a stand-alone application.
  143. * @param file The file to recursively delete.
  144. **/
  145. private void deleteFileOrDir(File file) {
  146. if (file.isDirectory())
  147. {
  148. File[] childs = file.listFiles()
  149. for (int i = 0;i < childs.length;i++)
  150. {
  151. deleteFileOrDir(childs[i])
  152. }
  153. }
  154. file.delete()
  155. }
  156. }
Add Comment
Please, Sign In to add comment