Package org.infinispan.util

Examples of org.infinispan.util.FileLookup


         }

         if (channel == null && props.containsKey(CONFIGURATION_FILE)) {
            cfg = props.getProperty(CONFIGURATION_FILE);
            try {
               channel = new JChannel(new FileLookup().lookupFileLocation(cfg));
            } catch (Exception e) {
               log.errorCreatingChannelFromConfigFile(cfg);
               throw new CacheException(e);
            }
         }

         if (channel == null && props.containsKey(CONFIGURATION_XML)) {
            cfg = props.getProperty(CONFIGURATION_XML);
            try {
               channel = new JChannel(XmlConfigHelper.stringToElement(cfg));
            } catch (Exception e) {
               log.errorCreatingChannelFromXML(cfg);
               throw new CacheException(e);
            }
         }

         if (channel == null && props.containsKey(CONFIGURATION_STRING)) {
            cfg = props.getProperty(CONFIGURATION_STRING);
            try {
               channel = new JChannel(cfg);
            } catch (Exception e) {
               log.errorCreatingChannelFromConfigString(cfg);
               throw new CacheException(e);
            }
         }
      }

      if (channel == null) {
         log.unableToUseJGroupsPropertiesProvided(props);
         try {
            channel = new JChannel(new FileLookup().lookupFileLocation(DEFAULT_JGROUPS_CONFIGURATION_FILE));
         } catch (ChannelException e) {
            throw new CacheException("Unable to start JGroups channel", e);
         }
      }
   }
