You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Michael Prescott <mi...@gmail.com> on 2012/06/21 19:43:53 UTC

@Symbol and web context-params

I'm hoping to use tapestry-hibernate, and also flyway to do db migrations,
and I'm having trouble injecting the data source from the servlet container
into each of these.

With tapestry-spring, I was able to have spring read web context params,
and go from there.  But in my tapestry module, @Symbol doesn't appear to
read context params.

Is there an orthodox way to go about this?

I don't want to hard-code the data source name in, say, a
hibernate.cfg.xml, because i need multiple apps running side by side.

Gratefully,

Michael

Re: @Symbol and web context-params

Posted by Michael Prescott <mi...@gmail.com>.
Nevermind. :-)  Turns out that my problem was just that I was trying to use
@Symbol on a module field, instead of on a method parameter.

Michael

On 21 June 2012 13:43, Michael Prescott <mi...@gmail.com>wrote:

> I'm hoping to use tapestry-hibernate, and also flyway to do db migrations,
> and I'm having trouble injecting the data source from the servlet container
> into each of these.
>
> With tapestry-spring, I was able to have spring read web context params,
> and go from there.  But in my tapestry module, @Symbol doesn't appear to
> read context params.
>
> Is there an orthodox way to go about this?
>
> I don't want to hard-code the data source name in, say, a
> hibernate.cfg.xml, because i need multiple apps running side by side.
>
> Gratefully,
>
> Michael
>

Re: @Symbol and web context-params

Posted by Michael Prescott <mi...@gmail.com>.
Yes - sorry I wasn't clear.  Thanks for your help.

On 21 June 2012 18:30, Thiago H de Paula Figueiredo <th...@gmail.com>wrote:

> On Thu, 21 Jun 2012 16:36:38 -0300, Michael Prescott <
> michael.r.prescott@gmail.com> wrote:
>
>  That's crazy talk.
>>
>
> Did it work?
>
>
>> Thanks. :-)
>>
>> On 21 June 2012 15:09, Thiago H de Paula Figueiredo <thiagohp@gmail.com
>> >wrote:
>>
>>  On Thu, 21 Jun 2012 15:11:04 -0300, Michael Prescott <
>>> michael.r.prescott@gmail.com> wrote:
>>>
>>>  MyModule {
>>>>
>>>>  // Doesn't work
>>>>  @Symbol("paramname")
>>>>  private String param;
>>>> }
>>>>
>>>> It works as an annotation on a method parameter, though!
>>>>
>>>>
>>> Have you tried to add @Inject to the field?
>>>
>>>
>>> --
>>> Thiago H. de Paula Figueiredo
>>>
>>> ------------------------------****----------------------------**
>>> --**---------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**a**pache.org<http://apache.org>
>>> <us...@tapestry.apache.org>
>>> >
>>>
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: @Symbol and web context-params

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 21 Jun 2012 16:36:38 -0300, Michael Prescott  
<mi...@gmail.com> wrote:

> That's crazy talk.

Did it work?

>
> Thanks. :-)
>
> On 21 June 2012 15:09, Thiago H de Paula Figueiredo  
> <th...@gmail.com>wrote:
>
>> On Thu, 21 Jun 2012 15:11:04 -0300, Michael Prescott <
>> michael.r.prescott@gmail.com> wrote:
>>
>>> MyModule {
>>>
>>>  // Doesn't work
>>>  @Symbol("paramname")
>>>  private String param;
>>> }
>>>
>>> It works as an annotation on a method parameter, though!
>>>
>>
>> Have you tried to add @Inject to the field?
>>
>>
>> --
>> Thiago H. de Paula Figueiredo
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail:  
>> users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>


-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Symbol and web context-params

Posted by Michael Prescott <mi...@gmail.com>.
That's crazy talk.

Thanks. :-)

On 21 June 2012 15:09, Thiago H de Paula Figueiredo <th...@gmail.com>wrote:

