RE: Dynamic service binding based on symbol source

2009-07-15 Thread Alfie Kirkpatrick
Hi Massimo, thanks for the reply. Unfortunately neither of these
patterns works for me because they rely on the chained service(s) being
instantiated in the normal way, ie. via bind or build.

Looking at DefaultModuleDefImpl there doesn't seem any reason in
principle why it's too early in the bind() method of a module to late
bind an implementation class based on a symbol. Or alternatively have a
special form of buildX which supports this kind of thing, ie.
allowing the builder to return a service definition rather than a
concrete class via new. Am still looking through the sources to see what
might be possible/simple.

Unless I'm missing something I don't think what I'm after can be done
without a change to Tapestry. Anyone disagree? Do people think this is
this a reasonable feature request?

Regards, Alfie.

-Original Message-
From: Massimo Lusetti [mailto:mluse...@gmail.com] 
Sent: 14 July 2009 13:47
To: Tapestry users
Subject: Re: Dynamic service binding based on symbol source

On Tue, Jul 14, 2009 at 2:43 PM, Alfie
Kirkpatrickalfie.kirkpatr...@ioko.com wrote:


 I would like to instantiate a different service implementation
depending
 on property file configuration, eg. a stub for testing and a real
 service for deployments. I'd like to put the FQN in my property file
 which is then wrapped in a SymbolProvider.

I highly suggest you to build a chain of command or a strategy pattern
depending on service type and let the IoC do the work for you.

-- 
Massimo
http://meridio.blogspot.com


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



Re: T5 Page field persistance and multithread problems

2009-07-15 Thread Otho
2009/7/14 Howard Lewis Ship hls...@gmail.com

 I am loathe to have the framework manage this automatically because it
 causes its own problems.

 For example, it is reasonable to process multiple Ajax requests in
 parallel if they only read data.


Exactly. Concurrent write access to data should be handled where it belongs
and that is definitely not the weblayer as such and I wouldn't even want the
webframework interfere with it. Doing things in a http-layer which naturally
belong to a persistence/transaction/business layer would be a quite dirty
hack in my opinion. There was a lot of research spent on making concurrent
writes threadsafe in databases. Transactions, optimistic and pessimistic
locking and isolation levels where developed for exactly that case. So there
is really no need to make a UI-Framework behave like a database with
ISOLATION_LEVEL_SERIALIZED.


Re: T5 Page field persistance and multithread problems

2009-07-15 Thread P . Stavrinides
 I suppose the framework could keep a Mutex keyed on session so that
 multiple page or event requests could be serialized on the server.
Actually I think it is a great idea, and a pretty clean solution... thats the 
way Spring resolves it, its certainly not a hack. Since you create a session 
once it should not be such a big deal at all: 
http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/web/util/HttpSessionMutexListener.html

 I am loathe to have the framework manage this automatically because it
 causes its own problems.
 For example, it is reasonable to process multiple Ajax requests in
 parallel if they only read data.
Other than a flag that the framework will have to manage, I really don't see it 
being such a big deal... maybe I am naive and missing something, but do you 
think it is better for Tapestry users to manage this? having Atomic references 
and Synchronized blocks all over our code, it is easy to miss something when 
dealing with thread safety, and what of performance?

Peter



- Original Message -
From: Howard Lewis Ship hls...@gmail.com
To: Tapestry users users@tapestry.apache.org
Sent: Tuesday, 14 July, 2009 22:08:04 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: T5 Page field persistance and multithread problems

On Tue, Jul 14, 2009 at 3:10 AM, kristjankeltkristjank...@hotmail.com wrote:

 Hi,


 Peter Stavrinides wrote:

 Kristjan, as Nille has explained to you that is simply not the case, what
 is happening is multiple requests are being generated when the submit
 button is clicked more than once, each of these Requests spawns a new
 thread, and triggers the events that modify the affected values
 accordingly.

I suppose the framework could keep a Mutex keyed on session so that
multiple page or event requests could be serialized on the server.

I am loathe to have the framework manage this automatically because it
causes its own problems.

For example, it is reasonable to process multiple Ajax requests in
parallel if they only read data.



 Persisted objects scoped to 'session' are essentially just objects placed
 in the HttpSession, which is perfectly thread safe to do, so what thread
 problems are you referring to?


 Multiple threads (initiated by multiple requests) accessing the same data is
 definitelly thread issue - it does not go away when you say that this is
 multiple request issue instead and everyone else is having the same problem.

 Of course this problem is caused by multiple requests that are allowed to
 run in paralel when they should wait in the queue instead but stating this
 does not make the code thread safe.

 And of course this is really simple example that does not involve any data
 sent by the client - that would introduce more problems.


 Peter Stavrinides wrote:

