Solved

what design pattern is this?

Posted on 2006-11-25
7
209 Views
Last Modified: 2013-11-24
hi experts,

From a java class(Action class) we are accessing the business delegate. The code is written in such a way that we are able to access/use  only the Business Delegate interfaces and the actual Business Delegate implimentation is hidden behind the Business Delegate interfaces. The main objective of the Business Delegate implimentation is to get a remote object(EJB object).

What Design pattern does the above statement represent?


thanks
J
0
Comment
Question by:jaggernat
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 10

Expert Comment

by:ADSLMark
ID: 18012011
Façade Pattern i think?

http://en.wikipedia.org/wiki/Fa%C3%A7ade_pattern

Mark
0
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 18012025
Adapter pattern
0
 
LVL 10

Assisted Solution

by:ADSLMark
ADSLMark earned 100 total points
ID: 18012079
My link is a bit weird, dont know why anyway let me try again:

http://en.wikipedia.org/wiki/Façade_pattern

So the question becomes, what's the difference.. look here:

Question: So the way to tell the difference between the Adapter pattern and the Facade pattern is that the Adapter wraps one class and the Facade may represent many classes?
Answer: No! Remember, the Adapter pattern changes the interface of one or more classes into one interface that a client is expecting. While most textbook examples show the adapter adapting one class, you may need to adapt many classes to provide the interface a client is coded to. Likewise, a Facade may provide a simplified interface to a single class with a very complex interface. The difference between the two is not in terms of how many classes they "wrap", it is in their intent. [Head First Design Patterns, p260]

(source: http://home.earthlink.net/~huston2/dp/facade.html)

Mark
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 10

Author Comment

by:jaggernat
ID: 18012108
This is my actual scenario in j2ee project:

I have a scenario where I have this code in Action class
_____________________
OrderInfoDelegate orderInfoDelegate = (OrderInfoDelegate) DelegateFactory .getInstance().getDelegate("OrderInfo");
____________________

Where “OrderInfoDelegate”  is an interface which has this method
public interface OrderInfoDelegate
{
     public ControllingOrderVO saveOrderInfo(ControllingOrderVO conVO);

}
_________________________
And the actual implementation is in another class called LocalDelegateOrderInfo which goes like :

public class LocalDelegateOrderInfo extends BaseDelegate implements OrderInfoDelegate
{

private OrderInfoLocal local;
private OrderInfoLocalHome home;

public LocalDelegateOrderInfo(String jndiServiceHomeName) {
          try {
               home =
                    (OrderInfoLocalHome) ServiceLocator.getInstance().getLocalHome(
                         jndiServiceHomeName);
               local = home.create();
          } catch (ServiceLocatorException ex) {
               ex.printStackTrace();
          } catch (CreateException ex) {
               ex.printStackTrace();
          }
     }    

     public ControllingOrderVO saveOrderInfo(ControllingOrderVO conVO) {

          //ControllingOrderVO coVO = null;
               try {
                    conVO = (ControllingOrderVO) local.saveOrderInfo(conVO);
               } catch (EJBException ejbExp) {
                    throw logExceptionFromEJB(ejbExp, FFMLoggingLevels.DEBUG);
               }
               return conVO;
          }



}
_______________________

so when i am transitioning from action class to delegate , i am just calling the Delegate interface in my Action class.
So is it Adapter pattern or Facade?
0
 
LVL 23

Assisted Solution

by:Ajay-Singh
Ajay-Singh earned 100 total points
ID: 18012112
Façade simplifies the ways entities communicate, whereas Adapter may NOT. Adapter allows two or more previously incompatible objects to interact.
0
 
LVL 10

Author Comment

by:jaggernat
ID: 18015007
>>>Adapter allows two or more previously incompatible objects to interact.


in my case the two objects are compatible.
0
 
LVL 8

Accepted Solution

by:
reach2piyush earned 280 total points
ID: 18016967
Perfect fit - J2EE Business Delegate pattern

Close - Proxy Pattern

Business Delgates can be used as Adapters when the Business Services that it invokes is not a part of the same system.
But in this case the Business Delegate is acting more as a remote proxy for the Session Beans

0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
thymeleaf natural templating vs JSP 2 96
Unhandled exception type Exception 18 31
Java string replace 11 45
Convert from a json string array to a Java object 3 31
I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This video teaches viewers about errors in exception handling.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question