本文整理汇总了Java中javax.naming.Name.size方法的典型用法代码示例。如果您正苦于以下问题:Java Name.size方法的具体用法?Java Name.size怎么用?Java Name.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.Name
的用法示例。
在下文中一共展示了Name.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNameParser
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Retrieves the parser associated with the named context. In a federation
* of namespaces, different naming systems will parse names differently.
* This method allows an application to get a parser for parsing names into
* their atomic components using the naming convention of a particular
* naming system. Within any single naming system, NameParser objects
* returned by this method must be equal (using the equals() test).
*
* @param name
* the name of the context from which to get the parser
* @return a name parser that can parse compound names into their atomic
* components
* @exception NamingException
* if a naming exception is encountered
*/
@Override
public NameParser getNameParser(Name name) throws NamingException {
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty())
return nameParser;
if (name.size() > 1) {
Object obj = bindings.get(name.get(0));
if (obj instanceof Context) {
return ((Context) obj).getNameParser(name.getSuffix(1));
} else {
throw new NotContextException(sm.getString("namingContext.contextExpected"));
}
}
return nameParser;
}
示例2: getNameParser
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Retrieves the parser associated with the named context. In a
* federation of namespaces, different naming systems will parse names
* differently. This method allows an application to get a parser for
* parsing names into their atomic components using the naming convention
* of a particular naming system. Within any single naming system,
* NameParser objects returned by this method must be equal (using the
* equals() test).
*
* @param name the name of the context from which to get the parser
* @return a name parser that can parse compound names into their atomic
* components
* @exception NamingException if a naming exception is encountered
*/
public NameParser getNameParser(Name name)
throws NamingException {
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty())
return nameParser;
if (name.size() > 1) {
Object obj = bindings.get(name.get(0));
if (obj instanceof Context) {
return ((Context) obj).getNameParser(name.getSuffix(1));
} else {
throw new NotContextException
(sm.getString("namingContext.contextExpected"));
}
}
return nameParser;
}
示例3: rebind
import javax.naming.Name; //导入方法依赖的package包/类
@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);
}
}
示例4: destroySubcontext
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Destroys the named context and removes it from the namespace. Any
* attributes associated with the name are also removed. Intermediate
* contexts are not destroyed.
* <p>
* This method is idempotent. It succeeds even if the terminal atomic
* name is not bound in the target context, but throws
* NameNotFoundException if any of the intermediate contexts do not exist.
*
* In a federated naming system, a context from one naming system may be
* bound to a name in another. One can subsequently look up and perform
* operations on the foreign context using a composite name. However, an
* attempt destroy the context using this composite name will fail with
* NotContextException, because the foreign context is not a "subcontext"
* of the context in which it is bound. Instead, use unbind() to remove
* the binding of the foreign context. Destroying the foreign context
* requires that the destroySubcontext() be performed on a context from
* the foreign context's "native" naming system.
*
* @param name the name of the context to be destroyed; may not be empty
* @exception NameNotFoundException if an intermediate context does not
* exist
* @exception NotContextException if the name is bound but does not name
* a context, or does not name a context of the appropriate type
*/
@Override
public void destroySubcontext(Name name) 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 (entry == null) {
throw new NameNotFoundException
(sm.getString("namingContext.nameNotBound", name, name.get(0)));
}
if (name.size() > 1) {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).destroySubcontext(name.getSuffix(1));
} else {
throw new NamingException
(sm.getString("namingContext.contextExpected"));
}
} else {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).close();
bindings.remove(name.get(0));
} else {
throw new NotContextException
(sm.getString("namingContext.contextExpected"));
}
}
}
示例5: unbind
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Unbinds the named object. Removes the terminal atomic name in name
* from the target context--that named by all but the terminal atomic
* part of name.
* <p>
* This method is idempotent. It succeeds even if the terminal atomic
* name is not bound in the target context, but throws
* NameNotFoundException if any of the intermediate contexts do not exist.
*
* @param name the name to bind; may not be empty
* @exception NameNotFoundException if an intermediate context does not
* exist
* @exception NamingException if a naming exception is encountered
*/
@Override
public void unbind(Name name) 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 (entry == null) {
throw new NameNotFoundException
(sm.getString("namingContext.nameNotBound", name, name.get(0)));
}
if (name.size() > 1) {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).unbind(name.getSuffix(1));
} else {
throw new NamingException
(sm.getString("namingContext.contextExpected"));
}
} else {
bindings.remove(name.get(0));
}
}
示例6: destroySubcontext
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Destroys the named context and removes it from the namespace. Any
* attributes associated with the name are also removed. Intermediate
* contexts are not destroyed.
* <p>
* This method is idempotent. It succeeds even if the terminal atomic
* name is not bound in the target context, but throws
* NameNotFoundException if any of the intermediate contexts do not exist.
*
* In a federated naming system, a context from one naming system may be
* bound to a name in another. One can subsequently look up and perform
* operations on the foreign context using a composite name. However, an
* attempt destroy the context using this composite name will fail with
* NotContextException, because the foreign context is not a "subcontext"
* of the context in which it is bound. Instead, use unbind() to remove
* the binding of the foreign context. Destroying the foreign context
* requires that the destroySubcontext() be performed on a context from
* the foreign context's "native" naming system.
*
* @param name the name of the context to be destroyed; may not be empty
* @exception NameNotFoundException if an intermediate context does not
* exist
* @exception NotContextException if the name is bound but does not name
* a context, or does not name a context of the appropriate type
*/
public void destroySubcontext(Name name)
throws NamingException {
checkWritable();
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty())
throw new NamingException
(sm.getString("namingContext.invalidName"));
NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
(sm.getString("namingContext.nameNotBound", name.get(0)));
}
if (name.size() > 1) {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).unbind(name.getSuffix(1));
} else {
throw new NamingException
(sm.getString("namingContext.contextExpected"));
}
} else {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).close();
bindings.remove(name.get(0));
} else {
throw new NotContextException
(sm.getString("namingContext.contextExpected"));
}
}
}
示例7: getParentGroupForGroup
import javax.naming.Name; //导入方法依赖的package包/类
@Override
public GroupBean getParentGroupForGroup(DirContext ctx, String groupID)
{
LDAPResult groupRes = ldap.getGroupResult(ctx, groupID, ldap.getGroupAttributes());
if( groupRes == null )
{
return null;
}
try
{
Name groupName = groupRes.getFullName();
int sz = groupName.size();
if( sz > 1 )
{
groupName.remove(sz - 1);
Attributes attributes = ctx.getAttributes(groupName);
Attribute attribute = attributes.get(LDAP.OBJECTCLASS);
if( attribute != null && attribute.contains(ldap.getGroupObject()) )
{
return ldap.getGroupBeanFromResult(groupRes);
}
}
}
catch( NamingException e )
{
LOGGER.error(e, e);
}
return null;
}
示例8: treeLookup
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Entry tree lookup.
*/
protected Entry treeLookup(Name name) {
if (name.isEmpty())
return entries;
Entry currentEntry = entries;
for (int i = 0; i < name.size(); i++) {
if (name.get(i).length() == 0)
continue;
currentEntry = currentEntry.getChild(name.get(i));
if (currentEntry == null)
return null;
}
return currentEntry;
}
示例9: unbind
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Unbinds the named object. Removes the terminal atomic name in name
* from the target context--that named by all but the terminal atomic
* part of name.
* <p>
* This method is idempotent. It succeeds even if the terminal atomic
* name is not bound in the target context, but throws
* NameNotFoundException if any of the intermediate contexts do not exist.
*
* @param name the name to bind; may not be empty
* @exception NameNotFoundException if an intermediate context does not
* exist
* @exception NamingException if a naming exception is encountered
*/
public void unbind(Name name)
throws NamingException {
checkWritable();
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty())
throw new NamingException
(sm.getString("namingContext.invalidName"));
NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
(sm.getString("namingContext.nameNotBound", name.get(0)));
}
if (name.size() > 1) {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).unbind(name.getSuffix(1));
} else {
throw new NamingException
(sm.getString("namingContext.contextExpected"));
}
} else {
bindings.remove(name.get(0));
}
}
示例10: destroySubcontext
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Destroys the named context and removes it from the namespace. Any
* attributes associated with the name are also removed. Intermediate
* contexts are not destroyed.
* <p>
* This method is idempotent. It succeeds even if the terminal atomic
* name is not bound in the target context, but throws
* NameNotFoundException if any of the intermediate contexts do not exist.
*
* In a federated naming system, a context from one naming system may be
* bound to a name in another. One can subsequently look up and perform
* operations on the foreign context using a composite name. However, an
* attempt destroy the context using this composite name will fail with
* NotContextException, because the foreign context is not a "subcontext"
* of the context in which it is bound. Instead, use unbind() to remove
* the binding of the foreign context. Destroying the foreign context
* requires that the destroySubcontext() be performed on a context from
* the foreign context's "native" naming system.
*
* @param name the name of the context to be destroyed; may not be empty
* @exception NameNotFoundException if an intermediate context does not
* exist
* @exception NotContextException if the name is bound but does not name
* a context, or does not name a context of the appropriate type
*/
public void destroySubcontext(Name name)
throws NamingException {
checkWritable();
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty())
throw new NamingException
(sm.getString("namingContext.invalidName"));
NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
if (entry == null) {
throw new NameNotFoundException
(sm.getString("namingContext.nameNotBound", name.get(0)));
}
if (name.size() > 1) {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).unbind(name.getSuffix(1));
} else {
throw new NamingException
(sm.getString("namingContext.contextExpected"));
}
} else {
if (entry.type == NamingEntry.CONTEXT) {
((Context) entry.value).close();
bindings.remove(name.get(0));
} else {
throw new NotContextException
(sm.getString("namingContext.contextExpected"));
}
}
}
示例11: destroySubcontext
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Destroys subcontext with name name. The subcontext must be empty otherwise
* ContextNotEmptyException is thrown. Once a context is destroyed, the instance should not be
* used.
*
* @param name subcontext to destroy
* @throws NoPermissionException if this context has been destroyed.
* @throws InvalidNameException if name is empty or is CompositeName that spans more than one
* naming system.
* @throws ContextNotEmptyException if Context name is not empty.
* @throws NameNotFoundException if subcontext with name name can not be found.
* @throws NotContextException if name is not bound to instance of ContextImpl.
*
*/
public void destroySubcontext(Name name) throws NamingException {
checkIsDestroyed();
Name parsedName = getParsedName(name);
if (parsedName.size() == 0 || parsedName.get(0).length() == 0) {
throw new InvalidNameException(
LocalizedStrings.ContextImpl_NAME_CAN_NOT_BE_EMPTY.toLocalizedString());
}
String subContextName = parsedName.get(0);
Object boundObject = ctxMaps.get(subContextName);
if (boundObject == null) {
throw new NameNotFoundException(LocalizedStrings.ContextImpl_NAME_0_NOT_FOUND_IN_THE_CONTEXT
.toLocalizedString(subContextName));
}
if (!(boundObject instanceof ContextImpl)) {
throw new NotContextException();
}
ContextImpl contextToDestroy = (ContextImpl) boundObject;
if (parsedName.size() == 1) {
// Check if the Context to be destroyed is empty. Can not destroy
// non-empty Context.
if (contextToDestroy.ctxMaps.size() == 0) {
ctxMaps.remove(subContextName);
contextToDestroy.destroyInternal();
} else {
throw new ContextNotEmptyException(
LocalizedStrings.ContextImpl_CAN_NOT_DESTROY_NONEMPTY_CONTEXT.toLocalizedString());
}
} else {
// Let the subcontext destroy the context
((ContextImpl) boundObject).destroySubcontext(parsedName.getSuffix(1));
}
}
示例12: rebind
import javax.naming.Name; //导入方法依赖的package包/类
/**
* Rebinds object obj to name name . If there is existing binding it will be overwritten.
*
* @param name name of the object to rebind.
* @param obj object to add. Can be null.
* @throws NoPermissionException if this context has been destroyed
* @throws InvalidNameException if name is empty or is CompositeName that spans more than one
* naming system
* @throws NotContextException if name has more than one atomic name and intermediate context is
* not found
* @throws NamingException if any other naming error occurs
*
*/
public void rebind(Name name, Object obj) throws NamingException {
checkIsDestroyed();
Name parsedName = getParsedName(name);
if (parsedName.size() == 0 || parsedName.get(0).length() == 0) {
throw new InvalidNameException(
LocalizedStrings.ContextImpl_NAME_CAN_NOT_BE_EMPTY.toLocalizedString());
}
String nameToBind = parsedName.get(0);
if (parsedName.size() == 1) {
ctxMaps.put(nameToBind, obj);
} else {
Object boundObject = ctxMaps.get(nameToBind);
if (boundObject instanceof Context) {
/*
* Let the subcontext bind the object.
*/
((Context) boundObject).bind(parsedName.getSuffix(1), obj);
} else {
if (boundObject == null) {
// Create new subcontext and let it do the binding
Context sub = createSubcontext(nameToBind);
sub.bind(parsedName.getSuffix(1), obj);
} else {
throw new NotContextException(LocalizedStrings.ContextImpl_EXPECTED_CONTEXT_BUT_FOUND_0
.toLocalizedString(boundObject));
}
}
}
}
示例13: bind
import javax.naming.Name; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例14: bind
import javax.naming.Name; //导入方法依赖的package包/类
/**
* 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);
}
}
}
示例15: bind
import javax.naming.Name; //导入方法依赖的package包/类
/**
* 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 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 {
checkWritable();
while ((!name.isEmpty()) && (name.get(0).length() == 0))
name = name.getSuffix(1);
if (name.isEmpty())
throw new NamingException
(sm.getString("namingContext.invalidName"));
NamingEntry entry = (NamingEntry) bindings.get(name.get(0));
if (name.size() > 1) {
if (entry == null) {
throw new NameNotFoundException
(sm.getString("namingContext.nameNotBound", 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);
}
}
}