示例#1
0
    // This method is called whenever an external entity is accessed
    // for the first time.
    public InputSource resolveEntity(String publicId, String systemId) {
      // Map the external entity to a local file
      if (URL_PROPERTY_LIST.equals(systemId)) {
        return new InputSource(ClassLoader.getSystemResourceAsStream(FILENAME_PROPERTY_LIST));
      }

      // Returning null causes the caller to try accessing the systemid
      return null;
    }
示例#2
0
    // return the resource as a stream
    private InputStream mapResource(String publicId) {
      if (publicId == null || id2resource == null) return null;

      String resourceName = (String) id2resource.get(publicId);
      ClassLoader loader = null;

      if (resourceName == null) return null;

      if (id2loader != null) loader = (ClassLoader) id2loader.get(publicId);

      if (loader == null) return ClassLoader.getSystemResourceAsStream(resourceName);
      return loader.getResourceAsStream(resourceName);
    }
示例#3
0
 private boolean testExecutionMode() {
   executionMode = false;
   JarFile file = null;
   try {
     file = new JarFile(getTangaraPath());
     ZipEntry entry = file.getEntry(EXECUTION_PROPERTIES_FILENAME);
     if (entry != null) {
       executionMode = true;
       System.out.println("execution mode detected");
       Properties executionProperties = new Properties();
       InputStream ips = ClassLoader.getSystemResourceAsStream(EXECUTION_PROPERTIES_FILENAME);
       executionProperties.load(ips);
       if (executionProperties.containsKey("main-program")) {
         String mainTangaraFile = executionProperties.getProperty("main-program");
         System.out.println("main tangara file: " + mainTangaraFile);
         properties.setProperty("main-program", mainTangaraFile);
       } else {
         System.err.println("error : main program not specified");
       }
       if (executionProperties.containsKey("language")) {
         String language = executionProperties.getProperty("language");
         properties.setProperty("language", language);
         System.out.println("language: " + language);
       } else {
         System.err.println("error : language not specified");
       }
       if (executionProperties.containsKey("resources")) {
         String resources = executionProperties.getProperty("resources");
         properties.setProperty("program.resources", resources);
         System.out.println("resources: " + resources);
       } else {
         System.err.println("error : resources not specified");
       }
     }
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     if (file != null) {
       try {
         file.close();
       } catch (IOException e) {
         System.err.println("error while closing tangara JAR file");
       }
     }
   }
   return executionMode;
 }
示例#4
0
 public InputStream getResourceAsStream(String name) {
   return ClassLoader.getSystemResourceAsStream(name);
 }