// parent
if (bindName == null)
this.parent.bind(name, value, allowOverwrites);
// If empty name, complain - we should have a child name here
else if (bindName.isEmpty())
throw new NamingException(ContainerJNDIManager.JNDI_RESOURCES.getString(
"WinstoneContext.AlreadyExists", name.toString()));
else if (bindName.size() > 1) {
Object ctx = lookup(bindName.get(0));
if (!(ctx instanceof Context))
throw new NotContextException(ContainerJNDIManager.JNDI_RESOURCES.getString(
"WinstoneContext.NotContext", new String[] {
bindName.get(0), ctx.getClass().getName() }));
else if (ctx == null)
throw new NameNotFoundException(ContainerJNDIManager.JNDI_RESOURCES.getString(
"WinstoneContext.NameNotFound", bindName.get(0)));
else
try {
if (allowOverwrites)
((Context) ctx).rebind(bindName.getSuffix(1), value);
else
((Context) ctx).bind(bindName.getSuffix(1), value);
} finally {
((Context) ctx).close();
}
} else if ((!allowOverwrites) && this.bindings.get(name.get(0)) != null)
throw new NamingException(ContainerJNDIManager.JNDI_RESOURCES.getString(
"WinstoneContext.AlreadyExists", name.toString()));
else {
value = NamingManager.getStateToBind(value, new CompositeName()
.add(bindName.get(0)), this, this.environment);
synchronized (this.contextLock) {