Dual View ServiceFacade - an anti pattern?

  5 posts   Feedicon  
Replies: 4 - Last Post: June 22, 2009 14:37
by: abien
showing 1 - 5 of 5
 
Posted: June 22, 2009 06:05 by abien
ServiceFacades can be easily deployed with @Remote and @Local views at once. I described the idea about the Dual View Strategy here:
BEANS WITH BOTH VIEWS (@LOCAL AND @REMOTE) - AN ANTI PATTERN?
You will find an example in ServiceFacade project (the ejb part in particular) and com.abien.patterns.business.sf.mc package.
 
Posted: June 22, 2009 09:28 by Zdenek Tronicek
My view is slightly different. First, anti-pattern is not anything which is bad in any case. Anti-patterns are rather something which often cause problems and so you should be very cautious about them. So, in my opinion, @Local and @Remote simultaneously IS an anti-pattern. For two reasons:

1) local and remote methods may have different semantics because parameters and return values are passed in a different way. That is, you cannot blindly change @Local to @Remote or @Remote to @Local. (Yes, it is true that for some types you do not have to care about how they are passed. But in general, you should be cautious.)

2) Facade should be a client view. If you add a local interface to a Facade, it means that you call the Facade as a business component. That is, Facade functions as a business component as well. And this is against the principle of "single responsibility". You should decide: it is either Facade or a business component. But not both.
 
Posted: June 22, 2009 13:30 by abien
From your view - you are right. But would you still access a ServiceFacade via a @Remote interface running the Web and EJB-Container in the same JVM? There a lots of appserver installations running in a single JVM. It is just a pragmatic optimization.

You could use the @Remote interface for external clients only.
 
Posted: June 22, 2009 14:17 by Zdenek Tronicek
No. Such optimization is ok, in my opinion. For example, a local interface for web components in the same JVM and remote interface for application client that is running on a remote computer.
 
Posted: June 22, 2009 14:37 by abien
Perfect. In few recent projects, I only added web-clients specific methods to the @Local interface. The @Remote interface remained stable - we didn't had to redeploy the clients. Dual View Facade was just perfect for that purpose.
Replies: 4 - Last Post: June 22, 2009 14:37
by: abien
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close