本文整理汇总了Java中javax.naming.RefAddr.getContent方法的典型用法代码示例。如果您正苦于以下问题:Java RefAddr.getContent方法的具体用法?Java RefAddr.getContent怎么用?Java RefAddr.getContent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.RefAddr
的用法示例。
在下文中一共展示了RefAddr.getContent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getObjectInstance
import javax.naming.RefAddr; //导入方法依赖的package包/类
/**
* Create a new DataSource instance.
*
* @param obj The reference object describing the DataSource
*/
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?,?> environment)
throws NamingException {
Object result = super.getObjectInstance(obj, name, nameCtx, environment);
// Can we process this request?
if (result!=null) {
Reference ref = (Reference) obj;
RefAddr userAttr = ref.get("username");
RefAddr passAttr = ref.get("password");
if (userAttr.getContent()!=null && passAttr.getContent()!=null) {
result = wrapDataSource(result,userAttr.getContent().toString(), passAttr.getContent().toString());
}
}
return result;
}
示例2: 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;
}
示例3: getObjectInstance
import javax.naming.RefAddr; //导入方法依赖的package包/类
/**
* Create a new DataSource instance.
*
* @param obj
* The reference object describing the DataSource
*/
@Override
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment)
throws NamingException {
Object result = super.getObjectInstance(obj, name, nameCtx, environment);
// Can we process this request?
if (result != null) {
Reference ref = (Reference) obj;
RefAddr userAttr = ref.get("username");
RefAddr passAttr = ref.get("password");
if (userAttr.getContent() != null && passAttr.getContent() != null) {
result = wrapDataSource(result, userAttr.getContent().toString(), passAttr.getContent().toString());
}
}
return result;
}
示例4: getObjectInstance
import javax.naming.RefAddr; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
// CHECKSTYLE:OFF
public synchronized Object getObjectInstance(Object obj, Name name, Context nameCtx, // NOPMD
Hashtable<?, ?> environment) throws NamingException { // NOPMD
// CHECKSTYLE:ON
final Reference reference = (Reference) obj;
final RefAddr jndiRefAddr = reference.get("jndi-ref");
if (jndiRefAddr == null) {
throw new NamingException("You must specify a 'jndi-ref' in the <Resource> tag");
}
final String jndiRef = (String) jndiRefAddr.getContent();
Object cachedObject = CACHED_OBJECTS.get(jndiRef);
if (cachedObject == null) {
final InitialContext context = new InitialContext();
cachedObject = context.lookup(jndiRef);
if (cachedObject == null) {
throw new NamingException("No jndi object found for the 'jndi-ref': " + jndiRef);
}
CACHED_OBJECTS.put(jndiRef, cachedObject);
}
return cachedObject;
}
示例5: lookup
import javax.naming.RefAddr; //导入方法依赖的package包/类
@Override
public Object lookup(String name) throws NamingException {
name = trimSlashes(name);
int i = name.indexOf("/");
String tok = i == -1 ? name : name.substring(0, i);
Object value = map.get(tok);
if (value == null) {
throw new NameNotFoundException("Name not found: " + tok);
}
if (value instanceof InVMNamingContext && i != -1) {
return ((InVMNamingContext) value).lookup(name.substring(i));
}
if (value instanceof Reference) {
Reference ref = (Reference) value;
RefAddr refAddr = ref.get("nns");
// we only deal with references create by NonSerializableFactory
String key = (String) refAddr.getContent();
return NonSerializableFactory.lookup(key);
} else {
return value;
}
}
示例6: lookup
import javax.naming.RefAddr; //导入方法依赖的package包/类
@Override
public Object lookup(String name) throws NamingException {
name = trimSlashes(name);
int i = name.indexOf("/");
String tok = i == -1 ? name : name.substring(0, i);
Object value = map.get(tok);
if (value == null) {
throw new NameNotFoundException("Name not found: " + tok);
}
if (value instanceof InVMContext && i != -1) {
return ((InVMContext) value).lookup(name.substring(i));
}
if (value instanceof Reference) {
Reference ref = (Reference) value;
RefAddr refAddr = ref.get("nns");
// we only deal with references create by NonSerializableFactory
String key = (String) refAddr.getContent();
return NonSerializableFactory.lookup(key);
} else {
return value;
}
}
示例7: 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;
}
示例8: getNewInstance
import javax.naming.RefAddr; //导入方法依赖的package包/类
protected InstanceKeyDataSource getNewInstance(Reference ref) {
SharedPoolDataSource spds = new SharedPoolDataSource();
RefAddr ra = ref.get("maxActive");
if (ra != null && ra.getContent() != null) {
spds.setMaxActive(
Integer.parseInt(ra.getContent().toString()));
}
ra = ref.get("maxIdle");
if (ra != null && ra.getContent() != null) {
spds.setMaxIdle(
Integer.parseInt(ra.getContent().toString()));
}
ra = ref.get("maxWait");
if (ra != null && ra.getContent() != null) {
spds.setMaxWait(
Integer.parseInt(ra.getContent().toString()));
}
return spds;
}
示例9: 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;
}
示例10: getObjectInstance
import javax.naming.RefAddr; //导入方法依赖的package包/类
/**
* @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
* javax.naming.Name, javax.naming.Context, java.util.Hashtable)
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment) throws Exception
{
Reference ref = (Reference) obj;
RefAddr addr = ref.get("url");
if (addr == null)
{
throw new NamingException("Missing parameter with key 'url'");
}
String urlName = (String) addr.getContent();
if (urlName == null)
{
throw new NamingException("Url attribute not set.");
}
try
{
return new URL(urlName);
}
catch (Exception e)
{
throw new RuntimeException("urlName="+urlName,e);
}
}
示例11: getObjectInstance
import javax.naming.RefAddr; //导入方法依赖的package包/类
/**
* @see javax.naming.spi.ObjectFactory#getObjectInstance(java.lang.Object,
* javax.naming.Name, javax.naming.Context, java.util.Hashtable)
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable<?, ?> environment) throws Exception
{
Reference ref = (Reference) obj;
RefAddr addr = ref.get("content");
if (addr == null)
{
throw new NamingException("Missing parameter with key 'content'");
}
String content = (String) addr.getContent();
if (content == null)
{
throw new NamingException("content attribute not set.");
}
return content;
}
示例12: initializeFrom
import javax.naming.RefAddr; //导入方法依赖的package包/类
void initializeFrom(Reference ref, ExceptionInterceptor exceptionInterceptor) throws SQLException {
RefAddr refAddr = ref.get(getPropertyName());
if (refAddr != null) {
String refContentAsString = (String) refAddr.getContent();
initializeFrom(refContentAsString, exceptionInterceptor);
}
}
示例13: 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);
}
示例14: 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 });
}
}
示例15: getContent
import javax.naming.RefAddr; //导入方法依赖的package包/类
protected String getContent(Reference ref, String key)
{
RefAddr addr = ref.get(key);
if(addr instanceof StringRefAddr) {
return (String) addr.getContent();
}
return null;
}