Search in sources :

Example 46 with RefAddr

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;
}
Also used : RefAddr(javax.naming.RefAddr) StringRefAddr(javax.naming.StringRefAddr) Properties(java.util.Properties)

Example 47 with RefAddr

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);
}
Also used : RefAddr(javax.naming.RefAddr) StringRefAddr(javax.naming.StringRefAddr) StringRefAddr(javax.naming.StringRefAddr)

Example 48 with RefAddr

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);
}
Also used : RefAddr(javax.naming.RefAddr) StringRefAddr(javax.naming.StringRefAddr) StringRefAddr(javax.naming.StringRefAddr)

Example 49 with RefAddr

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);
    }
}
Also used : RefAddr(javax.naming.RefAddr) StringRefAddr(javax.naming.StringRefAddr) StringRefAddr(javax.naming.StringRefAddr)

Example 50 with RefAddr

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);
}
Also used : RefAddr(javax.naming.RefAddr) StringRefAddr(javax.naming.StringRefAddr) StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) InitialContext(javax.naming.InitialContext) Test(org.junit.Test)

Aggregations

RefAddr (javax.naming.RefAddr)94 Reference (javax.naming.Reference)60 NamingException (javax.naming.NamingException)23 StringRefAddr (javax.naming.StringRefAddr)18 Properties (java.util.Properties)16 ObjectFactory (javax.naming.spi.ObjectFactory)12 InitialContext (javax.naming.InitialContext)9 Method (java.lang.reflect.Method)7 NameNotFoundException (javax.naming.NameNotFoundException)6 EjbRef (org.apache.naming.EjbRef)5 ResourceRef (org.apache.naming.ResourceRef)5 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)5 SerializableObjectRefAddr (org.glassfish.resources.naming.SerializableObjectRefAddr)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ArrayList (java.util.ArrayList)4 Enumeration (java.util.Enumeration)4 DataSource (javax.sql.DataSource)4 BeanInfo (java.beans.BeanInfo)3 PropertyDescriptor (java.beans.PropertyDescriptor)3 ResourceLinkRef (org.apache.naming.ResourceLinkRef)3