Clarity PPM

Expand all | Collapse all

Load a class in Gel

  • 1.  Load a class in Gel

    Posted 06-18-2014 09:48 AM

    Hi All.

    I need to use a standard class (I mean, a class that is already present in the <clarity>\lib folder) from a gel script.

    To test, I defined the following a very simple script:

     

    <gel:script

        xmlns:core="jelly:core"

        xmlns:util="jelly:util"

        xmlns:x="jelly:xml"

        xmlns:sql="jelly:sql"

        xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"

        xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"

    >

        <!-- create Properties class -->

        <core:new className="java.util.Properties" var="propertiesClass"/>

        <!-- Create session Class -->

        <core:new className="javax.mail.Session" var="sessionClass"/>

    </gel:script>

     

    both util.jar and mail.jar are present in the lib folder, but when I run the script, I get an error on the Session class creation, while the Properties class is correctly instantiated.

    Any help on this?

    Thanks

    Fabio



  • 2.  Re: Load a class in Gel

    Posted 06-18-2014 10:42 AM

    I think need to use the static getInstance method on javax.mail.Session.

     

    <gel:script

        xmlns:core="jelly:core"

        xmlns:util="jelly:util"

        xmlns:x="jelly:xml"

        xmlns:sql="jelly:sql"

        xmlns:gel="jelly:com.niku.union.gel.GELTagLibrary"

        xmlns:soap="jelly:com.niku.union.gel.SOAPTagLibrary"

    >

     

        <!-- create Properties class -->

     

        <core:new className="java.util.Properties" var="propertiesClass"/>

        <core:invoke method="put" on="${propertiesClass}">

            <core:arg type="java.lang.Object" value="mail.smtp.host"/>

            <core:arg type="java.lang.Object" value="smtp.gmail.com"/>

        </core:invoke>

            <core:invoke method="put" on="${propertiesClass}">

            <core:arg type="java.lang.Object" value="mail.smtp.port"/>

            <core:arg type="java.lang.Object" value="587"/>

        </core:invoke>

       

        <!-- Create session Class -->

     

        <!--

        Replace this with the invokeStatic

        <core:new className="javax.mail.Session" var="sessionClass"/>

        -->

       

        <core:invokeStatic var="sessionClass" className="javax.mail.Session" method="getInstance">

            <core:arg type="java.util.Properties" value="${propertiesClass}"/>

        </core:invokeStatic>

     

    </gel:script>

     

    V/r,

    Gene