every page instance would have it's own *copy* of the data
 Although a page object itself is pooled, and a clean copy is served when
 its requested. That does not mean that it contains copies of state objects
 / data, if you peek inside the users HttpSession you will find only a
 single SSO (or persistent field for that matter) of any session scoped
 objects. So far as I understand there are no 'copies' of these objects or
 any other session data floating around, any persistent object in your page
 would simply be a 'reference' to those in the HttpSession.


 Let say that I have new request. What happens now is that page is taken from
 the pool and is initiated.

 During that variable is read from the session and reference of the page
 object private variable is set to that variable.

 Let assume that there was object Integer(1) in the session. Now both,
 session and page object private variable are referencing to the same object.
 Let's name this variable a counter.

 Let say that in the page event method (like in my example) I want to
 increment the counter. For that I read the object Integer(1) int (primitive)
 value (or this is done by compiler using autoboxing), add one to it and
 create new object Integer(2) and set page private variable reference to new
 object (Object(2)) (this happens because Integer is immutable and I can not
 change it's innerstate).

 From this moment, page and session will have different copies (and it will
 stay so until session reference is overridden at the end of page
 processing).

 When different thread is reading from the session then it will still see the
 reference to Integer(1) and it's corrensponding page object private variable
 reference is set to Integer(1).

 Now this example involved only one variable and this was immutable (you can
 not change it's innerstate). Having multiple variables or immutable
 variables (like entity beans) will introduce more problems.

 Regards,
 Kristjan Kelt
 --
 View this message in context: 
 http://www.nabble.com/T5-Page-field-persistance-and-multithread-problems-tp24468298p24476799.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.


 

Re: Testify + Testng

2009-07-15 Thread Christian Edward Gruber
It can be useful if it's injecting stateful services.  If it injects  
them BeforeClass, then you can have state from one test affecting  
others.  Not all services are singleton-scoped.


Christian.

On 2009-07-15, at 01:32 , Paul Field wrote:


Hi Christian,


It might make sense to have a hit annotation for Testify that
follows @Inject which allows the injection to be beforeMethod or
beforeClass.  Unfortunately, we can't re-use the jUnit ones because
(if I recall correctly) they are not suitable for Field annotation,
just method.  But something similar would be good.  Maybe
@InjectBeforeTest and @InjectBeforeSuite could do it.


I'm not seeing why that would be useful. I would expect the @Inject
annotation to be injecting the same object whenever it is processed  
- it's
just a question of when that injection takes place for each instance  
of

the test class (e.g. at the start of the test class/before each test
method).

JUnit (3 and I assume 4) makes a new instance of the test class to run
each test method, so it makes sense to process @Inject for every test
method in order to populate that new instance.

TestNG makes one instance of the test class for all the test methods  
in

it, so it makes sense to process @Inject just once using TestNG's
@BeforeClass.

As usual, I may have missed something so feel free to educate me :-)

- Paul


---

This e-mail may contain confidential and/or privileged information.  
If you are not the intended recipient (or have received this e-mail  
in error) please notify the sender immediately and delete this e- 
mail. Any unauthorized copying, disclosure or distribution of the  
material in this e-mail is strictly forbidden.


Please refer to http://www.db.com/en/content/eu_disclosures.htm for  
additional EU corporate and regulatory disclosures.


Christian Edward Gruber
e-mail: christianedwardgru...@gmail.com
weblog: http://www.geekinasuit.com/


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



Re: Testify + Testng

2009-07-15 Thread Juan E. Maya
Great Christian !
I  was about to post an issue with this. It's working perfectly now!

Thanks a lot

On Wed, Jul 15, 2009 at 7:25 AM, Paul Fieldpaul.fi...@db.com wrote:
  I have been playing with Testng and the Testify library but i am
  having a small issue. It seems that the injection of services occurs
  after the @BeforeSuite.
 
 However, it does seem reasonable to process the @Inject annotations at
 the
 start of the TestNG suite, so the latest Testify snapshot does that...

 I'm not very
 clear about how all the TestNG features interact and exactly what
 happens
 with instances of test classes so I don't know if there are any
 unpleasant
 side effects of this change - so please let me know!

 I've done some more testing and discovered that @BeforeSuite doesn't work
 with inheritance, so I've changed Testify to process @Inject annotations
 @BeforeClass. It is relatively simple to get @Inject processed yourself,
 you just call tester.injectInto(this) in your @BeforeSuite method. I've
 updated the documentation to give an example:
 http://tapestry.formos.com/nightly/tapestry-testify/#TestNG

 - Paul




 ---

 This e-mail may contain confidential and/or privileged information. If you 
 are not the intended recipient (or have received this e-mail in error) please 
 notify the sender immediately and delete this e-mail. Any unauthorized 
 copying, disclosure or distribution of the material in this e-mail is 
 strictly forbidden.

 Please refer to http://www.db.com/en/content/eu_disclosures.htm for 
 additional EU corporate and regulatory disclosures.

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



Re: T5 Page field persistance and multithread problems

2009-07-15 Thread Kristian Marinkovic
my2cents

i also think this is a problem of the application not 
the web framework. though it could be handy to have 
some optional services in place to use.

if you want to allow multiple web browser / tabs 
per page that manipulates http session data 
(=same session id) you should consider 
conversations. (see trails for an implementation)

i'm preventing the multiple click (submit) problem
by generating a new requestid that is saved to the 
cookie on each request. on each subsequent request 
the requestid from the cookie is read and validated. 
if it is not valid you'll be redirected to an error page. 
This is easily implemented with a Dispatcher and 
the Cookies services (provided by Tapestry).

i dont have a lot of data in my session anyways. most 
of the the time i only have an entity id. on a submit a kind
of command object / dto is created and send to my back
end modules through a facade where all the transaction
handling,locking, ... is done. 

/my2cents

g,
kris




p.stavrini...@albourne.com 
15.07.2009 09:15
Bitte antworten an
Tapestry users users@tapestry.apache.org


An
Tapestry users users@tapestry.apache.org
Kopie

Thema
Re: T5 Page field persistance and multithread problems







 I suppose the framework could keep a Mutex keyed on session so that
 multiple page or event requests could be serialized on the server.
Actually I think it is a great idea, and a pretty clean solution... thats 
the way Spring resolves it, its certainly not a hack. Since you create a 
session once it should not be such a big deal at all: 
http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/web/util/HttpSessionMutexListener.html


 I am loathe to have the framework manage this automatically because it
 causes its own problems.
 For example, it is reasonable to process multiple Ajax requests in
 parallel if they only read data.
Other than a flag that the framework will have to manage, I really don't 
see it being such a big deal... maybe I am naive and missing something, 
but do you think it is better for Tapestry users to manage this? having 
Atomic references and Synchronized blocks all over our code, it is easy to 
miss something when dealing with thread safety, and what of performance?

Peter



- Original Message -
From: Howard Lewis Ship hls...@gmail.com
To: Tapestry users users@tapestry.apache.org
Sent: Tuesday, 14 July, 2009 22:08:04 GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul
Subject: Re: T5 Page field persistance and multithread problems

On Tue, Jul 14, 2009 at 3:10 AM, kristjankeltkristjank...@hotmail.com 
wrote:

 Hi,


 Peter Stavrinides wrote:

 Kristjan, as Nille has explained to you that is simply not the case, 
what
 is happening is multiple requests are being generated when the submit
 button is clicked more than once, each of these Requests spawns a new
 thread, and triggers the events that modify the affected values
 accordingly.

I suppose the framework could keep a Mutex keyed on session so that
multiple page or event requests could be serialized on the server.

I am loathe to have the framework manage this automatically because it
causes its own problems.

For example, it is reasonable to process multiple Ajax requests in
parallel if they only read data.



 Persisted objects scoped to 'session' are essentially just objects 
placed
 in the HttpSession, which is perfectly thread safe to do, so what 
thread
 problems are you referring to?


 Multiple threads (initiated by multiple requests) accessing the same 
data is
 definitelly thread issue - it does not go away when you say that this is
 multiple request issue instead and everyone else is having the same 
problem.

 Of course this problem is caused by multiple requests that are allowed 
to
 run in paralel when they should wait in the queue instead but stating 
this
 does not make the code thread safe.

 And of course this is really simple example that does not involve any 
data
 sent by the client - that would introduce more problems.


 Peter Stavrinides wrote:

every page instance would have it's own *copy* of the data
 Although a page object itself is pooled, and a clean copy is served 
when
 its requested. That does not mean that it contains copies of state 
objects
 / data, if you peek inside the users HttpSession you will find only a
 single SSO (or persistent field for that matter) of any session scoped
 objects. So far as I understand there are no 'copies' of these objects 
or
 any other session data floating around, any persistent object in your 
page
 would simply be a 'reference' to those in the HttpSession.


 Let say that I have new request. What happens now is that page is taken 
from
 the pool and is initiated.

 During that variable is read from the session and reference of the page
 object private variable is set to that variable.

 Let assume that there was object Integer(1) in the session. Now both,
 session and page object private variable are referencing to the same 
object.
 Let's 

Re: Problems deploying tapestry App in Tomcat 5.x/6.x

2009-07-15 Thread P . Stavrinides
For anyone that uses Chenillekit, you should probably include an exclusion to 
prevent the 2 conflicting versions of javassist appearing on your classpath:

dependency
groupIdorg.chenillekit/groupId
artifactIdchenillekit-tapestry/artifactId
version1.0.0/version
exclusions
exclusion
groupIdjboss/groupId
artifactIdjavassist/artifactId
/exclusion
/exclusions
/dependency

Peter
- Original Message -
From: jose luis sanchez joseluis.sanc...@m-centric.com
To: Tapestry users users@tapestry.apache.org
Sent: Tuesday, 14 July, 2009 10:51:29 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: Problems deploying tapestry App in Tomcat 5.x/6.x

Yes, that was the problem !!
Thanks ..  now, i have excluded the javassist that chenillekit depends 
on .. and old one, and everything looks and works ok :-)
 Maybe you have dublicate javassist jar in your classpath.

   


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


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



