本文整理汇总了Java中javax.naming.CannotProceedException类的典型用法代码示例。如果您正苦于以下问题:Java CannotProceedException类的具体用法?Java CannotProceedException怎么用?Java CannotProceedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CannotProceedException类属于javax.naming包,在下文中一共展示了CannotProceedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContinuationDirContext
import javax.naming.CannotProceedException; //导入依赖的package包/类
/**
* Creates a context in which to continue a <tt>DirContext</tt> operation.
* Operates just like <tt>NamingManager.getContinuationContext()</tt>,
* only the continuation context returned is a <tt>DirContext</tt>.
*
* @param cpe
* The non-null exception that triggered this continuation.
* @return A non-null <tt>DirContext</tt> object for continuing the operation.
* @exception NamingException If a naming exception occurred.
*
* @see NamingManager#getContinuationContext(CannotProceedException)
*/
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
CannotProceedException cpe) throws NamingException {
Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
if (env == null) {
env = new Hashtable<>(7);
} else {
// Make a (shallow) copy of the environment.
env = (Hashtable<Object,Object>) env.clone();
}
env.put(CPE, cpe);
return (new ContinuationDirContext(cpe, env));
}
示例2: getContinuationDirContext
import javax.naming.CannotProceedException; //导入依赖的package包/类
/**
* Creates a context in which to continue a {@code DirContext} operation.
* Operates just like {@code NamingManager.getContinuationContext()},
* only the continuation context returned is a {@code DirContext}.
*
* @param cpe
* The non-null exception that triggered this continuation.
* @return A non-null {@code DirContext} object for continuing the operation.
* @exception NamingException If a naming exception occurred.
*
* @see NamingManager#getContinuationContext(CannotProceedException)
*/
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
CannotProceedException cpe) throws NamingException {
Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
if (env == null) {
env = new Hashtable<>(7);
} else {
// Make a (shallow) copy of the environment.
env = (Hashtable<Object,Object>) env.clone();
}
env.put(CPE, cpe);
return (new ContinuationDirContext(cpe, env));
}
示例3: testGetContinuationDirContext
import javax.naming.CannotProceedException; //导入依赖的package包/类
public void testGetContinuationDirContext() throws NamingException {
// Step 1: Write a simple class which implements
// LdapContext and InitialContextFactory.
// Please refer to the following class MyLdapContext
// Step 2: Create an instance of MyLdapContext
DirContext context = new MyLdapContext();
// Step 3: Create an instance of CannotProceedException,
// and set the resolve object as "context"
CannotProceedException exception = new CannotProceedException(
"TestGetContinuationDirContext");
exception.setResolvedObj(context);
// Step 4: Call DirectoryManager.getContinuationDirContext and pass
// the "exception";
DirContext newContext = DirectoryManager
.getContinuationDirContext(exception);
// Step 5: check result
assertNotNull(newContext);
// System.out.println(context);
// System.out.println(newContext);
}
示例4: 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);
}
}
示例5: assertCPE
import javax.naming.CannotProceedException; //导入依赖的package包/类
private void assertCPE(CannotProceedException cpe, CompositeName altName,
MockContext context, Hashtable<String, String> h, CannotProceedException e,
Object obj) {
assertNull(e.getExplanation());
assertNull(e.getMessage());
assertNull(e.getRootCause());
assertNull(e.getRemainingName());
assertNull(e.getRemainingNewName());
assertNull(e.getResolvedName());
assertSame(e.getAltName(), altName);
assertSame(e.getAltNameCtx(), context);
assertEquals(e.getResolvedObj(), obj);
assertSame(e, cpe);
if (h != null) {
assertSame(e.getEnvironment(), h);
} else {
assertSame(e.getEnvironment().get(NamingManager.CPE), e);
}
}
示例6: 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);
}
}
示例7: 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);
}
}
示例8: testGetContinuationContext_OBJ_name_context_null
import javax.naming.CannotProceedException; //导入依赖的package包/类
public void testGetContinuationContext_OBJ_name_context_null()
throws NamingException {
log.setMethod("testGetContinuationContext_OBJ_name_context_null()");
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);
try {
NamingManager.getContinuationContext(cpe);
fail();
} catch (CannotProceedException e) {
assertCPE(cpe, altName, context, null, e, obj);
}
}
示例9: 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());
}
示例10: getMeanGOPLength
import javax.naming.CannotProceedException; //导入依赖的package包/类
public static int getMeanGOPLength(IContainer container) throws CannotProceedException, IOException {
int numStreams = container.getNumStreams();
if( numStreams <= 0 )
throw new IOException( "No streams found in container." );
List<IIndexEntry> index_list = null;
for( int j = 0; j < container.getNumStreams(); j++ ) {
IStream stream = container.getStream(j);
IStreamCoder coder = stream.getStreamCoder();
if( coder.getCodecType() != ICodec.Type.CODEC_TYPE_VIDEO)
continue;
index_list = stream.getIndexEntries();
}
if( index_list == null || index_list.size() == 0)
throw new CannotProceedException( "No index entries found!" );
int k = 0;
for( int i = 0; i < index_list.size(); i++ )
if ( index_list.get(i).isKeyFrame() ) k++;
return index_list.size() / k;
}
示例11: getContinuationDirContext
import javax.naming.CannotProceedException; //导入依赖的package包/类
/**
* Create the next <code>DirContext</code> when using federation so that
* the <code>DirContext</code> operation can be reinvoked.
* This should work similarly to
* <code>NamingManager.getContinuationContext</code> except that a
* reference to a <code>DirContext</code> is returned.
* <p>
* This method is also responsible for setting the property denoted by the
* <code>CPE</code> string to be the supplied
* <code>CannotProceedException</code> for that environment.</p>
*
* @param cpe the <code>CannotProceedException</code> generated by the
* <code>DirContext</code> of the previous naming system when
* it can proceed no further.
* @return the next <code>DirContext</code> when using federation
* @throws NamingException if the resolved object is not set or if a
* <code>DirContext</code> cannot be obtained from it either
* directly or indirectly.
*/
public static DirContext getContinuationDirContext(CannotProceedException cpe)
throws NamingException {
// obtain next context using NamingManager
Context nextContext = null;
try {
nextContext = NamingManager.getContinuationContext(cpe);
} catch (CannotProceedException e) {
// tolerate CannotProceedException here
}
// if it is a DirContext
if (nextContext instanceof DirContext) {
// return as DirContext
return (DirContext) nextContext;
} else {
// in case it's Context but not DirContext, wrap it as DirContext and return
return new Context2DirContextWrapper(nextContext, cpe);
}
}
示例12: getObjectInstance
import javax.naming.CannotProceedException; //导入依赖的package包/类
/**
* Returns new instance of the
* org.apache.harmony.test.func.api.javax.naming.directory.provider.dns.TestCtxFactory
*
* @param obj
* @param name
* @param nameCtx
* @param environment
* @param attrs
* @return
* @throws Exception
*/
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
Hashtable environment, Attributes attrs) throws Exception {
Object o = environment.get("java.naming.spi.CannotProceedException");
if ((o instanceof CannotProceedException)
&& (nameCtx instanceof DirContext)) {
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.harmony.test.func.api.javax."
+ "naming.provider.dns.TestCtxFactory");
return new InitialDirContext(env);
}
return null;
}
示例13: makeContinuationContext
import javax.naming.CannotProceedException; //导入依赖的package包/类
public static DirContext makeContinuationContext ( String codebase, String clazz ) throws Exception {
Class<?> ccCl = Class.forName("javax.naming.spi.ContinuationDirContext"); //$NON-NLS-1$
Constructor<?> ccCons = ccCl.getDeclaredConstructor(CannotProceedException.class, Hashtable.class);
ccCons.setAccessible(true);
CannotProceedException cpe = new CannotProceedException();
Reflections.setFieldValue(cpe, "stackTrace", new StackTraceElement[0]);
cpe.setResolvedObj(new Reference("Foo", clazz, codebase));
return (DirContext) ccCons.newInstance(cpe, null);
}
示例14: applyConfiguration
import javax.naming.CannotProceedException; //导入依赖的package包/类
/**
* Applies the specified configuration and stores the Configuration Report for
* later viewing.
*
* @param configurationId id of the configuration of the request
* @throws CannotProceedException In case a serious error occurs (for example
* in case a null Configuration Report is received).
*/
public void applyConfiguration(final long configurationId) throws CannotProceedException {
ReportHandler reportHandler = new ReportHandler(configurationId);
progressReports.put(String.valueOf(configurationId), reportHandler);
ConfigurationReport report = configurationService.applyConfiguration(configurationId, reportHandler);
logger.debug("getConfigurationReport: Received configuration report? -> " + configurationId + ": " + (report == null ? "NULL" : "SUCCESS"));
if (report == null) {
logger.error("Received NULL Configuration report for configuration id:" + configurationId);
throw new CannotProceedException("Did not receive Configuration Report.");
}
logger.debug("getConfigurationReport: Report=" + report.toXML());
if (report.getName().equals("UNKNOWN")) {
if (configurationReports.containsKey(String.valueOf(configurationId))) {
configurationReports.get(String.valueOf(configurationId)).add(report);
} else {
List<ConfigurationReport> reports = getConfigurationReports(String.valueOf(configurationId));
if (reports.isEmpty()) {
reports.add(report);
}
configurationReports.put(String.valueOf(configurationId), reports);
}
}
// store the report for viewing later
ConfigurationReportHeader header = new ConfigurationReportHeader(report.getId(), report.getName(), report.getUser(), report.getStatus(),
report.getStatusDescription(), report.getTimestamp());
configurationReportHeaders.add(header);
}
示例15: getContinuationContext
import javax.naming.CannotProceedException; //导入依赖的package包/类
/**
* Creates a context in which the context operation must be continued.
* This method is used by operations on names that span multiple namespaces.
*
* @param cpe the exception that triggered this continuation. This method
* obtains the environment ({@link CannotProceedException#getEnvironment()}
* and sets the environment property {@link #CPE} = cpe.
*
* @return a non null context for continuing the operation
*
* @throws NamingException if the naming problems have occured
*/
public static Context getContinuationContext (CannotProceedException cpe)
throws NamingException
{
Hashtable env = cpe.getEnvironment ();
if (env != null)
env.put (CPE, cpe);
// TODO: Check if this implementation matches the API specification
try
{
Object obj = getObjectInstance (cpe.getResolvedObj(),
cpe.getAltName (),
cpe.getAltNameCtx (),
env);
if (obj != null)
return (Context) obj;
}
catch (Exception _)
{
}
// fix stack trace for re-thrown exception (message confusing otherwise)
cpe.fillInStackTrace();
throw cpe;
}