View Full Code Here


      TRANSFORMATIONS.put(EHCACHE_CACHE1X, "xslt/ehcache1x2infinispan4x.xslt");
      TRANSFORMATIONS.put(COHERENCE_35X, "xslt/coherence35x2infinispan4x.xslt");
   }

   public void parse(InputStream is, OutputStream os, String xsltFile) throws Exception {
      InputStream xsltInStream = new FileLookup().lookupFile(xsltFile);
      if (xsltInStream == null) {
         throw new IllegalStateException("Cold not find xslt file! : " + xsltFile);
      }

      try {
         Document document = getInputDocument(is);

         // Use a Transformer for output
         Transformer transformer = getTransformer(xsltInStream);

         DOMSource source = new DOMSource(document);
         ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
         StreamResult result = new StreamResult(byteArrayOutputStream);
         transformer.transform(source, result);

         InputStream indentation = new FileLookup().lookupFile("xslt/indent.xslt");
         try {
            // Use a Transformer for output
            transformer = getTransformer(indentation);
            StreamResult finalResult = new StreamResult(os);
            StreamSource rawResult = new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
View Full Code Here

    * Writes to the <b>os</b> the infinispan 4.x configuration file resulted by transforming configuration file passed
    * in as <b>inputFile</b>. Transformation is performed according to the <b>xsltFile</b>. Both <b>inputFile</b> and he
    * xslt file are looked up using a {@link org.infinispan.util.FileLookup}
    */
   public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception {
      InputStream stream = new FileLookup().lookupFileStrict(inputFile);
      try {
         parse(stream, os, xsltFile);
      }
      finally {
         Util.close(stream);
View Full Code Here

         }

         if (channel == null && props.containsKey(CONFIGURATION_FILE)) {
            cfg = props.getProperty(CONFIGURATION_FILE);
            try {
               channel = new JChannel(new FileLookup().lookupFileLocation(cfg));
            } catch (Exception e) {
               log.errorCreatingChannelFromConfigFile(cfg);
               throw new CacheException(e);
            }
         }

         if (channel == null && props.containsKey(CONFIGURATION_XML)) {
            cfg = props.getProperty(CONFIGURATION_XML);
            try {
               channel = new JChannel(XmlConfigHelper.stringToElement(cfg));
            } catch (Exception e) {
               log.errorCreatingChannelFromXML(cfg);
               throw new CacheException(e);
            }
         }

         if (channel == null && props.containsKey(CONFIGURATION_STRING)) {
            cfg = props.getProperty(CONFIGURATION_STRING);
            try {
               channel = new JChannel(cfg);
            } catch (Exception e) {
               log.errorCreatingChannelFromConfigString(cfg);
               throw new CacheException(e);
            }
         }
      }

      if (channel == null) {
         log.unableToUseJGroupsPropertiesProvided(props);
         try {
            channel = new JChannel(new FileLookup().lookupFileLocation(DEFAULT_JGROUPS_CONFIGURATION_FILE));
         } catch (ChannelException e) {
            throw new CacheException("Unable to start JGroups channel", e);
         }
      }
   }
View Full Code Here

      boolean validating = !skipSchemaValidation();
      if (!validating)
         return null;

      //1. resolve given path
      FileLookup fileLookup = new FileLookup();
      InputStream is = null;
      if (localPathToSchema != null) {
         is = fileLookup.lookupFile(localPathToSchema);
         if (is != null) {
            log.debug("Using schema " + localPathToSchema);
            return is;
         }
         log.debug("Could not find schema on path " + localPathToSchema + ", resolving "
                 + SCHEMA_SYSTEM_PROPERTY + " to " + schemaPath());
      }

      //2. resolve local schema path in infinispan distro
      is = fileLookup.lookupFile(schemaPath());
      if (is != null) {
         log.debug("Using schema " + schemaPath());
         return is;
      }
      log.debug("Could not find schema on path " + schemaPath() + ", resolving "
View Full Code Here

   }

   private static InputStream findInputStream(String fileName) throws FileNotFoundException {
      if (fileName == null)
         throw new NullPointerException("File name cannot be null!");
      FileLookup fileLookup = new FileLookup();
      InputStream is = fileLookup.lookupFile(fileName);
      if (is == null)
         throw new FileNotFoundException("File " + fileName
                 + " could not be found, either on the classpath or on the file system!");
      return is;
   }
View Full Code Here

   public static InputStream findSchemaInputStream() {
      boolean validating = !skipSchemaValidation();
      if (!validating)
         return null;

      FileLookup fileLookup = new FileLookup();
      InputStream is = fileLookup.lookupFile(schemaPath());
      if (is != null)
         return is;
      try {
         is = new URL(schemaURL()).openStream();
         return is;
View Full Code Here

   }

   private static InputStream findInputStream(String fileName) throws FileNotFoundException {
      if (fileName == null)
         throw new NullPointerException("File name cannot be null!");
      FileLookup fileLookup = new FileLookup();
      InputStream is = fileLookup.lookupFile(fileName);
      if (is == null)
         throw new FileNotFoundException("File " + fileName
               + " could not be found, either on the classpath or on the file system!");
      return is;
   }
View Full Code Here

   }

   private ConfigurationBuilderHolder getConfigurationBuilderHolder(
         ClassLoader classLoader) {
      try {
         FileLookup fileLookup = FileLookupFactory.newInstance();
         InputStream configurationStream = uri.isAbsolute()
               ? fileLookup.lookupFileStrict(uri, classLoader)
               : fileLookup.lookupFileStrict(uri.toString(), classLoader);
         return new ParserRegistry(classLoader).parse(configurationStream);
      } catch (FileNotFoundException e) {
         // No such file, lets use default CBH
         return new ConfigurationBuilderHolder(classLoader);
      }
View Full Code Here

      String cfg;
      if (props != null) {
         if (props.containsKey(CONFIGURATION_FILE)) {
            cfg = props.getProperty(CONFIGURATION_FILE);
            try {
               channel = new JChannel(new FileLookup().lookupFileLocation(cfg));
            } catch (Exception e) {
               log.error("Error while trying to create a channel using config files: " + cfg);
               throw new CacheException(e);
            }
         }

         if (props.containsKey(CONFIGURATION_XML)) {
            cfg = props.getProperty(CONFIGURATION_XML);
            try {
               channel = new JChannel(XmlConfigHelper.stringToElement(cfg));
            } catch (Exception e) {
               log.error("Error while trying to create a channel using config XML: " + cfg);
               throw new CacheException(e);
            }
         }

         if (props.containsKey(CONFIGURATION_STRING)) {
            cfg = props.getProperty(CONFIGURATION_STRING);
            try {
               channel = new JChannel(cfg);
            } catch (Exception e) {
               log.error("Error while trying to create a channel using config string: " + cfg);
               throw new CacheException(e);
            }
         }
      }

      if (channel == null) {
         log.info("Unable to use any JGroups configuration mechanisms provided in properties {0}.  Using default JGroups configuration!", props);
         try {
            channel = new JChannel(new FileLookup().lookupFileLocation(DEFAULT_JGROUPS_CONFIGURATION_FILE));
         } catch (ChannelException e) {
            throw new CacheException("Unable to start JGroups channel", e);
         }
      }
   }
View Full Code Here

TOP

Related Classes of org.infinispan.util.FileLookup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.