RequestFactory: Usage of the EntityService / EntityLocator / ServiceLocator pattern

55 views
Skip to first unread message

Alexander Orlov

unread,
Jul 7, 2011, 8:39:52 PM7/7/11
to Google Web Toolkit
I've just implemented this pattern parallel to my basic RequestFactory
implementation on top of JPA. It seems that the ServiceLocator brings
a little bit more structure into the code...

But is the usage of the ServiceLocator pattern encouraged or
recommended, considering the future evolvement of Android's / GWT's
RequestFactory?

-Alex

Thomas Broyer

unread,
Jul 8, 2011, 4:42:05 AM7/8/11
to google-we...@googlegroups.com
ServiceLocator is the only mean you can use instance methods in your service, instead of static methods. It's up to you to choose. I believe both will continue to be supported (I can't see any reason it wouldn't be)

Alexander Orlov

unread,
Jul 8, 2011, 5:33:26 AM7/8/11
to Google Web Toolkit
On Jul 8, 10:42 am, Thomas Broyer <t.bro...@gmail.com> wrote:
> ServiceLocator is the only mean you can use instance methods in your
> service, instead of static methods. It's up to you to choose. I believe both

I'm rather interested in what's the more elegant way to manage
persistence via RF.

-Alex

Thomas Broyer

unread,
Jul 8, 2011, 5:51:32 AM7/8/11
to google-we...@googlegroups.com
All things 'static' are generally seen as "not elegant" in Java, so using a ServiceLocator would make "more elegant". YMMV.

Also, "elegant" doesn't necessarily match with "pragmatic", so there might be additional costs to making things "elegant".

If you ask me, I'd go with instance methods and a ServiceLocator (and dependency injection), because it makes testing the service with mock dependencies easier (less error prone, make it possible to test in parallel with different dependency mocks, etc.)

Alexander Orlov

unread,
Jul 8, 2011, 8:22:45 AM7/8/11
to Google Web Toolkit
On Jul 8, 11:51 am, Thomas Broyer <t.bro...@gmail.com> wrote:
> If you ask me, I'd go with instance methods and a ServiceLocator (and
> dependency injection),

Is there anywhere a concrete code sample for this pattern? I'm
considering to use Dep. Injection too.

Thx again for the info!

-Alex

Thomas Broyer

unread,
Jul 8, 2011, 8:42:11 AM7/8/11
to google-we...@googlegroups.com

StefanR

unread,
Jul 10, 2011, 1:26:09 PM7/10/11
to google-we...@googlegroups.com

Is there anywhere a concrete code sample for this pattern? I'm
considering to use Dep. Injection too.

Here's another example for a classic DAO pattern combined with Spring:
 
Reply all
Reply to author
Forward
0 new messages