org.figure8.join.services.scripting.ant.tasks
Class BindComponentTask

java.lang.Object
  extended by org.apache.tools.ant.ProjectComponent
      extended by org.apache.tools.ant.Task
          extended by org.figure8.join.services.scripting.ant.tasks.RemoteServiceTask
              extended by org.figure8.join.services.scripting.ant.tasks.BindComponentTask

public class BindComponentTask
extends RemoteServiceTask

This an Ant task to use for binding a component being built/discovered to a specified assembly and/or build.
As an example, use a bindcomponent that way to ensure attaching a component to an assembly :
>bindcomponent type="myComponent" assembly="myassembly-r1.0-v01" version="001" url="http://mydomain.org:8080/join"<
>fileset dir="${src.dir}/myComponent" includes="*.*"/< >/bindcomponent<

That task will then connect to Join system denoted by url to see if component of type "myComponent" exists with version "001". If no, il will create it into Join system, specifying its size using files from nested filesets. Finally, it will attach existing or newly created component to the existing "myassembly-r1.0-v01" assembly.
This task is very useful when creating an assembly using an Ant script and introspecting its content, searching for contained components : it allows you to trace what you have dynamically discovered.
When component version is not easily extractable, you can replace version attribute by extractor and thus specifying a VersionInfoExtractor implementation to use for extracting version info from files in nested filesets.

Version:
$Revision: 1.1 $
Author:
Laurent Broudoux

Field Summary
protected  VersionInfoExtractor versionExtractor
          The version information extractor instance used for retrieving component version
 
Fields inherited from class org.figure8.join.services.scripting.ant.tasks.RemoteServiceTask
REMOTE_URL_SUBCONTEXT
 
Fields inherited from class org.apache.tools.ant.Task
description, location, target, taskName, taskType, wrapper
 
Fields inherited from class org.apache.tools.ant.ProjectComponent
project
 
Constructor Summary
BindComponentTask()
          Creates a new instance of BindComponentTask
 
Method Summary
 void addFileset(org.apache.tools.ant.types.FileSet set)
          Adds a set of files (nested fileset element)
protected  void bindComponent(java.lang.String version, java.io.File[] files)
          Do the real component binding (remote service invocation)
protected  long computeSizeInBytes(java.io.File[] files)
          Compute the sum of files weigth.
 void execute()
          Execute this task : do the binding of configured component
 java.lang.String getAssembly()
           
 java.lang.Class getExtractor()
           
protected  java.io.File[] getFilesFromFileSets()
          Build an array of included files.
 java.lang.String getType()
           
 java.lang.String getVersion()
           
 void setAssembly(java.lang.String assembly)
           
 void setExtractor(java.lang.Class extractor)
           
 void setType(java.lang.String type)
           
 void setVersion(java.lang.String version)
           
protected  void validateAttributes()
          Validate this task attributes before execution.
 
Methods inherited from class org.figure8.join.services.scripting.ant.tasks.RemoteServiceTask
getPassword, getUrl, getUser, loginToRemoteService, releaseRemoteService, retrieveRemoteService, setPassword, setUrl, setUser
 
Methods inherited from class org.apache.tools.ant.Task
getDescription, getLocation, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, maybeConfigure, perform, reconfigure, setDescription, setLocation, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskType
 
Methods inherited from class org.apache.tools.ant.ProjectComponent
getProject, setProject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionExtractor

protected VersionInfoExtractor versionExtractor
The version information extractor instance used for retrieving component version

Constructor Detail

BindComponentTask

public BindComponentTask()
Creates a new instance of BindComponentTask

Method Detail

getType

public java.lang.String getType()
Returns:
The component type to bind a component for

setType

public void setType(java.lang.String type)
Parameters:
type - The component type to bind a component for

getAssembly

public java.lang.String getAssembly()
Returns:
The assembly that contains component

setAssembly

public void setAssembly(java.lang.String assembly)
Parameters:
assembly - The assembly that contains component

getVersion

public java.lang.String getVersion()
Returns:
The component version information

setVersion

public void setVersion(java.lang.String version)
Parameters:
version - The component version information

getExtractor

public java.lang.Class getExtractor()
Returns:
The component version extractor implementation to use

setExtractor

public void setExtractor(java.lang.Class extractor)
Parameters:
extractor - The component version extractor implementation to use

addFileset

public void addFileset(org.apache.tools.ant.types.FileSet set)
Adds a set of files (nested fileset element)

Parameters:
set - A FileSet containing files to process

execute

public void execute()
             throws org.apache.tools.ant.BuildException
Execute this task : do the binding of configured component

Overrides:
execute in class org.apache.tools.ant.Task
Throws:
org.apache.tools.ant.BuildException - if something wrong occurs during task process

validateAttributes

protected void validateAttributes()
                           throws org.apache.tools.ant.BuildException
Validate this task attributes before execution.

Throws:
org.apache.tools.ant.BuildException - if a mandatory attribute is not present

getFilesFromFileSets

protected java.io.File[] getFilesFromFileSets()
Build an array of included files.

Returns:
An array of files build from fileSets

bindComponent

protected void bindComponent(java.lang.String version,
                             java.io.File[] files)
                      throws org.apache.tools.ant.BuildException
Do the real component binding (remote service invocation)

Parameters:
files - The files representing component
Throws:
org.apache.tools.ant.BuildException - if service invocation fails

computeSizeInBytes

protected long computeSizeInBytes(java.io.File[] files)
                           throws java.lang.Exception
Compute the sum of files weigth. This sum is expressed in bytes.

Parameters:
files - The set of files to sum weigth.
Throws:
java.lang.Exception


Copyright © 2005-2008 Join. All Rights Reserved.