> On Thu, 21 Jun 2012 15:11:04 -0300, Michael Prescott <
> michael.r.prescott@gmail.com> wrote:
>
>> MyModule {
>>
>>  // Doesn't work
>>  @Symbol("paramname")
>>  private String param;
>> }
>>
>> It works as an annotation on a method parameter, though!
>>
>
> Have you tried to add @Inject to the field?
>
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: @Symbol and web context-params

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 21 Jun 2012 15:11:04 -0300, Michael Prescott  
<mi...@gmail.com> wrote:
> MyModule {
>
>   // Doesn't work
>   @Symbol("paramname")
>   private String param;
> }
>
> It works as an annotation on a method parameter, though!

Have you tried to add @Inject to the field?

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Symbol and web context-params

Posted by Michael Prescott <mi...@gmail.com>.
Steve, I need two web-apps running side by side, not two tapestry apps
within the same webapp. :-)  No problems there.

In any case, I figured out why what I was doing wasn't working, I was
trying to do

MyModule {

  // Doesn't work
  @Symbol("paramname")
  private String param;
}

It works as an annotation on a method parameter, though!

Thanks for your help.

On 21 June 2012 14:07, Steve Eynon <st...@alienfactory.co.uk> wrote:

> > because i need multiple apps running side by side.
>
> Err...
>
>
> http://tapestry.apache.org/configuration.html#Configuration-SegregatingApplicationsIntoFolders
> says, "At this time, it is still not possible to run multiple Tapestry
> 5 applications within the same web application."
>
> Other than that there's a ServletContextSymbolProvider which makes
> ServletContext init-parameters accessible as symbols. If that's no
> use, you could write your own SymbolProvider based on the above -
> which is only around 6 lines of code.
>
> Steve.
>
>
> On 22 June 2012 01:43, Michael Prescott <mi...@gmail.com>
> wrote:
> > I'm hoping to use tapestry-hibernate, and also flyway to do db
> migrations,
> > and I'm having trouble injecting the data source from the servlet
> container
> > into each of these.
> >
> > With tapestry-spring, I was able to have spring read web context params,
> > and go from there.  But in my tapestry module, @Symbol doesn't appear to
> > read context params.
> >
> > Is there an orthodox way to go about this?
> >
> > I don't want to hard-code the data source name in, say, a
> > hibernate.cfg.xml, because i need multiple apps running side by side.
> >
> > Gratefully,
> >
> > Michael
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: @Symbol and web context-params

Posted by Steve Eynon <st...@alienfactory.co.uk>.
> because i need multiple apps running side by side.

Err...

http://tapestry.apache.org/configuration.html#Configuration-SegregatingApplicationsIntoFolders
says, "At this time, it is still not possible to run multiple Tapestry
5 applications within the same web application."

Other than that there's a ServletContextSymbolProvider which makes
ServletContext init-parameters accessible as symbols. If that's no
use, you could write your own SymbolProvider based on the above -
which is only around 6 lines of code.

Steve.


On 22 June 2012 01:43, Michael Prescott <mi...@gmail.com> wrote:
> I'm hoping to use tapestry-hibernate, and also flyway to do db migrations,
> and I'm having trouble injecting the data source from the servlet container
> into each of these.
>
> With tapestry-spring, I was able to have spring read web context params,
> and go from there.  But in my tapestry module, @Symbol doesn't appear to
> read context params.
>
> Is there an orthodox way to go about this?
>
> I don't want to hard-code the data source name in, say, a
> hibernate.cfg.xml, because i need multiple apps running side by side.
>
> Gratefully,
>
> Michael

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: @Symbol and web context-params

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 21 Jun 2012 14:43:53 -0300, Michael Prescott  
<mi...@gmail.com> wrote:

> I'm hoping to use tapestry-hibernate, and also flyway to do db  
> migrations,
> and I'm having trouble injecting the data source from the servlet  
> container
> into each of these.
>
> With tapestry-spring, I was able to have spring read web context params,
> and go from there.  But in my tapestry module, @Symbol doesn't appear to
> read context params.
>
> Is there an orthodox way to go about this?
>
> I don't want to hard-code the data source name in, say, a
> hibernate.cfg.xml, because i need multiple apps running side by side.

I'd create a hibernate.cfg.xml with the configurations which are shared by  
all apps. Each one would have a Tapestry-IoC module class that contributes  
a HibernateConfigurer that adds the application-specific configurations.  
Or you could have a singe HibernateConfigurer implementation that picks  
and adds the correct configurations using some logic inside it.

-- 
Thiago H. de Paula Figueiredo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org