RE: Dynamic service binding based on symbol source

2009-07-15 Thread Alfie Kirkpatrick
Further to my last mail I think it could be possible to have a module
method convention like:

public static com.acme.service.MyService bindByConfiguration() {
}

This would look for a symbol com.acme.service.MyService based on the
return type and use a variant on the ConstructorServiceCreator to
instantiate the service.

Or perhaps a ServiceBinder.bind(MyService.class,
the.symbol.name.for.impl.class) method would work. It seems a bit
tidier.

Either should be possible since ServiceBuilderMethodInvoker is able to
resolve symbols as parameters via
InternalUtils.calculateParametersForMethod. It's just that the current
code/encapsulation level isn't really geared for what I want to do -- I
need a bit of both ConstructorServiceCreator and
ServiceBuilderMethodInvoker. But I'll keep digging.

Regards, Alfie.

-Original Message-
From: Massimo Lusetti [mailto:mluse...@gmail.com] 
Sent: 14 July 2009 13:47
To: Tapestry users
Subject: Re: Dynamic service binding based on symbol source

On Tue, Jul 14, 2009 at 2:43 PM, Alfie
Kirkpatrickalfie.kirkpatr...@ioko.com wrote:


 I would like to instantiate a different service implementation
depending
 on property file configuration, eg. a stub for testing and a real
 service for deployments. I'd like to put the FQN in my property file
 which is then wrapped in a SymbolProvider.

