javax.naming.Reference.getAll()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(117)

本文整理了Java中javax.naming.Reference.getAll方法的一些代码示例,展示了Reference.getAll的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.getAll方法的具体详情如下:
包路径:javax.naming.Reference
类名称:Reference
方法名:getAll

Reference.getAll介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

public static Properties getProperties(Reference reference) {
 Properties properties = new Properties();
 for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {
   StringRefAddr addr = (StringRefAddr)iter.nextElement();
   properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent());
 }
 return properties;
}

代码示例来源:origin: com.zaxxer/HikariCP

@Override
synchronized public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
{
 // We only know how to deal with <code>javax.naming.Reference</code> that specify a class name of "javax.sql.DataSource"
 if (obj instanceof Reference && "javax.sql.DataSource".equals(((Reference) obj).getClassName())) {
   Reference ref = (Reference) obj;
   Set<String> hikariPropSet = PropertyElf.getPropertyNames(HikariConfig.class);
   Properties properties = new Properties();
   Enumeration<RefAddr> enumeration = ref.getAll();
   while (enumeration.hasMoreElements()) {
    RefAddr element = enumeration.nextElement();
    String type = element.getType();
    if (type.startsWith("dataSource.") || hikariPropSet.contains(type)) {
      properties.setProperty(type, element.getContent().toString());
    }
   }
   return createDataSource(properties, nameCtx);
 }
 return null;
}

代码示例来源:origin: internetarchive/heritrix3

/**
   * Testing code.
   * @param args Command line arguments.
   * @throws NullPointerException 
   * @throws MalformedObjectNameException 
   * @throws NamingException 
   * @throws InvalidNameException 
   */
  public static void main(String[] args)
  throws MalformedObjectNameException, NullPointerException,
  InvalidNameException, NamingException {
    final ObjectName on = new ObjectName("org.archive.crawler:" +
        "type=Service,name=Heritrix00,host=debord.archive.org");
    Context c = getSubContext(getCompoundName(on.getDomain()));
    CompoundName key = bindObjectName(c, on);
    Reference r = (Reference)c.lookup(key);
    for (Enumeration<RefAddr> e = r.getAll(); e.hasMoreElements();) {
      System.out.println(e.nextElement());
    }
    unbindObjectName(c, on);
  }
}

代码示例来源:origin: org.mongodb/mongo-java-driver

Enumeration<RefAddr> props = ((Reference) obj).getAll();

代码示例来源:origin: org.mongodb/mongo-java-driver

Enumeration<RefAddr> props = ((Reference) obj).getAll();

代码示例来源:origin: apache/activemq

for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {

代码示例来源:origin: camunda/camunda-bpm-platform

@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
  if ((obj == null) || !(obj instanceof Reference)) {
    return null;
  }
  Reference ref = (Reference) obj;
  Enumeration<RefAddr> refs = ref.getAll();
  String type = ref.getClassName();
  Object o = Class.forName(type).newInstance();
  while (refs.hasMoreElements()) {
    RefAddr addr = refs.nextElement();
    String param = addr.getType();
    String value = null;
    if (addr.getContent()!=null) {
      value = addr.getContent().toString();
    }
    if (setProperty(o, param, value,false)) {
    } else {
      log.debug("Property not configured["+param+"]. No setter found on["+o+"].");
    }
  }
  return o;
}

代码示例来源:origin: org.onehippo.cms7.hst.components/hst-session-pool

private Map<String, String> getConfigurationMap(Reference ref) {
  Map<String, String> configMap = new HashMap<String, String>();
  
  if (ref != null) {
    Enumeration<RefAddr> addrs = ref.getAll();
    
    while (addrs.hasMoreElements()) {
      RefAddr addr = (RefAddr) addrs.nextElement();
      String type = addr.getType();
      String value = (String) addr.getContent();
      configMap.put(type, value);
    }
  }
  
  return configMap;
}

代码示例来源:origin: apache/activemq-artemis

public static Properties getProperties(Reference reference) {
 Properties properties = new Properties();
 for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {
   StringRefAddr addr = (StringRefAddr)iter.nextElement();
   properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent());
 }
 return properties;
}

代码示例来源:origin: apache/activemq-artemis

public static Properties getProperties(Reference reference) {
 Properties properties = new Properties();
 for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {
   StringRefAddr addr = (StringRefAddr)iter.nextElement();
   properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent());
 }
 return properties;
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

public static Properties getProperties(Reference reference) {
 Properties properties = new Properties();
 for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {
   StringRefAddr addr = (StringRefAddr)iter.nextElement();
   properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent());
 }
 return properties;
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

public static Properties getProperties(Reference reference) {
 Properties properties = new Properties();
 for (Enumeration iter = reference.getAll(); iter.hasMoreElements();) {
   StringRefAddr addr = (StringRefAddr)iter.nextElement();
   properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent());
 }
 return properties;
}

代码示例来源:origin: org.everit.osgi.bundles/org.everit.osgi.bundles.net.sourceforge.jtds

private HashMap loadProps( Reference ref, String[] props )
{
 HashMap config = new HashMap();
 HashMap values = new HashMap();
 Enumeration c = ref.getAll();
 while( c.hasMoreElements() )
 {
   RefAddr ra = (RefAddr) c.nextElement();
   values.put( ra.getType().toLowerCase(), ra.getContent() );
 }
 for( int i = 0; i < props.length; i ++ )
 {
   String value = (String) values.get( props[i].toLowerCase() );
   value = value == null ? (String) values.get( Messages.get( props[i].toLowerCase() ) ) : value;
   if( value != null )
   {
    config.put( props[i], value );
   }
 }
 return config;
}

