try {
// Add a binding.
ctx.bind("Name", new SampleObjectImpl());
// Replace a binding.
ctx.rebind("Name", new SampleObjectImpl());
// Remove a binding.
ctx.unbind("Name");
// Rename a binding.
ctx.rename("Name", "NewSample");
} catch (NamingException e) {
}
Tuesday, November 27, 2007
Monday, November 26, 2007
Using a URL as a Name to the Initial Context
This example looks up an object from the naming service by using a URL as a name.
try {
Object obj = new InitialContext().lookup("iiop://localhost/Sample");
} catch (NamingException e) {
}
try {
Object obj = new InitialContext().lookup("iiop://localhost/Sample");
} catch (NamingException e) {
}
Wednesday, November 21, 2007
Looking Up an Object from the Naming Service
This example looks up an object from the naming service.
try {
Object obj = ctx.lookup("Sample");
} catch (NamingException e) {
}
try {
Object obj = ctx.lookup("Sample");
} catch (NamingException e) {
}
Creating an Initial Context to the Naming Service
This example uses the JNDI/COS naming service provider to connect to the local tnameserv.
String url = "iiop://localhost/";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, url);
try {
Context ctx = new InitialContext(env);
} catch (NamingException e) {
}
String url = "iiop://localhost/";
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory");
env.put(Context.PROVIDER_URL, url);
try {
Context ctx = new InitialContext(env);
} catch (NamingException e) {
}
Thursday, November 15, 2007
Listing a Context in the Naming Service
This example lists a context in the naming service.
try {
NamingEnumeration enum = ctx.list("child");
while (enum.hasMore()) {
NameClassPair entry = (NameClassPair)enum.next();
process(entry);
}
} catch (NamingException e) {
}
try {
NamingEnumeration enum = ctx.list("child");
while (enum.hasMore()) {
NameClassPair entry = (NameClassPair)enum.next();
process(entry);
}
} catch (NamingException e) {
}
Subscribe to:
Posts (Atom)