Java Code Examples for javax.naming.Reference#size()

The following examples show how to use javax.naming.Reference#size() . 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: BurlapProxyFactory.java    From sofa-hessian with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
    String user = null;
    String password = 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 BurlapProxyFactory.");
    // XXX: could use meta protocol to grab this
    if (api == null)
        throw new NamingException("`type' must be configured for BurlapProxyFactory.");

    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    Class apiClass = Class.forName(api, false, loader);

    return create(apiClass, url);
}
 
Example 2
Source File: HessianProxyFactory.java    From sofa-hessian with Apache License 2.0 5 votes vote down vote up
/**
 * 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 3
Source File: DataSourceRegressionTest.java    From r-course with MIT License 5 votes vote down vote up
private void removeFromRef(Reference ref, String key) {
    int size = ref.size();

    for (int i = 0; i < size; i++) {
        RefAddr refAddr = ref.get(i);
        if (refAddr.getType().equals(key)) {
            ref.remove(i);
            break;
        }
    }
}
 
Example 4
Source File: DataSourceRegressionTest.java    From Komondor with GNU General Public License v3.0 5 votes vote down vote up
private void removeFromRef(Reference ref, String key) {
    int size = ref.size();

    for (int i = 0; i < size; i++) {
        RefAddr refAddr = ref.get(i);
        if (refAddr.getType().equals(key)) {
            ref.remove(i);
            break;
        }
    }
}
 
Example 5
Source File: DataSourceRegressionTest.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
private void removeFromRef(Reference ref, String key) {
    int size = ref.size();

    for (int i = 0; i < size; i++) {
        RefAddr refAddr = ref.get(i);
        if (refAddr.getType().equals(key)) {
            ref.remove(i);
            break;
        }
    }
}
 
Example 6
Source File: TestDriverAdapterCPDS.java    From commons-dbcp with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetObjectInstanceChangeDescription() throws Exception {
    final Reference ref = pcds.getReference();
    for (int i = 0; i < ref.size(); i++) {
        if (ref.get(i).getType().equals("description")) {
            ref.remove(i);
            break;
        }
    }
    ref.add(new StringRefAddr("description", "anything"));
    final Object o = pcds.getObjectInstance(ref, null, null, null);
    assertEquals(pcds.getDescription(), ((DriverAdapterCPDS) o).getDescription());
}