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

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

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

Reference.getClassName介绍

暂无

代码示例

代码示例来源:origin: alibaba/druid

@Override
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>s
  // that specify a class name of "javax.sql.DataSource"
  if ((obj == null) || !(obj instanceof Reference)) {
    return null;
  }
  Reference ref = (Reference) obj;
  if ((!"javax.sql.DataSource".equals(ref.getClassName())) //
      && (!"com.alibaba.druid.pool.DruidDataSource".equals(ref.getClassName())) //
  ) {
    return null;
  }
  Properties properties = new Properties();
  for (int i = 0; i < ALL_PROPERTIES.length; i++) {
    String propertyName = ALL_PROPERTIES[i];
    RefAddr ra = ref.get(propertyName);
    if (ra != null) {
      String propertyValue = ra.getContent().toString();
      properties.setProperty(propertyName, propertyValue);
    }
  }
  return createDataSourceInternal(properties);
}

代码示例来源:origin: org.postgresql/postgresql

public Object getObjectInstance(Object obj, Name name, Context nameCtx,
  Hashtable<?, ?> environment) throws Exception {
 Reference ref = (Reference) obj;
 String className = ref.getClassName();
 if (className.equals("org.postgresql.xa.PGXADataSource")) {
  return loadXADataSource(ref);
 } else {
  return null;
 }
}

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

public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                Hashtable environment) throws Exception
{
  Reference ref = (Reference)obj;
  String className = ref.getClassName();
  if (className.equals("org.postgresql.xa.PGXADataSource"))
  {
    return loadXADataSource(ref);
  }
else 
  return null;
}

代码示例来源:origin: org.postgresql/postgresql

/**
 * Dereferences a PostgreSQL DataSource. Other types of references are ignored.
 */
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
  Hashtable<?, ?> environment) throws Exception {
 Reference ref = (Reference) obj;
 String className = ref.getClassName();
 // Old names are here for those who still use them
 if (className.equals("org.postgresql.ds.PGSimpleDataSource")
   || className.equals("org.postgresql.jdbc2.optional.SimpleDataSource")
   || className.equals("org.postgresql.jdbc3.Jdbc3SimpleDataSource")) {
  return loadSimpleDataSource(ref);
 } else if (className.equals("org.postgresql.ds.PGConnectionPoolDataSource")
   || className.equals("org.postgresql.jdbc2.optional.ConnectionPool")
   || className.equals("org.postgresql.jdbc3.Jdbc3ConnectionPool")) {
  return loadConnectionPool(ref);
 } else if (className.equals("org.postgresql.ds.PGPoolingDataSource")
   || className.equals("org.postgresql.jdbc2.optional.PoolingDataSource")
   || className.equals("org.postgresql.jdbc3.Jdbc3PoolingDataSource")) {
  return loadPoolingDataSource(ref);
 } else {
  return null;
 }
}

代码示例来源: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: postgresql/postgresql