I highly suggest you to build a chain of command or a strategy pattern
depending on service type and let the IoC do the work for you.

-- 
Massimo
http://meridio.blogspot.com


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



Re: T5 Page field persistance and multithread problems

2009-07-15 Thread Otho
2009/7/15 p.stavrini...@albourne.com

 Other than a flag that the framework will have to manage, I really don't
 see it being such a big deal... maybe I am naive and missing something, but
 do you think it is better for Tapestry users to manage this? having Atomic
 references and Synchronized blocks all over our code, it is easy to miss
 something when dealing with thread safety, and what of performance?

 Peter


For what would you need that (atomic refs and synchronized blocks)?

The above example is completely artificial. It doesn't make any sense (in a
webapp) to write data which you don't persist in some way.

When you start using the session with writable objects there is very
probably a flaw in your design.

Take a user object for example. Let's assume you have a manger user with
editing rights which shows some malicious behaviour. An admin jumps in and
disables the user in the database to prevent future damage while the manager
is logged in. Now this manager has his user object alongside with his access
rights in his own session for convenient access and your code relies on
that session... Until his session expires he can still do anything the admin
wanted to prevent.

To overcome this reliably there is no way around reading the user object
from the datastore on every request. This sounds worse than it is, since all
modern datastores have caches, and it is in any circumstance better than
throwing the user around in the session. @Persist(session) and
@SessionState really only make sense for read-only data or data which
doesn't need to be guarded against concurrent write-access like temporary
state.

For example two users works on an invoice in a billing system and alter
different data. When the first one submits it is committed to database. When
the second one commits the database throws an exception, when optimistic
locking is on. But it would be a good idea to have the second users
temporary data @Persist ed since now you can catch the exception and show
the differences between the committed version and his version for
information and let him think about and alter his input before he commits
his final version.

It's not only in MMOs where you should never ever trust the client (and thus
his session).


Re: T5 Page field persistance and multithread problems

2009-07-15 Thread P . Stavrinides
I don't agree with your implication that a user should only be reading from the 
session, one example I am using is a wizard that uses an SSO over a few pages, 
once all steps are completed only then is the data written to the database and 
the SSO is discarded, using an SSO for this is natural choice imho, but even 
that is beside the point Otto, as I have mentioned already I don't think its a 
big deal since it is unlikely (although not impossible) that you will have 
concurrency problems  accessing the HttpSession, the original issue in question 
is the multiple threads modifying persistent data, a 'get - modify - set' 
pattern, which then has the potential to be wrong when re-reading the value. 

Peter


- Original Message -
From: Otho taa...@googlemail.com
To: Tapestry users users@tapestry.apache.org
Sent: Wednesday, 15 July, 2009 11:43:23 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: T5 Page field persistance and multithread problems

