Java 类javax.naming.StringRefAddr 实例源码

项目:tomcat7    文件:NamingContextListener.java   
/**
 * Set the specified EJBs in the naming context.
 */
public void addEjb(ContextEjb ejb) {

    // Create a reference to the EJB.
    Reference ref = new EjbRef
        (ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink());
    // Adding the additional parameters, if any
    Iterator<String> params = ejb.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) ejb.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        createSubcontexts(envCtx, ejb.getName());
        envCtx.bind(ejb.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:tomcat7    文件:NamingContextListener.java   
/**
 * Set the specified resources in the naming context.
 */
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {

    // Create a reference to the resource env.
    Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
    // Adding the additional parameters, if any
    Iterator<String> params = resourceEnvRef.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) resourceEnvRef.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        if (logger.isDebugEnabled())
            log.debug("  Adding resource env ref " + resourceEnvRef.getName());
        createSubcontexts(envCtx, resourceEnvRef.getName());
        envCtx.bind(resourceEnvRef.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:the-vigilantes    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:OpenVertretung    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:lams    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:lams    文件:NamingContextListener.java   
/**
 * Set the specified EJBs in the naming context.
 */
public void addEjb(ContextEjb ejb) {

    // Create a reference to the EJB.
    Reference ref = new EjbRef
        (ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink());
    // Adding the additional parameters, if any
    Iterator params = ejb.listProperties();
    while (params.hasNext()) {
        String paramName = (String) params.next();
        String paramValue = (String) ejb.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        createSubcontexts(envCtx, ejb.getName());
        envCtx.bind(ejb.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:lams    文件:NamingContextListener.java   
/**
 * Set the specified resources in the naming context.
 */
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {

    // Create a reference to the resource env.
    Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
    // Adding the additional parameters, if any
    Iterator params = resourceEnvRef.listProperties();
    while (params.hasNext()) {
        String paramName = (String) params.next();
        String paramValue = (String) resourceEnvRef.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        if (logger.isDebugEnabled())
            log.debug("  Adding resource env ref " + resourceEnvRef.getName());
        createSubcontexts(envCtx, resourceEnvRef.getName());
        envCtx.bind(resourceEnvRef.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:ProyectoPacientes    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:jerrydog    文件:NamingContextListener.java   
/**
 * Add additional parameters to the reference.
 */
private void addAdditionalParameters(NamingResources resources, 
                                     Reference ref, String name) {
    if (resources == null) {
        resources = namingResources;
    }
    ResourceParams resourceParameters = resources.findResourceParams(name);
    if (debug >= 2)
        log("  Resource parameters for " + name + " = " +
            resourceParameters);
    if (resourceParameters == null)
        return;
    Hashtable params = resourceParameters.getParameters();
    Enumeration _enum = params.keys();
    while (_enum.hasMoreElements()) {
        String paramName = (String) _enum.nextElement();
        String paramValue = (String) params.get(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
}
项目:BibliotecaPS    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:apache-tomcat-7.0.73-with-comment    文件:NamingContextListener.java   
/**
 * Set the specified EJBs in the naming context.
 */
public void addEjb(ContextEjb ejb) {

    // Create a reference to the EJB.
    Reference ref = new EjbRef
        (ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink());
    // Adding the additional parameters, if any
    Iterator<String> params = ejb.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) ejb.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        createSubcontexts(envCtx, ejb.getName());
        envCtx.bind(ejb.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:NamingContextListener.java   
/**
 * Set the specified resources in the naming context.
 */
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {

    // Create a reference to the resource env.
    Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
    // Adding the additional parameters, if any
    Iterator<String> params = resourceEnvRef.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) resourceEnvRef.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        if (logger.isDebugEnabled())
            log.debug("  Adding resource env ref " + resourceEnvRef.getName());
        createSubcontexts(envCtx, resourceEnvRef.getName());
        envCtx.bind(resourceEnvRef.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:lazycat    文件:NamingContextListener.java   
/**
 * Set the specified EJBs in the naming context.
 */
public void addEjb(ContextEjb ejb) {

    // Create a reference to the EJB.
    Reference ref = new EjbRef(ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink());
    // Adding the additional parameters, if any
    Iterator<String> params = ejb.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) ejb.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        createSubcontexts(envCtx, ejb.getName());
        envCtx.bind(ejb.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:lazycat    文件:NamingContextListener.java   
/**
 * Set the specified resources in the naming context.
 */
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {

    // Create a reference to the resource env.
    Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
    // Adding the additional parameters, if any
    Iterator<String> params = resourceEnvRef.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) resourceEnvRef.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        if (logger.isDebugEnabled())
            log.debug("  Adding resource env ref " + resourceEnvRef.getName());
        createSubcontexts(envCtx, resourceEnvRef.getName());
        envCtx.bind(resourceEnvRef.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:Geometry-wars    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:TPKB    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:cloudera-cli-scripts    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:daq-eclipse    文件:JNDIReferenceFactory.java   
/**
 * Create a Reference instance from a JNDIStorable object
 * 
 * @param instanceClassName
 * @param po
 * @return
 * @throws NamingException
 */

public static Reference createReference(String instanceClassName, JNDIStorableInterface po) throws NamingException {
    if (log.isTraceEnabled()) {
        log.trace("Creating reference: " + instanceClassName + "," + po);
    }
    Reference result = new Reference(instanceClassName, JNDIReferenceFactory.class.getName(), null);
    try {
        Properties props = po.getProperties();
        for (Enumeration iter = props.propertyNames(); iter.hasMoreElements();) {
            String key = (String)iter.nextElement();
            String value = props.getProperty(key);
            javax.naming.StringRefAddr addr = new javax.naming.StringRefAddr(key, value);
            result.add(addr);
        }
    } catch (Exception e) {
        log.error(e.getMessage(), e);
        throw new NamingException(e.getMessage());
    }
    return result;
}
项目:fil_project_mgmt_app_v2    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY,
            getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY,
            this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String
            .valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:jTDS    文件:JtdsDataSource.java   
public Reference getReference()
{
   Reference ref = new Reference( getClass().getName(), JtdsObjectFactory.class.getName(), null );

   Iterator it = _Config.entrySet().iterator();

   while( it.hasNext() )
   {
      Entry e = (Entry) it.next();

      String key = (String) e.getKey();
      String val = (String) e.getValue();

      ref.add( new StringRefAddr( key, val ) );
   }

   return ref;
}
项目:indoor-tracking    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY,
            getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY,
            this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String
            .valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:class-guard    文件:NamingContextListener.java   
/**
 * Set the specified resources in the naming context.
 */
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {

    // Create a reference to the resource env.
    Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
    // Adding the additional parameters, if any
    Iterator<String> params = resourceEnvRef.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) resourceEnvRef.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        if (logger.isDebugEnabled())
            log.debug("  Adding resource env ref " + resourceEnvRef.getName());
        createSubcontexts(envCtx, resourceEnvRef.getName());
        envCtx.bind(resourceEnvRef.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:cn1    文件:LinkRefTest.java   
public void testSerializable_Simple() throws ClassNotFoundException,
        IOException {
    String name = "www.apache.org/index.html";
    LinkRef linkRef = new LinkRef(name);
    StringRefAddr addr = new StringRefAddr("StringRefAddr",
            "This is a String RefAddr.");
    linkRef.add(addr);

    // write to byte array
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(linkRef);
    byte[] buffer = baos.toByteArray();
    oos.close();
    baos.close();

    // read from byte array
    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
    ObjectInputStream ois = new ObjectInputStream(bais);
    LinkRef linkRef2 = (LinkRef) ois.readObject();
    ois.close();
    bais.close();

    assertEquals(linkRef, linkRef2);
}
项目:cn1    文件:LinkRefTest.java   
public void testSerializable_compatibility() throws ClassNotFoundException,
        IOException {
    ObjectInputStream ois = new ObjectInputStream(getClass()
               .getClassLoader().getResourceAsStream(
                       "/serialization/javax/naming/LinkRef.ser"));
    LinkRef linkRef2 = (LinkRef) ois.readObject();
    ois.close();

    String name = "www.eclipse.org/org/index.html";
    LinkRef linkRef = new LinkRef(name);
    StringRefAddr addr = new StringRefAddr("StringRefAddr",
            "This is a String RefAddr.");
    linkRef.add(addr);

    assertEquals(linkRef, linkRef2);
}
项目:cn1    文件:StringRefAddrTest.java   
public void testSerializable_Simple() throws ClassNotFoundException,
        IOException {
    String type = "String address";
    String address = "this is a simple object";
    StringRefAddr addr = new StringRefAddr(type, address);

    // write to byte array
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(addr);
    byte[] buffer = baos.toByteArray();
    oos.close();
    baos.close();

    // read from byte array
    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
    ObjectInputStream ois = new ObjectInputStream(bais);
    StringRefAddr addr2 = (StringRefAddr) ois.readObject();
    ois.close();
    bais.close();

    assertEquals(addr, addr2);
}
项目:cn1    文件:ReferenceTest.java   
public void testToString_Simple() {
String className = "java.lang.String";
String classFactory = "class factory";
String location = "/home/neuser";
StringRefAddr addr0 = new StringRefAddr("String address",
        "this is a string");
StringRefAddr addr1 = new StringRefAddr("String address",
        "this is another string");
Reference reference = new Reference(className, addr0, classFactory,
        location);
reference.add(addr1);

/*
 * assertEquals( "Reference class name: " + className + "\nReference
 * addresses:\n\t" + addr0.toString() + "\n\t" + addr1.toString() +
 * "\n", reference.toString());
 */
assertNotNull(reference.toString());
      assertEquals("Reference Class Name: " + reference.getClassName() + "\n"
              + addr0.toString() + addr1.toString(), reference.toString());
  }
项目:hawtjms    文件:JNDIReferenceFactory.java   
/**
 * This will be called by a JNDIprovider when a Reference is retrieved from
 * a JNDI store - and generates the original instance
 *
 * @param object
 *        the Reference object
 * @param name
 *        the JNDI name
 * @param nameCtx
 *        the context
 * @param environment
 *        the environment settings used by JNDI
 *
 * @return the instance built from the Reference object
 *
 * @throws Exception
 *         if building the instance from Reference fails (usually class not
 *         found)
 */
@Override
public Object getObjectInstance(Object object, Name name, Context nameCtx, Hashtable<?, ?> environment)
        throws Exception {
    Object result = null;
    if (object instanceof Reference) {
        Reference reference = (Reference) object;
        Class<?> theClass = loadClass(this, reference.getClassName());
        if (JNDIStorable.class.isAssignableFrom(theClass)) {
            JNDIStorable store = (JNDIStorable) theClass.newInstance();
            Map<String, String> properties = new HashMap<String, String>();
            for (Enumeration<RefAddr> iter = reference.getAll(); iter.hasMoreElements();) {
                StringRefAddr addr = (StringRefAddr) iter.nextElement();
                properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent().toString());
            }
            store.setProperties(properties);
            result = store;
        }
    } else {
        throw new RuntimeException("Object " + object + " is not a reference");
    }
    return result;
}
项目:cn1    文件:ReferenceTest.java   
public void testSerializable_compatibility() throws ClassNotFoundException,
        IOException {
    ObjectInputStream ois = new ObjectInputStream(getClass()
               .getClassLoader().getResourceAsStream(
                       "/serialization/javax/naming/Reference.ser"));
    Reference reference2 = (Reference) ois.readObject();
    ois.close();

    Reference reference = new Reference("dazzle.naming.Reference",
            "dazzle.naming.factory.RefFactory", "http://www.apache.org");
    StringRefAddr addr = new StringRefAddr("StringRefAddr",
            "This is a String RefAddr.");
    BinaryRefAddr addr2 = new BinaryRefAddr("BinaryRefAddr", new byte[] {
            'a', 'b', 'c' });
    reference.add(addr);
    reference.add(addr2);

    assertEquals(reference, reference2);
}
项目:apache-tomcat-7.0.57    文件:NamingContextListener.java   
/**
 * Set the specified EJBs in the naming context.
 */
public void addEjb(ContextEjb ejb) {

    // Create a reference to the EJB.
    Reference ref = new EjbRef
        (ejb.getType(), ejb.getHome(), ejb.getRemote(), ejb.getLink());
    // Adding the additional parameters, if any
    Iterator<String> params = ejb.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) ejb.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        createSubcontexts(envCtx, ejb.getName());
        envCtx.bind(ejb.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:apache-tomcat-7.0.57    文件:NamingContextListener.java   
/**
 * Set the specified resources in the naming context.
 */
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {

    // Create a reference to the resource env.
    Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
    // Adding the additional parameters, if any
    Iterator<String> params = resourceEnvRef.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) resourceEnvRef.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        if (logger.isDebugEnabled())
            log.debug("  Adding resource env ref " + resourceEnvRef.getName());
        createSubcontexts(envCtx, resourceEnvRef.getName());
        envCtx.bind(resourceEnvRef.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:apache-tomcat-7.0.57    文件:NamingContextListener.java   
/**
 * Set the specified resources in the naming context.
 */
public void addResourceEnvRef(ContextResourceEnvRef resourceEnvRef) {

    // Create a reference to the resource env.
    Reference ref = new ResourceEnvRef(resourceEnvRef.getType());
    // Adding the additional parameters, if any
    Iterator<String> params = resourceEnvRef.listProperties();
    while (params.hasNext()) {
        String paramName = params.next();
        String paramValue = (String) resourceEnvRef.getProperty(paramName);
        StringRefAddr refAddr = new StringRefAddr(paramName, paramValue);
        ref.add(refAddr);
    }
    try {
        if (logger.isDebugEnabled())
            log.debug("  Adding resource env ref " + resourceEnvRef.getName());
        createSubcontexts(envCtx, resourceEnvRef.getName());
        envCtx.bind(resourceEnvRef.getName(), ref);
    } catch (NamingException e) {
        logger.error(sm.getString("naming.bindFailed", e));
    }

}
项目:SMPT42    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:ForYou    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY,
            getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY,
            this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String
            .valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:group-five    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:locaviewer    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:locaviewer    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY, getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY, this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String.valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:manydesigns.cn    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY,
            getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY,
            this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String
            .valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:Gladiatus    文件:MysqlDataSource.java   
/**
 * Required method to support this class as a <CODE>Referenceable</CODE>.
 * 
 * @return a Reference to this data source
 * 
 * @throws NamingException
 *             if a JNDI error occurs
 */
public Reference getReference() throws NamingException {
    String factoryName = "com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory";
    Reference ref = new Reference(getClass().getName(), factoryName, null);
    ref.add(new StringRefAddr(NonRegisteringDriver.USER_PROPERTY_KEY,
            getUser()));
    ref.add(new StringRefAddr(NonRegisteringDriver.PASSWORD_PROPERTY_KEY,
            this.password));
    ref.add(new StringRefAddr("serverName", getServerName()));
    ref.add(new StringRefAddr("port", "" + getPort()));
    ref.add(new StringRefAddr("databaseName", getDatabaseName()));
    ref.add(new StringRefAddr("url", getUrl()));
    ref.add(new StringRefAddr("explicitUrl", String
            .valueOf(this.explicitUrl)));

    //
    // Now store all of the 'non-standard' properties...
    //
    try {
        storeToRef(ref);
    } catch (SQLException sqlEx) {
        throw new NamingException(sqlEx.getMessage());
    }

    return ref;
}
项目:qpid-jms    文件:JNDIReferenceFactory.java   
/**
 * This will be called by a JNDIprovider when a Reference is retrieved from
 * a JNDI store - and generates the original instance
 *
 * @param object
 *        the Reference object
 * @param name
 *        the JNDI name
 * @param nameCtx
 *        the context
 * @param environment
 *        the environment settings used by JNDI
 *
 * @return the instance built from the Reference object
 *
 * @throws Exception
 *         if building the instance from Reference fails (usually class not found)
 */
@Override
public Object getObjectInstance(Object object, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception {
    Object result = null;
    if (object instanceof Reference) {
        Reference reference = (Reference) object;
        Class<?> theClass = loadClass(this, reference.getClassName());
        if (JNDIStorable.class.isAssignableFrom(theClass)) {
            JNDIStorable store = (JNDIStorable) theClass.getDeclaredConstructor().newInstance();
            Map<String, String> properties = new HashMap<String, String>();
            for (Enumeration<RefAddr> iter = reference.getAll(); iter.hasMoreElements();) {
                StringRefAddr addr = (StringRefAddr) iter.nextElement();
                properties.put(addr.getType(), (addr.getContent() == null) ? "" : addr.getContent().toString());
            }
            store.setProperties(properties);
            result = store;
        }
    } else {
        throw new RuntimeException("Object " + object + " is not a reference");
    }
    return result;
}
项目:OpenDiabetes    文件:JDBCDataSource.java   
/**
 * Retrieves the Reference of this object.
 *
 * @return The non-null Reference of this object.
 * @exception NamingException If a naming exception was encountered
 *          while retrieving the reference.
 */
public Reference getReference() throws NamingException {

    String    cname = "org.hsqldb.jdbc.JDBCDataSourceFactory";
    Reference ref   = new Reference(getClass().getName(), cname, null);

    ref.add(new StringRefAddr("database", getDatabase()));
    ref.add(new StringRefAddr("user", getUser()));
    ref.add(new StringRefAddr("password", password));
    ref.add(new StringRefAddr("loginTimeout",
                              Integer.toString(loginTimeout)));

    return ref;
}