Forse non mi sono spiegato granché:
Credo che le due parti di codice su scritte siano specifiche per ogni application server, almeno così ho letto sul libro che sto studiando... il punto è che il libro fa gli esempi utilizzando JBoss, mentre io voglio usare Glassfish!!!
Il libro, parlando della classe clients che ho scritto su, dice:
codice:
To access an enterprise bean, a client starts by using JNDI to obtain a directory connection to a bean's container. JNDI is an implementation-independent API for directory and naming systems. Every EJB vendor must provide a directory service that is JNDI-compliant. This means that they must provide a JNDI service provider, which is a piece of software analogous to a driver in JDBC. Different service providers connect to different directory servicesnot unlike JDBC, where different drivers connect to different relational databases. The getInitialContext( ) method uses JNDI to obtain a network connection to the EJB server.
The code used to obtain a JNDI context depends on which EJB vendor you use. Consult your vendor's documentation to find out how to obtain a JNDI context appropriate to your product. For example, the code used to obtain a JNDI context in WebSphere might look something like the following:
public static Context getInitialContext( )
throws javax.naming.NamingException {
java.util.Properties properties = new java.util.Properties( );
properties.put(javax.naming.Context.PROVIDER_URL, "iiop:///");
properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
"com.ibm.ejs.ns.jndi.CNInitialContextFactory");
return new InitialContext(properties);
}
The same method developed for JBoss would be different:
public static Context getInitialContext( )
throws javax.naming.NamingException {
Properties p = new Properties( );
p.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jnp.interfaces.NamingContextFactory");
p.put(Context.URL_PKG_PREFIXES,
" org.jboss.naming:org.jnp.interfaces");
p.put(Context.PROVIDER_URL, "jnp://localhost:1099");
return new javax.naming.InitialContext(p);
}
E' probabile che non abbia il package che mi hai chiesto prima, se esso è compreso in JBoss. Questo perchè io non ho installato JBoss!
Grazie dell'interessamento comunque!