com.memority.toolkit.rule.api.LibraryRule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of toolkit-rule-api Show documentation
Show all versions of toolkit-rule-api Show documentation
This artifact provides the API classes that are necessary to implement the contracts of Memority configuration Rules.
/*
* 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;
import com.memority.toolkit.rule.api.context.Context;
/**
* A Library Rule is a reusable piece of script that may be used by other (script) rules. Use the
* {@link com.memority.toolkit.rule.api.api.Libs LIBS} API to retrieve a lazy-instantiated singleton of a named
* Library Rule.
* Note: This only realy make sense for sanboxed groovy rules (which have a real, acessible underlying class).
*/
public interface LibraryRule extends Rule {
/**
* Creates and initializes a new instance of the underlying Rule class.
*
* @param context the execution context
* @return a new, initialized instance of the Library underlying class.
* @throws UnsupportedOperationException if the underlying engine does not provide compiled script classes
*/
Object newInstance(Context context);
/**
* Returns the underlying compiled script class.
*
* @param useCache instructs the rule engine to use its cache or not, if any. Useful eg. with groovy engine, when
* temporarily overriding the compiler configuration.
* @return the underlying compiled script class
* @throws UnsupportedOperationException if the underlying engine does not provide compiled script classes
*/
Class> getRuleClass(boolean useCache);
}