本文整理了Java中org.xwiki.context.ExecutionContext
类的一些代码示例,展示了ExecutionContext
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ExecutionContext
类的具体详情如下:
包路径:org.xwiki.context.ExecutionContext
类名称:ExecutionContext
[英]Contains all state data related to the current user action. Note that the execution context is independent of the environment and all environment-dependent data are stored in the Container component instead.
[中]包含与当前用户操作相关的所有状态数据。请注意,执行上下文独立于环境,所有与环境相关的数据都存储在容器组件中。
代码示例来源:origin: org.xwiki.commons/xwiki-commons-observation-local
/**
* @return the events stacked in the execution context
*/
private Stack<BeginEvent> getCurrentEvents()
{
Stack<BeginEvent> events = null;
ExecutionContext context = this.execution.getContext();
if (context != null) {
events = (Stack<BeginEvent>) context.getProperty(KEY_EVENTS);
}
return events;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-dashboard-macro
private void reduceDashboardRecursionCounter() throws MacroExecutionException
{
ExecutionContext ec = this.execution.getContext();
if (ec != null) {
Integer dashboardCalls = (Integer) ec.getProperty(DASHBOARD_MACRO_CALLS);
if (dashboardCalls != null) {
if (dashboardCalls > 0) {
ec.setProperty(DASHBOARD_MACRO_CALLS, dashboardCalls - 1);
}
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-icon-default
/**
* @param isonSet the icon set stored in the context
*/
public void setIconSet(IconSet isonSet)
{
ExecutionContext econtext = this.execution.getContext();
if (econtext != null) {
if (isonSet != null) {
econtext.setProperty(EPROPERTY_ICON, isonSet);
} else {
econtext.removeProperty(EPROPERTY_ICON);
}
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-notifications-filters-api
@Override
public Map<String, Boolean> getToggeableFilterActivations(DocumentReference user) throws NotificationException
{
// We need to store the user reference in the cache's key, otherwise all users of the same context will share
// the same cache, which can happen when a notification email is triggered.
final String contextEntry = String.format(CONTEXT_KEY_FORMAT, USER_TOGGLEABLE_FILTER_PREFERENCES,
serializer.serialize(user));
ExecutionContext context = execution.getContext();
if (context.hasProperty(contextEntry)) {
return (Map<String, Boolean>) context.getProperty(contextEntry);
}
Map<String, Boolean> values = modelBridge.getToggeableFilterActivations(user);
context.setProperty(contextEntry, values);
return values;
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-context
/**
* @param properties the properties to add to the context
*/
public void setProperties(Map<String, Object> properties)
{
for (Map.Entry<String, Object> entry : properties.entrySet()) {
setProperty(entry.getKey(), entry.getValue());
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-lesscss-default
private void setProperty(String propertyName, Object value)
{
Object property = getContext().getProperty(propertyName);
if (property != null) {
getContext().setProperty(propertyName, value);
} else {
getContext().newProperty(propertyName).inherited().initial(value).declare();
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-localization-api
/**
* @return the current bundles
*/
private Map<String, SortedSet<TranslationBundle>> getBundlesInternal()
{
Map<String, SortedSet<TranslationBundle>> bundles;
ExecutionContext context = this.execution.getContext();
if (context != null) {
bundles = (Map<String, SortedSet<TranslationBundle>>) context.getProperty(CKEY_BUNDLES);
if (bundles == null) {
// Register the Execution Context property with an empty map that will be populated for each wiki.
bundles = new HashMap<>();
context.newProperty(CKEY_BUNDLES).inherited().cloneValue().initial(bundles).declare();
}
} else {
bundles = new HashMap<>();
}
return bundles;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-observation-remote
/**
* Make sure an ExecutionContext initialized for remote->local thread.
*/
private void initializeContext()
{
if (this.execution.getContext() == null) {
ExecutionContext context = new ExecutionContext();
try {
this.executionContextManager.initialize(context);
} catch (Exception e) {
this.logger.error("failed to initialize execution context", e);
}
}
}
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* Initialize execution context for the current thread.
*
* @return the new execution context
* @throws ExecutionContextException error when try to initialize execution context
*/
protected ExecutionContext initExecutionContext() throws ExecutionContextException
{
ExecutionContextManager ecim = Utils.getComponent(ExecutionContextManager.class);
Execution execution = Utils.getComponent(Execution.class);
ExecutionContext ec = new ExecutionContext();
ecim.initialize(ec);
ec.setProperties(this.properties);
execution.setContext(ec);
return ec;
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-url-api
@Override
public void initialize(ExecutionContext context) throws ExecutionContextException
{
if (!context.hasProperty(DefaultURLContextManager.CONTEXT_KEY)) {
context.newProperty(DefaultURLContextManager.CONTEXT_KEY)
.inherited()
.initial(this.configuration.getURLFormatId())
.declare();
}
}
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-context
/**
* @param key the key under which to save the passed property value
* @param value the value to set
*/
public void setProperty(String key, Object value)
{
ExecutionContextProperty property = this.properties.get(key);
if (property == null) {
LOGGER.debug("Implicit declaration of property {}.", key);
newProperty(key).declare();
property = this.properties.get(key);
} else if (property.isFinal()) {
throw new PropertyIsFinalException(key);
}
property.setValue(value);
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-url-api
@Override
public void setURLFormatId(String urlFormatId)
{
ExecutionContext ec = this.execution.getContext();
ec.setProperty(CONTEXT_KEY, urlFormatId);
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-rendering-async-api
/**
* Push a new {@link ContextUse} in the context.
*/
public void pushContextUse()
{
ExecutionContext econtext = this.execution.getContext();
if (econtext != null) {
Deque<ContextUse> deque = (Deque<ContextUse>) econtext.getProperty(KEY_CONTEXTUSE);
if (deque == null) {
deque = new LinkedList<>();
DeclarationBuilder propertyBuilder = econtext.newProperty(KEY_CONTEXTUSE);
propertyBuilder.inherited();
propertyBuilder.makeFinal();
propertyBuilder.initial(deque);
propertyBuilder.declare();
}
deque.push(new ContextUse());
}
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-tool-test-component
public void initializeExecution() throws Exception
{
// Initialize the Execution Context
ExecutionContextManager ecm = getComponentManager().getInstance(ExecutionContextManager.class);
ExecutionContext ec = new ExecutionContext();
ecm.initialize(ec);
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-velocity
@Override
public void initialize(ExecutionContext executionContext) throws ExecutionContextException
{
try {
if (!executionContext.hasProperty(VELOCITY_CONTEXT_ID)) {
VelocityContext context = this.velocityContextFactory.createContext();
executionContext.newProperty(VELOCITY_CONTEXT_ID)
.cloneValue()
.inherited()
.initial(context)
.declare();
}
} catch (XWikiVelocityException e) {
throw new ExecutionContextException("Failed to initialize Velocity Context", e);
}
}
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-observation-local
/**
* @return the events stacked in the execution context
*/
private Stack<BeginEvent> getCurrentEvents()
{
Stack<BeginEvent> events = null;
ExecutionContext context = this.execution.getContext();
if (context != null) {
events = (Stack<BeginEvent>) context.getProperty(DefaultObservationContext.KEY_EVENTS);
}
return events;
}
代码示例来源:origin: com.xpn.xwiki.platform/xwiki-core
/**
* {@inheritDoc}
*
* @see org.xwiki.context.ExecutionContextInitializer#initialize(org.xwiki.context.ExecutionContext)
*/
public void initialize(ExecutionContext context) throws ExecutionContextException
{
XWikiContext xcontext = (XWikiContext) context.getProperty(XWikiContext.EXECUTIONCONTEXT_KEY);
if (xcontext == null) {
// if the XWikiContext is not provided in the Execution context it mean the Execution context is being
// initialized by a daemon thread
XWikiContext stubContext = this.stubContextProvider.createStubContext();
if (stubContext != null) {
// the stub context has been properly initialized, we inject it in the Execution context
context.setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, stubContext);
}
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-icon-script
/**
* Store a caught exception in the context, so that it can be later retrieved using {@link #getLastError()}.
*
* @param e the exception to store, can be {@code null} to clear the previously stored exception
* @see #getLastError()
* @since 6.3RC1
*/
private void setLastError(IconException e)
{
this.execution.getContext().setProperty(ERROR_KEY, e);
}
}
代码示例来源:origin: org.xwiki.commons/xwiki-commons-context
@Override
public void run()
{
// Create a clean Execution Context
ExecutionContext context = new ExecutionContext();
try {
this.componentManager.<ExecutionContextManager>getInstance(ExecutionContextManager.class)
.initialize(context);
} catch (Exception e) {
throw new RuntimeException("Failed to initialize Runnable [" + this.runnable + "] execution context", e);
}
try {
this.runnable.run();
} finally {
try {
this.componentManager.<Execution>getInstance(Execution.class).removeContext();
} catch (ComponentLookupException e) {
throw new RuntimeException("Failed to cleanup ExecutionContext after Runnable execution", e);
}
}
}
}
代码示例来源:origin: org.xwiki.platform/xwiki-platform-extension-script
/**
* Get the error generated while performing the previously called action.
*
* @return an eventual exception or {@code null} if no exception was thrown
*/
public Exception getLastError()
{
return (Exception) this.execution.getContext().getProperty(EXTENSIONERROR_KEY);
}
内容来源于网络,如有侵权,请联系作者删除!