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


Java Core.createSystemContext方法代码示例

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


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

示例1: messageArrived

import com.mendix.core.Core; //导入方法依赖的package包/类
@Override
public void messageArrived(String topic, MqttMessage mqttMessage) throws Exception {
    try {
        logger.info(String.format("messageArrived: %s, %s, %s", topic, new String(mqttMessage.getPayload()), client.getClientId()));
        IContext ctx = Core.createSystemContext();
        ISession session = ctx.getSession();
        MqttSubscription subscription = getSubscriptionForTopic(topic);
        if (subscription != null) {
            String microflow = subscription.getOnMessageMicroflow();
            logger.info(String.format("Calling onMessage microflow: %s, %s", microflow, client.getClientId()));
            final ImmutableMap map = ImmutableMap.of("Topic", topic, "Payload", new String(mqttMessage.getPayload()));
            logger.info("Parameter map: " + map);
            //Core.execute(ctx, microflow, true, map);
            Core.executeAsync(ctx, microflow, true, map);
        } else {
            logger.error(String.format("Cannot find microflow for message received on topic %s", topic));
        }
    } catch (Exception e) {
        logger.error(e);
    }
}
 
开发者ID:ako,项目名称:MqttClient,代码行数:22,代码来源:MxMqttCallback.java

示例2: onMessage

