FileDocCategorySizeDatePackage
ProfileClient.javaAPI DocExample2054Wed Apr 05 11:25:42 BST 2000stateful

ProfileClient

public class ProfileClient extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    String name = args[0];

    try {
      // Get a JNDI context for our EJB server
      Properties p = new Properties();
      p.put(Context.INITIAL_CONTEXT_FACTORY,
	    // For Ejbhome server
	    "com.ejbhome.naming.spi.rmi.RMIInitCtxFactory");
            // Following two lines for WebLogic server
// 	    "weblogic.jndi.T3InitialContextFactory");
//       p.put(Context.PROVIDER_URL, "t3://localhost:7001");
      Context context = new InitialContext(p);

      // Create a profile server
      ProfileHome pHome =
        (ProfileHome)context.lookup("stateful.ProfileHome");

      // Ask the server for the person's profile
      System.out.println("Creating profile for " + name);
      Profile profile = pHome.create(name);

      // Get/set some entries in the profile
      System.out.println("Setting profile entries for " + name);
      profile.setEntry("favoriteColor", "blue");
      profile.setEntry("language", "German");

      System.out.println("Getting profile entries for " + name);
      System.out.println("\tFavorite color: " +
                         profile.getEntry("favoriteColor"));
      System.out.println("\tLanguage: " + profile.getEntry("language"));
    }
//     catch (NoSuchPersonException nspe) {
//       System.out.println("Invalid person: " + name);
//     }
    catch (Exception e) {
      System.out.println("Error while creating/using profile.");
      e.printStackTrace();
    }