• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Decorator Pattern

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How javax.ejb.EJBObject is example of decorator Pattern?

Regards,
Jigar
[ May 12, 2008: Message edited by: JigaR Parekh ]
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I doubt about it.
javax.ejb.EJBObject is example of proxy pattern
 
JigaR Parekh
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this has been mention as example in book SCEA study guide by Paul R. Allen, Joseph J. Bambara

yes i agree that it should be example of Proxy.

Regards,
Jigar
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It should be decorator pattern. App server wraps the original bean method and adds other functionalities like transaction, security...
 
Ranch Hand
Posts: 1936
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can only an interface be an example of a design pattern?

I think only one pattern can be represented by only one class, that is Singleton pattern.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJBObject is there both in decorator and proxy pattern.

excerpt from Paul Allen's SCEA book.

"Java EE Technology Feature The Java EE technology feature associated with
the Proxy pattern is javax.ejb.EJBObject (EJB remote reference) in a structural sense.
Actually the �stub� object in the client�s address space provides the proxy."


Still not clear why it's an decorator pattern. Any DP expert???
 
JigaR Parekh
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by wang andrew:
It should be decorator pattern. App server wraps the original bean method and adds other functionalities like transaction, security...



Then EJBHome should also be example of decorator pattern but it is not see below question which has been asked in Mark Cade book.

Which pattern is used by the Home Interface of an EJB?
A. Proxy
B. Decorator
C. Mediator
D. Factory

The correct answer is D.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by JigaR Parekh:


Then EJBHome should also be example of decorator pattern but it is not see below question which has been asked in Mark Cade book.

Which pattern is used by the Home Interface of an EJB?
A. Proxy
B. Decorator
C. Mediator
D. Factory

The correct answer is D.




EJBHome is not based on decorator pattern because in case of EJBHome container is not adding any services to the actual purpose of the home object. The actual purpose of EJBHome is to act as a singleton factory for producing EJBObjects

EJBObject- This is a bit complex. You can say that when remote client accesses the EJBHome through jndi look up he gets a stub or a proxy object based on the proxy pattern which talks to the skeleton on the server side which in turn talks to the EJBObject implementation provided by server which wraps the actual bean instance. For each client method invocation, the EJB Object decorates the bean instance with services like security, transaction before invoking the actual methood on the bean instance.
 
JigaR Parekh
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
EJBObject as decorator pattern i have seen so many places but not able to understand why? Any body who has better understanding about design Patterns
 
Ajay Singh Rathore
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JigaR,

I am surprised to see you still have doubts about it after my explanation.
Try understanding a simple decorator pattern example[HF design pattern] and then link it with EJBObject

Here EJBObject is a decorator object which knows how to talk to the bean instance and also doing this it accomplishes some other functionality(security, transaction).

For eg Consider java IO classes like BufferedInputStream is a decorator which decorates the InputStream.
 
JigaR Parekh
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes i am still confused but not as why EJBObject is example of decorator but as why EJBHome is not example of decorator.
i might trying little hard to understand.

As you have correctly said that container will wrap services like Security and transaction around EJBObject will provide dynamically exatra resposibilty with actual bean.

this can be true to EJBHome also because EJBHome also gets wrapped with additional functionality like security.

I hope you can understand my doubt.

Regards,
Jigar
 
Ajay Singh Rathore
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by JigaR Parekh:
yes i am still confused but not as why EJBObject is example of decorator but as why EJBHome is not example of decorator.
i might trying little hard to understand.

As you have correctly said that container will wrap services like Security and transaction around EJBObject will provide dynamically exatra resposibilty with actual bean.

this can be true to EJBHome also because EJBHome also gets wrapped with additional functionality like security.

I hope you can understand my doubt.

Regards,
Jigar



JigaR i doubt that weather server implementation of EJBHome provides any sort of security services.
If you think logically the purpose of EJBHome in case of session bean is only to create EJBObjects, and the question of security or transaction only comes in picture when client calls the bean methods on the EJBObject stub not the EJBHome stub.

So the moral of the story is that EJBHome is a factory and EJBObject is a decorator.

Regards,
Ajay Singh Rathore

SCJP , SCDJWS
 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd say: EJBObject, as a Stub, is a Proxy. As an EJB, is a Decorator.
[ May 29, 2008: Message edited by: Pedro Erencia ]
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ajay,

You explained it in the best possible way. I agree with you on everything you said.

Thanks
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are a few major differences between the Proxy and Decorator object-oriented design patterns. In the lastest version of the Enterprise Javabeans API, the EJBObject class is no longer used.

When talking about the older versions of the EJB API, EJBObject was an implementation of the Decorator pattern. Code of the EJBObject added additionall functionality to the actual bean class. It "decorated" the bean class with additional functionality. EJBObject did not serve as a Proxy and was never used as a "stand-in" for the actual bean class.

Either way, the EJBObject was deprecated.
 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Clark:
There are a few major differences between the Proxy and Decorator object-oriented design patterns. In the lastest version of the Enterprise Javabeans API, the EJBObject class is no longer used.

When talking about the older versions of the EJB API, EJBObject was an implementation of the Decorator pattern. Code of the EJBObject added additionall functionality to the actual bean class. It "decorated" the bean class with additional functionality. EJBObject did not serve as a Proxy and was never used as a "stand-in" for the actual bean class.

Either way, the EJBObject was deprecated.



I am going to emerge this topic from the ashes to ask a question for those who already took the new SCEA 5 exam. Should I expected to see assumptions regarding old artifacts such as EJBObject in questions (about patterns or any subject) at the new SCEA5 exam?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic