本文整理汇总了Java中com.mendix.systemwideinterfaces.core.ISession类的典型用法代码示例。如果您正苦于以下问题:Java ISession类的具体用法?Java ISession怎么用?Java ISession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISession类属于com.mendix.systemwideinterfaces.core包,在下文中一共展示了ISession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: messageArrived
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的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: getContextFor
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
public static IContext getContextFor(IContext context, String username, boolean sudoContext) {
if (username == null || username.isEmpty()) {
throw new RuntimeException("Assertion: No username provided");
}
ISession session = getSessionFor(context, username);
IContext c = session.createContext();
if (sudoContext) {
return c.getSudoContext();
}
return c;
}
示例3: getSessionFor
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
private static ISession getSessionFor(IContext context, String username) {
ISession session = Core.getActiveSession(username);
if (session == null) {
IContext newContext = context.getSession().createContext().getSudoContext();
newContext.startTransaction();
try {
session = initializeSessionForUser(newContext, username);
} catch (CoreException e) {
newContext.rollbackTransAction();
throw new RuntimeException("Failed to initialize session for user: " + username + ": " + e.getMessage(), e);
} finally {
newContext.endTransaction();
}
}
return session;
}
示例4: executeAction
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
@Override
public java.lang.Boolean executeAction() throws Exception
{
// BEGIN USER CODE
ISession session = getContext().getSession();
IContext newContext = session.createContext();
Core.commit(newContext, mxObject);
newContext.endTransaction();
return true;
// END USER CODE
}
示例5: getContextFor
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
public static IContext getContextFor(IContext context, String username, boolean sudoContext) {
if (username == null || username.isEmpty()) {
throw new RuntimeException("Assertion: No username provided");
}
if (username.equals(context.getSession().getUser().getName()))
{
return context;
}
else
{
ISession session = getSessionFor(context, username);
IContext c = session.createContext();
if (sudoContext) {
return c.getSudoContext();
}
return c;
}
}
示例6: getContextFor
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
public static IContext getContextFor(IContext context, String username, boolean sudoContext) {
if (username == null || username.isEmpty()) {
throw new RuntimeException("Assertion: No username provided");
}
// Session does not have a user when it's a scheduled event.
if (context.getSession().getUser() != null && username.equals(context.getSession().getUser().getName()))
{
return context;
}
else
{
ISession session = getSessionFor(context, username);
IContext c = session.createContext();
if (sudoContext) {
return c.createSudoClone();
}
return c;
}
}
示例7: getSessionFor
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
private static ISession getSessionFor(IContext context, String username) {
ISession session = Core.getActiveSession(username);
if (session == null) {
IContext newContext = context.getSession().createContext().createSudoClone();
newContext.startTransaction();
try {
session = initializeSessionForUser(newContext, username);
} catch (CoreException e) {
newContext.rollbackTransAction();
throw new RuntimeException("Failed to initialize session for user: " + username + ": " + e.getMessage(), e);
} finally {
newContext.endTransaction();
}
}
return session;
}
示例8: getSessionTimeZone
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的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();
}
示例9: getSessionTimeZone
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的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();
}
示例10: initializeSessionForUser
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
private static ISession initializeSessionForUser(IContext context, String username) throws CoreException {
IUser user = Core.getUser(context, username);
if (user == null) {
throw new RuntimeException("Assertion: user with username '" + username + "' does not exist");
}
return Core.initializeSession(user, null);
}
示例11: runMicroflowInBackground
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的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;
}
示例12: executeAction
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
@Override
public Boolean executeAction() throws Exception
{
// BEGIN USER CODE
ISession session = getContext().getSession();
IContext newContext = session.createContext();
Core.commit(newContext, mxObject);
newContext.endTransaction();
return true;
// END USER CODE
}
示例13: sessionIsActive
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
private static boolean sessionIsActive(ISession session)
{
for (ISession s : Core.getActiveSessions())
if (s.equals(session))
return true;
return false;
}
示例14: releaseOldLocks
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
public synchronized static void releaseOldLocks()
{
Set<ISession> activeSessions = new HashSet<ISession>(Core.getActiveSessions()); //Lookup with Ord(log(n)) instead of Ord(n).
List<Long> tbrm = new ArrayList<Long>();
for (Entry<Long, ISession> lock : locks.entrySet())
if (!activeSessions.contains(lock.getValue()))
tbrm.add(lock.getKey());
for(Long key : tbrm)
locks.remove(key);
}
示例15: getFingerPrint
import com.mendix.systemwideinterfaces.core.ISession; //导入依赖的package包/类
public static String getFingerPrint(ISession session)
{
String agent = session.getUserAgent();
if (agent != null)
return base64Encode(agent.getBytes());
return "";
}