Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

local and remote component args

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been thinking about the difference in arguments of business methods for local and remote components as described in Headfirst EJB. If the component is local then what is passed as the business method arg is a copy of the reference to the object on the same heap, if it's remote it's a copy of the object from the clients heap to the server's heap.

I know that this relates to business logic, normal Java rules etc rather than being EJB specific, but can anybody think of a scenario where the internal coding of a business method would be different for both cases. It would help reinforce the idea.
 
Ranch Hand
Posts: 351
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you want to say the difference in the business method accepting arguments locally or remotly? Like if the business methods needs to wrok on the args differently?
So far as I know, its not so.

Leena
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One major difference is that when an object is passed as an argument to EJB's method and EJB's method does some action on that object and after the method returns the client works further on that object.
1. In case of Remote component, we need to explicitly return the object.
2. In case of Local component, we might not want to return anything as we are already working on the same object.

I always perfer to use remote components rather than local components. One reason is that in most of the application servers you can make the method invocations on remote components to "pass by reference" instead of "pass by value" by just checking a checkbox. The benefit of keeping remote components always is that in future if you want to move your EJBs on different machine, you don't need to make changes to the code.
 
Peter Warde
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Harpreet - I like your above example. One solution to the problem suggested by HeadFirst EJB is to maintain consistency have all arguments a copy of an object. You can do this with local interfaces by cloning the object and then passing a reference to the cloned object as a method argument.
 
Squanch that. And squanch this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic