SmartFrog 3.10.000

org.smartfrog.services.os.java
Class LibraryArtifactImpl

java.lang.Object
  extended by org.smartfrog.sfcore.reference.RemoteReferenceResolverHelperImpl
      extended by org.smartfrog.sfcore.prim.PrimImpl
          extended by org.smartfrog.sfcore.compound.CompoundImpl
              extended by org.smartfrog.services.filesystem.FileUsingCompoundImpl
                  extended by org.smartfrog.services.os.java.LibraryArtifactImpl
All Implemented Interfaces:
java.rmi.Remote, FileIntf, FileUsingComponent, UriIntf, LibraryArtifact, MessageKeys, Compound, ChildMinder, Diagnostics, Liveness, Prim, RemoteReferenceResolver, RemoteReferenceResolverHelper

public class LibraryArtifactImpl
extends FileUsingCompoundImpl
implements LibraryArtifact

Implementation of a library artifact. This is where all download logic is implemented. created 04-Apr-2005 13:38:47


Field Summary
static int BLOCKSIZE
          block size for downloads and digests 8192
static java.lang.String ERROR_ARTIFACT_NOT_FOUND
          Error when a file was not found in any repository
static java.lang.String ERROR_CHECKSUM_FAILURE
           
static java.lang.String ERROR_NO_OWNER
          Error text when there is no repository entry anywhere
static java.lang.String ERROR_NO_REPOSITORIES
          Error text when repostiories == [] and a download was needed.
 
Fields inherited from class org.smartfrog.sfcore.compound.CompoundImpl
childCap, childInc, lifecycleChildren, sfChildren, sfSyncTerminate
 
Fields inherited from class org.smartfrog.sfcore.prim.PrimImpl
refLivenessDelay, refLivenessFactor, sfCompleteName, sfContext, sfDeployHooks, sfDeployWithHooks, sfExportRef, sfIsDeployed, sfIsStarted, sfIsTerminated, sfIsTerminating, sfLivenessCount, sfLivenessDelay, sfLivenessFactor, sfLivenessSender, sfParent, sfStartHooks, sfTerminateWithHooks, termLock
 
Fields inherited from interface org.smartfrog.services.os.java.LibraryArtifact
ATTR_ARTIFACT, ATTR_BLOCKSIZE, ATTR_CLASSIFIER, ATTR_DOWNLOAD_ALWAYS, ATTR_DOWNLOAD_IF_ABSENT, ATTR_EXTENSION, ATTR_FAIL_IF_NOT_PRESENT, ATTR_LIBRARY, ATTR_MD5, ATTR_PROJECT, ATTR_SHA1, ATTR_SYNCHRONOUS, ATTR_TERMINATE, ATTR_VERSION
 
Fields inherited from interface org.smartfrog.services.filesystem.FileUsingComponent
ATTR_ABSOLUTE_PATH, ATTR_FILENAME, ATTR_URI
 
Fields inherited from interface org.smartfrog.services.filesystem.FileIntf
ATTR_DELETE_ON_EXIT, ATTR_DIR, ATTR_EXISTS, ATTR_IS_DIRECTORY, ATTR_IS_EMPTY, ATTR_IS_FILE, ATTR_IS_HIDDEN, ATTR_LENGTH, ATTR_MUST_BE_DIR, ATTR_MUST_BE_FILE, ATTR_MUST_EXIST, ATTR_MUST_READ, ATTR_MUST_WRITE, ATTR_SHORTNAME, ATTR_TEST_ON_LIVENESS, ATTR_TEST_ON_STARTUP, ATTR_TIMESTAMP
 
