You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jun Tsai <ju...@gmail.com> on 2007/05/29 11:52:29 UTC
how to implement hivemind.Startup function in T5?
In T4,I often use hivemind.Startup to initialize my application data.
Which contribution configuration as same function in t5?
thanks.
Jun Tsai
ps:I don't want to override the tapestry filter.
--
Welcome to China Java Users Group(CNJUG).
http://cnjug.dev.java.net
Re: how to implement hivemind.Startup function in T5?
Posted by Otho <ta...@googlemail.com>.
Thank you very much! That was it.
Just one more catch: Injecting the Services like I did doesn't work with
@EagerLoad. One needs to either cache them by providing a module constructor
or inject them at the method parameters as described here:
http://tapestry.apache.org/tapestry5/tapestry-ioc/module.html#Caching%20Services
Regards,
Otho
2007/6/11, Davor Hrg <hr...@gmail.com>:
>
> you missed it just sligtly,
>
> anotating your Impl works if you use "bind"
>
> here, because you are constructing th Impl tapestry is not
> checking out annotations on it.
> you have to annotate you build Method
> extract from doc:
> -------------------------------
> Eager Loading Services
> Services are normally created only as needed (per the scope discussion
> above).
> This can be tweaked slightly; by adding the EagerLoad annotation to the
> service builder method,....
> ...................................
>
>
> put:
> @EagerLoad
> public MyInterface buildMyInterface(final Log log)
> {
> log.debug("Creating service MyInterface");
> return new MyInterfaceImpl(springService);
> }
>
>
>
> On 6/11/07, Otho <ta...@googlemail.com> wrote:
> >
> > Any hints as to how that exactly works?
> >
> > I wrote a service interface,
> >
> > public interface MyInterface
> > {
> > }
> >
> > implemented it and annotated it with @EagerLoad
> >
> > @EagerLoad
> > public class MyInterfaceImpl implemets MyInterface
> > {
> > public MyInterfaceImpl(SpringService springService)
> > {
> > doSomeStuff(springService);
> > }
> >
> > private void doSomeStuff(SpringService springService);
> > }
> >
> > and in the app module wrote:
> >
> > @Inject
> > @Service("SpringService")
> > private SpringService springService; //will be reused in other services
> >
> > public MyInterface buildMyInterface(final Log log)
> > {
> > log.debug("Creating service MyInterface");
> > return new MyInterfaceImpl(springService); <=
> > }
> >
> >
> > Still... when debugging with Tomcat the buildMyInterface method isn't
> > executed, in contrast to all other methods (like the example timing
> filter
> > from the archetype). I am a bit lost at that.
> >
> > Regards,
> > Otho
> >
>
Re: how to implement hivemind.Startup function in T5?
Posted by Davor Hrg <hr...@gmail.com>.
you missed it just sligtly,
anotating your Impl works if you use "bind"
here, because you are constructing th Impl tapestry is not
checking out annotations on it.
you have to annotate you build Method
extract from doc:
-------------------------------
Eager Loading Services
Services are normally created only as needed (per the scope discussion
above).
This can be tweaked slightly; by adding the EagerLoad annotation to the
service builder method,....
...................................
put:
@EagerLoad
public MyInterface buildMyInterface(final Log log)
{
log.debug("Creating service MyInterface");
return new MyInterfaceImpl(springService);
}
On 6/11/07, Otho <ta...@googlemail.com> wrote:
>
> Any hints as to how that exactly works?
>
> I wrote a service interface,
>
> public interface MyInterface
> {
> }
>
> implemented it and annotated it with @EagerLoad
>
> @EagerLoad
> public class MyInterfaceImpl implemets MyInterface
> {
> public MyInterfaceImpl(SpringService springService)
> {
> doSomeStuff(springService);
> }
>
> private void doSomeStuff(SpringService springService);
> }
>
> and in the app module wrote:
>
> @Inject
> @Service("SpringService")
> private SpringService springService; //will be reused in other services
>
> public MyInterface buildMyInterface(final Log log)
> {
> log.debug("Creating service MyInterface");
> return new MyInterfaceImpl(springService); <=
> }
>
>
> Still... when debugging with Tomcat the buildMyInterface method isn't
> executed, in contrast to all other methods (like the example timing filter
> from the archetype). I am a bit lost at that.
>
> Regards,
> Otho
>
Re: how to implement hivemind.Startup function in T5?
Posted by Otho <ta...@googlemail.com>.
Any hints as to how that exactly works?
I wrote a service interface,
public interface MyInterface
{
}
implemented it and annotated it with @EagerLoad
@EagerLoad
public class MyInterfaceImpl implemets MyInterface
{
public MyInterfaceImpl(SpringService springService)
{
doSomeStuff(springService);
}
private void doSomeStuff(SpringService springService);
}
and in the app module wrote:
@Inject
@Service("SpringService")
private SpringService springService; //will be reused in other services
public MyInterface buildMyInterface(final Log log)
{
log.debug("Creating service MyInterface");
return new MyInterfaceImpl(springService); <=
}
Still... when debugging with Tomcat the buildMyInterface method isn't
executed, in contrast to all other methods (like the example timing filter
from the archetype). I am a bit lost at that.
Regards,
Otho
Re: how to implement hivemind.Startup function in T5?
Posted by Davor Hrg <hr...@gmail.com>.
Why not use EagerLoad
it was in Hivemind, and it exists in T5 as well...
http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html
look for "eager load"
Davor Hrg
On 6/11/07, Otho <ta...@googlemail.com> wrote:
>
> Hi all!
> I have the same problem [T5] of initializing the database at startup and
> tried it with contribution like this:
>
> In my MyAppModule I added
>
> public void
>
> contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializer>
> configuration)
> {
> configuration.add("myApp.applicationIitializer", new
> MyAppInitializer());
> }
>
> with MyAppInitializer implementing the ApplicationInitializer interface.
> Unfortunately that seems to be wrong, since the app is never entering the
> initializeApplication method.
>
> Any tips as to how to get that right?
>
> Regards,
> Otho
>
>
>
>
> 2007/5/29, Renat Zubairov <re...@gmail.com>:
> >
> > I assume the similar to 4.0 way - via ApplicationInitializer
> >
> >
> >
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java?view=markup
> >
> > And
> >
> >
> >
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ApplicationInitializerFilter.java?view=markup
> >
> > Renat
> >
> > On 29/05/07, Jun Tsai <ju...@gmail.com> wrote:
> > > In T4,I often use hivemind.Startup to initialize my application data.
> > > Which contribution configuration as same function in t5?
> > >
> > > thanks.
> > >
> > > Jun Tsai
> > >
> > > ps:I don't want to override the tapestry filter.
> > >
> > >
> > >
> > > --
> > > Welcome to China Java Users Group(CNJUG).
> > > http://cnjug.dev.java.net
> > >
> >
> >
> > --
> > Best regards,
> > Renat Zubairov
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
Re: how to implement hivemind.Startup function in T5?
Posted by Otho <ta...@googlemail.com>.
Hi all!
I have the same problem [T5] of initializing the database at startup and
tried it with contribution like this:
In my MyAppModule I added
public void
contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializer>
configuration)
{
configuration.add("myApp.applicationIitializer", new
MyAppInitializer());
}
with MyAppInitializer implementing the ApplicationInitializer interface.
Unfortunately that seems to be wrong, since the app is never entering the
initializeApplication method.
Any tips as to how to get that right?
Regards,
Otho
2007/5/29, Renat Zubairov <re...@gmail.com>:
>
> I assume the similar to 4.0 way - via ApplicationInitializer
>
>
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java?view=markup
>
> And
>
>
> http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ApplicationInitializerFilter.java?view=markup
>
> Renat
>
> On 29/05/07, Jun Tsai <ju...@gmail.com> wrote:
> > In T4,I often use hivemind.Startup to initialize my application data.
> > Which contribution configuration as same function in t5?
> >
> > thanks.
> >
> > Jun Tsai
> >
> > ps:I don't want to override the tapestry filter.
> >
> >
> >
> > --
> > Welcome to China Java Users Group(CNJUG).
> > http://cnjug.dev.java.net
> >
>
>
> --
> Best regards,
> Renat Zubairov
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: how to implement hivemind.Startup function in T5?
Posted by Renat Zubairov <re...@gmail.com>.
I assume the similar to 4.0 way - via ApplicationInitializer
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ApplicationInitializer.java?view=markup
And
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/ApplicationInitializerFilter.java?view=markup
Renat
On 29/05/07, Jun Tsai <ju...@gmail.com> wrote:
> In T4,I often use hivemind.Startup to initialize my application data.
> Which contribution configuration as same function in t5?
>
> thanks.
>
> Jun Tsai
>
> ps:I don't want to override the tapestry filter.
>
>
>
> --
> Welcome to China Java Users Group(CNJUG).
> http://cnjug.dev.java.net
>
--
Best regards,
Renat Zubairov
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding a parameter to the url for all pages
Posted by Denis McCarthy <dm...@annadaletech.com>.
Never mind - I just came across an example using the cookie source
hivemind service to accomplish this. This is a much cleaner solution. Thanks
Denis McCarthy wrote:
> That sounds like a good idea. However, I've been unable to find an
> explanation as to how to set a value explicitly in a cookie (I know that
> tapestry will implicitly set the session value in a cookie for you to
> synchronize the server state with the client using a session id) How do
> you get tapestry to store some other value in a cookie, and is there a
> way to easily access it? I'm using tap 4.1
> Thanks
> Denis
>
> Jesse Kuhnert wrote:
>> Why don't you just store the unique machine ID in a cookie ?
>>
>> On 5/29/07, Denis McCarthy <dm...@annadaletech.com> wrote:
>>>
>>> Hi,
>>> I've a custom application that runs on a set number of machines. The
>>> application consists of a custom browser (based on xulrunner and eclipse
>>> swt Browser class) and a tapestry application. Each machine on which the
>>> app runs has a unique ID. Currently, when users use the application,
>>> their information is stored in a standard tapestry visit object.
>>> However, I'm not a huge fan of the http session, and, given my
>>> environment, I could do away with it entirely by simply altering each
>>> submitted URL in the custom browser to include the machine id, and keep
>>> any session-based variables in the database.
>>>
>>> This is simple to do via a listener in the Browser. However, I'm not
>>> sure if this is possible on the tapestry side. Basically, each url would
>>> be modifed from http://localhost:8080/app/myPage.sdirect to
>>> http://localhost:8080/app/myPage.sdirect?machineId=4
>>>
>>> or http://localhost:8080/app/myOtherPage.sdirect?sp=1
>>> to http://localhost:8080/app/myOtherPage.sdirect?sp=1&machineId=4
>>>
>>> Does this idea make sense? Is there a way to always get a parameter like
>>> this out of the URL (regardless of whether it's a GET or POST?)
>>> I've been messing around with this idea in my app, but I'm running into
>>> problems like
>>> 'rewind of form myPage/form expected only 0 form elements, but an
>>> additional id was requested by component myPage/null'
>>>
>>> Is this notion I've come up with feasible, or have I been smoking too
>>> much crack again?
>>>
>>> Thanks
>>> Denis
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding a parameter to the url for all pages
Posted by Denis McCarthy <dm...@annadaletech.com>.
That sounds like a good idea. However, I've been unable to find an
explanation as to how to set a value explicitly in a cookie (I know that
tapestry will implicitly set the session value in a cookie for you to
synchronize the server state with the client using a session id) How do
you get tapestry to store some other value in a cookie, and is there a
way to easily access it? I'm using tap 4.1
Thanks
Denis
Jesse Kuhnert wrote:
> Why don't you just store the unique machine ID in a cookie ?
>
> On 5/29/07, Denis McCarthy <dm...@annadaletech.com> wrote:
>>
>> Hi,
>> I've a custom application that runs on a set number of machines. The
>> application consists of a custom browser (based on xulrunner and eclipse
>> swt Browser class) and a tapestry application. Each machine on which the
>> app runs has a unique ID. Currently, when users use the application,
>> their information is stored in a standard tapestry visit object.
>> However, I'm not a huge fan of the http session, and, given my
>> environment, I could do away with it entirely by simply altering each
>> submitted URL in the custom browser to include the machine id, and keep
>> any session-based variables in the database.
>>
>> This is simple to do via a listener in the Browser. However, I'm not
>> sure if this is possible on the tapestry side. Basically, each url would
>> be modifed from http://localhost:8080/app/myPage.sdirect to
>> http://localhost:8080/app/myPage.sdirect?machineId=4
>>
>> or http://localhost:8080/app/myOtherPage.sdirect?sp=1
>> to http://localhost:8080/app/myOtherPage.sdirect?sp=1&machineId=4
>>
>> Does this idea make sense? Is there a way to always get a parameter like
>> this out of the URL (regardless of whether it's a GET or POST?)
>> I've been messing around with this idea in my app, but I'm running into
>> problems like
>> 'rewind of form myPage/form expected only 0 form elements, but an
>> additional id was requested by component myPage/null'
>>
>> Is this notion I've come up with feasible, or have I been smoking too
>> much crack again?
>>
>> Thanks
>> Denis
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Adding a parameter to the url for all pages
Posted by Jesse Kuhnert <jk...@gmail.com>.
Why don't you just store the unique machine ID in a cookie ?
On 5/29/07, Denis McCarthy <dm...@annadaletech.com> wrote:
>
> Hi,
> I've a custom application that runs on a set number of machines. The
> application consists of a custom browser (based on xulrunner and eclipse
> swt Browser class) and a tapestry application. Each machine on which the
> app runs has a unique ID. Currently, when users use the application,
> their information is stored in a standard tapestry visit object.
> However, I'm not a huge fan of the http session, and, given my
> environment, I could do away with it entirely by simply altering each
> submitted URL in the custom browser to include the machine id, and keep
> any session-based variables in the database.
>
> This is simple to do via a listener in the Browser. However, I'm not
> sure if this is possible on the tapestry side. Basically, each url would
> be modifed from http://localhost:8080/app/myPage.sdirect to
> http://localhost:8080/app/myPage.sdirect?machineId=4
>
> or http://localhost:8080/app/myOtherPage.sdirect?sp=1
> to http://localhost:8080/app/myOtherPage.sdirect?sp=1&machineId=4
>
> Does this idea make sense? Is there a way to always get a parameter like
> this out of the URL (regardless of whether it's a GET or POST?)
> I've been messing around with this idea in my app, but I'm running into
> problems like
> 'rewind of form myPage/form expected only 0 form elements, but an
> additional id was requested by component myPage/null'
>
> Is this notion I've come up with feasible, or have I been smoking too
> much crack again?
>
> Thanks
> Denis
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Jesse Kuhnert
Tapestry/Dojo team member/developer
Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
Adding a parameter to the url for all pages
Posted by Denis McCarthy <dm...@annadaletech.com>.
Hi,
I've a custom application that runs on a set number of machines. The
application consists of a custom browser (based on xulrunner and eclipse
swt Browser class) and a tapestry application. Each machine on which the
app runs has a unique ID. Currently, when users use the application,
their information is stored in a standard tapestry visit object.
However, I'm not a huge fan of the http session, and, given my
environment, I could do away with it entirely by simply altering each
submitted URL in the custom browser to include the machine id, and keep
any session-based variables in the database.
This is simple to do via a listener in the Browser. However, I'm not
sure if this is possible on the tapestry side. Basically, each url would
be modifed from http://localhost:8080/app/myPage.sdirect to
http://localhost:8080/app/myPage.sdirect?machineId=4
or http://localhost:8080/app/myOtherPage.sdirect?sp=1
to http://localhost:8080/app/myOtherPage.sdirect?sp=1&machineId=4
Does this idea make sense? Is there a way to always get a parameter like
this out of the URL (regardless of whether it's a GET or POST?)
I've been messing around with this idea in my app, but I'm running into
problems like
'rewind of form myPage/form expected only 0 form elements, but an
additional id was requested by component myPage/null'
Is this notion I've come up with feasible, or have I been smoking too
much crack again?
Thanks
Denis
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org