當前位置: 首頁>>代碼示例>>Java>>正文


Java StringRefAddr類代碼示例

本文整理匯總了Java中javax.naming.StringRefAddr的典型用法代碼示例。如果您正苦於以下問題:Java StringRefAddr類的具體用法?Java StringRefAddr怎麽用?Java StringRefAddr使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


StringRefAddr類屬於javax.naming包,在下文中一共展示了StringRefAddr類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addEjb

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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));
    }

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:25,代碼來源:NamingContextListener.java

示例2: addResourceEnvRef

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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));
    }

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:26,代碼來源:NamingContextListener.java

示例3: getReference

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:bragex,項目名稱:the-vigilantes,代碼行數:31,代碼來源:MysqlDataSource.java

示例4: addEjb

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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));
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:NamingContextListener.java

示例5: addResourceEnvRef

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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));
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:26,代碼來源:NamingContextListener.java

示例6: addAdditionalParameters

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:24,代碼來源:NamingContextListener.java

示例7: addEjb

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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));
	}

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:24,代碼來源:NamingContextListener.java

示例8: addResourceEnvRef

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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));
	}

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:26,代碼來源:NamingContextListener.java

示例9: createReference

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:DiamondLightSource,項目名稱:daq-eclipse,代碼行數:29,代碼來源:JNDIReferenceFactory.java

示例10: getReference

import javax.naming.StringRefAddr; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:hinsenchan,項目名稱:fil_project_mgmt_app_v2,代碼行數:34,代碼來源:MysqlDataSource.java

示例11: getReference

import javax.naming.StringRefAddr; //導入依賴的package包/類
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;
}
 
開發者ID:milesibastos,項目名稱:jTDS,代碼行數:19,代碼來源:JtdsDataSource.java

示例12: testSerializable_Simple

import javax.naming.StringRefAddr; //導入依賴的package包/類
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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:26,代碼來源:LinkRefTest.java

示例13: testSerializable_compatibility

import javax.naming.StringRefAddr; //導入依賴的package包/類
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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:17,代碼來源:LinkRefTest.java

示例14: testSerializable_Simple

import javax.naming.StringRefAddr; //導入依賴的package包/類
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);
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:24,代碼來源:StringRefAddrTest.java

示例15: testToString_Simple

import javax.naming.StringRefAddr; //導入依賴的package包/類
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());
  }
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:ReferenceTest.java


注:本文中的javax.naming.StringRefAddr類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。