--- Bob Lee <[EMAIL PROTECTED]> wrote: > > > My point still holds true--Pico requires more code > than Guice.
Structly speaking using pico in a webapp requires no code at all (except of course container configuration in xml or whatever else) > > And annotation introduces explicit dependency to > > framework - kind of uncool. > > > It's a tradeoff--I'll take easier maintainability > and more concise code. Well, as said before there is no code related to pico at all. ( in classes being injected ) What is with third party libraries, which do not know anything about guice? It is really easy to inject velocity engine with pico ( for example to compose email message ): ( taken from my webapp, application scope ) -----------%<------------- <!-- properties for velocity engine for mail system --> <implementation key="renderProperties" class="org.picocontainer.gems.util.ConstructableProperties"> <constant> <string>render.properties</string> </constant> </implementation> <!-- velocity engine --> <implementation class="org.apache.velocity.app.VelocityEngine"> <dependency key="renderProperties"/> </implementation> -----------%<------------- ( well, I need little more verbose explicit configuration because I have more than one properties object ) Now every object which likes to use velocity engine just gets it. And velocity remains the same vanilla velocity coming out of maven repository at apache. If I understood you correctly, in guice there will be need to write some adapter / factory. Who got more code? > If I choose to not to provide such constructor - > > then container can not instantiate this component > - > > there will be an ugly telling you to provide > > dependency. > > > When does Pico give you this error? Guice gives you > a pretty message at > startup as opposed to runtime. It even points you to > the class and place > where you bound it. At container verification. AFAIR this happens before container in question is "started" - also pretty soon. It also tells what is missing ( and depending on WW setup this even comes on the page ) > ------------%<--------------- > > <!-- > > security and user management components > > --> > > > > <implementation key="securitySession" > > > class="org.nanocontainer.persistence.hibernate.FailoverSessionDelegator"> > > <dependency key="userSessionFactory"/> > > </implementation> > > > > <implementation key="securityLifecycle" > > > class="org.nanocontainer.persistence.hibernate.SessionLifecycle"> > > <dependency key="securitySession"/> > > </implementation> > > > > > > <!-- > > user manager > > --> > > <implementation key="userManager" > > > class="de.jtec.user.hibernate.HibernateUserManager"> > > <dependency key="securitySession"/> > > <dependency key="hasher"/> > > </implementation> > > > > --------------%<---------------- > > > It's difficult to say exactly because the example is > slightly incomplete, > but the equivalent of this in Guice is: Well, this was request scope ( as hibernate session is best opened in view ;) ). In aplication scope you will need something like this: -------------%<------------------ <!-- hibernate configuration & session factory for jtec-user --> <implementation key="userDbConfig" class="org.nanocontainer.persistence.hibernate.ConstructableConfiguration"> <constant> <string>/jtec-user-hibernate.cfg.xml</string> </constant> </implementation> <implementation key="userSessionFactory" class="org.nanocontainer.persistence.hibernate.SessionFactoryDelegator"> <dependency key="userDbConfig"/> </implementation> ----------------%<-------------- Again, explicit dependencies and keys are provided to avoid ambiguity as there are more hibernate domains. > bind(Session.class) > .annotatedWith(Secure.class) > .to(FailoverSessionDelegator.class); > > Then apply "@Inject @Secure" wherever you want a > secure Session. You can > obviously reuse the @Secure annotation elsewhere, > too. Correct me if I'm wrong ( due to lack of complete undertanging of guice ), but this means that you need to tell explicitely that org.hibernate.Session would be represented by FailoverSessionDelegator class? What if I like to use another session impl in the same container? You do not have to specify this with pico - your constructor states it need Session , container looks for implementation of session. If there is one than one available - ambiguity shall be resolved by means of explicit mapping ( no difference with guice? ) > Now any WW2/S2 action wishing to have reference to > > UserManager needs to declare it as constructor > > parameter. > > > Guice's Struts 2 plugin injects interceptors and > results, too. > > Guice also supports scoping using annotations. For > example, you can apply > @SessionScoped to an action and it will be stored in > the session. Scoping is another issue. Guice users depend on your wisdom to provide them with annotations. If those annotations are to be applied on some framework ( say, my menu framework for example ), then there is a leak of concepts - I have to decide component scope in a project which has nothing to do with web application ( but will be used for it ). What if I need different scope? There could be also way more scopes than usual suspects (application /session/request )? ( Look at nanocontainer chains - every directory in webapp can be own scope, this helps to hide somponents from each other. I also use those nested scopes to control access to parts of website: --------------%<----------------- <container> <implementation class="de.jtec.security.LoginChecker"/> <!-- activate contact entry we are at home --> <implementation class="de.jtec.menu.util.EntryActivator"> <dependency key="siteMenu"/> <dependency key="entryLocator"/> <constant> <string>menu.dashboard</string> </constant> </implementation> </container> --------------%<----------------- ( No request will be served beyond directory assotiated with container unless there is valid user login. This automatically secures all actions mapped in corresponding package at virtually no cost. Also activates certain menu entry ) This is also good for wizard-like applications, providing DAO-Classes for parts of website where they are really needed, or to check for some precondition like "to be able to use actions from this package you should have selected something before: -------------%<----------------- <container> <!-- require open account --> <implementation class="de.kesselweb.mydiablo.data.edit.AccountChecker"/> </container> -----------%<-------------- This small component would require that account was seslected for edit before, otherwise it will force redirect to appropriate page. > PS: is project space on code.google.com available > only > > for employees or also for mere mortals? > > > Google Code is open to anyone! who got gmail ;) looks like product marketing by blackmail ;) > Bob Konstantin ----[ Konstantin Pribluda http://www.pribluda.de ]---------------- Still using XDoclet 1.x? XDoclet 2 is released and of production quality. check it out: http://xdoclet.codehaus.org ____________________________________________________________________________________ Get your own web address. Have a HUGE year through Yahoo! Small Business. http://smallbusiness.yahoo.com/domains/?p=BESTDEAL --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]