Fields inherited from interface org.smartfrog.sfcore.common.MessageKeys
CANNOT_LINK_TO_PREDICATE, COMPONENT_TERMINATED, COPY_FAILED, COPY_SERIALIZE_FAILED, ERROR_NO_SECURITY_BUT_REQUIRED, ILLEGAL_BOOLEAN_PARAMETER, ILLEGAL_NUMERIC_PARAMETER, ILLEGAL_STRING_PARAMETER, ILLEGAL_VECTOR_PARAMETER, LIVENESS_SEND_FAILURE, LIVENESS_SEND_FAILURE_IN, MISSING_PARAMETER, MSG_CLASS_NOT_FOUND, MSG_CONNECT_ERR, MSG_CONT_OTHER_DEPLOY, MSG_DEPLOY_COMP_TERMINATED, MSG_DEPLOY_SUCCESS, MSG_DEPLOYWITH_PHASE_FAILED, MSG_DETACH_SUCCESS, MSG_DETACH_TERMINATE_SUCCESS, MSG_ERR_DEPLOY_FROM_URL, MSG_ERR_PARSE, MSG_ERR_RESOLVE_PHASE, MSG_ERR_SF_RUNNING, MSG_ERR_TERM, MSG_FAILED_INET_ADDRESS_LOOKUP, MSG_FAILED_TO_CONTACT_PARENT, MSG_FILE_NOT_FOUND, MSG_HOOK_ACTION_FAILED, MSG_ILLEGAL_ACCESS, MSG_ILLEGAL_CLASS_TYPE, MSG_ILLEGAL_CLASS_TYPE_EXPECTING_GOT, MSG_ILLEGAL_REFERENCE, MSG_INPUTSTREAM_NULL, MSG_INSTANTIATION_ERROR, MSG_INVALID_OBJECT_TYPE, MSG_INVOCATION_TARGET, MSG_LANG_NOT_FOUND, MSG_LIVENESS_START_FAILED, MSG_LOADING_URL, MSG_METHOD_NOT_FOUND, MSG_NON_REP_ATTRIB, MSG_NOT_COMPONENT_REFERENCE, MSG_NOT_FOUND_ATTRIBUTE, MSG_NOT_FOUND_REFERENCE, MSG_NOT_VALUE_REFERENCE, MSG_NULL_DEF_METHOD, MSG_NULL_URL, MSG_OBJECT_REGISTRATION_FAILED, MSG_PARENT_LOCATION_FAILED, MSG_PING_SUCCESS, MSG_RANDM_ERR, MSG_REMOTE_CONNECT_ERR, MSG_REPEATED_ATTRIBUTE, MSG_SF_DEAD, MSG_SF_READY, MSG_SF_TERMINATED, MSG_STACKTRACE_FOLLOWS, MSG_START_COMP_TERMINATED, MSG_TERMINATE_SUCCESS, MSG_UNHANDLED_EXCEPTION, MSG_UNKNOWN_HOST, MSG_UNRESOLVED_REFERENCE, MSG_UNRESOLVED_REFERENCE_IN, MSG_UPDATE_SUCCESS, MSG_URL_NOT_FOUND, MSG_URL_TO_PARSE_NOT_FOUND, MSG_WARNING_LIVENESS_ENABLED, MSG_WARNING_STACKTRACE_DISABLED, MSG_WARNING_STACKTRACE_ENABLED, ROOT_MUST_BE_COMPONENT, WARN_NO_SECURITY
 
Constructor Summary
LibraryArtifactImpl()
           
 
Method Summary
 void checkChecksum(java.io.File file, java.lang.String algorithm, java.lang.String hexValue, int blocksize)
          check the checksum of a file.
 void checkMd5Checksum()
          check that md5 checksum
 void checkSha1Checksum()
          check our sha1 checksum
 SerializedArtifact createSerializedArtifact()
          Create a serialized artifact to work with
 void download()
          Download the file, even if it is present.
 java.io.IOException downloadFromOneRepository(java.lang.String repositoryBaseURL)
          try to fetch the file from a single repository.
protected  Library findOwner()
          Find our owning Library direct attribute Parent
 java.lang.String getArtifact()
           
 java.lang.String getClassifier()
           
 java.lang.String getExtension()
           
 java.lang.String getMd5()
           
 java.lang.String getProject()
           
 java.lang.String getSha1()
           
 java.lang.String getVersion()
           
 boolean isDownloadAlways()
           
 boolean isDownloadIfAbsent()
           
 boolean isFailIfNotPresent()
           
 java.lang.String makeRemoteUrlPath()
          Determine our relative path.
 java.lang.String makeRepositoryUrlList()
          make string list of the repositories
 void setArtifact(java.lang.String artifact)
           
 void setClassifier(java.lang.String classifier)
           
 void setDownloadAlways(boolean downloadAlways)
           
 void setDownloadIfAbsent(boolean downloadIfAbsent)
           
 void setExtension(java.lang.String extension)
           
 void setFailIfNotPresent(boolean failIfNotPresent)
           
 void setMd5(java.lang.String md5)
           
 void setProject(java.lang.String project)
           
 void setSha1(java.lang.String sha1)
           
 void setVersion(java.lang.String version)
           
 void sfDeploy()
          Retrieve our file from our parent libraries.
 
