You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Tom van Dijk <to...@tvandijk.nl> on 2011/02/11 11:45:13 UTC

Fwd: Re: Noticed another stackoverflow question on Tapestry 5, go vote

Hey,

I see this message on the user list. A few months ago, when we were 
still developing 5.2, I had been busy with this topic. I have a solution 
that is satisfying to me, but it involved modifications to the IoC. 
Since then I've had little time to work on that particular project, but 
I have occasionally updated my branch with the trunk.

It would be great if some of the more involved members of the community 
could take it up and do something with it. At least then it could find 
its way into usefulness.

I still have my version on 
http://hetdiana.dyndns.org/gitweb/tapestry5.git use the branch "multiconf"

In short, what I did was extend the IoC with the @ConfigurationGroup 
annotation. You can contribute markers to the configuration groups. For 
every marker, a service will be created. So if you have services A, B 
and C. And markers X and Y. You get services A-X, B-X, C-X, A-Y, B-Y, 
C-Y. If you also add marker "null" you will also get services A, B, C. 
If you do not contribute markers, these will be created as well (= 
default behavior). Now, if you have services A depending on B, 
automatically A.X will depend on B.X. You can use injection to get a set 
of configuration markers. I added several methods in ObjectLocator to 
facilitate. <---- okay, this is a VERY BRIEF documentation. In reality, 
I should probably document every method here, but as I said I'm quite 
limited in my time here and I would like it if someone else could pick 
it up and do something with it.

In Hibernate and Hibernate-Core I used the @ConfigurationGroup 
annotation to allow multiple databases. All you have to do in your 
webapplication is contribute two markers, and use files 
hibernate-firstMarker.conf.xml etc. Then you can use 
@Contribute(HibernateServiceSomething) @FirstMarker to contribute 
packages to only that particular version of the service. If you want to 
use version X of service A, all you need to do is inject A with marker 
X. Done.

Example Module file of my rights database jar:
import org.apache.tapestry5.hibernate.HibernateCore;
import org.apache.tapestry5.hibernate.HibernateEntityPackageManager;
import org.apache.tapestry5.ioc.Configuration;
import org.apache.tapestry5.ioc.ServiceBinder;
import org.apache.tapestry5.ioc.annotations.Contribute;
import org.apache.tapestry5.ioc.annotations.ContributeConfigurationGroup;
import org.apache.tapestry5.ioc.annotations.Local;

public class Module {
     public static void bind(ServiceBinder binder) {
         binder.bind(RightsDAO.class, RightsDAOImpl.class);
     }

     @ContributeConfigurationGroup(HibernateCore.class)
     public static void 
contributeHibernateConfiguration(Configuration<Class> configuration) {
         configuration.add(RightsModel.class);
     }

     @Contribute(HibernateEntityPackageManager.class) @RightsModel
     public static void 
contributeHibernateEntityPackageManager(Configuration<String> 
configuration) {
         configuration.add("nl.almexx.rechten.model");
     }

}


Tom.

-------- Originele bericht --------
Onderwerp: 	Re: Noticed another stackoverflow question on Tapestry 5, go 
vote
Datum: 	Wed, 9 Feb 2011 00:31:39 -0800 (PST)
Van: 	antalk <an...@intercommit.nl>
Antwoord-naar: 	Tapestry users <us...@tapestry.apache.org>
Aan: 	users@tapestry.apache.org



True,

But they have forgotten to ask if the original poster wants to use multiple
databases, if so i wouldn't encourage using Tapestry (sigh).

For me this is one of the biggest letdown's , i have written 2 apps in Tap
5.2 who both require access to multiple datasources, but the inability to
use multiple databases (through tap-hibernate) has required me to do some
hacking around to get this working.

If i knew this beforehand i dont think i had choosen Tapestry..

On the other hand i think the framework is great and provides me with enough
flexibilty to do what i want to do.
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Noticed-another-stackoverflow-question-on-Tapestry-5-go-vote-tp3377101p3377198.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

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



Re: Fwd: Re: Noticed another stackoverflow question on Tapestry 5, go vote

Posted by antalk <an...@intercommit.nl>.
Hi Tom,

Appreciate your answer as i already had seen your remarks and your own
branch of this 'problem' . I may have a look into this but afaik it requires
me to run a custom build Tapestry version with my existing webapp. 

I could work but we are already hosting my web on a production platform and
we don't want any custom branched Tapestry code into production. I have
implemented our own multi datasource solution, but this requires every
developer to write his own tapestry module against my app. (Each module can
then have it's own DataSource)

Last thing i saw is that Igor Drobiazko already mentioned that he wants
JPA/HIbernate/ORM in Tap 5.3 , which i assume will work with multiple
datasources. So i guess i'll wait for that.

I may try your solution if i get a few extra hours on my project.



-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/Fwd-Re-Noticed-another-stackoverflow-question-on-Tapestry-5-go-vote-tp3380967p3380975.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.

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