Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH . All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: s IT Solutions AT Spardat GmbH - initial API and implementation /
 
 
 package at.spardat.xma.boot.cache;
 
 import java.io.File;
 import java.net.URL;
 
Interface to the file cache. Users of the file cache should always use it through this interface to stay apart of implementation details.

Author(s):
s3595 Chris Sch�fer (CGS)
Version:
$Id: IFileCache.java 2084 2007-11-27 14:53:31Z s3460 $
 
 public interface IFileCache {

    
This method will open a resource represented by a valid java.net.URL.
Same as openResource(java.net.URL,boolean,boolean,at.spardat.xma.boot.component.IRtXMASessionClient) called with (urlRemote, true, false, null).

Parameters:
urlRemote remote url to open.
Returns:
IFileCacheResource the cached resource
Throws:
java.io.IOException on filesystem errors
CommunicationException communication error with server
ServerException on server exception
java.lang.IllegalArgumentException prepare a valid url
 
     public abstract IFileCacheResource openResource(URL urlRemote)
         throws IOException;

    
This method will open a resource represented by a valid java.net.URL.
Same as openResource(java.net.URL,boolean,boolean,at.spardat.xma.boot.component.IRtXMASessionClient) called with (urlRemote, true, false, session).

Parameters:
session xma session (or null)
urlRemote remote url to open.
Returns:
IFileCacheResource the cached resource
Throws:
java.io.IOException on filesystem errors
CommunicationException communication error with server
ServerException on server exception
java.lang.IllegalArgumentException prepare a valid url
 
     public abstract IFileCacheResource openResource(IRtXMASessionClient sessionURL urlRemote)
         throws IOException;

    
This method will open a resource represented by a valid java.net.URL.
Same as openResource(java.net.URL,boolean,boolean,at.spardat.xma.boot.component.IRtXMASessionClient) called with (urlRemote, bmode, bforce, null).

Parameters:
urlRemote remote url to open.
bmode use true for buffered mode.
bforce force an update check with the server
Returns:
IFileCacheResource the cached resource
Throws:
java.io.IOException on filesystem errors
CommunicationException communication error with server
ServerException on server exception
java.lang.IllegalArgumentException prepare a valid url
 
     public abstract IFileCacheResource openResource(URL urlRemoteboolean bmode,  boolean bforce)
             throws IOException;


    
This method will open a resource represented by a valid java.net.URL.
Same as openResource(java.net.URL,boolean,boolean,at.spardat.xma.boot.component.IRtXMASessionClient) called with (urlRemote, bmode, false, null).

Parameters:
urlRemote remote url to open.
bmode use true for buffered mode.
Returns:
IFileCacheResource the cached resource
Throws:
java.io.IOException on filesystem errors
CommunicationException communication error with server
ServerException on server exception
java.lang.IllegalArgumentException prepare a valid url
 
     public abstract IFileCacheResource openResource(URL urlRemoteboolean bmode )
             throws IOException;

    
This method will open a resource represented by a valid java.net.URL.
The method returns a memory copy of the underlying file resource.
A resource is valid for the cache, if it is not expired yet. That means, that its expiration timestamp has not been reached yet, or there is none.
In buffered mode (bmode=true), the resource reads the cache entry, into a memory buffer imediately on object creation. In non buffered mode, the buffer is created on first access.
  • If the resource is cached and still valid, the cached copy is returned as is.
  • If the resource is not cached or is not valid any more, a new copy is loaded.

Parameters:
urlRemote remote url to open.
bmode read the cache entry, into a memory buffer imediately on object creation
bforce force an update check with the server
session xma session (or null)
Returns:
IFileCacheResource the cached resource
Throws:
java.io.IOException on filesystem errors
CommunicationException communication error with server
ServerException on server exception
java.lang.IllegalArgumentException prepare a valid url
    public IFileCacheResource openResourceURL urlRemoteboolean bmodeboolean bforce,  IRtXMASessionClient session )
            throws IOException;


    
This method will open a resource represented by a valid at.spardat.xma.boot.comp.data.XMAResource.
The method returns a memory copy of the underlying file resource.
The resouce is only valid, if the version hash of the at.spardat.xma.boot.comp.data.XMAResource match the hash of the cached resource.
  • If the resource is cached and still valid, the cached copy is returned as is.
  • If the resource is not cached or is not valid any more, a new copy is loaded.

