Re: (no subject)

"Andres Alcarraz" <[email protected]> Mon, 7 May 2007 22:52:05 -0300
Newsgroups gmane.comp.java.jpublish.devel
Message-ID <[email protected]>
--===============1600613984==
Content-Type: multipart/alternative; 
	boundary="----=_Part_761_23040854.1178589125916"

------=_Part_761_23040854.1178589125916
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 t=
o
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=E9s


2007/5/7, Florin T.PATRASCU <[email protected]>:
>
> 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=3D"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=E9s
> >
> > ----------------------------------------------------------------------
> > ---
> > 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
> > [email protected]
> > 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jpublish-developer
>

------=_Part_761_23040854.1178589125916
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hello Florin thank you very much for answering so fast, but problem I&#39;m=
 having is in a Java class action, there es where I cannot access the site =
context.<br>Precisely I&#39;m now trying to use java classes for actions, I=
&#39;m not trying to migrate all the application that previously used beans=
hell actions to this new approach but I want new things in pure java.
<br>What I don&#39;t understand is that asymmetry between java class based =
action and script based ones. I&#39;m not saying Jpublish is a bad thing, i=
&#39;ve been using it from years but nobody and nothing is perfect.<br>
In fact what I tried to say is that java class based actions have nothing t=
o do at start up if they can not access the site context, because where cou=
ld they put any object created?<br>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 :).
<br>Certainly I can fix that in my own Application by calling a StartupActi=
on from a generic BeanShell kind of adapter where the action class is a par=
ameter of the beanshell adapter script.<br><br>my proposal is to define a n=
ew interface:
<br style=3D"font-family: courier new,monospace;"><span style=3D"font-famil=
y: courier new,monospace;">public interface StartupAction extends Action{</=
span><br style=3D"font-family: courier new,monospace;"><span style=3D"font-=
family: courier new,monospace;">
&nbsp;&nbsp;&nbsp; public void setSiteContext(SiteContext context);</span><=
br style=3D"font-family: courier new,monospace;"><span style=3D"font-family=
: courier new,monospace;">}</span><br style=3D"font-family: courier new,mon=
ospace;"><br>And in the part of the code where the action is found (in find=
Action() when handling start up actions)=20
<br><span style=3D"font-family: courier new,monospace;">if (action instance=
of StartupAction)</span><br style=3D"font-family: courier new,monospace;"><=
span style=3D"font-family: courier new,monospace;">&nbsp;&nbsp;&nbsp; ((Sta=
rtupAction)action).setSiteContext(siteContext);
</span><br><br>or something like this.<br><br>Best regards and thanks again=
<br><br>Andr=E9s<br><br><br><div><span class=3D"gmail_quote">2007/5/7, Flor=
in T.PATRASCU &lt;<a href=3D"mailto:[email protected]">florin.patra=
[email protected]
</a>&gt;:</span><blockquote class=3D"gmail_quote" style=3D"border-left: 1px=
 solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">H=
i,<br><br>If you need the SiteContext in startup actions, then in your Acti=
on
<br>(bsh, js, etc.) you can simply use the parameter &#39;site&#39;. For ex=
ample,<br>a simple startup Action (StartUpTest.bsh)&nbsp;&nbsp;containing o=
nly one line<br>of code:<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&=
nbsp;syslog.info( &quot;configuration path: &quot;+site.getConfigurationPat=
h());
<br><br>The file jpublish.xml:<br>...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&lt;action-manager&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;startup-ac=
tion name=3D&quot;StartUpTest.bsh&quot;/&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;&lt;/action-manager&gt;<br>...<br><br>And when you&#39=
;ll start your JPublish application you&#39;ll see in the
<br>logs something like this:<br>...<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;2275 [main] INFO&nbsp;&nbsp;syslog&nbsp;&nbsp;- configuration =
path: WEB-INF/jpublish.xml<br>...<br><br>Don&#39;t worry, JPublish is a fin=
e application :)<br>-florin<br><br><br>On 07-May-07, at 16:16 , Andres Alca=
rraz wrote:
<br><br>&gt; Hi all, I was trying to make a java startup action when I real=
ized<br>&gt; that I cannot access the site context from them because the Co=
ntext is<br>&gt; null, that doesn&#39;t occur in script actions where you h=
ave a reference
<br>&gt; to the site context, I wonder what is the sense of having a startu=
p<br>&gt; action that has no access to the site context.<br>&gt; Looking at=
 the code I&#39;ve found that when an action script is found<br>&gt; site c=
ontext is passed through the constructor, but that doesn&#39;t
<br>&gt; happen in java actions, I think the execute method could have more=
<br>&gt; parameters or Action interface could have a setSiteContext() metho=
d, I<br>&gt; know this would not be backward compatible, but a new StartupA=
ction
<br>&gt; could be defined.<br>&gt; What others means do i have to access th=
e site context from a java<br>&gt; startup action?<br>&gt;<br>&gt; I&#39;m =
using jpublish 3.0b2 thanks in advance<br>&gt;<br>&gt;<br>&gt; Andr=E9s<br>
&gt;<br>&gt; --------------------------------------------------------------=
--------<br>&gt; ---<br>&gt; This SF.net email is sponsored by DB2 Express<=
br>&gt; Download DB2 Express C - the FREE version of DB2 express and take
<br>&gt; control of your XML. No limits. Just data. Click to get it now.<br=
>&gt; <a href=3D"http://sourceforge.net/powerbar/db2/">http://sourceforge.n=
et/powerbar/db2/</a><br>&gt; ______________________________________________=
_
<br>&gt; Jpublish-developer mailing list<br>&gt; <a href=3D"mailto:Jpublish=
[email protected]">[email protected]<=
/a><br>&gt; <a href=3D"https://lists.sourceforge.net/lists/listinfo/jpublis=
h-developer">
https://lists.sourceforge.net/lists/listinfo/jpublish-developer</a><br><br>=
<br>-----------------------------------------------------------------------=
--<br>This SF.net email is sponsored by DB2 Express<br>Download DB2 Express=
 C - the FREE version of DB2 express and take
<br>control of your XML. No limits. Just data. Click to get it now.<br><a h=
ref=3D"http://sourceforge.net/powerbar/db2/">http://sourceforge.net/powerba=
r/db2/</a><br>_______________________________________________<br>Jpublish-d=
eveloper mailing list
<br><a href=3D"mailto:[email protected]">Jpublish-de=
[email protected]</a><br><a href=3D"https://lists.sourceforge.n=
et/lists/listinfo/jpublish-developer">https://lists.sourceforge.net/lists/l=
istinfo/jpublish-developer
</a><br></blockquote></div><br>

------=_Part_761_23040854.1178589125916--


--===============1600613984==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

-------------------------------------------------------------------------
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/
--===============1600613984==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Jpublish-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jpublish-developer

--===============1600613984==--