Methods inherited from class org.smartfrog.services.filesystem.FileUsingCompoundImpl
bind, bind, getAbsolutePath, getFile, getURI, setAbsolutePath
 
Methods inherited from class org.smartfrog.sfcore.compound.CompoundImpl
sfAddChild, sfASyncTerminateWith, sfChildren, sfContainsChild, sfCreateNewApp, sfCreateNewChild, sfCreateNewChild, sfDeployChildren, sfDeployComponentDescription, sfDeployWith, sfDeployWithChildren, sfDumpState, sfParentageChanged, sfPing, sfPingChild, sfRemoveAttribute, sfRemoveChild, sfStart, sfStartChildren, sfSyncTerminateWith, sfTerminatedWith, sfTerminateWith
 
Methods inherited from class org.smartfrog.sfcore.prim.PrimImpl
equals, hashCode, registerWithProcessCompound, sfAddAttribute, sfAttributeKeyFor, sfAttributes, sfCompleteName, sfCompleteNameSafe, sfContainsAttribute, sfContainsValue, sfContext, sfDeployedHost, sfDeployedProcessName, sfDetach, sfDetachAndTerminate, sfDiagnosticsReport, sfExport, sfExportRef, sfExportRef, sfGetApplicationLog, sfGetCoreLog, sfGetLog, sfIsDeployed, sfIsRemote, sfIsStarted, sfIsTerminated, sfIsTerminating, sfLivenessFailure, sfLog, sfParent, sfReplaceAttribute, sfResolve, sfResolve, sfResolveHere, sfResolveHere, sfResolveParent, sfSetLog, sfStartLivenessSender, sfStopLivenessSender, sfTerminate, sfTerminateQuietlyWith, sfValues, terminateComponent, terminateNotifying, toString
 
Methods inherited from class org.smartfrog.sfcore.reference.RemoteReferenceResolverHelperImpl
sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolveWithParser
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.smartfrog.sfcore.prim.Prim
sfAddAttribute, sfAttributeKeyFor, sfAttributes, sfCompleteName, sfContainsAttribute, sfContainsValue, sfContext, sfDeployedHost, sfDeployedProcessName, sfDetach, sfDetachAndTerminate, sfIsDeployed, sfIsStarted, sfIsTerminated, sfIsTerminating, sfParent, sfReplaceAttribute, sfTerminate, sfTerminateQuietlyWith, sfValues
 
Methods inherited from interface org.smartfrog.sfcore.reference.RemoteReferenceResolver
sfResolve, sfResolve, sfResolveHere, sfResolveHere, sfResolveParent
 
Methods inherited from interface org.smartfrog.sfcore.reference.RemoteReferenceResolverHelper
sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolve, sfResolveWithParser
 
Methods inherited from interface org.smartfrog.sfcore.prim.Diagnostics
sfDiagnosticsReport
 

Field Detail

ERROR_CHECKSUM_FAILURE

public static final java.lang.String ERROR_CHECKSUM_FAILURE
See Also:
Constant Field Values

BLOCKSIZE

public static final int BLOCKSIZE
block size for downloads and digests 8192

See Also:
Constant Field Values

ERROR_NO_OWNER

public static final java.lang.String ERROR_NO_OWNER
Error text when there is no repository entry anywhere

See Also:
Constant Field Values

ERROR_NO_REPOSITORIES

public static final java.lang.String ERROR_NO_REPOSITORIES
Error text when repostiories == [] and a download was needed.

See Also:
Constant Field Values

ERROR_ARTIFACT_NOT_FOUND

public static final java.lang.String ERROR_ARTIFACT_NOT_FOUND
Error when a file was not found in any repository

See Also:
Constant Field Values
Constructor Detail

LibraryArtifactImpl

public LibraryArtifactImpl()
                    throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException
Method Detail

sfDeploy

public void sfDeploy()
              throws SmartFrogException,
                     java.rmi.RemoteException
Retrieve our file from our parent libraries.

  1. locate parent Library implementation
  2. get information about repository cache
  3. work out names of remote URL, local filename
  4. bind our localfilename
  5. fetch the jar (or fail)
  6. validate the JAR (or fail)

Specified by:
sfDeploy in interface Prim
Overrides:
sfDeploy in class CompoundImpl
Throws:
SmartFrogException - error while deploying
java.rmi.RemoteException - In case of network/rmi error

download

