kerry
4 years ago
7 changed files with 73 additions and 44 deletions
@ -0,0 +1,56 @@
|
||||
package com.fr.design.utils; |
||||
|
||||
import com.fr.general.GeneralContext; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.rpc.ExceptionHandler; |
||||
import com.fr.rpc.RPCInvokerExceptionInfo; |
||||
import com.fr.stable.EnvChangedListener; |
||||
import com.fr.workspace.WorkContext; |
||||
import com.fr.workspace.server.predefined.PredefinedStyleOperator; |
||||
|
||||
/** |
||||
* Created by kerry on 2020-11-06 |
||||
*/ |
||||
public class PredefinedStyleUtils { |
||||
/** |
||||
* 判断当前环境是否支持预定义样式的设置 |
||||
*/ |
||||
private static Boolean allowPredefinedSetting = null; |
||||
|
||||
static { |
||||
GeneralContext.addEnvChangedListener(new EnvChangedListener() { |
||||
@Override |
||||
public void envChanged() { |
||||
allowPredefinedSetting = checkAllowPredefinedSetting(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 判断当前环境是否支持预定义样式的设置 |
||||
* @return boolean |
||||
*/ |
||||
public synchronized static boolean isAllowPredefinedSetting() { |
||||
if (allowPredefinedSetting == null) { |
||||
allowPredefinedSetting = checkAllowPredefinedSetting(); |
||||
} |
||||
return allowPredefinedSetting; |
||||
} |
||||
|
||||
private PredefinedStyleUtils() { |
||||
|
||||
} |
||||
|
||||
private static boolean checkAllowPredefinedSetting() { |
||||
if (WorkContext.getCurrent().isLocal()) { |
||||
return true; |
||||
} |
||||
return WorkContext.getCurrent().get(PredefinedStyleOperator.class, new ExceptionHandler() { |
||||
@Override |
||||
public Object callHandler(RPCInvokerExceptionInfo exceptionInfo) { |
||||
FineLoggerFactory.getLogger().error(exceptionInfo.getException().getMessage(), exceptionInfo.getException()); |
||||
return false; |
||||
} |
||||
}).allowPredefinedSetting(); |
||||
} |
||||
} |
Loading…
Reference in new issue