FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Make DSSS extendable like Ant is

 
Post new topic   Reply to topic     Forum Index -> DSSS
View previous topic :: View next topic  
Author Message
keinfarbton



Joined: 03 Dec 2005
Posts: 224
Location: Stuttgart - Germany

PostPosted: Sat Feb 17, 2007 2:50 pm    Post subject: Make DSSS extendable like Ant is Reply with quote

Ant can be easily extended by user tasks. To implement a user task, the task does not need to parser arguments or such. In Java it is easy, reflection is used. If a method
setMyValue( boolean a ){...}
exists, this means the Tasks can get an bool option called "myvalue" in the build.xml.
See also http://ant.apache.org/manual/index.html

Dsss could do the same. simply define a user task in the dsss.conf file with a .d file. Then dsss compiles the .d together with some files from dsss itself. The aim is, to provide a unified interface to the users tasks. It is now in a separated binary, but the arguments are passed in a well known way. And the needed args can be retrieved.

Dsss supplies this:
Code:

public class Args{
  Option[] getOptions();
  Argument[] getArgument();
}
// more classes for different kinds of options
// bool, string, integer, file, fileset, dirs
// optional/non-optional
// help/usage texts

interface DsssTask{
  // return object that describes the possible arguments.
  // Dsss fills in the data from the dsss.conf and the commandline args.
  public Args getArgs();
 
  // Dsss will call this if all args are in place.
  // shall throw DsssBuildException in case of error.
  public void execute();
}
// ...


Dsss compile the users task together with this main module.
This module is part of the dsss distro.
Code:

import dsss.CustomTask;

extern DsssTask getDsssTask();

int main( char[][] args ){
   CustomTask.main( args, getDsssTask() );
}



A user task can look like this. This module is written by third party.
Code:

DsssTask getDsssTask(){
   return new MyTask();
}

class MyTask : DsssTask {
  MyArgs args;
  public this(){
    args = new MyArgs();
  }
  override Args getArgs(){
    return args;
  }
  override void execute(){
    foreach( Option opt; args.getOptions ){
      ....
    }
    ....
  }
}


The main function can now provide something like a -discribeargs option, to output all options in a way, the main dsss can parse it and call the task a second time with all information it requires.

With simple arguments there is no big advantage. but now it is also possible to provide file collections or build more complex functionality on this.

Is it understandable what i want to say Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DSSS All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group