本文整理匯總了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;
}