Parameters:
appUri uri of the xma application
resource the wanted resource inside this application
serverVers version number of the xma-runtime on the server
bforce force an update check with the server
Returns:
IFileCacheResource the cached resource
Throws:
java.io.IOException on filesystem errors
CommunicationException communication error with server
ServerException on server exception
java.lang.IllegalArgumentException prepare a valid url
Author(s):
s2877
Since:
1.3.0
    public IFileCacheResource openResource(XMA_URI appUriXMAResource resourceVersionNumber serverVersboolean bforcethrows IOException;

    
This method will open a resource represented by a valid at.spardat.xma.boot.transport.XMA_URI.
The method returns a memory copy of the underlying file resource.
The resouce is only valid, if the given hash match the hash value of the cached resource.
  • If the resource is cached and still valid, the cached copy is returned as is.
  • If the resource is not cached or is not valid any more, a new copy is loaded.

Parameters:
resource the wanted resource
hash the expected hash value of the resouce
serverVers version number of the xma-runtime on the server
bforce force an update check with the server
Returns:
IFileCacheResource the cached resource
Throws:
java.io.IOException on filesystem errors
CommunicationException communication error with server
ServerException on server exception
java.lang.IllegalArgumentException prepare a valid url
Author(s):
s2877
Since:
1.3.0
    public IFileCacheResource openResource(XMA_URI resource,String hash,VersionNumber serverVers,boolean bforcethrows IOException;

    
Open a resource from the local cache. No effort is made to download it, if it is not cached null is returned. The resource is not checked for expiration or integrity. This method does not find shared resources.

Parameters:
resource to open
Returns:
the resource from the local cache or null if not cached.
Throws:
java.io.IOException containing the filename on filesystem errors
Author(s):
s2877
Since:
1.3.0
    public IFileCacheResource openLocalResource(XMA_URI resource);


    

invalidates a cache-entry if exists

will invalidate all file-resources from the file cache directory for this url.
If the resource is not found/is not cached, no error is reported.

Parameters:
urlRemote the remote url that is the key to the cached resources
Throws:
java.io.IOException on file errors
    public abstract void invalidateResource(URL urlRemotethrows IOException;

    
call this method to remove (delete) all information of this cached resource.

Parameters:
ifcr the resource to invalidate
    public abstract void invalidateResource(IFileCacheResource ifcr);

    
Check if there is allready a local copy of this remote URL.
It does not check, wheather the local copy is expired.

Parameters:
urlRemote remote URL to check for a local cached copy
Returns:
returns true if the resource is cached
Throws:
java.lang.IllegalArgumentException if the source is not cacheable
    public abstract boolean isCached(URL urlRemote);

    
Get the directory where the file cache is located.

Author(s):
s2877
Since:
1.3.0
    public File getBaseDir();

    
Check if there is allready a local copy of the given resouce.
It checks if the resource is not expired and the stored hash value matches the given hash.

Parameters:
uri defining the resource
hash expected hash value of the resource
Returns:
true if the resoure is cached an valid according to hash and expiration.
Throws:
java.io.IOException
Author(s):
s2877
Since:
1.3.0
    public boolean isCachedAndValid(XMA_URI uri,String hashthrows IOException;

    
Check if there is allready a local copy of the given resouce.
It checks if the resource is not expired and the stored hash value matches the given hash.

Parameters:
resource to check
hash expected hash value of the resource
Returns:
true if the resoure is cached an valid according to hash and expiration.
Throws:
java.io.IOException
Author(s):
s2877
Since:
1.3.0
    public boolean isCachedAndValid(IFileCacheResource resource,String hash);

    
Check the integrity of the given resource.
The given hash value is compared to the stored hash value of the resource. Additionally the hash value is calculated from the resource and compared. This does not only detect a wrong version of the resource. It detects corrupted and manipulated resources, too.

Parameters:
resource to check
hash expected hash value
isJar if the resource is a jar file or not
Returns:
true if the hash matches, false otherwise
Author(s):
s2877
Since:
1.3.0
    public boolean checkHash(IFileCacheResource resourceString hashboolean isJar);
New to GrepCode? Check out our FAQ X