org.abstracthorizon.extend.repository.maven
Class MavenRepoModuleLoader

java.lang.Object
  extended by org.abstracthorizon.extend.server.deployment.service.AbstractServiceModuleLoader
      extended by org.abstracthorizon.extend.repository.maven.MavenRepoModuleLoader
All Implemented Interfaces:
ModuleLoader

public class MavenRepoModuleLoader
extends AbstractServiceModuleLoader

Module loader that loads files from maven style repository

Author:
Daniel Sendula

Field Summary
protected  int bufferSize
          Download buffer size
static int DEFAULT_BUFFER_SIZE
          Default buffer size - 10K
protected  File localRepository
          Local repository path
protected  Map<String,POM> pomCache
          POM cache
protected  Map<String,URL> repositories
          Repositories
 
Fields inherited from class org.abstracthorizon.extend.server.deployment.service.AbstractServiceModuleLoader
deploymentManager, extensions
 
Constructor Summary
MavenRepoModuleLoader()
          Constructor
 
Method Summary
 boolean canLoad(URI uri)
          This method checks if URI protocol is "repo" and file starts with "maven".
protected  void collectProperties(Map<String,String> properties, POM pom)
           
static boolean copyFile(File fromFile, File toFile)
          Copies files and directories
 File createLocalFile(Artifact artifact)
           
 File createLocalFile(Artifact artifact, String file)
           
 void downloadFile(Artifact artifact, File toFile)
           
 void downloadFile(URL url, Artifact artifact, File toFile)
           
 void downloadFile(URL url, Artifact artifact, String altVersion, File toFile)
           
protected  void downloadFile(URL url, File file)
           
static boolean excludesContain(Set<Artifact> excludes, Dependency dependency)
           
 Map<String,URL> getRepositories()
          Returns repositories
 Module load(URI uri)
          Loads a file from maven style repository
 Module loadAndDeploy(Artifact artifact, Set<Artifact> excludes)
           
 Module loadAs(URI uri, ModuleId moduleId)
          Loads a file from maven style repository
 POM loadPom(Artifact pomArtifact)
           
static Artifact parseArtifact(String fileId)
           
 void processDependencies(POM pom, Module module, Set<Artifact> excludes)
           
 void setRepositories(Map<String,URL> repositories)
          Sets repositories
 void stop()
          Stop method removes URLResolver from "DefaultURLResolver".
 ModuleId toModuleId(URI uri)
          Translates URI to moduleId
 void updateDependency(POM pom, Dependency dependency)
           
 
Methods inherited from class org.abstracthorizon.extend.server.deployment.service.AbstractServiceModuleLoader
getDeploymentManager, getExtensions, setDeploymentManager, setExtensions, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BUFFER_SIZE

public static final int DEFAULT_BUFFER_SIZE
Default buffer size - 10K

See Also:
Constant Field Values

pomCache

protected Map<String,POM> pomCache
POM cache


repositories

protected Map<String,URL> repositories
Repositories


bufferSize

protected int bufferSize
Download buffer size


localRepository

protected File localRepository
Local repository path

Constructor Detail

MavenRepoModuleLoader

public MavenRepoModuleLoader()
Constructor

Method Detail

setRepositories

public void setRepositories(Map<String,URL> repositories)
Sets repositories

Parameters:
repositories - repositories

getRepositories

public Map<String,URL> getRepositories()
Returns repositories

Returns:
repositories

stop

public void stop()
Stop method removes URLResolver from "DefaultURLResolver".

Overrides:
stop in class AbstractServiceModuleLoader

canLoad

public boolean canLoad(URI uri)
This method checks if URI protocol is "repo" and file starts with "maven". Also rest of the file must have at least two ":" for group id, artifact id and version. Type is assumed as jar and classifier can be empty.

Specified by:
canLoad in interface ModuleLoader
Overrides:
canLoad in class AbstractServiceModuleLoader
Parameters:
uri - URI
Returns:
true if URI protocol is "repo" and file starts with "maven".

toModuleId

public ModuleId toModuleId(URI uri)
Description copied from interface: ModuleLoader
Translates URI to moduleId

Parameters:
uri - uri
Returns:
module id or null

load

public Module load(URI uri)
Loads a file from maven style repository

Parameters:
uri - URI
Returns:
module from given URI

loadAs

public Module loadAs(URI uri,
                     ModuleId moduleId)
Loads a file from maven style repository

Parameters:
uri - URI
moduleId - module id
Returns:
module from given URI

loadAndDeploy

public Module loadAndDeploy(Artifact artifact,
                            Set<Artifact> excludes)

loadPom

public POM loadPom(Artifact pomArtifact)
            throws FileNotFoundException
Throws:
FileNotFoundException

collectProperties

protected void collectProperties(Map<String,String> properties,
                                 POM pom)

processDependencies

public void processDependencies(POM pom,
                                Module module,
                                Set<Artifact> excludes)
                         throws FileNotFoundException
Throws:
FileNotFoundException

updateDependency

public void updateDependency(POM pom,
                             Dependency dependency)

excludesContain

public static boolean excludesContain(Set<Artifact> excludes,
                                      Dependency dependency)

createLocalFile

public File createLocalFile(Artifact artifact)

createLocalFile

public File createLocalFile(Artifact artifact,
                            String file)

downloadFile

public void downloadFile(Artifact artifact,
                         File toFile)
                  throws FileNotFoundException
Throws:
FileNotFoundException

downloadFile

public void downloadFile(URL url,
                         Artifact artifact,
                         File toFile)
                  throws FileNotFoundException
Throws:
FileNotFoundException

downloadFile

public void downloadFile(URL url,
                         Artifact artifact,
                         String altVersion,
                         File toFile)
                  throws FileNotFoundException
Throws:
FileNotFoundException

downloadFile

protected void downloadFile(URL url,
                            File file)
                     throws FileNotFoundException
Throws:
FileNotFoundException

parseArtifact

public static Artifact parseArtifact(String fileId)

copyFile

public static boolean copyFile(File fromFile,
                               File toFile)
Copies files and directories

Parameters:
fromFile - source file/dir
toFile - destination file/dir
Returns:


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.