public void download()
              throws SmartFrogException
Download the file, even if it is present. Tries every repository in turn.

Throws:
SmartFrogException - if there are no repositories.

makeRepositoryUrlList

public java.lang.String makeRepositoryUrlList()
make string list of the repositories

Returns:
a (possibly empty) list of URLs

downloadFromOneRepository

public java.io.IOException downloadFromOneRepository(java.lang.String repositoryBaseURL)
                                              throws SmartFrogException
try to fetch the file from a single repository. All IOExceptions caught during fetching are logged at debug level, and turned into a failure of this method.

Parameters:
repositoryBaseURL -
Returns:
the exception that got us here
Throws:
SmartFrogException

checkMd5Checksum

public void checkMd5Checksum()
                      throws SmartFrogException
check that md5 checksum

Throws:
SmartFrogException

checkSha1Checksum

public void checkSha1Checksum()
                       throws SmartFrogException
check our sha1 checksum

Throws:
SmartFrogException

checkChecksum

public void checkChecksum(java.io.File file,
                          java.lang.String algorithm,
                          java.lang.String hexValue,
                          int blocksize)
                   throws SmartFrogException
check the checksum of a file. This is not hidden at download time, as we do it *every* load, even if the file is in cache. That may be overkill, but there you go.

Parameters:
file -
algorithm -
hexValue -
blocksize -
Throws:
SmartFrogException

makeRemoteUrlPath

public java.lang.String makeRemoteUrlPath()
                                   throws java.rmi.RemoteException,
                                          SmartFrogException
Determine our relative path. This forwards up to the owner, which must, of course, not be null

Returns:
path
Throws:
java.rmi.RemoteException - if things go wrong
SmartFrogException

findOwner

protected Library findOwner()
                     throws SmartFrogResolutionException,
                            java.rmi.RemoteException
Find our owning Library
  1. direct attribute
  2. Parent
  3. Returns:
    a libraries instance or an error
    Throws:
    SmartFrogResolutionException - on resolution trouble
    java.rmi.RemoteException

getArtifact

public java.lang.String getArtifact()
Returns:
Returns the artifact.

setArtifact

public void setArtifact(java.lang.String artifact)
Parameters:
artifact - The artifact to set.

getClassifier

public java.lang.String getClassifier()
Returns:
Returns the classifier.

setClassifier

public void setClassifier(java.lang.String classifier)
Parameters:
classifier - The classifier to set.

isDownloadAlways

public boolean isDownloadAlways()
Returns:
Returns the downloadAlways.

setDownloadAlways

public void setDownloadAlways(boolean downloadAlways)
Parameters:
downloadAlways - The downloadAlways to set.

isDownloadIfAbsent

public boolean isDownloadIfAbsent()
Returns:
Returns the downloadIfAbsent.

setDownloadIfAbsent

public void setDownloadIfAbsent(boolean downloadIfAbsent)
Parameters:
downloadIfAbsent - The downloadIfAbsent to set.

getExtension

public java.lang.String getExtension()
Returns:
Returns the extension.

setExtension

public void setExtension(java.lang.String extension)
Parameters:
extension - The extension to set.

isFailIfNotPresent

public boolean isFailIfNotPresent()
Returns:
Returns the failIfNotPresent flag.

setFailIfNotPresent

public void setFailIfNotPresent(boolean failIfNotPresent)
Parameters:
failIfNotPresent - The failIfNotPresent to set.

getMd5

public java.lang.String getMd5()
Returns:
Returns the md5.

setMd5

public void setMd5(java.lang.String md5)
Parameters:
md5 - The md5 to set.

getProject

public java.lang.String getProject()
Returns:
Returns the project.

setProject

public void setProject(java.lang.String project)
Parameters:
project - The project to set.

getSha1

public java.lang.String getSha1()
Returns:
Returns the sha1.

setSha1

public void setSha1(java.lang.String sha1)
Parameters:
sha1 - The sha1 to set.

getVersion

public java.lang.String getVersion()
Returns:
Returns the version.

setVersion

public void setVersion(java.lang.String version)
Parameters:
version - The version to set.

createSerializedArtifact

public SerializedArtifact createSerializedArtifact()
Create a serialized artifact to work with

Specified by:
createSerializedArtifact in interface LibraryArtifact
Returns:
a serialized representation of the artifact's state.

SmartFrog CORE 3.10.000

(C) Copyright 1998-2006 Hewlett-Packard Development Company, LP