2009/7/15 p.stavrini...@albourne.com

 Other than a flag that the framework will have to manage, I really don't
 see it being such a big deal... maybe I am naive and missing something, but
 do you think it is better for Tapestry users to manage this? having Atomic
 references and Synchronized blocks all over our code, it is easy to miss
 something when dealing with thread safety, and what of performance?

 Peter


For what would you need that (atomic refs and synchronized blocks)?

The above example is completely artificial. It doesn't make any sense (in a
webapp) to write data which you don't persist in some way.

When you start using the session with writable objects there is very
probably a flaw in your design.

Take a user object for example. Let's assume you have a manger user with
editing rights which shows some malicious behaviour. An admin jumps in and
disables the user in the database to prevent future damage while the manager
is logged in. Now this manager has his user object alongside with his access
rights in his own session for convenient access and your code relies on
that session... Until his session expires he can still do anything the admin
wanted to prevent.

To overcome this reliably there is no way around reading the user object
from the datastore on every request. This sounds worse than it is, since all
modern datastores have caches, and it is in any circumstance better than
throwing the user around in the session. @Persist(session) and
@SessionState really only make sense for read-only data or data which
doesn't need to be guarded against concurrent write-access like temporary
state.

For example two users works on an invoice in a billing system and alter
different data. When the first one submits it is committed to database. When
the second one commits the database throws an exception, when optimistic
locking is on. But it would be a good idea to have the second users
temporary data @Persist ed since now you can catch the exception and show
the differences between the committed version and his version for
information and let him think about and alter his input before he commits
his final version.

It's not only in MMOs where you should never ever trust the client (and thus
his session).

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



RE: t5: moving to 5.1.0.5 and can't find @Inject

2009-07-15 Thread Newham, Cameron
I actually have M2 already installed. I hadn't looked at the dependency
feature in the editor - thanks Thiago.

I now know tapestry-ioc-5.0.18.jar is being used by Chenillekit.

However, I am still unable to locate:

org.apache.tapestry5.ioc.annotations.Inject

It just doesn't exist - anywhere!

Could someone please tell me in which JAR file it is supposed to be?  It
isn't in tapestry-ioc-5.0.18.jar (which is the only version of
tapestry-ioc-xxx that Maven is downloading) as far as I can see.

I don't understand why moving to 5.1.0.5 has caused this problem nor do
I understand why @Inject has disappeared as it obviously existed before;
I've been quite happily using that annotation throughout my project!

If it would help to show my project POM I can post it...

Thanks.


-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] 
Sent: 14 July 2009 14:58
To: Tapestry users
Subject: Re: t5: moving to 5.1.0.4 and can't find @Inject

Em Tue, 14 Jul 2009 10:19:49 -0300, Newham, Cameron
cameron.new...@bl.uk  
escreveu:

 If I don't include:

 dependency
   groupIdorg.apache.tapestry/groupId
   artifactIdtapestry-ioc/artifactId
   version${tapestry-release-version}/version
   /dependency

 In the POM I get 5.1.0.5 for all jars *except* tapestry-ioc which
