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

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

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

Reference.get介绍

暂无

代码示例

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

protected String getProperty(Reference ref, String s) {
 RefAddr addr = ref.get(s);
 if (addr == null) {
  return null;
 }
 return (String) addr.getContent();
}

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

private static String getReferenceProperty(Reference ref, String propertyName) {
 RefAddr addr = ref.get(propertyName);
 if (addr == null) {
  return null;
 }
 return (String) addr.getContent();
}

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

if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
  JdbcDataSource dataSource = new JdbcDataSource();
  dataSource.setURL((String) ref.get("url").getContent());
  dataSource.setUser((String) ref.get("user").getContent());
  dataSource.setPassword((String) ref.get("password").getContent());
  dataSource.setDescription((String) ref.get("description").getContent());
  String s = (String) ref.get("loginTimeout").getContent();
  dataSource.setLoginTimeout(Integer.parseInt(s));
  return dataSource;

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

protected String getProperty(Reference ref, String s)
{
  RefAddr addr = ref.get(s);
  if (addr == null)
  {
    return null;
  }
  return (String)addr.getContent();
}

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

if (ref.getClassName().equals(JdbcDataSource.class.getName())) {
  JdbcDataSource dataSource = new JdbcDataSource();
  dataSource.setURL((String) ref.get("url").getContent());
  dataSource.setUser((String) ref.get("user").getContent());
  dataSource.setPassword((String) ref.get("password").getContent());
  dataSource.setDescription((String) ref.get("description").getContent());
  String s = (String) ref.get("loginTimeout").getContent();
  dataSource.setLoginTimeout(Integer.parseInt(s));
  return dataSource;

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

@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
    throws Exception {
  Reference ref = (Reference) obj;
  RefAddr addr = ref.get("configPath");
  return buildClient(addr.getContent().toString());
}

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

@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
    throws Exception {
  Reference ref = (Reference) obj;
  RefAddr addr = ref.get("configPath");
  return buildClient(addr.getContent().toString());
}

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

@Override
  public Object getObjectInstance(Object reference, Name name, Context nameCtx, Hashtable<?, ?> environment)
      throws Exception {
    LOG.debugf( "JNDI lookup: %s", name );
    final String uuid = (String) ( (Reference) reference ).get( 0 ).getContent();
    LOG.tracef( "Resolved to UUID = %s", uuid );
    return INSTANCE.getSessionFactory( uuid );
  }
}

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

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);

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

static ObjectFactory lookForURLs(Reference ref, Hashtable environment)
    throws NamingException {
  for (int i = 0; i < ref.size(); i++) {
    RefAddr addr = ref.get(i);
    if (addr instanceof StringRefAddr &&
        addr.getType().equalsIgnoreCase("URL")) {
      String url = (String) addr.getContent();
      ObjectFactory answer = processURL(url, environment);
      if (answer != null) {
        return answer;
      }
    }
  }
  return null;
}

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

private static javax.naming.Context getContinuationContext(CannotProceedException cpe) throws NamingException {
  try {
    return NamingManager.getContinuationContext(cpe);
  } catch (CannotProceedException e) {
    java.lang.Object resObj = e.getResolvedObj();
    if (resObj instanceof Reference) {
      Reference ref = (Reference) resObj;
      RefAddr addr = ref.get("nns");
      if (addr.getContent() instanceof javax.naming.Context) {
        NamingException ne = IIOPLogger.ROOT_LOGGER.noReferenceFound();
        ne.setRootCause(cpe.getRootCause());
        throw ne;
      }
    }
    throw e;
  }
}

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

protected String getProperty(
      final Reference ref, final String propName, final String defValue) {
    final RefAddr addr = ref.get(propName);
    if (addr == null) {
      return defValue;
    }
    return (String) addr.getContent();
  }
}

代码示例来源:origin: hector-client/hector

private void configure(Reference resourceRef) throws Exception {
 RefAddr hostsRefAddr = resourceRef.get("hosts");
 RefAddr clusterNameRef = resourceRef.get("clusterName");
 RefAddr keyspaceNameRef = resourceRef.get("keyspace");
 RefAddr maxActiveRefAddr = resourceRef.get("maxActive");
 RefAddr maxWaitTimeWhenExhausted = resourceRef.get("maxWaitTimeWhenExhausted");
 RefAddr maxExhaustedTimeBeforeMarkingAsDown = resourceRef.get("maxExhaustedTimeBeforeMarkingAsDown");
 RefAddr autoDiscoverHosts = resourceRef.get("autoDiscoverHosts");
 RefAddr runAutoDiscoverAtStartup = resourceRef.get("runAutoDiscoveryAtStartup");
 RefAddr retryDownedHostDelayInSeconds = resourceRef.get("retryDownedHostDelayInSeconds");
 if ( hostsRefAddr == null || hostsRefAddr.getContent() == null) {
  throw new Exception("A url and port on which Cassandra is installed and listening " + 
  "on must be provided as a ResourceParams in the context.xml");
 cassandraHostConfigurator = new CassandraHostConfigurator((String)hostsRefAddr.getContent());
 if ( autoDiscoverHosts != null ) {
  cassandraHostConfigurator.setAutoDiscoverHosts(Boolean.parseBoolean((String)autoDiscoverHosts.getContent()));
  if ( runAutoDiscoverAtStartup  != null )
   cassandraHostConfigurator.setRunAutoDiscoveryAtStartup(Boolean.parseBoolean((String)autoDiscoverHosts.getContent()));

代码示例来源:origin: org.ow2.joram/joram-client-jms

/** Restores the administered object from a naming reference. */
public void fromReference(Reference ref) throws NamingException {
 agentId = (String) ref.get("dest.agentId").getContent();
 adminName = (String) ref.get("dest.adminName").getContent();
}

代码示例来源:origin: org.apache.openejb/openejb-tomcat-naming

public static String getProperty(Reference ref, String name) {
  RefAddr addr = ref.get(name);
  if (addr == null) return null;
  Object value = addr.getContent();
  return (String) value;
}

代码示例来源:origin: org.apache.openejb/openejb-tomcat-common

public static String getProperty(Reference ref, String name) {
  RefAddr addr = ref.get(name);
  if (addr == null) return null;
  Object value = addr.getContent();
  return (String) value;
}

代码示例来源:origin: org.apache.openejb/tomee-common

public static String getProperty(Reference ref, String name) {
  RefAddr addr = ref.get(name);
  if (addr == null) return null;
  Object value = addr.getContent();
  return (String) value;
}

相关文章