Excellent, thanks a ton! I missed the unmodifiable method! :)
As for DTO's, yeah I keep hearing that from ppl. Since I'm just following the
book along I'm reading, I'm learning what can and can't be done. After that,
from doing server-side programming for a few years, then I will pick the best
method that reaps performance and ease of use/extensibility.
With that said, I'm getting a little help from my friends at Wiley, I picked up
the EJB Patterns book. Good reading, I think I'm just a little too junior on
the EJB side yet. Thank god for home projects where you can cut your teeth on
something not job critical! :)
Thanks again!
--
-bk
Quoting David Ward <[EMAIL PROTECTED]>:
> If you really want to return an unmodifiable Collection structure, you
> can use one of these helper methods in the java.util.Collections class:
>
> static Collection unmodifiableCollection(Collection c)
> static List unmodifiableList(List list)
> static Map unmodifiableMap(Map m)
> static Set unmodifiableSet(Set s)
> static SortedMap unmodifiableSortedMap(SortedMap m)
> static SortedSet unmodifiableSortedSet(SortedSet s)
>
> So you could do:
> {
> ...
> origList = new ArrayList();
> origList.add(x);
> ...
> return Collections.unmodifiableList( origList );
> }
>
> Just make sure the contents of the Collection are Serializable or Remote.
>
> Now, that being said, if this EJB you're talking about is a stateless
> session bean (slsb) accessing entities, it would be ***BAD*** to return
> remote interfaces of those entities. Much network calls and separate
> transactions = bad performance and more.
>
> Instead, use local interfaces to your entites from your slsb, put the
> data into Serializable data transfer objects (reg. javabeans, or
> "dto's"), shove them into an ArrayList, and return that. Of course,
> that's just one (common) design pattern among other viable options.
>
> Hope this helps,
> David
>
> --
>
> Brandon Knitter wrote:
> > Okay, I know this is not JBoss specific, but I got a good response from my
> last
> > question, and this is a question in the context of EJB.
> >
> > When returning a java.util.Collection, what object is the best to return?
> I'm
> > assuming that returning a Vector is not really a good idea as it is able to
> be
> > modified. What options for immutable Collection implementations are
> there?
> >
> >
>
>
>
> _______________________________________________________________
>
> Sponsored by:
> ThinkGeek at http://www.ThinkGeek.com/
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/jboss-user
>
>
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -
http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-user