Skip to main content

Creating client applications for Geronimo

Leverage Geronimo's client application container or roll your own

Return to article


The getCats() method in CatClientStandalone.java
		
	private Vector getCats() {
		Vector cats = new Vector();
		Collection coll = null;
		CategoryRemote cr = null;
	
		Properties props = new Properties();
		props.put("java.naming.factory.initial",
				"org.openejb.client.RemoteInitialContextFactory");
		props.put("java.naming.provider.url", "127.0.0.1:4201");
		props.put("java.naming.security.principal", "testuser");
		props.put("java.naming.security.credentials", "testpassword");

		try {
       
			Context ic = new InitialContext(props);
			Object o = ic.lookup("CategoryBean");

			CategoryHome home = (CategoryHome) PortableRemoteObject.narrow(o,
				CategoryHome.class);
			coll = home.findAll();
			Iterator it = coll.iterator();

			while (it.hasNext()) {
				cr = (CategoryRemote) it.next();
				cats.add("Cat id= " + cr.getId() + ";  Name= " + cr.getName());
			} // of while

		} catch (Exception ex) {
			ex.printStackTrace();
		}

		return cats;
	}

Return to article