(no subject)

View: New views
5 Messages — Rating Filter:   Alert me  

(no subject)

by Andres Alcarraz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all, I was trying to make a java startup action when I realized
that I cannot access the site context from them because the Context is
null, that doesn't occur in script actions where you have a reference
to the site context, I wonder what is the sense of having a startup
action that has no access to the site context.
Looking at the code I've found that when an action script is found
site context is passed through the constructor, but that doesn't
happen in java actions, I think the execute method could have more
parameters or Action interface could have a setSiteContext() method, I
know this would not be backward compatible, but a new StartupAction
could be defined.
What others means do i have to access the site context from a java
startup action?

I'm using jpublish 3.0b2 thanks in advance


Andrés

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer

Re: (no subject)

by Florin T. PATRASCU :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

If you need the SiteContext in startup actions, then in your Action  
(bsh, js, etc.) you can simply use the parameter 'site'. For example,  
a simple startup Action (StartUpTest.bsh)  containing only one line  
of code:

        syslog.info( "configuration path: "+site.getConfigurationPath());

The file jpublish.xml:
...
        <action-manager>
      <startup-action name="StartUpTest.bsh"/>
        </action-manager>
...

And when you'll start your JPublish application you'll see in the  
logs something like this:
...
        2275 [main] INFO  syslog  - configuration path: WEB-INF/jpublish.xml
...

Don't worry, JPublish is a fine application :)
-florin


On 07-May-07, at 16:16 , Andres Alcarraz wrote:

> Hi all, I was trying to make a java startup action when I realized
> that I cannot access the site context from them because the Context is
> null, that doesn't occur in script actions where you have a reference
> to the site context, I wonder what is the sense of having a startup
> action that has no access to the site context.
> Looking at the code I've found that when an action script is found
> site context is passed through the constructor, but that doesn't
> happen in java actions, I think the execute method could have more
> parameters or Action interface could have a setSiteContext() method, I
> know this would not be backward compatible, but a new StartupAction
> could be defined.
> What others means do i have to access the site context from a java
> startup action?
>
> I'm using jpublish 3.0b2 thanks in advance
>
>
> Andrés
>
> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jpublish-developer mailing list
> Jpublish-developer@...
> https://lists.sourceforge.net/lists/listinfo/jpublish-developer


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer

Re: (no subject)

by Andres Alcarraz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Florin thank you very much for answering so fast, but problem I'm having is in a Java class action, there es where I cannot access the site context.
Precisely I'm now trying to use java classes for actions, I'm not trying to migrate all the application that previously used beanshell actions to this new approach but I want new things in pure java.
What I don't understand is that asymmetry between java class based action and script based ones. I'm not saying Jpublish is a bad thing, i've been using it from years but nobody and nothing is perfect.
In fact what I tried to say is that java class based actions have nothing to do at start up if they can not access the site context, because where could they put any object created?
My intention was to mention a quick and backward compatible fix (StartupAction interface) that I have no problem to implement, the same problem may be occurring in Shutdown actions so there may be a better name :).
Certainly I can fix that in my own Application by calling a StartupAction from a generic BeanShell kind of adapter where the action class is a parameter of the beanshell adapter script.

my proposal is to define a new interface:
public interface StartupAction extends Action{
    public void setSiteContext(SiteContext context);
}

And in the part of the code where the action is found (in findAction() when handling start up actions)
if (action instanceof StartupAction)
    ((StartupAction)action).setSiteContext(siteContext);

or something like this.

Best regards and thanks again

Andrés


2007/5/7, Florin T.PATRASCU <florin.patrascu@...>:
Hi,

If you need the SiteContext in startup actions, then in your Action
(bsh, js, etc.) you can simply use the parameter 'site'. For example,
a simple startup Action (StartUpTest.bsh)  containing only one line
of code:

        syslog.info( "configuration path: "+site.getConfigurationPath());

The file jpublish.xml:
...
        <action-manager>
                <startup-action name="StartUpTest.bsh"/>
        </action-manager>
...

And when you'll start your JPublish application you'll see in the
logs something like this:
...
        2275 [main] INFO  syslog  - configuration path: WEB-INF/jpublish.xml
...

Don't worry, JPublish is a fine application :)
-florin


On 07-May-07, at 16:16 , Andres Alcarraz wrote:

> Hi all, I was trying to make a java startup action when I realized
> that I cannot access the site context from them because the Context is
> null, that doesn't occur in script actions where you have a reference
> to the site context, I wonder what is the sense of having a startup
> action that has no access to the site context.
> Looking at the code I've found that when an action script is found
> site context is passed through the constructor, but that doesn't
> happen in java actions, I think the execute method could have more
> parameters or Action interface could have a setSiteContext() method, I
> know this would not be backward compatible, but a new StartupAction
> could be defined.
> What others means do i have to access the site context from a java
> startup action?
>
> I'm using jpublish 3.0b2 thanks in advance
>
>
> Andrés
>

> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jpublish-developer mailing list
> Jpublish-developer@...
> https://lists.sourceforge.net/lists/listinfo/jpublish-developer


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer

Startup/Shutdown Action can get access to 'site'

by Florin T.PATRASCU :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Andres,

is done; a bit different than your proposal, but with the same or better effect, I hope ;)

I believe you have to wait a bit for the sf.net to synchronize the public CVS before you can grab the updated version of JP3.

For Java actions you will have now a minimum context available at startup and shutdown. In this context you don't have only the 'site' but you'll also find few helpers to help you do ... stuff at startup :) 

These helpers are:

RequestContext.JPUBLISH_DATE_UTILITIES
RequestContext.JPUBLISH_NUMBER_UTILITIES
"messageUtilities"
RequestContext.JPUBLISH_SYSLOG

and the one that you requested:
RequestContext.JPUBLISH_SITE


I tested my changes with the followings:
- in jpublish.xml
<action-manager>
    <startup-action name="org.jpublish.test.JavaStartUpAction"/>
....

- JavaStartUpAction.java (excerpt)
    public void execute(RequestContext context, Configuration configuration) {

        Log syslog = (Log) context.get(RequestContext.JPUBLISH_SYSLOG);
        SiteContext site = context.getSiteContext(); // or ...get( RequestContext.JPUBLISH_SITE

        syslog.info("configuration path: "+site.getConfigurationPath());

    }


And you have a space (the context received by the Action) where all the startup actions can share Objects. This is happening because I am reusing the same context for all the Actions executed at startup; a similar approach being used for shutdown.

I hope it helps, 
-florin


PS
Now I have to back-port this functionality to JPublish 2.0 ;)


On 07-May-07, at 21:52 , Andres Alcarraz wrote:

Hello Florin thank you very much for answering so fast, but problem I'm having is in a Java class action, there es where I cannot access the site context.
Precisely I'm now trying to use java classes for actions, I'm not trying to migrate all the application that previously used beanshell actions to this new approach but I want new things in pure java.
What I don't understand is that asymmetry between java class based action and script based ones. I'm not saying Jpublish is a bad thing, i've been using it from years but nobody and nothing is perfect.
In fact what I tried to say is that java class based actions have nothing to do at start up if they can not access the site context, because where could they put any object created?
My intention was to mention a quick and backward compatible fix (StartupAction interface) that I have no problem to implement, the same problem may be occurring in Shutdown actions so there may be a better name :).
Certainly I can fix that in my own Application by calling a StartupAction from a generic BeanShell kind of adapter where the action class is a parameter of the beanshell adapter script.

my proposal is to define a new interface:
public interface StartupAction extends Action{
    public void setSiteContext(SiteContext context);
}

And in the part of the code where the action is found (in findAction() when handling start up actions)
if (action instanceof StartupAction)
    ((StartupAction)action).setSiteContext(siteContext);

or something like this.

Best regards and thanks again

Andrés


2007/5/7, Florin T.PATRASCU <florin.patrascu@...>:
Hi,

If you need the SiteContext in startup actions, then in your Action
(bsh, js, etc.) you can simply use the parameter 'site'. For example,
a simple startup Action (StartUpTest.bsh)  containing only one line
of code:

        syslog.info( "configuration path: "+site.getConfigurationPath());

The file jpublish.xml:
...
        <action-manager>
                <startup-action name="StartUpTest.bsh"/>
        </action-manager>
...

And when you'll start your JPublish application you'll see in the
logs something like this:
...
        2275 [main] INFO  syslog  - configuration path: WEB-INF/jpublish.xml
...

Don't worry, JPublish is a fine application :)
-florin


On 07-May-07, at 16:16 , Andres Alcarraz wrote:

> Hi all, I was trying to make a java startup action when I realized
> that I cannot access the site context from them because the Context is
> null, that doesn't occur in script actions where you have a reference
> to the site context, I wonder what is the sense of having a startup
> action that has no access to the site context.
> Looking at the code I've found that when an action script is found
> site context is passed through the constructor, but that doesn't
> happen in java actions, I think the execute method could have more
> parameters or Action interface could have a setSiteContext() method, I
> know this would not be backward compatible, but a new StartupAction
> could be defined.
> What others means do i have to access the site context from a java
> startup action?
>
> I'm using jpublish 3.0b2 thanks in advance
>
>
> Andrés
>

> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jpublish-developer mailing list
> Jpublish-developer@...
> https://lists.sourceforge.net/lists/listinfo/jpublish-developer


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
Jpublish-developer mailing list


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer

Re: Startup/Shutdown Action can get access to 'site'

by Andres Alcarraz-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Some parts of this message have been removed. Learn more about Nabble's security policy.
Wow that was quick, Thank you very much Florin I'll test this tomorrow ASAP.

Have a nice day

Andrés

2007/5/8, Florin T.PATRASCU <flop@...>:
Hi Andres,

is done; a bit different than your proposal, but with the same or better effect, I hope ;)

I believe you have to wait a bit for the sf.net to synchronize the public CVS before you can grab the updated version of JP3.

For Java actions you will have now a minimum context available at startup and shutdown. In this context you don't have only the 'site' but you'll also find few helpers to help you do ... stuff at startup :) 

These helpers are:

RequestContext.JPUBLISH_DATE_UTILITIES
RequestContext.JPUBLISH_NUMBER_UTILITIES
"messageUtilities"
RequestContext.JPUBLISH_SYSLOG

and the one that you requested:
RequestContext.JPUBLISH_SITE


I tested my changes with the followings:
- in jpublish.xml
<action-manager>
    <startup-action name="org.jpublish.test.JavaStartUpAction"/>
....

- JavaStartUpAction.java (excerpt)
    public void execute(RequestContext context, Configuration configuration) {

        Log syslog = (Log) context.get(RequestContext.JPUBLISH_SYSLOG);
        SiteContext site = context.getSiteContext(); // or ...get( RequestContext.JPUBLISH_SITE

        syslog.info("configuration path: "+site.getConfigurationPath());

    }


And you have a space (the context received by the Action) where all the startup actions can share Objects. This is happening because I am reusing the same context for all the Actions executed at startup; a similar approach being used for shutdown.

I hope it helps, 
-florin


PS
Now I have to back-port this functionality to JPublish 2.0 ;)


On 07-May-07, at 21:52 , Andres Alcarraz wrote:

Hello Florin thank you very much for answering so fast, but problem I'm having is in a Java class action, there es where I cannot access the site context.
Precisely I'm now trying to use java classes for actions, I'm not trying to migrate all the application that previously used beanshell actions to this new approach but I want new things in pure java.
What I don't understand is that asymmetry between java class based action and script based ones. I'm not saying Jpublish is a bad thing, i've been using it from years but nobody and nothing is perfect.
In fact what I tried to say is that java class based actions have nothing to do at start up if they can not access the site context, because where could they put any object created?
My intention was to mention a quick and backward compatible fix (StartupAction interface) that I have no problem to implement, the same problem may be occurring in Shutdown actions so there may be a better name :).
Certainly I can fix that in my own Application by calling a StartupAction from a generic BeanShell kind of adapter where the action class is a parameter of the beanshell adapter script.

my proposal is to define a new interface:
public interface StartupAction extends Action{
    public void setSiteContext(SiteContext context);
}

And in the part of the code where the action is found (in findAction() when handling start up actions)
if (action instanceof StartupAction)
    ((StartupAction)action).setSiteContext(siteContext);

or something like this.

Best regards and thanks again

Andrés


2007/5/7, Florin T.PATRASCU <florin.patrascu@...>:
Hi,

If you need the SiteContext in startup actions, then in your Action
(bsh, js, etc.) you can simply use the parameter 'site'. For example,
a simple startup Action (StartUpTest.bsh)  containing only one line
of code:

        syslog.info( "configuration path: "+site.getConfigurationPath());

The file jpublish.xml:
...
        <action-manager>
                <startup-action name="StartUpTest.bsh"/>
        </action-manager>
...

And when you'll start your JPublish application you'll see in the
logs something like this:
...
        2275 [main] INFO  syslog  - configuration path: WEB-INF/jpublish.xml
...

Don't worry, JPublish is a fine application :)
-florin


On 07-May-07, at 16:16 , Andres Alcarraz wrote:

> Hi all, I was trying to make a java startup action when I realized
> that I cannot access the site context from them because the Context is
> null, that doesn't occur in script actions where you have a reference
> to the site context, I wonder what is the sense of having a startup
> action that has no access to the site context.
> Looking at the code I've found that when an action script is found
> site context is passed through the constructor, but that doesn't
> happen in java actions, I think the execute method could have more
> parameters or Action interface could have a setSiteContext() method, I
> know this would not be backward compatible, but a new StartupAction
> could be defined.
> What others means do i have to access the site context from a java
> startup action?
>
> I'm using jpublish 3.0b2 thanks in advance
>
>
> Andrés
>

> ----------------------------------------------------------------------
> ---
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Jpublish-developer mailing list
> Jpublish-developer@...
> https://lists.sourceforge.net/lists/listinfo/jpublish-developer


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
Jpublish-developer mailing list


-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer



-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Jpublish-developer mailing list
Jpublish-developer@...
https://lists.sourceforge.net/lists/listinfo/jpublish-developer
LightInTheBox - Buy quality products at wholesale price