Java Code Examples for javax.naming.spi.NamingManager#getStateToBind()
The following examples show how to use
javax.naming.spi.NamingManager#getStateToBind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistryContext.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 2
Source File: LocalContext.java From unitime with Apache License 2.0 | 6 votes |
@Override public void rebind(Name name, Object obj) throws NamingException { if (name.isEmpty()) throw new InvalidNameException("Cannot bind empty name"); Name nm = getMyComponents(name); String atom = nm.get(0); if (nm.size() == 1) { obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv); iBindings.put(atom, obj); } else { Object inter = iBindings.get(atom); if (!(inter instanceof Context)) throw new NotContextException(atom + " does not name a context"); ((Context) inter).rebind(nm.getSuffix(1), obj); } }
Example 3
Source File: LocalContext.java From unitime with Apache License 2.0 | 6 votes |
@Override public void bind(Name name, Object obj) throws NamingException { if (name.isEmpty()) { throw new InvalidNameException("Cannot bind empty name"); } Name nm = getMyComponents(name); String atom = nm.get(0); Object inter = iBindings.get(atom); if (nm.size() == 1) { if (inter != null) throw new NameAlreadyBoundException("Use rebind to override"); obj = NamingManager.getStateToBind(obj, new CompositeName().add(atom), this, iEnv); iBindings.put(atom, obj); } else { if (!(inter instanceof Context)) throw new NotContextException(atom + " does not name a context"); ((Context) inter).bind(nm.getSuffix(1), obj); } }
Example 4
Source File: RegistryContext.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 5
Source File: RegistryContext.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 6
Source File: RegistryContext.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 7
Source File: RegistryContext.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 8
Source File: RegistryContext.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 9
Source File: RegistryContext.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 10
Source File: RegistryContext.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 11
Source File: RegistryContext.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 12
Source File: RegistryContext.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 13
Source File: RegistryContext.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 14
Source File: RegistryContext.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 15
Source File: RegistryContext.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Encodes an object prior to binding it in the registry. First, * NamingManager.getStateToBind() is invoked. If the resulting * object is Remote, it is returned. If it is a Reference or * Referenceable, the reference is wrapped in a Remote object. * Otherwise, an exception is thrown. * * @param name The object's name relative to this context. */ private Remote encodeObject(Object obj, Name name) throws NamingException, RemoteException { obj = NamingManager.getStateToBind(obj, name, this, environment); if (obj instanceof Remote) { return (Remote)obj; } if (obj instanceof Reference) { return (new ReferenceWrapper((Reference)obj)); } if (obj instanceof Referenceable) { return (new ReferenceWrapper(((Referenceable)obj).getReference())); } throw (new IllegalArgumentException( "RegistryContext: " + "object to bind must be Remote, Reference, or Referenceable")); }
Example 16
Source File: NamingContext.java From Tomcat8-Source-Read with MIT License | 4 votes |
/** * Binds a name to an object. All intermediate contexts and the target * context (that named by all but terminal atomic component of the name) * must already exist. * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @param rebind if true, then perform a rebind (ie, overwrite) * @exception NameAlreadyBoundException if name is already bound * @exception javax.naming.directory.InvalidAttributesException if object * did not supply all mandatory attributes * @exception NamingException if a naming exception is encountered */ protected void bind(Name name, Object obj, boolean rebind) throws NamingException { if (!checkWritable()) { return; } while ((!name.isEmpty()) && (name.get(0).length() == 0)) name = name.getSuffix(1); if (name.isEmpty()) throw new NamingException (sm.getString("namingContext.invalidName")); NamingEntry entry = bindings.get(name.get(0)); if (name.size() > 1) { if (entry == null) { throw new NameNotFoundException(sm.getString( "namingContext.nameNotBound", name, name.get(0))); } if (entry.type == NamingEntry.CONTEXT) { if (rebind) { ((Context) entry.value).rebind(name.getSuffix(1), obj); } else { ((Context) entry.value).bind(name.getSuffix(1), obj); } } else { throw new NamingException (sm.getString("namingContext.contextExpected")); } } else { if ((!rebind) && (entry != null)) { throw new NameAlreadyBoundException (sm.getString("namingContext.alreadyBound", name.get(0))); } else { // Getting the type of the object and wrapping it within a new // NamingEntry Object toBind = NamingManager.getStateToBind(obj, name, this, env); if (toBind instanceof Context) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.CONTEXT); } else if (toBind instanceof LinkRef) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.LINK_REF); } else if (toBind instanceof Reference) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else if (toBind instanceof Referenceable) { toBind = ((Referenceable) toBind).getReference(); entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else { entry = new NamingEntry(name.get(0), toBind, NamingEntry.ENTRY); } bindings.put(name.get(0), entry); } } }
Example 17
Source File: NamingContext.java From Tomcat7.0.67 with Apache License 2.0 | 4 votes |
/** * Binds a name to an object. All intermediate contexts and the target * context (that named by all but terminal atomic component of the name) * must already exist. * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @param rebind if true, then perform a rebind (ie, overwrite) * @exception NameAlreadyBoundException if name is already bound * @exception javax.naming.directory.InvalidAttributesException if object * did not supply all mandatory attributes * @exception NamingException if a naming exception is encountered */ protected void bind(Name name, Object obj, boolean rebind) throws NamingException { if (!checkWritable()) { return; } while ((!name.isEmpty()) && (name.get(0).length() == 0)) name = name.getSuffix(1); if (name.isEmpty()) throw new NamingException (sm.getString("namingContext.invalidName")); NamingEntry entry = bindings.get(name.get(0)); if (name.size() > 1) { if (entry == null) { throw new NameNotFoundException(sm.getString( "namingContext.nameNotBound", name, name.get(0))); } if (entry.type == NamingEntry.CONTEXT) { if (rebind) { ((Context) entry.value).rebind(name.getSuffix(1), obj); } else { ((Context) entry.value).bind(name.getSuffix(1), obj); } } else { throw new NamingException (sm.getString("namingContext.contextExpected")); } } else { if ((!rebind) && (entry != null)) { throw new NameAlreadyBoundException (sm.getString("namingContext.alreadyBound", name.get(0))); } else { // Getting the type of the object and wrapping it within a new // NamingEntry Object toBind = NamingManager.getStateToBind(obj, name, this, env); if (toBind instanceof Context) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.CONTEXT); } else if (toBind instanceof LinkRef) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.LINK_REF); } else if (toBind instanceof Reference) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else if (toBind instanceof Referenceable) { toBind = ((Referenceable) toBind).getReference(); entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else { entry = new NamingEntry(name.get(0), toBind, NamingEntry.ENTRY); } bindings.put(name.get(0), entry); } } }
Example 18
Source File: NamingContext.java From tomcatsrc with Apache License 2.0 | 4 votes |
/** * Binds a name to an object. All intermediate contexts and the target * context (that named by all but terminal atomic component of the name) * must already exist. * * @param name the name to bind; may not be empty * @param obj the object to bind; possibly null * @param rebind if true, then perform a rebind (ie, overwrite) * @exception NameAlreadyBoundException if name is already bound * @exception javax.naming.directory.InvalidAttributesException if object * did not supply all mandatory attributes * @exception NamingException if a naming exception is encountered */ protected void bind(Name name, Object obj, boolean rebind) throws NamingException { if (!checkWritable()) { return; } while ((!name.isEmpty()) && (name.get(0).length() == 0)) name = name.getSuffix(1); if (name.isEmpty()) throw new NamingException (sm.getString("namingContext.invalidName")); NamingEntry entry = bindings.get(name.get(0)); if (name.size() > 1) { if (entry == null) { throw new NameNotFoundException(sm.getString( "namingContext.nameNotBound", name, name.get(0))); } if (entry.type == NamingEntry.CONTEXT) { if (rebind) { ((Context) entry.value).rebind(name.getSuffix(1), obj); } else { ((Context) entry.value).bind(name.getSuffix(1), obj); } } else { throw new NamingException (sm.getString("namingContext.contextExpected")); } } else { if ((!rebind) && (entry != null)) { throw new NameAlreadyBoundException (sm.getString("namingContext.alreadyBound", name.get(0))); } else { // Getting the type of the object and wrapping it within a new // NamingEntry Object toBind = NamingManager.getStateToBind(obj, name, this, env); if (toBind instanceof Context) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.CONTEXT); } else if (toBind instanceof LinkRef) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.LINK_REF); } else if (toBind instanceof Reference) { entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else if (toBind instanceof Referenceable) { toBind = ((Referenceable) toBind).getReference(); entry = new NamingEntry(name.get(0), toBind, NamingEntry.REFERENCE); } else { entry = new NamingEntry(name.get(0), toBind, NamingEntry.ENTRY); } bindings.put(name.get(0), entry); } } }