当前位置: 首页>>代码示例>>Java>>正文


Java FactoryEnumeration类代码示例

本文整理汇总了Java中com.sun.naming.internal.FactoryEnumeration的典型用法代码示例。如果您正苦于以下问题:Java FactoryEnumeration类的具体用法?Java FactoryEnumeration怎么用?Java FactoryEnumeration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


FactoryEnumeration类属于com.sun.naming.internal包,在下文中一共展示了FactoryEnumeration类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createObjectFromFactories

import com.sun.naming.internal.FactoryEnumeration; //导入依赖的package包/类
private static Object createObjectFromFactories(Object obj, Name name,
        Context nameCtx, Hashtable<?,?> environment, Attributes attrs)
    throws Exception {

    FactoryEnumeration factories = ResourceManager.getFactories(
        Context.OBJECT_FACTORIES, environment, nameCtx);

    if (factories == null)
        return null;

    ObjectFactory factory;
    Object answer = null;
    // Try each factory until one succeeds
    while (answer == null && factories.hasMore()) {
        factory = (ObjectFactory)factories.next();
        if (factory instanceof DirObjectFactory) {
            answer = ((DirObjectFactory)factory).
                getObjectInstance(obj, name, nameCtx, environment, attrs);
        } else {
            answer =
                factory.getObjectInstance(obj, name, nameCtx, environment);
        }
    }
    return answer;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:DirectoryManager.java

示例2: createObjectFromFactories

import com.sun.naming.internal.FactoryEnumeration; //导入依赖的package包/类
/**
 * Creates an object using the factories specified in the
 * <tt>Context.OBJECT_FACTORIES</tt> property of the environment
 * or of the provider resource file associated with <tt>nameCtx</tt>.
 *
 * @return factory created; null if cannot create
 */
private static Object createObjectFromFactories(Object obj, Name name,
        Context nameCtx, Hashtable<?,?> environment) throws Exception {

    FactoryEnumeration factories = ResourceManager.getFactories(
        Context.OBJECT_FACTORIES, environment, nameCtx);

    if (factories == null)
        return null;

    // Try each factory until one succeeds
    ObjectFactory factory;
    Object answer = null;
    while (answer == null && factories.hasMore()) {
        factory = (ObjectFactory)factories.next();
        answer = factory.getObjectInstance(obj, name, nameCtx, environment);
    }
    return answer;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:NamingManager.java

示例3: createObjectFromFactories

import com.sun.naming.internal.FactoryEnumeration; //导入依赖的package包/类
/**
 * Creates an object using the factories specified in the
 * {@code Context.OBJECT_FACTORIES} property of the environment
 * or of the provider resource file associated with {@code nameCtx}.
 *
 * @return factory created; null if cannot create
 */
private static Object createObjectFromFactories(Object obj, Name name,
        Context nameCtx, Hashtable<?,?> environment) throws Exception {

    FactoryEnumeration factories = ResourceManager.getFactories(
        Context.OBJECT_FACTORIES, environment, nameCtx);

    if (factories == null)
        return null;

    // Try each factory until one succeeds
    ObjectFactory factory;
    Object answer = null;
    while (answer == null && factories.hasMore()) {
        factory = (ObjectFactory)factories.next();
        answer = factory.getObjectInstance(obj, name, nameCtx, environment);
    }
    return answer;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:26,代码来源:NamingManager.java

示例4: createObjectFromFactories

import com.sun.naming.internal.FactoryEnumeration; //导入依赖的package包/类
private static Object createObjectFromFactories(Object obj, Name name,
        Context nameCtx, Hashtable environment, Attributes attrs)
    throws Exception {

    FactoryEnumeration factories = ResourceManager.getFactories(
        Context.OBJECT_FACTORIES, environment, nameCtx);

    if (factories == null)
        return null;

    ObjectFactory factory;
    Object answer = null;
    // Try each factory until one succeeds
    while (answer == null && factories.hasMore()) {
        factory = (ObjectFactory)factories.next();
        if (factory instanceof DirObjectFactory) {
            answer = ((DirObjectFactory)factory).
                getObjectInstance(obj, name, nameCtx, environment, attrs);
        } else {
            answer =
                factory.getObjectInstance(obj, name, nameCtx, environment);
        }
    }
    return answer;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:26,代码来源:DirectoryManager.java

示例5: createObjectFromFactories

import com.sun.naming.internal.FactoryEnumeration; //导入依赖的package包/类
/**
 * Creates an object using the factories specified in the
 * <tt>Context.OBJECT_FACTORIES</tt> property of the environment
 * or of the provider resource file associated with <tt>nameCtx</tt>.
 *
 * @return factory created; null if cannot create
 */
private static Object createObjectFromFactories(Object obj, Name name,
        Context nameCtx, Hashtable environment) throws Exception {

    FactoryEnumeration factories = ResourceManager.getFactories(
        Context.OBJECT_FACTORIES, environment, nameCtx);

    if (factories == null)
        return null;

    // Try each factory until one succeeds
    ObjectFactory factory;
    Object answer = null;
    while (answer == null && factories.hasMore()) {
        factory = (ObjectFactory)factories.next();
        answer = factory.getObjectInstance(obj, name, nameCtx, environment);
    }
    return answer;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:26,代码来源:NamingManager.java

示例6: getControlInstance

import com.sun.naming.internal.FactoryEnumeration; //导入依赖的package包/类
/**
  * Creates a control using known control factories.
  * <p>
  * The following rule is used to create the control:
  *<ul>
  * <li> Use the control factories specified in
  *    the <tt>LdapContext.CONTROL_FACTORIES</tt> property of the
  *    environment, and of the provider resource file associated with
  *    <tt>ctx</tt>, in that order.
  *    The value of this property is a colon-separated list of factory
  *    class names that are tried in order, and the first one that succeeds
  *    in creating the control is the one used.
  *    If none of the factories can be loaded,
  *    return <code>ctl</code>.
  *    If an exception is encountered while creating the control, the
  *    exception is passed up to the caller.
  *</ul>
  * <p>
  * Note that a control factory
  * must be public and must have a public constructor that accepts no arguments.
  * <p>
  * @param ctl The non-null control object containing the OID and BER data.
  * @param ctx The possibly null context in which the control is being created.
  * If null, no such information is available.
  * @param env The possibly null environment of the context. This is used
  * to find the value of the <tt>LdapContext.CONTROL_FACTORIES</tt> property.
  * @return A control object created using <code>ctl</code>; or
  *         <code>ctl</code> if a control object cannot be created using
  *         the algorithm described above.
  * @exception NamingException if a naming exception was encountered
  *         while attempting to create the control object.
  *         If one of the factories accessed throws an
  *         exception, it is propagated up to the caller.
  * If an error was encountered while loading
  * and instantiating the factory and object classes, the exception
  * is wrapped inside a <tt>NamingException</tt> and then rethrown.
  */
public static Control getControlInstance(Control ctl, Context ctx,
                                         Hashtable<?,?> env)
    throws NamingException {

    // Get object factories list from environment properties or
    // provider resource file.
    FactoryEnumeration factories = ResourceManager.getFactories(
        LdapContext.CONTROL_FACTORIES, env, ctx);

    if (factories == null) {
        return ctl;
    }

    // Try each factory until one succeeds
    Control answer = null;
    ControlFactory factory;
    while (answer == null && factories.hasMore()) {
        factory = (ControlFactory)factories.next();
        answer = factory.getControlInstance(ctl);
    }

    return (answer != null)? answer : ctl;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:61,代码来源:ControlFactory.java

示例7: getControlInstance

import com.sun.naming.internal.FactoryEnumeration; //导入依赖的package包/类
/**
  * Creates a control using known control factories.
  * <p>
  * The following rule is used to create the control:
  *<ul>
  * <li> Use the control factories specified in
  *    the {@code LdapContext.CONTROL_FACTORIES} property of the
  *    environment, and of the provider resource file associated with
  *    {@code ctx}, in that order.
  *    The value of this property is a colon-separated list of factory
  *    class names that are tried in order, and the first one that succeeds
  *    in creating the control is the one used.
  *    If none of the factories can be loaded,
  *    return {@code ctl}.
  *    If an exception is encountered while creating the control, the
  *    exception is passed up to the caller.
  *</ul>
  * <p>
  * Note that a control factory must be public and must have a public
  * constructor that accepts no arguments.
  * In cases where the factory is in a named module then it must be in a
  * package which is exported by that module to the {@code java.naming}
  * module.
  *
  * @param ctl The non-null control object containing the OID and BER data.
  * @param ctx The possibly null context in which the control is being created.
  * If null, no such information is available.
  * @param env The possibly null environment of the context. This is used
  * to find the value of the {@code LdapContext.CONTROL_FACTORIES} property.
  * @return A control object created using {@code ctl}; or
  *         {@code ctl} if a control object cannot be created using
  *         the algorithm described above.
  * @exception NamingException if a naming exception was encountered
  *         while attempting to create the control object.
  *         If one of the factories accessed throws an
  *         exception, it is propagated up to the caller.
  * If an error was encountered while loading
  * and instantiating the factory and object classes, the exception
  * is wrapped inside a {@code NamingException} and then rethrown.
  */
public static Control getControlInstance(Control ctl, Context ctx,
                                         Hashtable<?,?> env)
    throws NamingException {

    // Get object factories list from environment properties or
    // provider resource file.
    FactoryEnumeration factories = ResourceManager.getFactories(
        LdapContext.CONTROL_FACTORIES, env, ctx);

    if (factories == null) {
        return ctl;
    }

    // Try each factory until one succeeds
    Control answer = null;
    ControlFactory factory;
    while (answer == null && factories.hasMore()) {
        factory = (ControlFactory)factories.next();
        answer = factory.getControlInstance(ctl);
    }

    return (answer != null)? answer : ctl;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:64,代码来源:ControlFactory.java


注:本文中的com.sun.naming.internal.FactoryEnumeration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。