本文整理汇总了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));
}
}
示例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);
}
示例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;
}