commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Raphaël Piéroni <raphael_mail...@yahoo.fr>
Subject [Jelly] jelly script in an Object's String attribute / FROM user list
Date Fri, 07 Mar 2003 12:49:58 GMT
Hello everybody,
i have created 2 methods for JellyContext. 
but due to some personal agenda, i will not have access to a java
compiler for a little time.

i sent the methods (never compiled) with this mail, if someone is
interrested.

i will try to compile them this WE and test them

i will inform the list after.

the code :
import java.io.PipedOutputStream;
import java.io.PipedInputStream;
import java.io.OutputStreamWriter;

public JellyContext JellyContext.runStringScript(String stringScript,
XMLOutput output) {

    Script script = compileStringScript(stringScript);


    JellyContext newJellyContext = newJellyContext();
    //newJellyContext.setRootURL( newJellyContextURL );
    //newJellyContext.setCurrentURL( newJellyContextURL );
    newJellyContext.setExport( DEFAULT_EXPORT );
    newJellyContext.setInherit( DEFAULT_INHERIT );

 //   if ( inherit ) {
        // use the same variable scopes
    newJellyContext.variables = this.variables;
 //   }

    if (log.isDebugEnabled() ) {
        log.debug( "About to run script: " + url );
        log.debug( "root context URL: " + newJellyContext.rootURL );
        log.debug( "current context URL: " + newJellyContext.currentURL
);
    }

    script.run(newJellyContext, output);
    return newJellyContext;
}

public Script JelltContext.compileStringScript(String script) throws
JellyException {
    XMLParser parser = new XMLParser();
    parser.setContext(this);
    PipedOutputStream pos;
    InputStream in = new PipedInputStream(pos);
    OutputStreamWriter osw = new OutputStreamWriter(pos);
    osw.write(script, 0, script.length());

    if (in == null) {
        throw new JellyException("Could not find Jelly script: " +
script);
    }
    Script script = null;
    try {
        script = parser.parse(in);
    } catch (IOException e) {
        throw new JellyException("Could not parse Jelly script",e);
    } catch (SAXException e) {
        throw new JellyException("Could not parse Jelly script",e);
    }

    return script.compile();
}



 --- Raphaël Piéroni <raphael_mailing@yahoo.fr> a écrit : > Hello
everybody, 
> I'm currently trying to understand how to use jelly but, 
> it seems that we can not use a script stored as a string attribute of
> an object.
> 
> i have a plentyfull of objects that will have to execute a jelly
> script
> that is not stored a a file but a an attribute of the executing
> object.
> 
> i have found that to run a script you have to know the URI where the
> script is, but i don't know how to make the URI going to an
> instanciated object. (i may, but it's not a good design for me store
> the scripts in a jar file, but i still don't know how to create a
> good
> URI)
> 
> in advance, thanks for any piece of advice.
> 
> Raphaël Piéroni
> 
> 
> =====
> ------------------------------------
> | Raphaël Piéroni                  |
> | 33+ 223 351 354                  |
> | mailto:rpieroni@dexem.com        |
> | http://www.dexem.com             |
> | mailing:raphael_mailing@yahoo.fr |
> ------------------------------------
> 
> ___________________________________________________________
> Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
> Yahoo! Mail : http://fr.mail.yahoo.com
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>  

=====
------------------------------------
| Raphaël Piéroni                  |
| 33+ 223 351 354                  |
| mailto:rpieroni@dexem.com        |
| http://www.dexem.com             |
| mailing:raphael_mailing@yahoo.fr |
------------------------------------

___________________________________________________________
Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
Yahoo! Mail : http://fr.mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message