当前位置: 首页>>代码示例>>Java>>正文


Java NotesContext.termThread方法代码示例

本文整理汇总了Java中com.ibm.domino.xsp.module.nsf.NotesContext.termThread方法的典型用法代码示例。如果您正苦于以下问题:Java NotesContext.termThread方法的具体用法?Java NotesContext.termThread怎么用?Java NotesContext.termThread使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ibm.domino.xsp.module.nsf.NotesContext的用法示例。


在下文中一共展示了NotesContext.termThread方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: afterTest

import com.ibm.domino.xsp.module.nsf.NotesContext; //导入方法依赖的package包/类
@Override
protected void afterTest(final FrameworkMethod method) {
	if (oldCl == null) {
		super.tearDown();
		return;
	}
	Thread.currentThread().setContextClassLoader(oldCl);
	oldCl = null;
	Factory.termThread();
	NotesContext.termThread();

}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:13,代码来源:ModuleJUnitRunner.java

示例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();
	}

}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:33,代码来源:SessionFactory.java

示例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();
		}
	}
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:35,代码来源:XotsDominoExecutor.java

示例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();
	}
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:42,代码来源:XotsWrappedTask.java

示例5: 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();
	}
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:53,代码来源:XotsDominoExecutor.java

示例6: 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;
}
 
开发者ID:OpenNTF,项目名称:org.openntf.domino,代码行数:52,代码来源:XotsNsfScanner.java


注:本文中的com.ibm.domino.xsp.module.nsf.NotesContext.termThread方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。