always
 downloads the 5.0.18 version  /:-(

This looks like some other package you're using depends on Tapestry-IoC

5.0.18. If you're using Eclipse, install the Sonatype's m2eclipse
plugin.  
In its Maven pom.xml editor, it has a very nice feature that shows what

dependencies are being included and by which dependency (transitive  
dependency).

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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

**
 
Experience the British Library online at www.bl.uk
 
The British Library's new interactive Annual Report and Accounts 2007/08 : 
www.bl.uk/knowledge
 
Help the British Library conserve the world's knowledge. Adopt a Book. 
www.bl.uk/adoptabook
 
The Library's St Pancras site is WiFi - enabled
 
*
 
The information contained in this e-mail is confidential and may be legally 
privileged. It is intended for the addressee(s) only. If you are not the 
intended recipient, please delete this e-mail and notify the postmas...@bl.uk : 
The contents of this e-mail must not be disclosed or copied without the 
sender's consent. 
 
The statements and opinions expressed in this message are those of the author 
and do not necessarily reflect those of the British Library. The British 
Library does not take any responsibility for the views of the author. 
 
*

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



RE: Dynamic service binding based on symbol source

2009-07-15 Thread Kristian Marinkovic
hi alfie,

i don't know if i'm missing something but you could
solve it this way:

public Service buildService(@Inject @Sysmbol(whatever) Long numeric, 
@InjectService(VariantA) Service serviceA, @InjectService(VariantB) 
Service serviceB)
{
switch(numeric)
   {
case 2: return serviceA;
case 42: return serviceB;
default:
throw new Exception();
}
}

if you want to use the Service without qualifier you 
could define another inteface for the variants

g,
kris




Alfie Kirkpatrick alfie.kirkpatr...@ioko.com 
15.07.2009 10:42
Bitte antworten an
Tapestry users users@tapestry.apache.org


An
Massimo Lusetti mluse...@gmail.com, Tapestry users 
users@tapestry.apache.org
Kopie

Thema
RE: Dynamic service binding based on symbol source







Further to my last mail I think it could be possible to have a module
method convention like:

 public static com.acme.service.MyService 
bindByConfiguration() {
 }

This would look for a symbol com.acme.service.MyService based on the
return type and use a variant on the ConstructorServiceCreator to
instantiate the service.

Or perhaps a ServiceBinder.bind(MyService.class,
the.symbol.name.for.impl.class) method would work. It seems a bit
tidier.

Either should be possible since ServiceBuilderMethodInvoker is able to
resolve symbols as parameters via
InternalUtils.calculateParametersForMethod. It's just that the current
code/encapsulation level isn't really geared for what I want to do -- I
need a bit of both ConstructorServiceCreator and
ServiceBuilderMethodInvoker. But I'll keep digging.

Regards, Alfie.

-Original Message-
From: Massimo Lusetti [mailto:mluse...@gmail.com] 
Sent: 14 July 2009 13:47
To: Tapestry users
Subject: Re: Dynamic service binding based on symbol source

On Tue, Jul 14, 2009 at 2:43 PM, Alfie
Kirkpatrickalfie.kirkpatr...@ioko.com wrote:


 I would like to instantiate a different service implementation
depending
 on property file configuration, eg. a stub for testing and a real
 service for deployments. I'd like to put the FQN in my property file
 which is then wrapped in a SymbolProvider.

I highly suggest you to build a chain of command or a strategy pattern
depending on service type and let the IoC do the work for you.

-- 
Massimo
http://meridio.blogspot.com


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




RE: t5: moving to 5.1.0.5 and can't find @Inject

2009-07-15 Thread Kristian Marinkovic
@Inject is located in tapestry5-annotations-5.1.0.5.jar

steps i have in mind

1) have you run mvn eclipse:eclipse... it will add any maven 
dependency as external library. remove all entries except
the JRE entry and the Maven Dependencies entry.

2) deactivate the maven offline mode and do a dependency 
update 

g,
kris




Newham, Cameron cameron.new...@bl.uk 
15.07.2009 11:56
Bitte antworten an
Tapestry users users@tapestry.apache.org


An
Tapestry users users@tapestry.apache.org
Kopie

Thema
RE: t5: moving to 5.1.0.5 and can't find @Inject







I actually have M2 already installed. I hadn't looked at the dependency
feature in the editor - thanks Thiago.

I now know tapestry-ioc-5.0.18.jar is being used by Chenillekit.

However, I am still unable to locate:

org.apache.tapestry5.ioc.annotations.Inject

It just doesn't exist - anywhere!

Could someone please tell me in which JAR file it is supposed to be?  It
isn't in tapestry-ioc-5.0.18.jar (which is the only version of
tapestry-ioc-xxx that Maven is downloading) as far as I can see.

I don't understand why moving to 5.1.0.5 has caused this problem nor do
I understand why @Inject has disappeared as it obviously existed before;
I've been quite happily using that annotation throughout my project!

If it would help to show my project POM I can post it...

Thanks.


-Original Message-
From: Thiago H. de Paula Figueiredo [mailto:thiag...@gmail.com] 
Sent: 14 July 2009 14:58
To: Tapestry users
Subject: Re: t5: moving to 5.1.0.4 and can't find @Inject

Em Tue, 14 Jul 2009 10:19:49 -0300, Newham, Cameron
cameron.new...@bl.uk 
escreveu:

 If I don't include:

 dependency
groupIdorg.apache.tapestry/groupId
artifactIdtapestry-ioc/artifactId
 version${tapestry-release-version}/version
/dependency

 In the POM I get 5.1.0.5 for all jars *except* tapestry-ioc which
