本文整理匯總了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;
}
示例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;
}
示例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;
}
示例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);
}
示例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 });
}
}
示例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);
}
示例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;
}