Skip to content
Nicolas Himmelmann edited this page Jul 27, 2018 · 16 revisions

Framework Extension HowTos

How to create a new context class

(This process still requires some work to do, we plan to simplify this in future versions of the framework.)

Adding a new context type to the framework is a process of the following steps.

  1. Add and implement the new class in the package vstore.framework.context.types:

    • Your context class should inherit from the base class VContextType.
    • The name of your context class should be appended as a type for the generic:
      • Example: public class MyContextType extends VContextType<MyContextType> { ... }
    • Give your new context class the desired attributes.
    • The following abstract methods must be implemented:
      • The constructor MyContextType(JSONObject): Used for creating a new object of your context type from a given json object.
      • JSONObject getJson(): Used for retrieving a JSON representation of your new context type
      • boolean matches(MyContextType other): Used for checking, if your context matches another given context of the same type
  2. Add your new context type to the ContextDescription class in the package vstore.framework.context:

    • Add it as a private member.
    • Add the necessary initializations in the constructors.
    • Add getter and setter for your context type.
    • Add a void clear[MyContextType]Context() method which sets the private member to null.
    • Add a boolean has[MyContextType]Context() method, which returns true if your context type is set in the ContextDescription
    • Add it to the getJson() function of the ContextDescription class.
  3. Proceed similarly for the RuleContextDescription class, if you want to be able to use your context in the decision rules

  4. Finally, define the desired behavior when using the context during the matching procedure (class Matching in the package vstore.framework.matching):

    • Add a method private boolean checkConditions_[yourConditionName](VStoreRule r, VStoreFile f) { ... }
      • Must return true, if the rule should be kept in the result set
      • Mus return false, if the rule should be deleted from the result set, because your context conditions are not met.
    • Add your condition to the conjunction in the method boolean eliminateRuleByContext().
  5. That's it! Now you can pass a context description and rules to the framework which use your context type.

App-Developer HowTos

Getting Started

Clone this wiki locally