本文整理汇总了Java中com.mendix.systemwideinterfaces.core.IContext.getSession方法的典型用法代码示例。如果您正苦于以下问题:Java IContext.getSession方法的具体用法?Java IContext.getSession怎么用?Java IContext.getSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mendix.systemwideinterfaces.core.IContext
的用法示例。
在下文中一共展示了IContext.getSession方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: messageArrived
import com.mendix.systemwideinterfaces.core.IContext; //导入方法依赖的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);
}
}
示例2: getSessionTimeZone
import com.mendix.systemwideinterfaces.core.IContext; //导入方法依赖的package包/类
public static TimeZone getSessionTimeZone( IContext context ) {
ISession session = context.getSession();
if ( session != null ) {
TimeZone timeZone = session.getTimeZone();
if ( timeZone != null )
return timeZone;
return getUTCTimeZone();
}
return getUTCTimeZone();
}
示例3: getSessionTimeZone
import com.mendix.systemwideinterfaces.core.IContext; //导入方法依赖的package包/类
public static TimeZone getSessionTimeZone(IContext context) {
ISession session = context.getSession();
if (session != null) {
TimeZone timeZone = session.getTimeZone();
if (timeZone != null) {
return timeZone;
}
return getUTCTimeZone();
}
return getUTCTimeZone();
}
示例4: runMicroflowInBackground
import com.mendix.systemwideinterfaces.core.IContext; //导入方法依赖的package包/类
public static Boolean runMicroflowInBackground(final IContext context, final String microflowName,
final IMendixObject paramObject)
{
final ISession session = context.getSession();
if (paramObject != null)
session.retain(paramObject);
MFSerialExecutor.instance().execute(new Runnable() {
@Override
public void run()
{
try
{
IContext c = Core.createSystemContext();
if (paramObject != null) {
Core.executeAsync(c, microflowName, true, paramObject).get(); //MWE: somehow, it only works with system context... well thats OK for now.
}
else
Core.executeAsync(c, microflowName, true, new HashMap<String,Object>()).get(); //MWE: somehow, it only works with system context... well thats OK for now.
}
catch (Exception e)
{
throw new RuntimeException("Failed to run Async: "+ microflowName + ": " + e.getMessage(), e);
}
finally {
if (paramObject != null)
session.release(paramObject.getId());
}
}
});
return true;
}