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


Java NamingException.setRootCause方法代碼示例

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


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

示例1: lookup

import javax.naming.NamingException; //導入方法依賴的package包/類
@Override
public Object lookup(Name name) throws NamingException {
	if (name.isEmpty())
		return cloneCtx();

	Name nm = getMyComponents(name);
	String atom = nm.get(0);
	Object inter = iBindings.get(atom);

	if (nm.size() == 1) {
		if (inter == null)
			throw new NameNotFoundException(name + " not found");

		try {
			return NamingManager.getObjectInstance(inter, new CompositeName().add(atom), this, iEnv);
		} catch (Exception e) {
			NamingException ne = new NamingException("getObjectInstance failed");
			ne.setRootCause(e);
			throw ne;
		}
	} else {
		if (!(inter instanceof Context))
			throw new NotContextException(atom + " does not name a context");

		return ((Context) inter).lookup(nm.getSuffix(1));
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:28,代碼來源:LocalContext.java

示例2: next

import javax.naming.NamingException; //導入方法依賴的package包/類
public Object next() throws NamingException {
	String name = (String) iNames.nextElement();
	Object obj = iBindings.get(name);

	try {
		obj = NamingManager.getObjectInstance(obj, new CompositeName().add(name), LocalContext.this, LocalContext.this.iEnv);
	} catch (Exception e) {
		NamingException ne = new NamingException("getObjectInstance failed");
		ne.setRootCause(e);
		throw ne;
	}

	return new Binding(name, obj);
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:15,代碼來源:LocalContext.java

示例3: callStoredProcedure

import javax.naming.NamingException; //導入方法依賴的package包/類
/**
 * Invoke a Stored Procedure
 * 
 * @param ctx The execution context
 * @param procedureName The procedure to execute
 * @param arguments The procedure's arguments
 * @return The execution resut
 * @throws NamingException If we have had an error whil executing the stored procedure
 */
public static Object callStoredProcedure( LdapContext ctx, String procedureName, Object[] arguments )
    throws NamingException
{
    String language = "Java";

    Object responseObject;
    try
    {
        /**
         * Create a new stored procedure execution request.
         */
        StoredProcedureRequestImpl req = new StoredProcedureRequestImpl( 0, procedureName, language );

        /**
         * For each argument UTF-8-encode the type name
         * and Java-serialize the value
         * and add them to the request as a parameter object.
         */
        for ( int i = 0; i < arguments.length; i++ )
        {
            byte[] type;
            byte[] value;
            type = arguments[i].getClass().getName().getBytes( "UTF-8" );
            value = SerializationUtils.serialize( ( Serializable ) arguments[i] );
            req.addParameter( type, value );
        }

        /**
         * Call the stored procedure via the extended operation
         * and get back its return value.
         */
        ExtendedRequest jndiReq = LdapApiServiceFactory.getSingleton().toJndi( req );
        ExtendedResponse resp = ctx.extendedOperation( jndiReq );

        /**
         * Restore a Java object from the return value.
         */
        byte[] responseStream = resp.getEncodedValue();
        responseObject = SerializationUtils.deserialize( responseStream );
    }
    catch ( Exception e )
    {
        NamingException ne = new NamingException();
        ne.setRootCause( e );
        throw ne;
    }

    return responseObject;
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:59,代碼來源:JavaStoredProcUtils.java


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