Package org.apache.excalibur.source

Examples of org.apache.excalibur.source.SourceValidity


            try {
                List invalid = new LinkedList();
                for (Iterator i = javaSource.entrySet().iterator(); i.hasNext();) {
                    Map.Entry e = (Map.Entry) i.next();
                    String uri = (String) e.getKey();
                    SourceValidity validity = (SourceValidity) e.getValue();
                    int valid = validity.isValid();
                    if (valid == SourceValidity.UNKNOWN) {
                        Source newSrc = null;
                        try {
                            newSrc = sourceResolver.resolveURI(uri);
                            valid = newSrc.getValidity().isValid(validity);
View Full Code Here


        this.configuration = configuration;
    }

    public Object get(Source source, String prefix) {
        String key = prefix + source.getURI();
        SourceValidity newValidity = source.getValidity();

        // If source is not valid then remove object from cache and return null
        if (newValidity == null) {
            this.cache.remove(key);
            return null;
        }

        // If object is not in cache then return null
        Object[] objectAndValidity = (Object[]) this.cache.get(key);
        if (objectAndValidity == null) {
            return null;
        }

        // Check stored validity against current source validity
        SourceValidity storedValidity = (SourceValidity) objectAndValidity[1];
        int valid = storedValidity.isValid();
        boolean isValid;
        if (valid == SourceValidity.UNKNOWN) {
            valid = storedValidity.isValid(newValidity);
            isValid = (valid == SourceValidity.VALID);
        } else {
            isValid = (valid == SourceValidity.VALID);
        }
View Full Code Here

        return objectAndValidity[0];
    }

    public void set(Object object, Source source, String prefix) throws IOException {
        String key = prefix + source.getURI();
        SourceValidity validity = source.getValidity();
        if (validity != null) {
            Object[] objectAndValidity = {object,  validity};
            cache.put(key, objectAndValidity);
        }
    }
View Full Code Here

        assertTrue("New file already exists", !child.exists());
        fillSource(child, text + " and blah!");

        long length = child.getContentLength();

        SourceValidity validity = child.getValidity();
        assertEquals("Validity is not valid", 1, validity.isValid());

        // Wait 2 seconds before updating the file
        Thread.sleep(2 * 1000L);

        // Now change its content
        PrintWriter pw = new PrintWriter(child.getOutputStream());
        pw.write(text);

        assertEquals("File length modified", length, child.getContentLength());

        pw.close();

        assertTrue("File length not modified", length != child.getContentLength());

        assertEquals("Validity is valid", -1, validity.isValid());
    }
View Full Code Here

    public void testValidity() throws Exception
    {
        ResourceSource src1 = new ResourceSource("resource://org/apache/excalibur/source/test/ResourceSourceTestCase.class");
        ResourceSource src2 = new ResourceSource("resource://org/apache/excalibur/source/test/ResourceSourceTestCase.class");

        SourceValidity val1 = src1.getValidity();
        SourceValidity val2 = src2.getValidity();
       
        assertEquals("Validities should match", SourceValidity.VALID, val1.isValid(val2));
    }
View Full Code Here

    Object result = null;
    if (this.objectCache == null)
      init();
    CacheEntry cacheEntry = (CacheEntry) this.objectCache.get(key);
    if (cacheEntry != null) {
      SourceValidity previous = cacheEntry.validity;
      Source source = null;
      switch (previous.isValid()) {
        case SourceValidity.VALID:
          result = cacheEntry.object;
          break;
        case SourceValidity.UNKNOWN:
          source = resolver.resolveURI(uri);
          SourceValidity fresh = source.getValidity();
          switch (previous.isValid(fresh)){
            case SourceValidity.VALID:
              result = cacheEntry.object;
              break;
            case SourceValidity.UNKNOWN:
View Full Code Here

  public void store(Serializable key,
                    CachedResponse response)
                    throws ProcessingException {
        SourceValidity[] validities = response.getValidityObjects();
        for (int i=0; i< validities.length;i++) {
            SourceValidity val = validities[i];
            examineValidity(val, key);
        }
        super.store(key, response);
  }
View Full Code Here

                                    AbstractAggregatedValidity val,
                                    Serializable key) {
        // AggregatedValidity must be investigated further.
         Iterator it = val.getValidities().iterator();
         while (it.hasNext()) {
             SourceValidity thisVal = (SourceValidity)it.next();
             // Allow recursion
             examineValidity(thisVal, key);
         }
    }
View Full Code Here

        this.configuration = configuration;
    }

    public Object get(Source source, String prefix) {
        String key = prefix + source.getURI();
        SourceValidity newValidity = source.getValidity();

        if (newValidity == null) {
            cache.remove(key);
            return null;
        }

        Object[] objectAndValidity = (Object[])cache.get(key);
        if (objectAndValidity == null)
            return null;

        SourceValidity storedValidity = (SourceValidity)objectAndValidity[1];
        int valid = storedValidity.isValid();
        boolean isValid;
        if (valid == 0) {
            valid = storedValidity.isValid(newValidity);
            isValid = (valid == 1);
        } else {
            isValid = (valid == 1);
        }
View Full Code Here

        return objectAndValidity[0];
    }

    public void set(Object object, Source source, String prefix) throws IOException {
        String key = prefix + source.getURI();
        SourceValidity validity = source.getValidity();
        if (validity != null) {
            Object[] objectAndValidity = {object,  validity};
            cache.put(key, objectAndValidity);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.excalibur.source.SourceValidity

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.