Java Code Examples for javax.naming.RefAddr#getContent()
The following examples show how to use
javax.naming.RefAddr#getContent() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GenericNamingResourcesFactory.java From Tomcat7.0.67 with Apache License 2.0 | 6 votes |
@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; }
Example 2
Source File: GenericNamingResourcesFactory.java From tomcatsrc with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: InVMNamingContext.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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; } }
Example 4
Source File: InVMNamingContext.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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; } }
Example 5
Source File: ViburDBCPObjectFactory.java From vibur-dbcp with Apache License 2.0 | 6 votes |
@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; }
Example 6
Source File: InVMContext.java From activemq-artemis with Apache License 2.0 | 6 votes |
@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; } }
Example 7
Source File: HessianProxyFactory.java From sofa-hessian with Apache License 2.0 | 5 votes |
/** * 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); }
Example 8
Source File: MailSessionFactory.java From jqm with Apache License 2.0 | 5 votes |
private String god(Reference resource, String key, String defaultValue) { RefAddr val = resource.get(key); String res = (String) (val == null ? null : val.getContent()); if (res == null) { return defaultValue; } else { return res; } }
Example 9
Source File: NonSerializableFactory.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable<?, ?> env) throws Exception { Reference ref = (Reference) obj; RefAddr addr = ref.get("nns"); String key = (String) addr.getContent(); return NonSerializableFactory.getWrapperMap().get(key); }
Example 10
Source File: InstanceKeyDataSourceFactory.java From Tomcat8-Source-Read with MIT License | 5 votes |
/** * Implements ObjectFactory to create an instance of SharedPoolDataSource or PerUserPoolDataSource */ @Override public Object getObjectInstance(final Object refObj, final Name name, final Context context, final Hashtable<?, ?> env) throws IOException, ClassNotFoundException { // The spec says to return null if we can't create an instance // of the reference Object obj = null; if (refObj instanceof Reference) { final Reference ref = (Reference) refObj; if (isCorrectClass(ref.getClassName())) { final RefAddr refAddr = ref.get("instanceKey"); if (refAddr != null && refAddr.getContent() != null) { // object was bound to JNDI via Referenceable API. obj = instanceMap.get(refAddr.getContent()); } else { // Tomcat JNDI creates a Reference out of server.xml // <ResourceParam> configuration and passes it to an // instance of the factory given in server.xml. String key = null; if (name != null) { key = name.toString(); obj = instanceMap.get(key); } if (obj == null) { final InstanceKeyDataSource ds = getNewInstance(ref); setCommonProperties(ref, ds); obj = ds; if (key != null) { instanceMap.put(key, ds); } } } } } return obj; }
Example 11
Source File: AbstractRuntimeProperty.java From FoxTelem with GNU General Public License v3.0 | 5 votes |
@Override public void initializeFrom(Reference ref, ExceptionInterceptor exceptionInterceptor) { RefAddr refAddr = ref.get(getPropertyDefinition().getName()); if (refAddr != null) { String refContentAsString = (String) refAddr.getContent(); if (refContentAsString != null) { setValueInternal(refContentAsString, exceptionInterceptor); this.initialValue = this.value; } } }
Example 12
Source File: SharedPoolDataSourceFactory.java From Tomcat8-Source-Read with MIT License | 5 votes |
@Override protected InstanceKeyDataSource getNewInstance(final Reference ref) { final SharedPoolDataSource spds = new SharedPoolDataSource(); final RefAddr ra = ref.get("maxTotal"); if (ra != null && ra.getContent() != null) { spds.setMaxTotal(Integer.parseInt(ra.getContent().toString())); } return spds; }
Example 13
Source File: ConnectionPropertiesImpl.java From Komondor with GNU General Public License v3.0 | 5 votes |
void initializeFrom(Reference ref, ExceptionInterceptor exceptionInterceptor) throws SQLException { RefAddr refAddr = ref.get(getPropertyName()); if (refAddr != null) { String refContentAsString = (String) refAddr.getContent(); initializeFrom(refContentAsString, exceptionInterceptor); } }
Example 14
Source File: SharedPoolDataSourceFactory.java From commons-dbcp with Apache License 2.0 | 5 votes |
@Override protected InstanceKeyDataSource getNewInstance(final Reference ref) { final SharedPoolDataSource spds = new SharedPoolDataSource(); final RefAddr ra = ref.get("maxTotal"); if (ra != null && ra.getContent() != null) { spds.setMaxTotal(Integer.parseInt(ra.getContent().toString())); } return spds; }
Example 15
Source File: NonSerializableFactory.java From activemq-artemis with Apache License 2.0 | 5 votes |
@Override public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable<?, ?> env) throws Exception { Reference ref = (Reference) obj; RefAddr addr = ref.get("nns"); String key = (String) addr.getContent(); return NonSerializableFactory.getWrapperMap().get(key); }
Example 16
Source File: NamingUtil.java From tomee with Apache License 2.0 | 5 votes |
public static boolean isPropertyTrue(final Reference ref, final String name) { final RefAddr addr = ref.get(name); if (addr == null) { return false; } final Object value = addr.getContent(); return Boolean.parseBoolean(String.valueOf(value)); }
Example 17
Source File: DriverAdapterCPDS.java From Tomcat8-Source-Read with MIT License | 4 votes |
private boolean isNotEmpty(RefAddr ra) { return ra != null && ra.getContent() != null; }
Example 18
Source File: DriverAdapterCPDS.java From commons-dbcp with Apache License 2.0 | 4 votes |
private boolean isNotEmpty(RefAddr ra) { return ra != null && ra.getContent() != null; }
Example 19
Source File: ReferenceableDataSource.java From gemfirexd-oss with Apache License 2.0 | 4 votes |
/** 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; }
Example 20
Source File: MysqlDataSourceFactory.java From FoxTelem with GNU General Public License v3.0 | 3 votes |
private String nullSafeRefAddrStringGet(String referenceName, Reference ref) { RefAddr refAddr = ref.get(referenceName); String asString = refAddr != null ? (String) refAddr.getContent() : null; return asString; }