Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing objects or Vector of objects via HTTP  RSS feed

 
ashish gode
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends,
If we design an application, as a complex mixture of classes & interfaces. Does it affect the performance if the class objects are passed, to the servlets.
Or is it better to wrap the class data in Vectors and then pass the vector?

Please guide.
------------------
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure if you really gain a significant performance improvement by using a vector to wrap the objects. A vector will only help you deal with the objects as a collection. Not to mention additional overheads in using a Vector because it is synchronized. If you must use a collection and don't foresee concurrent access, try using an ArrayList.
Having said that, I would recommend you to pass primitives to the servlet as an name-value pair( eg; EmployeeId = 1234 ). You can maintain an object pool in the server and do a lookup by id that gets passed along. This way you can do away with passing objects.
Hope that helps,
------------------
Ajith Kallambella M.
Sun Certified Programmer for the Java2 Platform.
 
Kathy Shkarlet
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you have a bunch of objects that you need to pass to servlet at once, then by all means WRAP THEM! Sending one Vector filled with lots of objects gives tremendous speed increase over lots of individual connections.
 
ashish gode
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ajith & kathy for your help. Does it affect to use session beans to access database or using entity beans directly?
------------------
 
Kirk Pepperdine
Author
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Halter and Steve Munroe (Enterprise Java Performace) get into the metaphor of "Performance Physics." They write that accessing remote objects has a high energy barrier that is costly to overcome. I like this type of description because the analogy allows you to equate volume to mass. The larger the mass, the more energy that you must expend to over come the barrier. Thus reducing the amount of data that needs to be transfered is good (smaller mass to push). Limiting the number of calls is good (fewer passes through the energy barrier). So, for HTTP, key/value pairs with state saved in the servlet would seem to minimize things. In general, I don't see any value gather up parameters (but your mileage may differ) into a collection. There is an energy barrier to using synchronization. Thus Vector does put up a higher barrier than unsynchronized collections.
In order of scability (least to most), Entity, Statefull, Stateless. To be quite honest, the only value I see in using EntityBeans is to act as a state holder (or in other terms, an Iterator) for a result set from a query for a client. IMHO, this is the best way to turn statefull session beans into stateless session beans. Only using stateless session beans in your service layer is the least resource intensive way to design you application.

 
Ajay Singhal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi! friends
All of u r taking about performance. I'm also working with same technology.
I found it very much faster to pass objects rather than premetives because here we can pass the collection of data.
Tell me one thing that how I'll be able to store the objects in a Database.specify the the method to extract the object from a database.just like we use readObject in case of File or Stream.
Ajay Singhal
------------------
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!