本文整理汇总了Java中javax.naming.spi.DirStateFactory.Result类的典型用法代码示例。如果您正苦于以下问题:Java Result类的具体用法?Java Result怎么用?Java Result使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Result类属于javax.naming.spi.DirStateFactory包,在下文中一共展示了Result类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getStateToBind
import javax.naming.spi.DirStateFactory.Result; //导入依赖的package包/类
/**
* Get the state of an Object. Returns a <code>DirStateFactory</code>.
* Result which cannot be null. It contains the attributes and object to be
* bound, either of which may be null. Once returned the caller is the owner
* of it. The behaviour is like that for the <code>getStateToBind</code>
* method of <code>NamingManager</code> however it should be noted that
* the intermediate state factory may be of type
* <code>DirStateFactory</code> rather than just <code>StateFactory</code>
* in which case it should also use the supplied <code>Attributes</code>
* when getting the state.
*
* @param o
* An object which may provide reference or location information.
* May be null.
* @param n
* The name of the <code>Object</code> relative to the default
* initial context (or relative to the Context c if it is
* supplied)
* @param c
* The <code>Context</code> to which the <code>Name</code> is
* relative
* @param h
* a <code>Hashtable</code> containing environment properties
* and values - may be null
* @param a
* <code>Attributes</code> - if some or all of the attributes
* of <code>Object o</code> are already known they can be
* supplied so that the factory does not have to do the work of
* looking them up.
* @return the state of the object
* @throws NamingException
* if one is encountered
*/
public static DirStateFactory.Result getStateToBind(Object o, Name n,
Context c, Hashtable<?, ?> h, Attributes a) throws NamingException {
// obtain state factories from hashtable and service provider resource
// file
String fnames[] = EnvironmentReader
.getFactoryNamesFromEnvironmentAndProviderResource(h, c,
Context.STATE_FACTORIES);
for (String element : fnames) {
// new factory instance by its class name
StateFactory factory = null;
try {
factory = (StateFactory) classForName(element).newInstance();
} catch (Exception e) {
continue;
}
if (factory instanceof DirStateFactory) {
// try obtain state using the DirStateFactory
Result r = ((DirStateFactory) factory).getStateToBind(o, n, c,
h, a);
// if the result is not null, return it
if (null != r) {
return r;
}
} else {
// try obtain state using the StateFactory
Object state = factory.getStateToBind(o, n, c, h);
// if a state obtained successfully, return it
if (null != state) {
return new Result(state, a);
}
}
}
// all factories failed, return the input argument o
return new Result(o, a);
}
开发者ID:shannah,项目名称:cn1,代码行数:72,代码来源:DirectoryManager.java
示例2: getStateToBind
import javax.naming.spi.DirStateFactory.Result; //导入依赖的package包/类
/**
* Get the state of an Object. Returns a <code>DirStateFactory</code>.
* Result which cannot be null. It contains the attributes and object to be
* bound, either of which may be null. Once returned the caller is the owner
* of it. The behaviour is like that for the <code>getStateToBind</code>
* method of <code>NamingManager</code> however it should be noted that
* the intermediate state factory may be of type
* <code>DirStateFactory</code> rather than just <code>StateFactory</code>
* in which case it should also use the supplied <code>Attributes</code>
* when getting the state.
*
* @param o
* An object which may provide reference or location information.
* May be null.
* @param n
* The name of the <code>Object</code> relative to the default
* initial context (or relative to the Context c if it is
* supplied)
* @param c
* The <code>Context</code> to which the <code>Name</code> is
* relative
* @param h
* a <code>Hashtable</code> containing environment properties
* and values - may be null
* @param a
* <code>Attributes</code> - if some or all of the attributes
* of <code>Object o</code> are already known they can be
* supplied so that the factory does not have to do the work of
* looking them up.
* @return the state of the object
* @throws NamingException
* if one is encountered
*/
public static Result getStateToBind(Object o, Name n,
Context c, Hashtable<?, ?> h, Attributes a) throws NamingException {
// obtain state factories from hashtable and service provider resource
// file
String fnames[] = EnvironmentReader
.getFactoryNamesFromEnvironmentAndProviderResource(h, c,
Context.STATE_FACTORIES);
for (String element : fnames) {
// new factory instance by its class name
StateFactory factory = null;
try {
factory = (StateFactory) classForName(element).newInstance();
} catch (Exception e) {
continue;
}
if (factory instanceof DirStateFactory) {
// try obtain state using the DirStateFactory
Result r = ((DirStateFactory) factory).getStateToBind(o, n, c,
h, a);
// if the result is not null, return it
if (null != r) {
return r;
}
} else {
// try obtain state using the StateFactory
Object state = factory.getStateToBind(o, n, c, h);
// if a state obtained successfully, return it
if (null != state) {
return new Result(state, a);
}
}
}
// all factories failed, return the input argument o
return new Result(o, a);
}
开发者ID:nextopio,项目名称:nextop-client,代码行数:72,代码来源:DirectoryManager.java
示例3: bind
import javax.naming.spi.DirStateFactory.Result; //导入依赖的package包/类
public void bind(Name name, Object obj, Attributes attributes)
throws NamingException {
checkName(name);
if (hasMultiNamingSpace(name)) {
/*
* multi ns, find next ns context, delegate operation to the next
* contex
*/
DirContext nns = (DirContext) findNnsContext(name);
Name remainingName = name.getSuffix(1);
nns.bind(remainingName, attributes);
return;
}
/*
* there is only one ldap ns
*/
if (obj == null && attributes == null) {
// ldap.2E=cannot bind null object without attributes
throw new IllegalArgumentException(Messages.getString("ldap.2E")); //$NON-NLS-1$
}
if (obj == null) {
createSubcontext(name, attributes);
return;
}
Result result = DirectoryManager.getStateToBind(obj, name, this, env,
attributes);
Object o = result.getObject();
Attributes attrs = null;
if (o instanceof Reference) {
attrs = convertRefToAttribute((Reference) o);
} else if (o instanceof Referenceable) {
attrs = convertRefToAttribute(((Referenceable) o).getReference());
} else if (o instanceof Serializable) {
attrs = convertSerialToAttribute((Serializable) o);
} else if (o instanceof DirContext) {
DirContext cxt = (DirContext) o;
attrs = cxt.getAttributes("");
} else {
throw new IllegalArgumentException(Messages.getString("ldap.24")); //$NON-NLS-1$
}
NamingEnumeration<? extends Attribute> enu = attrs.getAll();
if (result.getAttributes() != null) {
Attributes resultAttributes = result.getAttributes();
while (enu.hasMore()) {
Attribute element = enu.next();
if (element.getID().equalsIgnoreCase("objectClass")) {
element = mergeAttribute(resultAttributes
.get("objectClass"), element);
Attribute oc = resultAttributes.get("objectClass");
if (oc != null) {
if (!oc.contains("javaContainer") && oc.size() > 0) {
element.remove("javaContainer");
}
}
resultAttributes.put(element);
} else if (resultAttributes.get(element.getID()) == null) {
resultAttributes.put(element);
}
}
createSubcontext(name, resultAttributes);
} else {
createSubcontext(name, attrs);
}
}
开发者ID:shannah,项目名称:cn1,代码行数:74,代码来源:LdapContextImpl.java
示例4: getStateToBind
import javax.naming.spi.DirStateFactory.Result; //导入依赖的package包/类
/**
* Get the state of an Object.
* Returns a <code>DirStateFactory</code>. Result which cannot be null. It
* contains the attributes and object to be bound, either of which may be
* null. Once returned the caller is the owner of it.
* The behaviour is like that for the <code>getStateToBind</code> method of
* <code>NamingManager</code> however it should be noted that the
* intermediate state factory may be of type <code>DirStateFactory</code>
* rather than just <code>StateFactory</code> in which case it should also
* use the supplied <code>Attributes</code> when getting the state.
*
* @param o An object which may provide reference or location information.
* May be null.
* @param n The name of the <code>Object</code> relative to the default
* initial context (or relative to the Context c if it is supplied)
* @param c The <code>Context</code> to which the <code>Name</code> is
* relative
* @param h a <code>Hashtable</code> containing environment properties and
* values - may be null
* @param a <code>Attributes</code> - if some or all of the attributes of
* <code>Object o</code> are already known they can be supplied so
* that the factory does not have to do the work of looking them up.
* @return the state of the object
* @throws NamingException if one is encountered
*/
public static DirStateFactory.Result getStateToBind(
Object o,
Name n,
Context c,
Hashtable<?, ?> h,
Attributes a)
throws NamingException {
// obtain state factories from hashtable and service provider resource file
String fnames[] =
EnvironmentReader.getFactoryNamesFromEnvironmentAndProviderResource(
h,
c,
Context.STATE_FACTORIES);
for (String element : fnames) {
// new factory instance by its class name
StateFactory factory = null;
try {
factory = (StateFactory) classForName(element).newInstance();
} catch (Exception e) {
continue;
}
if (factory instanceof DirStateFactory) {
// try obtain state using the DirStateFactory
Result r = ((DirStateFactory) factory).getStateToBind(o, n, c, h, a);
// if the result is not null, return it
if (null != r) {
return r;
}
} else {
// try obtain state using the StateFactory
Object state = factory.getStateToBind(o, n, c, h);
// if a state obtained successfully, return it
if (null != state) {
return new Result(state, a);
}
}
}
// all factories failed, return the input argument o
return new Result(o, a);
}
开发者ID:freeVM,项目名称:freeVM,代码行数:69,代码来源:DirectoryManager.java
注:本文中的javax.naming.spi.DirStateFactory.Result类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论