use of javax.naming.RefAddr in project rabbitmq-jms-client by rabbitmq.
the class RMQConnectionFactoryTest method getProps.
private static Properties getProps(Reference ref) {
Enumeration<RefAddr> refEnum = ref.getAll();
Properties props = new Properties();
while (refEnum.hasMoreElements()) {
RefAddr ra = refEnum.nextElement();
props.setProperty(ra.getType(), (String) ra.getContent());
}
return props;
}
use of javax.naming.RefAddr in project rabbitmq-jms-client by rabbitmq.
the class RMQConnectionFactoryTest method addStringRefProperty.
/**
* Adds a String valued property to a Reference (as a RefAddr)
*
* @param ref - the reference to contain the value
* @param propertyName - the name of the property
* @param value - the value to store with the property
*/
private static void addStringRefProperty(Reference ref, String propertyName, String value) {
if (value == null || propertyName == null)
return;
removeRefProperty(ref, propertyName);
RefAddr ra = new StringRefAddr(propertyName, value);
ref.add(ra);
}
use of javax.naming.RefAddr in project rabbitmq-jms-client by rabbitmq.
the class RMQDestination method addStringProperty.
/**
* Adds a String valued property to a Reference (as a RefAddr) if it is non-<code>null</code>.
* @param ref - the reference to contain the value
* @param propertyName - the name of the property
* @param value - the value to store with the property
*/
private static final void addStringProperty(Reference ref, String propertyName, String value) {
if (value == null || propertyName == null)
return;
RefAddr ra = new StringRefAddr(propertyName, value);
ref.add(ra);
}
use of javax.naming.RefAddr in project rabbitmq-jms-client by rabbitmq.
the class RMQDestination method addBooleanProperty.
/**
* Adds a boolean valued property to a Reference (as a StringRefAddr) if the value is <code>true</code>
* (default <code>false</code> on read assumed).
* @param ref - the reference to contain the value
* @param propertyName - the name of the property
* @param value - the value to store with the property
*/
private static final void addBooleanProperty(Reference ref, String propertyName, boolean value) {
if (propertyName == null)
return;
if (value) {
RefAddr ra = new StringRefAddr(propertyName, String.valueOf(value));
ref.add(ra);
}
}
use of javax.naming.RefAddr in project jetty.project by eclipse.
the class TestNamingEntries method testResourceReference.
@Test
public void testResourceReference() throws Exception {
RefAddr refAddr = new StringRefAddr("val", "10");
Reference ref = new Reference(SomeObject.class.getName(), refAddr, SomeObjectFactory.class.getName(), null);
InitialContext icontext = new InitialContext();
Resource resource = new Resource(null, "resourceByRef", ref);
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceByRef");
assertNotNull(ne);
assertTrue(ne instanceof Resource);
Object o = icontext.lookup("resourceByRef");
assertNotNull(o);
assertTrue(o instanceof SomeObject);
assertEquals(((SomeObject) o).getValue(), 10);
}
Aggregations