import com.mendix.core.Core; //导入方法依赖的package包/类
public void onMessage(String channel, String message) {
	HashMap<String, Object> parameters = new HashMap<String, Object>();
	parameters.put("Channel", channel);
	parameters.put("Pattern", null);
	parameters.put("Message", message);
	IContext systemContext = Core.createSystemContext();
	try {
		Core.getLogger("RedisConnector").debug("onMessage: Channel " + channel + " message: " + message);
		Core.execute(systemContext, Constants.getOnReceiveMessageMicroflow(), parameters);
	} catch (CoreException e) {
		Core.getLogger("RedisConnector").error("Error onMessage: Channel " + channel + " Message: " + message, e);
	}
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:14,代码来源:MendixRedisPubSub.java

示例3: onPMessage

import com.mendix.core.Core; //导入方法依赖的package包/类
public void onPMessage(String pattern, String channel, String message) {
	HashMap<String, Object> parameters = new HashMap<String, Object>();
	parameters.put("Channel", channel);
	parameters.put("Pattern", pattern);
	parameters.put("Message", message);
	IContext systemContext = Core.createSystemContext();
	try {
		Core.getLogger("RedisConnector").debug("onMessage: Channel " + channel + " message: " + message);
		Core.execute(systemContext, redisconnector.proxies.constants.Constants.getOnReceiveMessageMicroflow(),
				parameters);
	} catch (CoreException e) {
		Core.getLogger("RedisConnector")
				.error("Error onPMessage: Channel " + channel + " Pattern " + pattern + " Message: " + message, e);
	}
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:16,代码来源:MendixRedisPubSub.java

示例4: serveRunStart

import com.mendix.core.Core; //导入方法依赖的package包/类
private synchronized void serveRunStart(HttpServletRequest request,
		HttpServletResponse response, String path) throws IOException, CoreException, InvalidCredentialsException {
	JSONObject input = parseInput(request);
	verifyPassword(input);

	IContext context = Core.createSystemContext();
	if (!detectedUnitTests) {
		TestManager.instance().findAllTests(context);
		detectedUnitTests = true;
	}
	
	if (testSuiteRunner != null && !testSuiteRunner.isFinished()) {
		throw new IllegalArgumentException("Cannot start a test run while another test run is still running");
	}
	
	LOG.info("[remote api] starting new test run");
	testSuiteRunner = new TestSuiteRunner();
	
	Thread t = new Thread() {
		@Override
		public void run() {
			testSuiteRunner.run();
		}
	};
	
	t.start();
	response.setStatus(HttpServletResponse.SC_NO_CONTENT);		
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:29,代码来源:RemoteApiServlet.java

示例5: getStatus

import com.mendix.core.Core; //导入方法依赖的package包/类
public synchronized JSONObject getStatus() throws CoreException {
	JSONObject result = new JSONObject();
	result.put("completed", this.finished);
	result.put("runtime", totalTime);
	
	IContext context = Core.createSystemContext();
	long count = 0l;
	long failures = 0l;
	
	for(TestSuite suite : XPath.create(context, TestSuite.class).all()) {
		count += suite.getTestCount();
		failures += suite.getTestFailedCount();
	}
	
	result.put("tests", count);
	result.put("failures", failures);
	
	JSONArray failedTests = new JSONArray();
	result.put("failed_tests", failedTests);
	
	for(UnitTest test : XPath.create(context, UnitTest.class)
			//failed tests
			.eq(UnitTest.MemberNames.Result, UnitTestResult._2_Failed)
			//in testsuites which are not running anymore
			.eq(UnitTest.MemberNames.UnitTest_TestSuite, TestSuite.entityName, TestSuite.MemberNames.Result, UnitTestResult._2_Failed)
			.all()) 
	{
		JSONObject i = new JSONObject();
		i.put("name", test.getName());
		i.put("error", test.getResultMessage());
		i.put("step", test.getLastStep());
		failedTests.put(i);
	}
	
	return result;
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:37,代码来源:RemoteApiServlet.java

示例6: runMicroflowTest

import com.mendix.core.Core; //导入方法依赖的package包/类
private boolean runMicroflowTest(String mf, UnitTest test, TestSuite testSuite) throws CoreException
{
	/** 
	 * Prepare...
	 */
	LOG.info("Starting unittest for microflow " + mf);

	reportStep("Starting microflow test '" + mf + "'");
	
	test.setResult(UnitTestResult._1_Running);
	test.setName(mf);
	test.setResultMessage("");
	test.setLastRun(new Date());

	if (Core.getInputParameters(mf).size() != 0) {
		test.setResultMessage("Unable to start test '" +  mf + "', microflow has parameters");
		test.setResult(UnitTestResult._2_Failed);
	}
	else if (Core.getReturnType(mf).getType() != IDataType.DataTypeEnum.Boolean && 
					 Core.getReturnType(mf).getType() != IDataType.DataTypeEnum.String &&
					 Core.getReturnType(mf).getType() != IDataType.DataTypeEnum.Nothing) {
		
		test.setResultMessage("Unable to start test '" +  mf + "', microflow should return either a boolean or a string or nothing at all");
		
		test.setResult(UnitTestResult._2_Failed);
	}

	commitSilent(test);

	IContext mfContext = Core.createSystemContext();
	if (testSuite.getAutoRollbackMFs())
		mfContext.startTransaction();

	long start = System.currentTimeMillis();

	try {
		Object resultObject = Core.execute(mfContext, mf, emptyArguments);
		
		start = System.currentTimeMillis() - start;
		boolean res = 	resultObject == null || Boolean.TRUE.equals(resultObject) || "".equals(resultObject);
			
		test.setResult(res ? UnitTestResult._3_Success : UnitTestResult._2_Failed);
		
		if (res) {
			test.setResultMessage("Microflow completed successfully");
		}
		
		return res;
	}
	catch(Exception e) {
		start = System.currentTimeMillis() - start;
		test.setResult(UnitTestResult._2_Failed);
		Throwable cause = ExceptionUtils.getRootCause(e);
		if (cause != null && cause instanceof AssertionException)
			test.setResultMessage(cause.getMessage());
		else
			test.setResultMessage("Exception: " + e.getMessage() + "\n\n" + ExceptionUtils.getStackTrace(e));
		return false;
		
	}
	finally {
		if (testSuite.getAutoRollbackMFs())
			mfContext.rollbackTransAction();
			
		test.setLastStep(lastStep);
		test.setReadableTime((start > 10000 ? Math.round(start / 1000) + " seconds" : start + " milliseconds"));
		commitSilent(test);

		LOG.info("Finished unittest " + mf + ": " + test.getResult());
	}
}
 
开发者ID:appronto,项目名称:RedisConnector,代码行数:72,代码来源:TestManager.java


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