Search in sources :

Example 6 with StringRefAddr

use of javax.naming.StringRefAddr in project wildfly by wildfly.

the class ObjectFactoryBuilder method lookForURLs.

static ObjectFactory lookForURLs(Reference ref, Hashtable environment) throws NamingException {
    for (int i = 0; i < ref.size(); i++) {
        RefAddr addr = ref.get(i);
        if (addr instanceof StringRefAddr && addr.getType().equalsIgnoreCase("URL")) {
            String url = (String) addr.getContent();
            ObjectFactory answer = processURL(url, environment);
            if (answer != null) {
                return answer;
            }
        }
    }
    return null;
}
Also used : RefAddr(javax.naming.RefAddr) StringRefAddr(javax.naming.StringRefAddr) DirObjectFactory(javax.naming.spi.DirObjectFactory) ServiceAwareObjectFactory(org.jboss.as.naming.ServiceAwareObjectFactory) ObjectFactory(javax.naming.spi.ObjectFactory) StringRefAddr(javax.naming.StringRefAddr)

Example 7 with StringRefAddr

use of javax.naming.StringRefAddr in project wildfly by wildfly.

the class NamingContextTestCase method bindListWithContinuations.

private void bindListWithContinuations() throws NamingException {
    final Name name = new CompositeName("test/test");
    final Object object = new Object();
    namingStore.bind(name, object);
    final Name nameTwo = new CompositeName("test/testTwo");
    final Object objectTwo = new Object();
    namingStore.bind(nameTwo, objectTwo);
    final Name nameThree = new CompositeName("test/testThree");
    final Object objectThree = new Object();
    namingStore.bind(nameThree, objectThree);
    final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "test"), TestObjectFactoryWithNameResolution.class.getName(), null);
    namingStore.bind(new CompositeName("comp"), reference);
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) CompositeName(javax.naming.CompositeName) CompositeName(javax.naming.CompositeName) Name(javax.naming.Name)

Example 8 with StringRefAddr

use of javax.naming.StringRefAddr in project wildfly by wildfly.

the class NamingContextTestCase method testLookupWithContinuation.

@Test
public void testLookupWithContinuation() throws Exception {
    namingStore.bind(new CompositeName("comp/nested"), "test");
    final Reference reference = new Reference(String.class.getName(), new StringRefAddr("nns", "comp"), TestObjectFactoryWithNameResolution.class.getName(), null);
    namingStore.bind(new CompositeName("test"), reference);
    Object result = namingContext.lookup(new CompositeName("test/nested"));
    assertEquals("test", result);
    //the same with security permissions
    result = testActionPermission(JndiPermission.ACTION_LOOKUP, Arrays.asList(new JndiPermission("comp/nested", "lookup")), namingContext, "test/nested");
    assertEquals("test", result);
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference) CompositeName(javax.naming.CompositeName) JndiPermission(org.wildfly.naming.java.permission.JndiPermission) Test(org.junit.Test)

Example 9 with StringRefAddr

use of javax.naming.StringRefAddr in project datanucleus-rdbms by datanucleus.

the class SharedPoolDataSource method getReference.

/**
 * Returns a <code>SharedPoolDataSource</code> {@link Reference}.
 */
@Override
public Reference getReference() throws NamingException {
    Reference ref = new Reference(getClass().getName(), SharedPoolDataSourceFactory.class.getName(), null);
    ref.add(new StringRefAddr("instanceKey", getInstanceKey()));
    return ref;
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference)

Example 10 with StringRefAddr

use of javax.naming.StringRefAddr in project datanucleus-rdbms by datanucleus.

the class DriverAdapterCPDS method getReference.

// ----------------------------------------------------------------------
// Referenceable implementation
/**
 * <CODE>Referenceable</CODE> implementation.
 */
@Override
public Reference getReference() throws NamingException {
    // this class implements its own factory
    String factory = getClass().getName();
    Reference ref = new Reference(getClass().getName(), factory, null);
    ref.add(new StringRefAddr("description", getDescription()));
    ref.add(new StringRefAddr("driver", getDriver()));
    ref.add(new StringRefAddr("loginTimeout", String.valueOf(getLoginTimeout())));
    ref.add(new StringRefAddr("password", getPassword()));
    ref.add(new StringRefAddr("user", getUser()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("poolPreparedStatements", String.valueOf(isPoolPreparedStatements())));
    ref.add(new StringRefAddr("maxIdle", String.valueOf(getMaxIdle())));
    ref.add(new StringRefAddr("timeBetweenEvictionRunsMillis", String.valueOf(getTimeBetweenEvictionRunsMillis())));
    ref.add(new StringRefAddr("numTestsPerEvictionRun", String.valueOf(getNumTestsPerEvictionRun())));
    ref.add(new StringRefAddr("minEvictableIdleTimeMillis", String.valueOf(getMinEvictableIdleTimeMillis())));
    ref.add(new StringRefAddr("maxPreparedStatements", String.valueOf(getMaxPreparedStatements())));
    return ref;
}
Also used : StringRefAddr(javax.naming.StringRefAddr) Reference(javax.naming.Reference)

Aggregations

StringRefAddr (javax.naming.StringRefAddr)67 Reference (javax.naming.Reference)51 NamingException (javax.naming.NamingException)18 RefAddr (javax.naming.RefAddr)9 Test (org.junit.Test)8 Name (javax.naming.Name)7 Properties (java.util.Properties)6 HashMap (java.util.HashMap)5 Iterator (java.util.Iterator)5 CompositeName (javax.naming.CompositeName)5 NameAlreadyBoundException (javax.naming.NameAlreadyBoundException)5 ObjectFactory (javax.naming.spi.ObjectFactory)5 MalformedURLException (java.net.MalformedURLException)4 Enumeration (java.util.Enumeration)4 Hashtable (java.util.Hashtable)4 Map (java.util.Map)4 Context (javax.naming.Context)4 NameNotFoundException (javax.naming.NameNotFoundException)3 Context (org.apache.catalina.Context)3 NamingContext (org.apache.naming.NamingContext)3