当前位置: 首页>>代码示例>>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;未经允许,请勿转载。