String className = ref.getClassName();
if (className.equals("org.postgresql.ds.PGSimpleDataSource")
    || className.equals("org.postgresql.jdbc2.optional.SimpleDataSource")

代码示例来源:origin: com.h2database/h2

if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
  JdbcDataSource dataSource = new JdbcDataSource();
  dataSource.setURL((String) ref.get("url").getContent());

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

log.trace("Getting instance of " + reference.getClassName());
Class theClass = loadClass(this, reference.getClassName());
if (JNDIStorableInterface.class.isAssignableFrom(theClass)) {

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

if (object instanceof Reference) {
  Reference reference = (Reference) object;
  Class<?> theClass = loadClass(this, reference.getClassName());
  if (JNDIStorable.class.isAssignableFrom(theClass)) {
   JNDIStorable store = (JNDIStorable) theClass.newInstance();

代码示例来源:origin: lealone/Lealone

if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
  JdbcDataSource dataSource = new JdbcDataSource();
  dataSource.setURL((String) ref.get("url").getContent());

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

private static JndiBinding createJndiBinding(String path, Binding binding) {
  final String name = getBindingName(path, binding);
  final String className = binding.getClassName();
  final Object object = binding.getObject();
  final String contextPath;
  final String value;
  if (object instanceof Context
      // "javax.naming.Context".equals(className) nécessaire pour le path "comp" dans JBoss 6.0
      || "javax.naming.Context".equals(className)
      // pour jetty :
      || object instanceof Reference
          && "javax.naming.Context".equals(((Reference) object).getClassName())) {
    if (!path.isEmpty()) {
      contextPath = path + '/' + name;
    } else {
      // nécessaire pour jonas 5.1.0
      contextPath = name;
    }
    value = null;
  } else {
    contextPath = null;
    value = formatValue(object);
  }
  return new JndiBinding(name, className, contextPath, value);
}

代码示例来源:origin: Impetus/Kundera

/**
 * Returns reference to userTransaction object.
 * 
 * @see javax.naming.spi.ObjectFactory
 */
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception
{
  Reference ref = (Reference) obj;
  Object ret = null;
  if (ref.getClassName().equals("javax.transaction.UserTransaction")
      || ref.getClassName().equals("com.impetus.kundera.persistence.jta.KunderaJTAUserTransaction"))
  {
    ret = KunderaJTAUserTransaction.getCurrentTx();
  }
  if (ret == null)
  {
    ret = new KunderaJTAUserTransaction();
  }
  return ret;
}

代码示例来源:origin: com.alibaba/druid

@Override
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>s
  // that specify a class name of "javax.sql.DataSource"
  if ((obj == null) || !(obj instanceof Reference)) {
    return null;
  }
  Reference ref = (Reference) obj;
  if ((!"javax.sql.DataSource".equals(ref.getClassName())) //
      && (!"com.alibaba.druid.pool.DruidDataSource".equals(ref.getClassName())) //
  ) {
    return null;
  }
  Properties properties = new Properties();
  for (int i = 0; i < ALL_PROPERTIES.length; i++) {
    String propertyName = ALL_PROPERTIES[i];
    RefAddr ra = ref.get(propertyName);
    if (ra != null) {
      String propertyValue = ra.getContent().toString();
      properties.setProperty(propertyName, propertyValue);
    }
  }
  return createDataSourceInternal(properties);
}

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

@Override
 public Object getObjectInstance(Object refObj,
                 Name nm,
                 Context ctx,
                 Hashtable<?,?> env) throws Exception {

  final Reference ref = (Reference) refObj;
  final String className = ref.getClassName();

  if (className != null && className.equals(DATASOURCE_CLASS_NAME)) {

   P6DataSource dataSource;
   try {
    dataSource = (P6DataSource) Class.forName(className).newInstance();
   } catch (Exception ex) {
    throw new RuntimeException("Unable to create DataSource of " +
      "class '" + className + "': " + ex.toString());
   }
   // name of the real datasource
   dataSource.setRealDataSource((String) ref.get("dataSourceName").getContent());

   return dataSource;
  } else {
   // Who's class is this anyway, I ask ya!
   return null;
  }
 }
}

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

boolean XA = false;
boolean ok = false;
if ("javax.sql.DataSource".equals(ref.getClassName())) {
  ok = true;
if ("javax.sql.XADataSource".equals(ref.getClassName())) {
  ok = true;
  XA = true;
if (org.apache.tomcat.jdbc.pool.DataSource.class.getName().equals(ref.getClassName())) {
  ok = true;
  log.warn(ref.getClassName()+" is not a valid class name/type for this JNDI factory.");
  return null;

代码示例来源: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: geotools/geotools

/**
 * @return an {@link ISessionPool} ready to be shared (ie, per connection option singleton).
 *     Whether shared or not is a matter of external JNDI configuration.
 * @see ObjectFactory#getObjectInstance(Object, Name, Context, Hashtable)
 */
public Object getObjectInstance(
    final Object obj,
    final Name name,
    final Context nameCtx,
    final Hashtable<?, ?> environment)
    throws Exception {
  final Reference ref = (Reference) obj;
  LOGGER.info("ArcSDEConnectionFactory: ref is " + ref);
  final String className = ref.getClassName();
  LOGGER.info("ArcSDEConnectionFactory: className is " + className);
  // may an alternate SessionPoolFactory being set?
  checkAlternateSessionPoolFactory(ref);
  Object dereferencedObject = null;
  if (ISessionPool.class.getName().equals(className)) {
    ArcSDEConnectionConfig config = createConfig(ref);
    LOGGER.info("ArcSDEConnectionFactory: config is " + config);
    ISessionPool sharedPool = getSharedPool(config);
    LOGGER.info("ArcSDEConnectionFactory: shared pool is " + sharedPool);
    dereferencedObject = sharedPool;
  } else {
    LOGGER.info("ArcSDEConnectionFactory: not a config");
  }
  return dereferencedObject;
}

代码示例来源:origin: org.objectweb.joram/jndi-server

private static String getClassName(Object obj) {
 if (obj instanceof Reference) {
  Reference ref = (Reference)obj;
  return ref.getClassName();
 }
 return obj.getClass().getName();
}

代码示例来源:origin: org.ancoron.postgresql/org.postgresql

public Object getObjectInstance(Object obj, Name name, Context nameCtx,
                Hashtable environment) throws Exception
{
  Reference ref = (Reference)obj;
  String className = ref.getClassName();
  if (className.equals("org.postgresql.xa.PGXADataSource"))
  {
    return loadXADataSource(ref);
  }
else 
  return null;
}

代码示例来源:origin: org.jboss.jbossas/jboss-as-server

public Object getObjectInstance(Object obj, Name name,
                  Context nameCtx, Hashtable environment)
   throws Exception
  {
   Reference ref = (Reference)obj;
    if (!ref.getClassName().equals(ClientUserTransaction.class.getName()))
     return null;

   return getUserTransaction();
  }
}

相关文章