ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject AW: Creating custom InputHandler
Date Mon, 12 Jul 2004 06:51:08 GMT
Indeed, seems to be a problem.

The initialization procedure for InputHandlers doesnt store a project
reference (and 
couldnt do it, because the IH-Interface doesnt requires a
setProject(Project) method).

So only a workaround comes into my mind:
- your InputHandler has to provide the setProject method
- set the reference for yourself before using the handler by using a Task:
  (code not tested - even compiled):
  public class SetProjectReferenceOnInputHandler extends Task {
      public void execute() {
          InputHandler ih = getProject().getInputHandler();
          if (ih instanceof MyInputHandler) {
              ((MyInputHandler)ih).setProject(getProject());
          }
      }
  }
  

Maybe we should check if the InputHandler is a ProjectComponent and set the
project
reference then ... 


Jan



Input.java:0100:     public void execute () throws BuildException {
Input.java:0116:
getProject().getInputHandler().handleInput(request);

Project.java:0239:     public Project() {
Project.java:0240:         fileUtils = FileUtils.newFileUtils();
Project.java:0241:         inputHandler = new DefaultInputHandler();
Project.java:0242:     }

Main.java:0736:     private void addInputHandler(Project project) throws
BuildException {
Main.java:0737:         InputHandler handler = null;
Main.java:0738:         if (inputHandlerClassname == null) {
Main.java:0739:             handler = new DefaultInputHandler();
Main.java:0740:         } else {
Main.java:0741:             try {
Main.java:0742:                 handler = (InputHandler)
Main.java:0743:
(Class.forName(inputHandlerClassname).newInstance());
Main.java:0744:                 if (project != null) {
Main.java:0745:                     project.setProjectReference(handler);
Main.java:0746:                 }
Main.java:0759:         project.setInputHandler(handler);
Main.java:0760:     }





> -----Urspr√ľngliche Nachricht-----
> Von: Ivan Ivanov [mailto:rambiusparkisanius@yahoo.com]
> Gesendet am: Montag, 12. Juli 2004 08:34
> An: user@ant.apache.org
> Betreff: Creating custom InputHandler
> 
> Dear Colleagues,
> 
> Some time ago I was playing with <input> task and I
> noticed that if you input a string, that contains a
> property in it, the property is not expanded to its
> value. Jan Matèrne adviced me in this list that I
> should implement an InputHandler to do this.
> 
> I created one that is reading the input correctly, but
> I ran into the problem how should I expand the
> properties in the  string that is inputted. When
> writing a custom task it is easy with
> getProject.replaceProperties(String). However I do not
> see a way to get the current Project in an
> InputHandler.
> 
> Any ideas how I can resolve the input?
> 
> Thanks in advance
> Ivan
> 
> 
> 		
> __________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - Send 10MB messages!
> http://promotions.yahoo.com/new_mail 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message