本文整理汇总了Java中javax.naming.CannotProceedException.setEnvironment方法的典型用法代码示例。如果您正苦于以下问题:Java CannotProceedException.setEnvironment方法的具体用法?Java CannotProceedException.setEnvironment怎么用?Java CannotProceedException.setEnvironment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.naming.CannotProceedException
的用法示例。
在下文中一共展示了CannotProceedException.setEnvironment方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testGetContinuationContext_OBJ_name_context_badnameh
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
public void testGetContinuationContext_OBJ_name_context_badnameh()
throws NamingException {
log.setMethod("testGetContinuationContext_OBJ_name_context_badnameh()");
CannotProceedException cpe = new CannotProceedException();
Object obj = "resolved object";
cpe.setResolvedObj(obj);
CompositeName altName = new CompositeName("abc/abc");
cpe.setAltName(altName);
MockContext context = new MockContext(new Hashtable<String, Object>());
cpe.setAltNameCtx(context);
Hashtable<String, String> h = new Hashtable<String, String>();
h.put(Context.OBJECT_FACTORIES, "bad name:asdfa");
cpe.setEnvironment(h);
try {
NamingManager.getContinuationContext(cpe);
fail();
} catch (CannotProceedException e) {
assertCPE(cpe, altName, context, h, e, obj);
}
}
示例2: testGetContinuationContext_OBJ_name_context_wrongh
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
public void testGetContinuationContext_OBJ_name_context_wrongh()
throws NamingException {
log.setMethod("testGetContinuationContext_OBJ_name_context_wrongh()");
CannotProceedException cpe = new CannotProceedException();
Object obj = "resolved object";
cpe.setResolvedObj(obj);
CompositeName altName = new CompositeName("abc/abc");
cpe.setAltName(altName);
MockContext context = new MockContext(new Hashtable<String, Object>());
cpe.setAltNameCtx(context);
Hashtable<String, String> h = new Hashtable<String, String>();
h
.put(Context.OBJECT_FACTORIES,
"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactory");
cpe.setEnvironment(h);
try {
NamingManager.getContinuationContext(cpe);
fail();
} catch (CannotProceedException e) {
assertCPE(cpe, altName, context, h, e, obj);
}
}
示例3: testGetContinuationContext_null_name_context_h
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
public void testGetContinuationContext_null_name_context_h()
throws NamingException {
log.setMethod("testGetContinuationContext_null_name_context_h()");
CannotProceedException cpe = new CannotProceedException();
CompositeName altName = new CompositeName("abc/abc");
cpe.setAltName(altName);
MockContext context = new MockContext(new Hashtable<String, Object>());
cpe.setAltNameCtx(context);
Hashtable<String, String> h = new Hashtable<String, String>();
h.put(Context.OBJECT_FACTORIES,"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockContextObjectFactory");
cpe.setEnvironment(h);
try {
NamingManager.getContinuationContext(cpe);
fail();
} catch (CannotProceedException e) {
assertCPE(cpe, altName, context, h, e, null);
}
}
示例4: testConstructorAndGetterSetter
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
public void testConstructorAndGetterSetter() throws InvalidNameException {
log.setMethod("testConstructorAndGetterSetter()");
CannotProceedException cpe = new CannotProceedException();
Name altName = new CompositeName("1");
Context altContext = null;
Hashtable<?, ?> h = new Hashtable<Object, Object>();
Name newName = new CompositeName("2");
cpe.setAltName(altName);
assertEquals(altName, cpe.getAltName());
cpe.setAltNameCtx(altContext);
assertEquals(altContext, cpe.getAltNameCtx());
cpe.setEnvironment(h);
assertEquals(h, cpe.getEnvironment());
cpe.setRemainingNewName(newName);
assertEquals(newName, cpe.getRemainingNewName());
}
示例5: testGetContinuationContext_OBJ_name_context_h
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
public void testGetContinuationContext_OBJ_name_context_h()
throws NamingException {
log.setMethod("testGetContinuationContext_OBJ_name_context_h()");
CannotProceedException cpe = new CannotProceedException();
cpe.setResolvedObj("resolved object");
cpe.setAltName(new CompositeName("abc/abc"));
cpe.setAltNameCtx(new MockContext(new Hashtable<String, Object>()));
Hashtable<String, String> h = new Hashtable<String, String>();
h
.put(Context.OBJECT_FACTORIES,
"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockContextObjectFactory");
cpe.setEnvironment(h);
Context r = NamingManager.getContinuationContext(cpe);
assertTrue(r instanceof MockContext);
}
示例6: testGetContinuationContext_OBJ_null_ctx_h
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
public void testGetContinuationContext_OBJ_null_ctx_h()
throws NamingException {
log.setMethod("testGetContinuationContext_OBJ_null_ctx_h()");
CannotProceedException cpe = new CannotProceedException();
cpe.setResolvedObj("resolved object");
cpe.setAltNameCtx(new MockContext(new Hashtable<String, Object>()));
Hashtable<String, String> h = new Hashtable<String, String>();
h
.put(Context.OBJECT_FACTORIES,
"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockContextObjectFactory");
cpe.setEnvironment(h);
Context r = NamingManager.getContinuationContext(cpe);
assertTrue(r instanceof MockContext);
}
示例7: testGetContinuationContext_OBJ_name_null_h
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
public void testGetContinuationContext_OBJ_name_null_h()
throws NamingException {
log.setMethod("testGetContinuationContext_OBJ_name_null_h()");
CannotProceedException cpe = new CannotProceedException();
cpe.setResolvedObj("resolved object");
cpe.setAltName(new CompositeName("abc/abc"));
Hashtable<String, String> h = new Hashtable<String, String>();
h
.put(Context.OBJECT_FACTORIES,
"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockContextObjectFactory");
cpe.setEnvironment(h);
Context r = NamingManager.getContinuationContext(cpe);
assertTrue(r instanceof MockContext);
}
示例8: getContinuationContext
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
/**
* Create the next context when using federation. All the information
* required to do this is contained in the
* <code>CannotProceedException</code> <code>e</code>. If the resolved
* object is null then throw the supplied
* <code>CannotProceedException</code> <code>e</code> using the stack
* details from this thread. The resolved object in <code>e</code> may
* already be a <code>Context</code>. This is the case where the service
* provider gives an explicit pointer to the next naming system. A Context
* object is returned as the continuation context, but need not be the same
* object instance as the resolved object.
* <p>
* If the resolved object is not already a <code>Context</code> then it is
* necessary to use the resolved object together with the
* <code>altName</code> name, the <code>altNameCtx</code> context and
* the environment hashtable to get an instance of the object. This should
* then be a context which is returned as the continuation context. If an
* instance cannot be obtained then throw the supplied
* <code>CannotProceedException</code> using the stack details from this
* thread.
* </p>
* <p>
* This method is responsible for setting the property denoted by the
* <code>CPE</code> string to be the supplied
* <code>CannotProceedException</code> for the exception <code>e</code>
* environment. The continuation context should then inherit this property.
* </p>
*
* @param cpe
* the <code>CannotProceedException</code> generated by the
* context of the previous naming system when it can proceed no
* further.
* @return the next Context when using federation
* @throws NamingException
* if the resolved object is null or if a context cannot be
* obtained from it either directly or indirectly.
*/
@SuppressWarnings("unchecked") //$NON-NLS-1$
public static Context getContinuationContext(CannotProceedException cpe)
throws NamingException {
Context ctx = null;
// set CPE property of the env
if (cpe.getEnvironment() == null) {
cpe.setEnvironment(new Hashtable<String, CannotProceedException>());
}
((Hashtable<String, CannotProceedException>) cpe.getEnvironment()).put(CPE, cpe);
// if resolved object is null
if (null == cpe.getResolvedObj()) {
// re-throw cpe
cpe.fillInStackTrace();
throw cpe;
}
// if cpe's resolved obj is Context
if (cpe.getResolvedObj() instanceof Context) {
// accept it as the continuation context
ctx = (Context) cpe.getResolvedObj();
} else {
// otherwise, call getObjectInstance() to get a context instance
try {
ctx = (Context) getObjectInstance(cpe.getResolvedObj(), cpe
.getAltName(), cpe.getAltNameCtx(), cpe
.getEnvironment());
} catch (Exception ex) {
// throw back CPE in case of any exception
throw cpe;
}
// if ctx cannot be obtained
if (null == ctx) {
// re-throw CPE
cpe.fillInStackTrace();
throw cpe;
}
}
// return the continuation context
return ctx;
}
示例9: createCannotProceedException
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
/**
* Lookups the first component (considered a URL) of the specified name
* using {@link #lookup(String)} and wraps it into
* {@link CannotProceedException}.
*
* @param name
* Name to parse.
*
* @return Created {@link CannotProceedException}.
*
* @throws NamingException
* If some naming error occurs.
*/
protected final CannotProceedException createCannotProceedException(
Name name) throws NamingException {
CannotProceedException cpe = new CannotProceedException();
cpe.setResolvedObj(lookup(name.get(0)));
cpe.setEnvironment(environment);
return cpe;
}
示例10: createCannotProceedException
import javax.naming.CannotProceedException; //导入方法依赖的package包/类
/**
* Lookups the first component (considered a URL)
* of the specified name using {@link #lookup(String)}
* and wraps it into {@link CannotProceedException}.
*
* @param name
* Name to parse.
*
* @return Created {@link CannotProceedException}.
*
* @throws NamingException
* If some naming error occurs.
*/
protected final CannotProceedException createCannotProceedException(
Name name) throws NamingException {
CannotProceedException cpe = new CannotProceedException();
cpe.setResolvedObj(lookup(name.get(0)));
cpe.setEnvironment(environment);
return cpe;
}