All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.memority.toolkit.rule.api.context.Context Maven / Gradle / Ivy

Go to download

This artifact provides the API classes that are necessary to implement the contracts of Memority configuration Rules.

There is a newer version: 3.43.1
Show newest version
/*
 * Copyright (c) 2016-2023 Memority. All Rights Reserved.
 *
 * This file is part of Memority Toolkit API , a Memority project.
 *
 * This file is released under the Memority Public Artifacts End-User License Agreement,
 * see 
 * Unauthorized copying of this file, via any medium is strictly prohibited.
 */
package com.memority.toolkit.rule.api.context;

import com.memority.toolkit.core.api.security.PasswordGeneratorApi;

import java.util.Map;

/**
 * A Context holds information about the situation in which an operation is performed. It may contain
 * short lived information (strictly used for the current, atomic operation) and long lived ones (that
 * may be reused for several operations (for example the currently logged in user).
 *
 * 

The Context is divided into multiple sub-contexts that may or may not be present depending on the * operation that is being performed. Those contexts can be accessed in a type safe manner through specific * getter methods (see {@link #getActorsContext()}...)

* *

Also, each sub-context implements the Map<String,Object> interface and can hold any * number of specific properties.

* *

The KEY_XXX are used to make the contexts available in scripts or SPEL, through * correspondingly named variables.

* *

Operations that transform the context will typically use the {@link VariablesContext} to store * transformation variables, as most of the other sub-contexts are immutable by design.

* */ public interface Context { /** * The main context key, exposed as {@value #KEY_CTXT} */ String KEY_CTXT = "CTXT"; /** * The context variables, exposed as {@value #KEY_VARS} */ String KEY_VARS = "VARS"; /** * The context of all actors that participate in the current operation, exposed as {@value #KEY_ACTORS} */ String KEY_ACTORS = "ACTORS"; /** * the subject actor (the user currently logged in), exposed as {@value #KEY_SUBJECT} */ String KEY_SUBJECT = "SUBJECT"; /** * The "requester" actor, exposed as {@value #KEY_REQUESTER} */ String KEY_REQUESTER = "REQUESTER"; /** * The simulation context key, exposed as {@value #KEY_SIMULATION} */ @SuppressWarnings("JavaDoc") // JavaDoc pointing to itself String KEY_SIMULATION = "SIMULATION"; /** * The rule context key, exposed as {@value #KEY_RULE} */ String KEY_RULE = "RULE"; /** * The password generation API (see {@link PasswordGeneratorApi}, exposed as {@value #KEY_PASSWORD} */ String KEY_PASSWORD = "PASSWORD"; /** * @return the objects that will also be bound to the Groovy execution environment in addition to this Context, see ScriptRuleSupport. * The Map key is the name enabling to access the object in the Groovy script, such as "OBJECT" or "ATTRIBUTE". * By convention this "master" Context is always bound with the key {@value #KEY_CTXT} to the Groovy script. */ Map getRootContexts(); /** * @return the sub-context describing the logged in user (subject) */ ActorsContext getActorsContext(); /** * @return the sub-context holding the mutable variables */ VariablesContext getVariablesContext(); /** * @return The notification event type */ String getNotificationEventType(); /** * * @return {@code true} indicating that this context is part of a simulation process */ boolean isSimulation(); /** * When set (eg. in the context of a simulation), the seed to use when generating random stuff to produce * consistent results across simulations. This may be used in custom groovy rules to seed random generators. * * @return a non null value in simulation context, null otherwise */ Long getRandomSeed(); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy