本文整理汇总了Java中com.ibm.domino.xsp.module.nsf.NotesContext.initThread方法的典型用法代码示例。如果您正苦于以下问题:Java NotesContext.initThread方法的具体用法?Java NotesContext.initThread怎么用?Java NotesContext.initThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.domino.xsp.module.nsf.NotesContext
的用法示例。
在下文中一共展示了NotesContext.initThread方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openSessionCloner
import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
public static Session openSessionCloner(){
Session session = null;
try{
SessionCloner sessionCloner=SessionCloner.getSessionCloner();
NSFComponentModule module= NotesContext.getCurrent().getModule();
NotesContext context = new NotesContext( module );
NotesContext.initThread( context );
session = sessionCloner.getSession();
}catch(NotesException n){
logger.log(Level.SEVERE,null,n);
}
return session;
}
示例2: TestTrustedSessionWNotesContext
import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
@Test
public void TestTrustedSessionWNotesContext() throws ServletException {
NSFComponentModule module = ModuleLoader.loadModule("names.nsf", false);
NotesContext ctx = new NotesContext(module);
NotesContext.initThread(ctx);
try {
ctx.initRequest(new FakeHttpRequest("CN=Roland Praml/OU=01/OU=int/O=FOCONIS"));
Session sess = Factory.getSession(SessionType.TRUSTED);
assertTrue(sess.isTrustedSession());
assertFalse(sess.isAnonymous());
assertFalse(sess.isRestricted());
System.out.println("Native Session User name " + sess.getUserName());
System.out.println("Native Session Effective name " + sess.getEffectiveUserName());
assertEquals(TestEnv.SESSION_USER, sess.getUserName());
assertEquals(TestEnv.SESSION_USER, sess.getEffectiveUserName());
// now check if we can access a database on a trusted server (this should work)
Database nab = sess.getDatabase(TestEnv.REMOTE_TRUSTED_SERVER, "names.nsf");
assertNotNull(nab);
IconNote icn = nab.getDesign().getIconNote();
assertNotNull(icn);
// now check if we can access a database on an untrusted server (this should work, because we have a trusted session)
nab = sess.getDatabase(TestEnv.REMOTE_UNTRUSTED_SERVER, "names.nsf");
assertNotNull(nab);
} finally {
NotesContext.termThread();
}
}
示例3: XotsModuleTasklet
import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
public XotsModuleTasklet(final String moduleName, final String className, final Object... args) {
super();
this.moduleName = moduleName;
this.className = className;
this.args = args;
if (NotesContext.getCurrentUnchecked() == null) {
// perform a check if there is NO open context.
// if there is an open context, we cannot switch the module.
// maybe we can do this in a separate thread
NSFComponentModule module = loadModule();
NotesContext ctx = new NotesContext(module);
NotesContext.initThread(ctx);
try {
Factory.initThread(ODAPlatform.getAppThreadConfig(module.getNotesApplication()));
try {
ClassLoader mcl = module.getModuleClassLoader();
ClassLoader oldCl = switchClassLoader(mcl);
Factory.setClassLoader(mcl);
try {
Class<?> clazz = mcl.loadClass(className);
findConstructor(clazz, args); // try if we can find the constructor
} catch (ClassNotFoundException e) {
throw new IllegalArgumentException("Could not load class " + className + " in module " + moduleName, e);
} finally {
switchClassLoader(oldCl);
}
} finally {
Factory.termThread();
}
} finally {
NotesContext.termThread();
}
}
}
示例4: callOrRun
import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
/**
* Common code for the wrappers
*
* @param module
* @param bubbleException
* @param sessionFactory
* @param callable
* @param runnable
* @return
*/
protected Object callOrRun(final NSFComponentModule module) throws Exception {
NSFComponentModule codeModule = null;
if (module != null) {
codeModule = module.getTemplateModule() == null ? module : module.getTemplateModule();
if (module.isDestroyed() || codeModule.isDestroyed()) {
throw new IllegalArgumentException("Module was destroyed in the meantime. Cannot run");
}
module.updateLastModuleAccess();
codeModule.updateLastModuleAccess();
}
final NotesContext ctx = new NotesContext(module);
NotesContext.initThread(ctx);
try {
// checkme: What should we use here?
//Factory.initThread(ODAPlatform.getAppThreadConfig(module.getNotesApplication()));
Factory.initThread(sourceThreadConfig);
try {
return invokeTasklet(ctx, codeModule);
} catch (Exception e) {
DominoUtils.handleException(e);
return null;
} finally {
Factory.termThread();
}
} finally {
NotesContext.termThread();
}
}
示例5: beforeTest
import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
@Override
protected void beforeTest(final FrameworkMethod method) {
String db = getDatabase(method);
if (StringUtil.isEmpty(db)) {
super.beforeTest(method);
return;
}
assertNotNull(db);
NSFComponentModule module = null;
try {
module = ModuleLoader.loadModule(db, false);
} catch (ServletException e1) {
e1.printStackTrace();
}
assertNotNull("Module " + db + " does not exist or is locked by server process", module);
NotesContext ctx = new NotesContext(module);
NotesContext.initThread(ctx); // Request is initialized later
Factory.initThread(Factory.STRICT_THREAD_CONFIG);
String runAs = getRunAs(method);
if (StringUtil.isEmpty(runAs)) {
runAs = Factory.getLocalServerName();
}
FakeHttpRequest req = new FakeHttpRequest(runAs);
try {
ctx.initRequest(req);
} catch (java.lang.NoSuchFieldError nfe) {
System.err.println("Could not init context completely: " + nfe);
nfe.printStackTrace();
} catch (ServletException e) {
e.printStackTrace();
}
oldCl = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(module.getModuleClassLoader());
ISessionFactory sf = new XPageCurrentSessionFactory();
//ISessionFactory sfFull = new XPageSessionFactory(ctx.getSessionAsSignerFullAdmin(), true);
Factory.setSessionFactory(sf, SessionType.CURRENT);
//Factory.setSessionFactory(sfFull, SessionType.CURRENT_FULL_ACCESS);
}
示例6: call
import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
@Override
public Object call() throws Exception {
NSFComponentModule module = loadModule();
NotesContext ctx = new NotesContext(module);
NotesContext.initThread(ctx);
try {
// CHECKME which username should we use? Server
ctx.initRequest(new FakeHttpRequest(Factory.getLocalServerName()));
// ThreadLock readLock = null;
//
// if (ODAPlatform.isAppFlagSet("LOCKXOTS", codeModule.getNotesApplication())) {
// readLock = getLockManager(codeModule).getReadLock();
// readLock.acquire();
// }
// try {
Factory.initThread(ODAPlatform.getAppThreadConfig(module.getNotesApplication()));
try {
ClassLoader mcl = module.getModuleClassLoader();
ClassLoader oldCl = switchClassLoader(mcl);
Factory.setClassLoader(mcl);
Factory.setSessionFactory(new NativeSessionFactory(moduleName), SessionType.CURRENT);
DominoUtils.setBubbleExceptions(true);
try {
// Construct & set up
Class<?> clazz = mcl.loadClass(className);
Constructor<?> cTor = findConstructor(clazz, args);
setWrappedTask(cTor.newInstance(args));
Object wrappedTask = getWrappedTask();
if (wrappedTask instanceof Observable && observers != null) {
for (Observer o : observers) {
((Observable) wrappedTask).addObserver(o);
}
}
return invokeTasklet(ctx, module);
} finally {
switchClassLoader(oldCl);
}
} finally {
setWrappedTask(null);
Factory.termThread();
}
// } finally {
// if (readLock != null)
// readLock.release();
// }
} finally {
NotesContext.termThread();
}
}
示例7: call
import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
@Override
public List<ScheduleData> call() throws Exception {
NSFComponentModule module = ModuleLoader.loadModule(apiPath, true);
NotesContext ctx = new NotesContext(module);
NotesContext.initThread(ctx);
List<ScheduleData> ret = new ArrayList<ScheduleData>();
try {
ctx.initRequest(new FakeHttpRequest(Factory.getLocalServerName()));
RuntimeFileSystem vfs = module.getRuntimeFileSystem();
Map<String, NSFResource> resources = vfs.getAllResources();
ClassLoader mcl = module.getModuleClassLoader();
String dbPath = ctx.getCurrentDatabase().getFilePath();
for (NSFResource resource : resources.values()) {
if (resource instanceof NSFXspClassResource) {
String path = resource.getNSFPath();
// Check all classes, but not xsp.*
if (path.startsWith("WEB-INF/classes/") && path.endsWith(".class") && !path.startsWith("WEB-INF/classes/xsp/")) {
String className = path.substring(16, path.length() - 6).replace('/', '.');
try {
Class<?> clazz = mcl.loadClass(className);
ScheduleData data = XotsUtil.getSchedule(dbPath, clazz);
if (data != null) {
ret.add(data);
}
//if (effectiveSchedDefs != null) {
// ret.add(new ScheduleDataNSF(replicaID, className, apiPath, effectiveSchedDefs));
//}
} catch (Exception e) {
Factory.println(this, "Cannot load: " + className + ". " + e.getMessage());
}
}
}
//if (resource instanceof NSFXspClassResource) {
// NSFXspClassResource clResource = (NSFXspClassResource) resource;
// clResource.
// byte[] arrayOfByte = ((RuntimeFileSystem)localObject3).getFileContentAsByteArray(((NotesContext)localObject2).getNotesDatabase(), str);
//}
}
} finally {
NotesContext.termThread();
}
return ret;
}