當前位置: 首頁>>代碼示例>>Java>>正文


Java RefAddr.getType方法代碼示例

本文整理匯總了Java中javax.naming.RefAddr.getType方法的典型用法代碼示例。如果您正苦於以下問題:Java RefAddr.getType方法的具體用法?Java RefAddr.getType怎麽用?Java RefAddr.getType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.naming.RefAddr的用法示例。


在下文中一共展示了RefAddr.getType方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getObjectInstance

import javax.naming.RefAddr; //導入方法依賴的package包/類
@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;
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:27,代碼來源:GenericNamingResourcesFactory.java

示例2: getObjectInstance

import javax.naming.RefAddr; //導入方法依賴的package包/類
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
    throws ViburDBCPException {

    Reference reference = (Reference) obj;
    Enumeration<RefAddr> enumeration = reference.getAll();
    Properties props = new Properties();
    while (enumeration.hasMoreElements()) {
        RefAddr refAddr = enumeration.nextElement();
        String pName = refAddr.getType();
        String pValue = (String) refAddr.getContent();
        props.setProperty(pName, pValue);
    }

    ViburDBCPDataSource dataSource = new ViburDBCPDataSource(props);
    dataSource.start();
    return dataSource;
}
 
開發者ID:vibur,項目名稱:vibur-dbcp,代碼行數:19,代碼來源:ViburDBCPObjectFactory.java

示例3: getObjectInstance

import javax.naming.RefAddr; //導入方法依賴的package包/類
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;
}
 
開發者ID:WhiteBearSolutions,項目名稱:WBSAirback,代碼行數:26,代碼來源:GenericNamingResourcesFactory.java

示例4: getObjectInstance

import javax.naming.RefAddr; //導入方法依賴的package包/類
/**
 * JNDI object factory so the proxy can be used as a resource.
 */
public Object getObjectInstance(Object obj, Name name,
                                Context nameCtx, Hashtable<?,?> environment)
  throws Exception
{
  Reference ref = (Reference) obj;

  String api = null;
  String url = null;
  
  for (int i = 0; i < ref.size(); i++) {
    RefAddr addr = ref.get(i);

    String type = addr.getType();
    String value = (String) addr.getContent();

    if (type.equals("type"))
      api = value;
    else if (type.equals("url"))
      url = value;
    else if (type.equals("user"))
      setUser(value);
    else if (type.equals("password"))
      setPassword(value);
  }

  if (url == null)
    throw new NamingException("`url' must be configured for HessianProxyFactory.");
  // XXX: could use meta protocol to grab this
  if (api == null)
    throw new NamingException("`type' must be configured for HessianProxyFactory.");

  Class apiClass = Class.forName(api, false, _loader);

  return create(apiClass, url);
}
 
開發者ID:yajsw,項目名稱:yajsw,代碼行數:39,代碼來源:HessianProxyFactory.java

示例5: setBeanProperties

import javax.naming.RefAddr; //導入方法依賴的package包/類
/**
 * Set the Java bean properties for an object from its Reference. The
 * Reference contains a set of StringRefAddr values with the key being the
 * bean name and the value a String representation of the bean's value. This
 * code looks for setXXX() method where the set method corresponds to the
 * standard bean naming scheme and has a single parameter of type String,
 * int, boolean or short.
 */
private static void setBeanProperties(Object ds, Reference ref)
        throws Exception {

    for (Enumeration e = ref.getAll(); e.hasMoreElements();) {

        RefAddr attribute = (RefAddr) e.nextElement();

        String propertyName = attribute.getType();

        String value = (String) attribute.getContent();

        String methodName = "set"
                + propertyName.substring(0, 1).toUpperCase(
                        java.util.Locale.ENGLISH)
                + propertyName.substring(1);

        Method m;

        Object argValue;
        try {
            m = ds.getClass().getMethod(methodName, STRING_ARG);
            argValue = value;
        } catch (NoSuchMethodException nsme) {
            try {
                m = ds.getClass().getMethod(methodName, INT_ARG);
                argValue = Integer.valueOf(value);
            } catch (NoSuchMethodException nsme2) {
                try {
                    m = ds.getClass().getMethod(methodName, BOOLEAN_ARG);
                    argValue = Boolean.valueOf(value);
                } catch (NoSuchMethodException nsme3) {
                    m = ds.getClass().getMethod(methodName, SHORT_ARG);
                    argValue = Short.valueOf(value);
                }
            }
        }
        m.invoke(ds, new Object[] { argValue });
    }
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:48,代碼來源:ClientDataSourceFactory.java

示例6: getObjectInstance

import javax.naming.RefAddr; //導入方法依賴的package包/類
@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> 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())) {
      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);
}
 
開發者ID:openbouquet,項目名稱:HikariCP,代碼行數:28,代碼來源:HikariJNDIFactory.java

示例7: getObjectInstance

import javax.naming.RefAddr; //導入方法依賴的package包/類
/**
	Re-Create Derby datasource given a reference.

	@param obj The possibly null object containing location or reference
	information that can be used in creating an object. 
	@param name The name of this object relative to nameCtx, or null if no
	name is specified. 
	@param nameCtx The context relative to which the name parameter is
	specified, or null if name is relative to the default initial context. 
	@param environment The possibly null environment that is used in
	creating the object. 

	@return One of the Derby datasource object created; null if an
	object cannot be created. 

	@exception Exception  if this object factory encountered an exception
	while attempting to create an object, and no other object factories are
	to be tried. 
 */
public Object getObjectInstance(Object obj,
								Name name,
								Context nameCtx,
								Hashtable environment)
	 throws Exception
{
	Reference ref = (Reference)obj;
	String classname = ref.getClassName();

	Object ds = Class.forName(classname).newInstance();

	for (Enumeration e = ref.getAll(); e.hasMoreElements(); ) {
		
		RefAddr attribute = (RefAddr) e.nextElement();

		String propertyName = attribute.getType();

		String value = (String) attribute.getContent();

		String methodName = "set" + propertyName.substring(0,1).toUpperCase(java.util.Locale.ENGLISH) + propertyName.substring(1);

		Method m;
		
		Object argValue;
		try {
			m = ds.getClass().getMethod(methodName, STRING_ARG);
			argValue = value;
		} catch (NoSuchMethodException nsme) {
			try {
				m = ds.getClass().getMethod(methodName, INT_ARG);
				argValue = Integer.valueOf(value);
			} catch (NoSuchMethodException nsme2) {
				m = ds.getClass().getMethod(methodName, BOOLEAN_ARG);
				argValue = Boolean.valueOf(value);
			}
		}
		m.invoke(ds, new Object[] { argValue });
	}

	return ds;
}
 
開發者ID:gemxd,項目名稱:gemfirexd-oss,代碼行數:61,代碼來源:ReferenceableDataSource.java


注:本文中的javax.naming.RefAddr.getType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。