Presented by developerWorks, your source for great tutorials
ibm.com/developerWorks
Listing 14: Implementation for
getUsers()
/** Add the getUsers method to the implementation */
public class UserManagementBean implements SessionBean {
public Collection getUsers(){
ArrayList userList = new ArrayList(50);
Collection collection = userHome.findAll();
Iterator iterator = collection.iterator();
while(iterator.hasNext()){
LocalUser user = (LocalUser)iterator.next();
userList.add(user.getEmail());
}
return userList;
}
Using the
getUsers()
public class Section2Client {
methods from the client
public static void main(String[] args) {
The client code invokes the
getUsers()
method.
Collection collection
It
=
then
userMgmt.getUsers();
takes the collection of emails that uniquely
Iterator iterator = collection.iterator();
identify a user returned from the
getUsers()
while(iterator.hasNext()){
method and prints them out to standard out.
String email = (String)iterator.next();
System.out.println("user id=" + email);
}
}
}
Compiling and deploying the
findAll()
EJB QL
example
The same technique can be used to the build, package, and deploy the findAll example
as was used to build, package, and deploy the first example which can be found at the
on page panel. All of the source and build file for this example can be found at
cmpCmr/section2.2
.
Introducing EJB CMP/CMR, Part 1 of 2
Page 45 of 48






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

tomcat web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved