> Create a service wrapper around
> DatabaseConnection.getReadConnection(). This will put the
> eager-loading mechanism on your side.
I will try this, but this is not relevant to the issue in question, which is 
how to control the ordering of eagerloaded services. The very need to eagerload 
a service already implies that order is important, not being able to imho is an 
oversight.

> Alternately, put in proper synchronization semantics on
> DatabaseConnection static methods.l
> Use of statics in an application using Tapestry IoC is a design smell.
The is a database connection pool that has all the relevant synchronization 
semantics in place, I agree that pure IoC would be better but this is legacy 
code used in thousands of classes, so is difficult to change, but again that 
should not detract from the question

but thanks for the tip Howard,
Peter

----- Original Message -----
From: "Howard Lewis Ship" <hls...@gmail.com>
To: "Tapestry users" <users@tapestry.apache.org>
Sent: Monday, 27 July, 2009 18:09:16 GMT +02:00 Athens, Beirut, Bucharest, 
Istanbul
Subject: Re: Tapestry 5 IoC Eagerloading and ordering of services

Create a service wrapper around
DatabaseConnection.getReadConnection(). This will put the
eager-loading mechanism on your side.

Alternately, put in proper synchronization semantics on
DatabaseConnection static methods.l

Use of statics in an application using Tapestry IoC is a design smell.

On Mon, Jul 27, 2009 at 12:55 AM, <p.stavrini...@albourne.com> wrote:
> Hi,
>
> Before I open a jira for this I have devised an coded example to illustrate 
> it, and hopefully get some comments:
>
> //Example: The shell of an eagerloaded service
> public class ImageService {
>
>        /** Cache to hold thumbnail images */
>        private static ConcurrentHashMap<Integer, Thumbnail> imageCache_ = new 
> ConcurrentHashMap<Integer, Thumbnail>();
>
>
>        public void preloadImageCache() {
>                DbConnection connection = null;
>                try {
>                        //Sometimes this turns into a Null Pointer Exception 
> as another eagerloaded service sets up the connection pool etc.
>                        //this service should start up after that one, but 
> this is not always the case in practice??
>                        connection = DatabaseConnection.getReadConnection();
>                        //database query
>                } catch (Exception e) {
>                        //handle exception
>                }
>        }
>
>
>        public static ImageService build() {
>                return new ImageService();
>        }
>
>        public ImageService() {
>                preloadImageCache();
>        }
>  }
>
> //Workaround: adding a dependency on the other eagerloaded service solves it, 
> but this is not a practical solution if there are many of these services
> public class ImageService {
>
>        /** Cache to hold thumbnail images */
>        private static ConcurrentHashMap<Integer, Thumbnail> imageCache_ = new 
> ConcurrentHashMap<Integer, Thumbnail>();
>
>
>        public void preloadImageCache() {
>                DbConnection connection = null;
>                try {
>                        connection = DatabaseConnection.getReadConnection();
>                        //database query
>                } catch (Exception e) {
>                        //handle exception
>                }
>        }
>
>
>        public static ImageService build(SiteInitialise siteInitialise) {
>                return new ImageService(siteInitialise);
>        }
>
>        public ImageService(SiteInitialise siteInitialise) {
>                if(siteInitialise.isConnectionOk())
>                        preloadImageCache();
>        }
>  }
>
> If there is a way to ensure the ordering of eagerloaded services, then this 
> is not an issue, perhaps this is a regression from the fix to 
> http://issues.apache.org/jira/browse/TAPESTRY-2267 ? otherwise I am surprised 
> that others have not come across this, perhaps I have missed something?
>
> Cheers,
> Peter
>
>
> ----- Original Message -----
> From: "Peter Stavrinides" <p.stavrini...@albourne.com>
> To: "Tapestry Mailing List" <users@tapestry.apache.org>
> Sent: Friday, 24 July, 2009 15:59:20 GMT +02:00 Athens, Beirut, Bucharest, 
> Istanbul
> Subject: Tapestry 5 IoC Eagerloading and ordering of services
>
> Hi everyone,
>
> Is it possible to control the ordering of eagerloaded IoC services, 
> especially if the services exist is separate but dependent IoC modules.
>
> I found an issue http://issues.apache.org/jira/browse/TAPESTRY-2267 that 
> states these service proxies are claimed and loaded collectively, however no 
> mention is made of how to ensure the correct ordering of these claimed 
> services?
>
> Any help with this would be greatly appreciated.
>
> Kind regards,
> Peter
>
>
>
> ---------------------------------------------------------------------
> 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
>
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry
Director of Open Source Technology at Formos

---------------------------------------------------------------------
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

Reply via email to