always
 downloads the 5.0.18 version  /:-(

This looks like some other package you're using depends on Tapestry-IoC

5.0.18. If you're using Eclipse, install the Sonatype's m2eclipse
plugin. 
In its Maven pom.xml editor, it has a very nice feature that shows what

dependencies are being included and by which dependency (transitive 
dependency).

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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

**
 
Experience the British Library online at www.bl.uk
 
The British Library's new interactive Annual Report and Accounts 2007/08 : 
www.bl.uk/knowledge
 
Help the British Library conserve the world's knowledge. Adopt a Book. 
www.bl.uk/adoptabook
 
The Library's St Pancras site is WiFi - enabled
 
*
 
The information contained in this e-mail is confidential and may be 
legally privileged. It is intended for the addressee(s) only. If you are 
not the intended recipient, please delete this e-mail and notify the 
postmas...@bl.uk : The contents of this e-mail must not be disclosed or 
copied without the sender's consent. 
 
The statements and opinions expressed in this message are those of the 
author and do not necessarily reflect those of the British Library. The 
British Library does not take any responsibility for the views of the 
author. 
 
*

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




Re: Dynamic service binding based on symbol source

2009-07-15 Thread Thiago H. de Paula Figueiredo
Why wouldn't a buildXXX() method injecting the symbol as a parameter and  
some ifs or switch statements work in your scenario?


--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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



Re: Dynamic service binding based on symbol source

2009-07-15 Thread Kristian Marinkovic
hi Alfie,

i think i understand your problem

in such situations i define a service with a dummy implementation. 
now another module can override the service with a correct implementation.
its also useful to break up cyclic dependencies.

lets say if have a security module that provides a SubjectService. because
the user data is managed by another module that itself depends on the 
security module i cannot have a SubjectService implementation within the
security module that loads the user data (using the user module services). 

Instead i have a dummy implementation that throws an exception. only if 
the 
user module is deployed it will override this dummy implementation with a 
proper 
one. (see ServiceOverride for more details)

in other circumstances i have a chain with a defined interface any other
module can contribute to. now when i build the services (builder method)
i delegate it to the chain and it will return the appropriate 
implementation.
so a chain element can decide to return a specific implementation if it 
needs to and stop the chain.

i hope this helps

g,
kris



Thiago H. de Paula Figueiredo thiag...@gmail.com 
15.07.2009 14:18
Bitte antworten an
Tapestry users users@tapestry.apache.org


An
Tapestry users users@tapestry.apache.org
Kopie

Thema
Re: Dynamic service binding based on symbol source







Why wouldn't a buildXXX() method injecting the symbol as a parameter and 
some ifs or switch statements work in your scenario?

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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




Re: How do you display a HashMapString, ArrayListobject in a .tml table

2009-07-15 Thread cajmrn

Hello Igor, 

Thank you for the reply, What I've implemented so far is I've converted the
hashmap keys and values to their respective collection types. but when I
pass either one of them to the grid component it displays the number of
objects passed but none of the information is passed. below is the code that
i have written for the display page.

So say for example i wanted to display just the keys i would pass the
issueKeys collection to the grid component correct? but it just displays as
aforementioned, an empty grid header with a false value in each row.
Side note:
this gird is being populated based on set of selections made on a grid that
was displayed on a previous page. I've debugged the information flow and i
can see the the HashMap is passed to this page and I see that the enclosed
ArrayList has information as well, its just Im not sure if perhaps the
information is getting lost at some point during the display of this grid?
Or maybe the accessor object that the component uses? Honestly I'm at a loss
as to what is going on...


public class Contact
{
@ApplicationState
private jiraDataSource jDO;
private HashMap String, ArrayListIssue issuesList;
private CollectionArrayListIssue issuesSet;
private CollectionString issueKeys;
private String issueKey;

private Issue issue;

void onActivate()
{
issuesList =jDO.getAllIssuesLists(); 
}

public void setIssuesList(HashMap String, ArrayListIssue issuesList)
{
this.issuesList = issuesList;
}

public HashMap String, ArrayListIssue getIssuesList()
{
return issuesList;
}

public Collection String getIssueKeys()
{
issueKeys = issuesList.keySet();
return issueKeys;
}

public CollectionArrayListIssue getIssuesSet()
{
issuesSet = issuesList.values();
return issuesSet;
}

public String getIssueKey()
{
return issueKey;
}

public Issue getIssue()
{
return issue;
}

public void setIssue(Issue i)
{
this.issue = i;
}
}

this is the page class its coming from:

public class About
{
@ApplicationState
private jiraDataSource jiraDO;
private Filter filter;

@InjectPage
private Contact contact;

public List Filter getAllFilters()
{
return jiraDO.getAllFilters();
}

public Filter getFilter()
{
return filter;
}

public void setFilter(Filter f)
{
this.filter = f;
}

@OnEvent(value=checkbox)
void CheckboxClick()
{
System.out.println(a Checkbox was clicked);
}

@OnEvent(value=submit)
Object tromSubmit()
{
System.out.println(submission made);
HashMap String, ArrayListIssue issuesList =
jiraDO.getAllIssuesLists();
contact.setIssuesList(issuesList);
return contact;
}

}


Igor Drobiazko wrote:
 
 Just convert your Map into a GridDataSource which you pass to the
 component.
 
 Take a look at Tapestry's internal implementation of GridDataSource which
 is
 constructed from a collection.
 
 http://tapestry.formos.com/nightly/tapestry5/apidocs/src-html/org/apache/tapestry5/internal/grid/CollectionGridDataSource.html#line.29
 
 You can also provide a type coercion from a Map to GridDataSource or to
 Collection. Tapestry will do the coercion for you.
 
 
 On Wed, Jul 15, 2009 at 4:35 AM, cajmrn caj...@gmail.com wrote:
 

 Hello all,

 I am once again stuck and unsure as to how to implement the following. I
 have a HashMap that contains a String id for the Key and an ArrayList as
 the
 value. What I need to do is to display in a table or grid each arrayList
 as
 it corresponds to a Key.

 How would you go about iterating first through the the id and implement
 it
 as a table header for example, then iterate through its corresponding
 ArrayList? Basically nesting the loops... Sort or like generating a table
 for each entry in the HashMap. Or if it could be implemented in one table
 that should be fine as well.

 Any help would be greatly appreciated.
 Thanks,
 Carlo


 --
 View this message in context:
 http://www.nabble.com/How-do-you-display-a-HashMap%3CString%2C-ArrayList%3Cobject%3E%3E-in-a-.tml-table-tp24490975p24490975.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.


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

T5 Asset URLs

2009-07-15 Thread John Frege
Hi,
For a while now, I've been happily including images in my pages like so:

img src=${context:images/blah.jpg}

This has worked quite well, but when I view the image in my browser, I'm
taken to /[project name]/assets/ctx/1.0-SNAPSHOT/images/blah.jpg.  I've read
that this is to aid the browser in aggressive caching, but is there anyway I
can strip the /assets/ctx/[project version] bit out of the URLs regardless?

Thanks,
John


Re: How to inform a user that a form is submitted?

2009-07-15 Thread Sergey Didenko
What about writing the number of iteration 0 forms submitted, 1
form submitted, 2 forms submitted and so on.

You can also show the latest submit was at 15:56 message.

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



setting up maven in eclipse

2009-07-15 Thread John Frege
Hi all,
Another question:

I began my tapestry project by following these instructions:
http://tapestry.apache.org/tapestry5/quickstart/ .  Then after running mvn
package, I imported the .war file into eclipse and have been working with
that project ever since.  (I'm not entirely sure why I did it this way.  I
think I was more or less following the instructions from the Kolesnikov
book).  They key result of this is that my pom.xml file is located at
WebContent/META-INF/maven/[project group]/[project name]/pom.xml.

Now I'm trying to get Hibernate working, and it seems like the easiest way
to do this is by adding dependencies to the pom.xml file and then getting
the Maven Eclipse plugin to magically pull down all of the new .jar files.
 Unfortunately it doesn't seem to be working that way.  The plugin doesn't
recognize that my project even has a pom.xml file, and it forces me add a
new one (located at the project root by default) to get the .jars.

So before I proceed further and muck things up even more, does anyone have
any advice on how to get the maven eclipse plugin to recognize that my
project is actually a maven project?

Thanks for the help,
John


How should missing page context be handled?

2009-07-15 Thread Pete Poulos
lets say I have a view product page which expects the product id in
its context.  The URL for this might look like
http://app-root/product/view/12345;.

What is the best way to detect if the user modifies their URL to
http://app-root/product/view; without the context?

The only way I've found is to do something like the following:

public class ViewProduct {

   @Property
   private Product product;

   Object onActivate() {
  if( product == null ) {
 return RedirectPage.class;
  }
  return null;
   }

   void onActivate( Product product ) {
  this.product = product;
   }

}

I found that only onActivate() gets called when the context is
missing, but that both of them are called if the context is present.
The order of exection is as follows:

onActivate(Product)
onActivate()

This leads me into a second question:  Is this the way it is supposed
to behave (it seems wierd to me), and if so why is this the preferred
behavior?

Also, returning to my original question, is this the best way to
handle pages without context?  It seems like there should be a better
way.

Thanks in advance,
pete.pou...@gmail.com

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



Re: Log remote IP address with MDC class?

2009-07-15 Thread DH
Hi,

Have a try with

public RequestFilter buildRequestLoggingFilter(RequestGlobals requestGlobals){
}
, requestGlobals has the HttpServletRequest.

DH
http://www.gaonline.com.cn


- Original Message - 
From: learningtapestry satish...@yahoo.com
To: users@tapestry.apache.org
Sent: Thursday, July 16, 2009 9:33 AM
Subject: Log remote IP address with MDC class?


 
 Is there any way to log the remote IP address using the log4j MDC. If I
 contribute to RequestHandler inside my AppModule, I have a way of getting a
 hold of the org.apache.tapestry5.services.Request, but from this Request,
 there isn't no way of getting the IP address of the remote machine.
 
 I don't want to add this my pages/components for various reasons.
 
 
 public RequestFilter buildRequestLoggingFilter(){
return new RequestFilter(){
  public boolean service(Request request, Response response,
 RequestHandler handler) throws IOException {
  MDC.put(remoteIP,  );
  return handler.service(request, response);
  }
};
}
 
 
 
 
 -- 
 View this message in context: 
 http://www.nabble.com/Log-remote-IP-address-with-MDC-class--tp24508725p24508725.html
 Sent from the Tapestry - User mailing list archive at Nabble.com.
 
 
 -
 To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org