...
Code Block | ||
---|---|---|
| ||
public class MyLocator {
private final Context context;
public MyLocator(String commonPrefix) throws NamingException {
this(null);
}
public MyLocator(String commonPrefix) throws NamingException {
Properties properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.client.RemoteInitialContextFactory");
properties.put(Context.PROVIDER_URL, "ejbd://localhost:4201/");
this.context = new InitialContext(properties);
}
public Object lookup(String name) {
try {
if (commonPrefix != null) name = commonPrefix + "/" +name;
return context.lookup(name);
} catch (NamingException e) {
throw new IllegalArgumentException(e);
}
}
}
|
...