Package org.infinispan.util

Examples of org.infinispan.util.FileLookup


         }
      }
   }

   public ConfigurationBuilderHolder parseFile(String filename) throws IOException {
      FileLookup fileLookup = FileLookupFactory.newInstance();
      InputStream is = fileLookup.lookupFile(filename, cl);
      if(is==null) {
         throw new FileNotFoundException(filename);
      }
      try {
         return parse(is);
View Full Code Here


   public void setEntryWrapper(EntryWrapper<?, ?> entryWrapper) {
      this.entryWrapper = entryWrapper;
   }

   public void setHotRodClientPropertiesFile(String hotRodClientPropertiesFile) {
      FileLookup fileLookup = FileLookupFactory.newInstance();
      InputStream inputStream = fileLookup.lookupFile(hotRodClientPropertiesFile, getClassLoader());
      try {
         hotRodClientProperties.load(inputStream);
      } catch (IOException e) {
         log.error("Issues while loading properties from file " + hotRodClientPropertiesFile, e);
         throw new CacheException(e);
View Full Code Here

      gc.transport().clusterName(null).build();
   }

   @Test
   public void testSchema() throws Exception {
      FileLookup lookup = FileLookupFactory.newInstance();
      URL schemaFile = lookup.lookupFileLocation("schema/infinispan-config-5.2.xsd", Thread.currentThread().getContextClassLoader());
      Source xmlFile = new StreamSource(lookup.lookupFile("configs/all.xml", Thread.currentThread().getContextClassLoader()));
      SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(schemaFile).newValidator().validate(xmlFile);
   }
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) {
         // Schema's are always stored in Infinispan
         is = fileLookup.lookupFile(localPathToSchema, null);
         if (is != null) {
            log.debugf("Using schema %s", localPathToSchema);
            return is;
         }
         if (log.isDebugEnabled()) {
            log.debugf("Could not find schema on path %s, resolving %s to %s",
                       localPathToSchema, SCHEMA_SYSTEM_PROPERTY, schemaPath());
         }
      }

      //2. resolve local schema path in infinispan distro
      is = fileLookup.lookupFile(schemaPath(), null);
      if (is != null) {
         log.debugf("Using schema %s", schemaPath());
         return is;
      }
      if (log.isDebugEnabled()) {
View Full Code Here

   }

   private static InputStream findInputStream(String fileName, ClassLoader cl) throws FileNotFoundException {
      if (fileName == null)
         throw new NullPointerException("File name cannot be null!");
      FileLookup fileLookup = new FileLookup();
      InputStream is = fileLookup.lookupFile(fileName, cl);
      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 void setHotRodClientProperties(Properties props) {
      this.hotRodClientProperties.putAll(props);
   }

   public void setHotRodClientPropertiesFile(String hotRodClientProperties) {
      FileLookup fileLookup = new FileLookup();
      InputStream inputStream = fileLookup.lookupFile(hotRodClientProperties);
      try {
         this.hotRodClientProperties.load(inputStream);
      } catch (IOException e) {
         log.error("Issues while loading properties from file", e);
         throw new CacheException(e);
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 static final String EHCACHE_CACHE16X = "Ehcache16x";
   private static final String EHCACHE_CACHE15X = "Ehcache15x";
   public static final String[] SUPPORTED_FORMATS = {JBOSS_CACHE3X, EHCACHE_CACHE15X, EHCACHE_CACHE16X};

   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);
      }

      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");
      // Use a Transformer for output
      transformer = getTransformer(indentation);
      StreamResult finalResult = new StreamResult(os);
      StreamSource rawResult = new StreamSource(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
      transformer.transform(rawResult, finalResult);
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.jboss.cache.util.FileLookup}
    */
   public void parse(String inputFile, OutputStream os, String xsltFile) throws Exception {
      InputStream stream = new FileLookup().lookupFile(inputFile);
      try {
         parse(stream, os, xsltFile);
      }
      finally {
         stream.close();
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.