代码示例来源:origin: org.apache.sentry/sentry-shaded-miscellaneous

public Object getObjectInstance(Object object, Name name, Context context, Hashtable<?, ?> table) throws Exception {
  Reference ref = (Reference) object;
  Enumeration<RefAddr> addrs = ref.getAll();
  Properties props = new Properties();
  while (addrs.hasMoreElements()) {
    RefAddr addr = addrs.nextElement();
    if (addr.getType().equals("driverClassName")){
      Class.forName((String) addr.getContent());
    } else {
      props.put(addr.getType(), addr.getContent());
    }
  }        
  BoneCPConfig config = new BoneCPConfig(props);
  return new BoneCPDataSource(config);
}

代码示例来源:origin: org.nuxeo.ecm.platform/nuxeo-platform-notification-core

@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) {
  final Reference ref = (Reference) obj;
  if (!ref.getClassName().equals("javax.mail.Session"))
    return (null);
  final Properties properties = toProperties(ref.getAll());
  return AccessController.doPrivileged((PrivilegedAction<Session>) () -> EmailHelper.newSession(properties));
}

代码示例来源:origin: org.batoo.jpa/batoo-jpa

/**
 * {@inheritDoc}
 * 
 */
@Override
public Object getObjectInstance(Object object, Name name, Context context, Hashtable<?, ?> table) throws Exception {
  final Reference ref = (Reference) object;
  final Enumeration<RefAddr> addrs = ref.getAll();
  final Properties props = new Properties();
  while (addrs.hasMoreElements()) {
    final RefAddr addr = addrs.nextElement();
    if (addr.getType().equals("driverClassName")) {
      Class.forName((String) addr.getContent());
    }
    else {
      props.put(addr.getType(), addr.getContent());
    }
  }
  final BoneCPConfig config = new BoneCPConfig(props);
  return new BoneCPDataSource(config);
}

代码示例来源:origin: org.apache.tomcat/jdbc-pool

public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
  if ((obj == null) || !(obj instanceof Reference)) {
    return null;
  }
  Reference ref = (Reference) obj;
  Enumeration<RefAddr> refs = ref.getAll();
  
  String type = ref.getClassName();
  Object o = Class.forName(type).newInstance();
  
  while (refs.hasMoreElements()) {
    RefAddr addr = refs.nextElement();
    String param = addr.getType();
    String value = null;
    if (addr.getContent()!=null) {
      value = addr.getContent().toString();
    }
    if (setProperty(o, param, value,false)) {
      
    } else {
      log.debug("Property not configured["+param+"]. No setter found on["+o+"].");
    }
  }
  return o;
}

代码示例来源:origin: com.zaxxer/HikariCP-java7

@Override
synchronized public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception
{
 // We only know how to deal with <code>javax.naming.Reference</code> that specify a class name of "javax.sql.DataSource"
 if (!(obj instanceof Reference)) {
   return null;
 }
 Reference ref = (Reference) obj;
 if (!"javax.sql.DataSource".equals(ref.getClassName())) {
   throw new NamingException(ref.getClassName() + " is not a valid class name/type for this JNDI factory.");
 }
 Set<String> hikariPropSet = PropertyElf.getPropertyNames(HikariConfig.class);
 Properties properties = new Properties();
 Enumeration<RefAddr> enumeration = ref.getAll();
 while (enumeration.hasMoreElements()) {
   RefAddr element = enumeration.nextElement();
   String type = element.getType();
   if (type.startsWith("dataSource.") || hikariPropSet.contains(type)) {
    properties.setProperty(type, element.getContent().toString());
   }
 }
 return createDataSource(properties, nameCtx);
}

代码示例来源:origin: c3p0/c3p0

public Object getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env)
throws Exception
{
if (refObj instanceof Reference)
  {
  Reference ref = (Reference) refObj;
  Map refAddrsMap = new HashMap();
  for (Enumeration e = ref.getAll(); e.hasMoreElements(); )
    {
    RefAddr addr = (RefAddr) e.nextElement();
    refAddrsMap.put( addr.getType(), addr );
    }
  Class beanClass = Class.forName( ref.getClassName() );
  Set refProps = null;
  RefAddr refPropsRefAddr = (BinaryRefAddr) refAddrsMap.remove( JavaBeanReferenceMaker.REF_PROPS_KEY );
  if ( refPropsRefAddr != null )
    refProps = (Set) SerializableUtils.fromByteArray( (byte[]) refPropsRefAddr.getContent() );
  Map propMap = createPropertyMap( beanClass, refAddrsMap );
  return findBean( beanClass, propMap, refProps );
  }
else
  return null;
}

代码示例来源:origin: com.mchange/mchange-commons-java

public Object getObjectInstance(Object refObj, Name name, Context nameCtx, Hashtable env)
throws Exception
{
if (refObj instanceof Reference)
  {
  Reference ref = (Reference) refObj;
  Map refAddrsMap = new HashMap();
  for (Enumeration e = ref.getAll(); e.hasMoreElements(); )
    {
    RefAddr addr = (RefAddr) e.nextElement();
    refAddrsMap.put( addr.getType(), addr );
    }
  Class beanClass = Class.forName( ref.getClassName() );
  Set refProps = null;
  RefAddr refPropsRefAddr = (BinaryRefAddr) refAddrsMap.remove( JavaBeanReferenceMaker.REF_PROPS_KEY );
  if ( refPropsRefAddr != null )
    refProps = (Set) SerializableUtils.fromByteArray( (byte[]) refPropsRefAddr.getContent() );
  Map propMap = createPropertyMap( beanClass, refAddrsMap );
  return findBean( beanClass, propMap, refProps );
  }
else
  return null;
}

相关文章