ReBL User Guide and Reference Manual
Version 1.0
2017/06/10
This can be used to create reusable business logic or full reusable business languages (ie Domain Specific Languages).
Contents
PART 0 - Legal
Copyright ©2017 Logic Machine Ltd.Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
PART 1 - Introduction
1.1 Introduction
This document contains a detailed and comprehensive user guide for the "ReBL" language template library developed by Logic:Machine Software Development Studio.The purpose of this library is to simplify and standardise the creation of either reuseable Business Logic or full reuseable Business Languages (i.e. Domain Specific Languages).
Reuse is at the heart of this approach, with the idea being to break down the business functionality into small meaningful blocks which can be written and tested separately before being amalgamated into a fully functioning system.
Related business components can be gathered together into classes, making use of all the normal features offered by the implementing language, such as encapsulation.
The ideas and architecture embedded within this platform are language agnostic. So whilst our implementation of this language platform is written in Java, it may be ported to any other language.
1.2 Overview
All of the applications and utilities created by Logic:Machine Software Development Studio are built on top of a re-usable platform.This platform therefore provides all of the low-level infrastructure support required by the applications, and this core platform is reused across all applications developed by Logic:Machine.
Full applications comprise:
- the core platform
- the relevant application configuration files - including internationalised translations and localisation settings
- the application business logic
- an automated test suite - typically including combinations of unit tests, integration tests, system tests and performance tests
- build scripts
- application documentation, including:
- comprehensive code documentation (ie JavaDocs)
- a user guide
- an installation guide
- an administration guide
- a system operation guide
- a troubleshooting guide, including details of error codes
- a set of automated test results and typical performance results (where applicable)
- a project web-site, automatically created by the build tools
This project focuses on the creation of Reusable Business Languages or Reusable Business Logic, based on generic templates.
Whilst our standard reuseable core platform may be used to create all of the underlying infrastructure code, this is not a mandatory requirement. It is therefore equally encouraged to utilise this business language template library alongside any implementation of the infrastructure code.
One key feature of reusable infrastructure code however is that no such code should attempt to handle any exceptions, since each component should be a self-contained block of functionality which performs a single activity (i.e. the single responsibility principle). Each block should therefore attempt to perform a single activity, which will either succeed or fail. Indication of failure should be highlighted to the caller by either returning a suitable error response code or by throwing an exception. But, crucially, no exception handling should be attempted within any part of the infrastructure code.
This is important since no infrastructure component should have any awareness of who is calling it, when it is being called or under what circumstances it is being called. Given this lack of awareness, no component should be in a position to know what to do next in the event of an exception being thrown or an error being detected.
All exception handling code is a form of orchestration. All orchestraction code is a form of business logic. Therefore it follows that all orchestration code belongs within the business logic. This becomes obvious upon the realisation that it is only the business logic which maintains awareness of where we are within the overall process flow and hence how we should attempt recovery (or retry) in the event of an error within any given step of the business process.
The ability to segment the execution of business logic into blocks is therefore extremely important, coupled with the ability to assign specific exception handling functionality to such blocks at a fine level of granularity.
These design principle are at the heart of the implementation of this business language template library.
For further details, see the section on 'Scopes' within this document, as well as the JavaDocs for the Scope classes.
PART 2 User Guide
2.1 Abstract
The 'ReBL' package contains the classes which form the building blocks for the creation of Reusable Business Languages or Reusable Business Logic, based on generic templates.A key element of such languages is the handling of scope. The 'Scope' class therefore forms the backbone of this implementation, providing both isolation and segmentation of the business logic.
Scopes represent a 'block' of business logic and each such scope can either be nested and run sequentially, or be flagged to run concurrently.
A scope instance holds the exception handlers which will be called in the event of an exception being thrown within that scope. If no exception handler within this scope can handle the exception, the parent scope (if any) is queried, with the exception handlers within this enclosing parent scope then being called.
This process will continue until either one of the exception handlers can handle the exception, or we reach the top-level scope; at which point the default system exception handler will be called (which will simply log the exception and cleanly terminate the application).
The selection of objects which can be attached to any scope, includes:
- exception handlers
- environment objects
- resources
- state machines
- component package names
- business entities
- monitors
Derived scope classes can also store additional information.
2.2 Introduction
The basic principle of reusable business logic is to offer the possiblilty of sharing existing business logic (created for one particular project) within another project, which is currently under construction. This implies that some functional overlap exists between these project; or else no reuse would be required nor considered.This also implies that the existing business logic has been broken down to a fine level of granularity, to permit access to specific individual parts (rather than existing as some monolithic entity). This means that these individual components can be shared across applications.
Another name for Reusable Business Logic is a Domain Specific Language (DSL). This means that various blocks of business logic can be accessed through high-level constructs offered by the Domain Specific Language.
This is a well debated subject, with some of the more thorough and detailed descriptions from well known and highly respected people like Martin Fowler. For further details, see the book on this subject by the same author, as well as some of his personal essays.
DSL's can exist in two forms, namely 'External' and 'Internal'. Probably one of the best known examples of an external-DSL is that of the "Structured Query Language" (SQL), commonly used to interact with relational databases.
In general though, we recommend that 'External' DSL's be avoided. They are deceptively attractive however, as they offer the illusion that any inherent complexity can be hidden away behind a more straightforward interface. An often-heard argument in their favour is that it makes it so easy to use, anyone could do it. This argument is typically levelled at Business Analysts, creating the expectation that a business domain expert can easily express complex business requirements using this simplified language.
This is, without a doubt, an incredibly stupid notion.
This same argument has been made since the days of COBOL - which was supposed to make programming so easy and intuitive that anyone could do it.
How did that work out?
Not so well, eh!
With the (almost singular) exception of SQL (which is both well-known and useful), most other attempts to create external-DSL's have failed miserably.
Internal-DSL's are a different matter though. An internal-DSL is the thing that an external-DSL ultimately calls, albeit via some complicated intermediate translation.
Attempting to design and develop this intermediate translation system is both problematic and futile, with this system often becoming so complex that it dwarfs the complexity of the underlying system. A pointless exercise in stupidity. Attempting to create an external-DSL implies "dumbing-down" the interface to a point where it becomes mostly pointless when compared to the rich and varied possibilities available within the corresponding Internal-DSL.
It is perhaps easier to comprehend once it is understood that the complexity doesn't miraculously disappear, but is rather just hidden within another abstraction layer. Similarly, simplification of the DSL can only be achieved by reducing the available functionality and placing limits, bounds and constraints on the remaining constructs.
Ignoring the Siren-like call to create an external-DSL removes the need to create and maintain the intermediate abstraction layer, meaning that all efforts can be focused on the creation of the internal-DSL.
Why would you go to all the trouble to create a well-designed, feature-rich, internal-DSL, then wrap that within an artificially complex abstraction layer before concocting a rigid and dumbed-down 'simple' external-DSL in which business domain experts are then expected to gain proficency? Each additional layer takes significant time and money to design, develop, test, debug and maintain; restricting the available functionality whilst offering little in terms of Return-on-investment (ROI).
Software developers have no difficulty in designing, developing and working with internal-DSL's, since this is effectively what we have always done - simply exposing entry-points into the lower-level code in a structured and coherent manner.
To create a proper internal-DSL though requires that we take this interface a little further, to turn it into a "Fluent-Interface".
A "Fluent-Interface" is really just a highly-readable call into the underlying code, which also provides some scoping and name-space isolation.
Business Logic written using a Fluent-Interface (ie. an internal-DSL) should be easily READABLE by any business domain expert.
The crucial difference however is that, unlike with an External-DSL, whilst business domain experts should be able to easily READ logic written using the Fluent-Interface, they should NOT be encouraged NOR allowed to attempt to WRITE it.
Writing business logic using a Fluent-Interface should be left to those who both understand what they are doing and have the ability to select from the wide range of possible solutions as well as verify the resultant operations - this means that Software Developers are the only people who should be permitted to WRITE this logic.
So we have now determined that:
- "Reusable Business Logic" is another way of saying "Domain-Specific Language" (DSL)
- A DSL can exist in 2 forms, namely an External-DSL and an Internal-DSL
- External-DSL's are of limited use and are best avoided
- An Internal-DSL can be created using a "Fluent-Interface", which is highly READABLE by domain experts
- Business logic should be WRITTEN using the Fluent-Interface by Software Engineers (and no one else)
Common attributes of a Fluent-Interface include:
- method chaining; which makes the code readable, provided good Object, Method and Parameter names are used
- scope; which provides both context and name-space isolation
The platform we are describing within this document provides a means of creating Domain-Specific Languages through the creation of Internal-DSL's, in the form of Fluent-Interfaces.
This platform offers a common approach to the creation of such Fluent-Interfaces.
2.3 Overview
Since this platform concerns itself with the creation of Domain-Specific Languages, the top-level class is the Language class. This class should be used to initialise the platform and create a new language instance of a given name.The language will include a limited Vocabulary and Grammar. Whilst your language can ultimately define its own such constructs, the Vocabulary and Grammar classes included with the platform contain only those elements required by the platform; hence these classes are very light-weight, containing much less than you might imagine.
The next most important class is the Scope class, described in detail below. However the basic idea is to support the granular segmentation of the business logic into blocks and to provide a holding area for relevant data, environment variables, state machines, resources and exception handling.
The Scope class forms a base-class from which other scope types are subsequently derived. Each such sub-class builds on the central scope principles whilst offering additional functionality, such as support for transactions. Further sub-classes can be created, as necessary, to fulfil additional requirements.
The Entity class is the base-class from which a range of entities are derived.
Firstly, we have an Actor class, which forms an OwningEntity. As the terminology implies, an Actor is an Entity which 'owns' some other entities. An example would be a bank customer. In this example, the customer is the Actor who 'owns' a bank account.
The remaining entity types can be split into ActiveEntity instances and PassiveEntity instances, which are best explained by expanding our banking example. The bank account would be the ActiveEntity, since this is the entity we interact with directly. In particular, Actions are applied to this ActiveEntity, whereas the account balance would be a PassiveEntity since we do not directly interact with the balance. Rather we apply actions to the account and these actions cause the accounting logic to modify the balance appropriately.
The Action class forms a base-class for all other actions, which can then be applied to any ActiveEntity instance. In our bank example, we may create a Deposit action, a Withdrawal action and a Purchase action; each of which can then be applied to an account.
As well as requiring data to act upon and actions to trigger our business functionality, we must also be able to access Resource instances. Each Resource instance should wrap some specific resource required by our application, such as a database or queue, for example.
All of the other classes within the platform serve to support the creation of detailed business logic based around the classes described above. The key platform classes are therefore:
Language | including Vocabulary and Grammar |
Scope | including TransactionAwareScope, JdbcTransactionAwareScope, TransactionAwareWithWriteAheadScope |
Actor | |
Entity | including OwningEntity, ActiveEntity, PassiveEntity |
Action | |
Resource |
Each of the above classes are described in detail below, along with the other supporting classes within the platform. See also the comprehensive JavaDocs for all platform classes.
Useful usage examples for each class can be found within the corresponding unit test classes.
The integration tests should also be used as an excellent source of reference. The integration tests provide examples of:
- an "Hello World" example, to get you up-and-running
- how to use the scope classes
- how to use state machines
- how to use the exception handling mechanism
- how to use state machines as an exception handling mechanism
- a simple banking application created using the platform
2.4 Repository Structure
Mercurial is used as our Distributed Source Control Manager.Maven is our build tool.
The ReBL platform uses the following repository structure:
rebl | top-level project, which includes the License files and Maven parent POM file |
reblDocs | contains this UserGuide and web-site resources |
reblCore | contains all of the platform source code |
reblUnitTests | holds unit test files for each module within reblCore |
reblIntegrationTests | holds the integration tests mentioned above |
2.5 Code Layout
The logical layout of the code is depicted below:+------------+ +------------+ | | --------> | Grammar | | Language | +------------+ | | +------------+ | | --------> | Vocabulary | +-------------+ +------------+ +------------+ + -----> | Exception | | | | Handlers | | | +-------------+ v + -----> | Environment | +------------+ | | Objects | +--------+ | Language | +------------+ | +-------------+ | Common | -------- | Assignable | --------> | | +------------+ + -----> | Resources | +--------+ +------------+ | | | | | | | | | | Scope | | +-------------+ | Scope | -----> | Assignable | --+ -----> | State | | | | | | | Machines | | | +------------+ | +-------------+ | | + -----> | Monitors | +------------+ | | | | | +-------------+ | | | Component | v + -----> | Package | +--------------+ | | Names | | Transactions | | +-------------+ | | + -----> | ## Entities | +--------------+ | | | +-------------+ +-------------+ +-----------------+------------------+ | Transaction | | | | | Action | ------ + v v v +-------------+ | +------------+ +--------------+ +------------+ +-- | Attributes | | Managers | | Resources | +-------------+ | +------------+ +--------------+ +------------+ | XID | ------ + | | +-------------+ | | | | +---------------------------------------+ | | +-----------------------+ | # TransactionAwareScope | -------- + + ----------> | TransactionResource | +---------------------------------------+ | | +-----------------------+ | # JdbcTransactionAwareScope | -------- + + ----------> | TransactionXAResource | +---------------------------------------+ | +-----------------------+ | # TransactionAwareWithWriteAheadScope | -------- + +---------------------------------------+ # note that these entities are also Scope sub-types, as well as being TransactionManagers ## expanded in Entity diagram, below
The Entities shown above can be further expanded, as depicted below:
+------------+ | | | Entity | | | +------------+ | | +-----------------------+-------------------------+ | | | | | | v v v +------------+ +------------+ +------------+ | Owning | | Passive | | Active | | Entity | | Entity | | Entity | +------------+ +------------+ +------------+ | ^^ | :: v :: +------------+ :: | Actor | :: | | +------------+ +------------+ | Action | | | +------------+ This diagram illustrates that the Entity class forms a base class for all other entity types. An OwningEntity is an interface, with an Actor implementation class. An Actor instance "owns" other entities. Actions can only be applied to ActiveEntities (which is why they are referred to as "Active"). An Action applied to an ActiveEntity *may* result in a PassiveEntity being modified, but PassiveEntities are never directly referenced (which is why they are referred to as "Passive").
2.6 Hello World
For any software concept, it is common practice to include an "Hello World" example as a starting point, to confirm that all required software has been installed and configured, to ensure all the code compiles cleanly and to act as a simple introduction to get you up-and-running quickly.Therefore please refer to the "HelloWorld" example in the "reblIntegrationTests" repository. This runnable example shows the smallest possible system written using this platform.
The main block of code resides in the "call()" method, which is shown below:
@Override public Object call() { return new Language("HelloWorld", Scope.class) .withLocale(Locale.UK) .withDefaultScope() .withEntities(buildEntities()) .withActor(MyActor.class, "foo") .withActiveEntity("bar") .withAction(new HelloWorldAction()) .apply() .done() .closeScope(); }
Note that whilst the layout and indentation serve no functional purpose, they do help indicate which parts of the code are related and which parts are nested. As a style guide, we encourage this approach and feel that it greatly aids readability. However care should be taken to ensure that proper meaning is understood, as it is possible to create an invalid illusion of the code structure through incorrect layout and indentation. Therefore ensure that you are reading the CODE and NOT the layout.
From the above code snippet, it can be seen that we start by instantiating a new Language instance, passing in both a language name and a Scope class. The type of the Scope class defines certain characteristics which become available to the code associated with the Scope. Here, we are using the basic Scope class, but looking at the other Scope classes which are provided (see the JavaDocs for the Scope package) we can see that there is a "JdbcTransactionAwareScope" class (for example), which offers support for talking to a database via JDBC. Whilst a selection of scope classes are provided, it is equally possible (and indeed expected) that additional scope classes will be created, as required, by extending either the basic Scope class or any of the others.
Note that within a typical application, we would expect to see several different scope classes being used within different parts of the code. Therefore please do not think that only a single scope type can be used.
Next, we specify the required Locale. Here, we are using the UK locale. This is used to select the Locale-specific resource bundle holding the externally visible strings used by the platform as well as defining the formatting of dates, numbers and currency values. Within the platform, currently only the UK locale is supported (more specifically the English "EN" locale). However additional locales can easily be incorporated by providing translations of the locale resource bundles. These files are located within the "resources" directory. Simply duplicate the existing "en" sub-directory and translate the included bundles to the required Locale.
Before we define any business logic, we must firstly identify a scope instance. In this example we are using the "default" scope, which is simply an instance (of the given scope class) which is created automatically by the Language constructor. Therefore creating a new Language instance also automatically creates a new default scope, of the type identified by the parameter given to the Language constructor.
Note that, in general, we may have created a large number of scopes and so need to select the required instance by name. Therefore it should be noted that all scopes are identified by an associated name. The default scope uses an internal default name, but all other scopes MUST be given a non-null unique name. We therefore recommend a canonical naming convention be used for this purpose.
If not using the default scope, then the exact scope instance required must be selected by name. See also the "withScope()" method in the Language class.
Now that we have selected the required scope instance, we can set about attaching objects to it. A scope is basically a straightforward class which acts as a cargo object, allowing a range of additional objects to be stored within it.
We may wish to attach such items as:
- Exception Handlers
- Finite State Machines
- Business Objects (holding the data we need to process)
For a full list, see the JavaDocs for each scope class, since each additional scope class will typically store additional data over and above that offered by the basic Scope class.
In our example, we call the "withEntities()" method on the default scope, handing over responsibility of Entity creation to the method "buildEntities()", which in this case just creates a single entity - an Actor instance called "foo".
An Actor is a type of Entity called an OwningEntity. As the name implies, this class "owns" other entities. Looking within the definition of the "MyActor" class, we can see that the class constructor also creates an entity called an ActiveEntity. In this example, our ActiveEntity has been named "bar".
So, thus far, we have created the following:
- A new Language instance, which also created a default scope instance of the given scope type
- An Actor instance, named "foo", which owns an ActiveEntity named "bar"
Additionally, we have stated that we wish to interact with the default scope. Next, we must select the Actor instance we are going to focus on. In this example we only have one such Actor available, but in a typical system we may well have thousands to select from. Consider a banking system; in such an example we will have many Customers. Each individual Customer would be an Actor instance, whose corresponding "CustomerId" would be the unique key associated with that Actor instance.
But in our example, the only Actor we have is called "foo". So we go ahead and select that instance via the "withActor()" call. This method will search the currently selected scope for an actor of the given class and with the given name. Note that this also implies that we could have multiple Actor instances sharing the same name, but having different class types. Whilst this is certainly possible, care should be taken to avoid creating undue complexity. Although this technique could be utilised to group related artifacts (belonging to different classes) with identical identifiers, within the same scope.
Now that we have selected an Actor from our scope, we must also select an ActiveEntity from that Actor. We do this via the "withActiveEntity()" call. Again, there may be a range of such ActiveEntities to choose from. But within our example we only have one, so we search within our specified Actor instance for an ActiveEntity called "bar".
Now we can create an Action that we wish to apply to this ActiveEntity. In this case we create an instance of our "HelloWorldAction" class.
Finally, we can invoke that Action on the selected ActiveEntity which is associated with the selected Actor, which resides within the selected Scope. It is the call to the "apply()" method which actually invokes our defined action. In this example, our action simply outputs the standard "Hello World" message to the standard output stream.
Note that in this example we are only defining a single Action. However we could equally define a list of Actions, which would all be invoked (in the order of definition) on the selected ActiveEntity once the "apply()" method is called.
All that remains is to tidy up. Firstly we call the "done()" method, which doesn't really do anything except end the interaction with the lower-level ActiveEntity. We can then call the "closeScope()" method, which will clear the memory used by this scope prior to system termination. Although it should be noted that typically we will have some Resources (eg a database) associated with a scope, and the act of closing the scope would also automatically commit any outstanding transactions and free the database connection. The exact functionality invoked by the 'closeScope()' method is therefore highly specific to each scope type.
Within this "Hello World" example, code has been included to allow this program to run as either a Java program or as a JUnit test. Invoking the example in either fashion will result in a simple "Hello world!" message being output to the console.
To assist with gaining a more detailed understanding of the platform, it is highly recommended to step through this example in a debugger within your preferred IDE; taking the time to step into each of the functions to see what it does and how it works. Care has been taken to include 'toString()' methods within each of the main classes; this ensures that all relevant data will be neatly formatted and displayed within your debugger. Therefore also take the time to view the class member variables and method parameters whilst performing this debugging step. Whilst stepping through this example, take note of the 'done()' method. As stated above, this method does very little, however it is an excellent example of a transformation method (of which several exist within the platform). The 'done()' method lives within the ActiveEntity class, but returns a Scope instance. This method therefore performs a translation between ActiveEntity and Scope. We thus call the 'apply()' method on an ActiveEntity but call the 'closeScope()' method on a Scope instance, courtesy of the intervening 'done()' method call.
2.7 Additional Usage Examples
The included set of integration tests should be viewed as a resource providing additional usage examples. Whilst their primary purpose is to validate the end-to-end processing associated with a range of key platform components, they have been carefully selected to show-case the principles behind the operation of these important classes.In addition to the "Hello World" example, described above, the integration tests include examples of:
Scope Handling | which includes basic scope details as well as nested scopes and sibling scopes |
Resource Handling | including resource definitions and resource interactions (the example resource used is a database) |
State Machines | including state definitions, state transitions and exception handling implemented as state transitions |
Exception Handling | including exception handling within both sequential and parallel scopes |
A small 'Banking' application | which shows a full working example of an application created from all key platform components |
2.8 References
Whilst the integration tests provide detailed usage example of key platform components, the included unit tests should also be viewed as a useful resource, providing a large number of usage examples of EVERY platform class.The unit tests should be consulted in addition to the javadocs to aid understanding of the platform classes.
The project web-site also provides a wealth of information, including:
Design and Architecture | A range of diagrams and detailed descriptions are included to help explain, describe and illustrate the purpose of the platform as well as its internal layout, design and overall architecture. |
Javadocs | Care has been taken to ensure that the included javadocs are both complete and comprehensive, providing detailed information for EVERY class and EVERY method. |
Source Code | A browsable version of the full cross-referenced source code is included. Note that this covers not just the base platform, but also the source code for both the unit and integration tests. |
Project License | The full text of the project license is viewable. |
Project Reports | The reports generated automatically by the static code analysis tools as well as the results of running the unit tests. |
Community Links | A number of external links are included, linking to the source code repository, mailing lists, defect tracker and other related resources. |
PART 3 Reference Guide
3.1 Copyright
The source code and associated documentation are provided under the terms of separate licenses, as specified below.3.1.1 Documentation
All documentation related to this project is made available under the terms and conditions of the GNU Free Documentation License, as detailed below.Logic:Machine Software Development Studio assert their moral right to be acknowledged as the authors of this work.
Copyright ©2017 Logic Machine Ltd.
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License".
For further details see: www.logicmachine.co.uk/licenses/rebl or www.gnu.org/licenses
3.1.2 Source Code
The sub-packages contained within this project form the 'Intellectual Property' of Logic:Machine Software Development Studio.Logic:Machine Software Development Studio assert their moral right to be acknowledged as the creators of this work.
Copyright ©2017 Logic Machine Ltd.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. A copy of the license is included in the section entitled "GNU Lesser General Public License".
For further details see: www.logicmachine.co.uk/licenses/rebl or www.gnu.org/licenses
3.2 Configuration
Creating code which has the potential for reuse requires there to be no built-in constraints, limitations or assumptions. Rather all such bounds or restrictions must instead be made configurable.Since the entire point of this platform is to aid the creation of reusable business logic, such configuration options have been included within the platform.
Therefore refer to the following classes for all configurable parameters:
- org.logicmachine.rebl.common.Constants
- org.logicmachine.rebl.common.i18n.ExternalStrings
- org.logicmachine.rebl.common.i18n.ErrorMessages
While creating your own business logic, ensure that all similar properties are made configurable.
3.3 Common
The "reblCore: rebl.common.Common" class offers a range of helper and convenience methods.The Common class is an example of a LanguageAssignable class, which maintains a reference back to the Language instance. Further, it is the Language constructor which instantiates the singleton Common instance with a call to the method: Common.forLanguage()
All public methods within the Common class are static methods, by design. This provides a number of convenience methods, allowing both the Language instance and Scope instances to be referenced directly.
There are also methods offering Locale-specific functionality, such as:
- withLocale()
- dateToLocaleString()
- currencyToLocaleString()
A range of String manipulation functions are also included; many of which are extensively used within the 'toString()' methods of other classes to neatly format and align member variables for debugging purposes - either directly via logging statements or within a debugger in an IDE.
The Common class also provides the ability to capture both the standard output stream and standard error stream within PrintStream instances. This mechanism is particularly useful when creating unit tests, where it is required to assert on logged output. Many of the included unit tests utilise this exact functionality. See the methods:
- withErrorStream()
- withOutputStream()
The above methods can be used with the platform logging methods:
log(String) | a single method which logs the given string |
logException(Exception) | a range of method variants for logging exceptions |
The Common class also maintains a map of all Scope instances which have been flagged as parallel. For sequential processing, scopes are chained together based on a parent/child relationship. But for parallel processing, the map within the Common class stores a handle to the Scope which created the new Thread being used to process the parallel functionality. This map therefore holds a mapping from thread name to corresponding Scope instance.
Whilst we do not explicitly do much with this information currently, it seems prudent to keep a handle on such parallel scopes for future use.
Similarly, the Common class also maintains a map of all ActiveEntities flagged as running in parallel within a given Scope. In this instance, this information is used to ensure that no attempt is made to clear a scope until the threads for any parallel ActiveEntity instances have completed. The lifecycle clean-up methods for the Scope class use this map to wait for the completion of all relevant threads before returning.
It should be noted that all such parallel functionality offered by the platform is currently of an experimental nature. Whilst this functionality has been tested, like all concurrent processing it has the potential to expose issues such as deadlocks and starvation as well as synchronisation problems and issues with code blocks which are not thread-safe. Such issues are well understood within concurrent processing, however caution is still advised as it is highly likely that the concurrent parts of the platform will undergo further rework and extension as more experience is gained in exploring and exploiting this functionality within the context of this platform.
3.4 Maybe
This interface is available throughout the fluent-interface code-base to handle those circumstances when a method could otherwise return a null value. In such cases the return object should instead be a Maybe value, whose 'isEmpty()' method should return true.Null values are the worst-case return values within a fluent-interface. Therefore ensure that any possible null return value is instead handled as an empty instance.
Similarly, any argument passed into a method can be tested to check if it represents an empty instance before proceeding with the subsequent logic.
Additionally, the 'empty()' method should invoke the required functionality to initialise a new instance as an 'empty' instance.
This interface should be used as follows:
public class MyThing implements Maybe { .... } MyThing thing = new MyThing().empty(); Assert.assertTrue(thing.get().isEmpty());
Or:
MyThing otherThing = thing.get();
3.5 Collections
A small number of classes are included to assist with the grouping of artifacts into collections. This includes the suitably named Some and Many templated classes.These classes may be used to create collections of homogenous objects.
This mechanism is used throughout the code-base to provide related groupings, such as:
- Actor / Actors
- Action / Actions
- Monitor / Monitors
- Resource / Resources
As suggested by the names, the Some class should be used when a relatively small number of elements are expected within the collection. Whereas the Many class should be used when large numbers of elements are expected. Both of these classes expose identical interfaces, however as an implementation note, the Some class is backed by a List and the Many class by a Map.
These classes are explained more fully below.
3.5.1 Some
This class is intended to be used in those circumstances where we have a relatively small collection of 'things' which we wish to refer to directly, by key.For example, we may have a small collection of resources. We would not want to have to iterate over this collection each time we needed access to a specific resource; rather we would prefer to access the required resource directly.
As an implementation note, this class is backed by a Map. Therefore the 'find()' and 'findAll()' methods complete in O(1) time.
However since this is backed by a Map, duplicate keys are not supported. Therefore the 'findAll()' method within this class will only return a list containing one element at most.
See also the related 'Many' class, which is backed by a List and which therefore also supports duplicate keys. The Some and Many classes each provide an identical API.
3.5.2 Many
This is a general purpose 'pluraliser' class which can be used as a base class for the creation of a collection of 'singular' objects.Note that the intention here is to support 'large' collections over which we may wish to iterate. As an example, if we have "Many" customers, we may need to iterate over this collection and invoke some business logic on each customer.
As an implementation note, this class is backed by a List. Therefore the 'find()' and 'findAll()' methods complete in O(n) time.
Note also that since this is backed by a List, duplicate keys are supported.
See also the related 'Some' class, which is backed by a Map. However the 'Some' collection class cannot contain duplicate keys. The Some and Many classes each provide an identical API.
3.6 Assignables
The notion of Assignables is used to denote those classes which are part of, or enclosed within, some other class.Further, each assignable object maintains a handle back to its enclosing object.
The assignable classes link back to key platform instances such as the Language definition instance and the Scope instances.
3.6.1 LanguageAssignable
The top-most class within this platform is the Language class. Since the intent of this platform is to facilitate the creation of a range of Business Languages, the platform is created and initialised via the instantiation of a new Language instance.The LanguageAssignable helper class denotes support for an element which can reference its enclosing Language instance. This mechanism is used primarily by the Scope classes, but also by the Common class.
3.6.2 ScopeAssignable
After the Language class, the next most important class is the Scope class. Each Scope instance provides isolation and segmentation of a block of business logic.The ScopeAssignable helper class denotes support for an element which can reference its enclosing Scope instance.
This class provides the ability to assign a range of objects, of a given type, to a given scope.
Note that objects of differing types should not be added to the same ScopeAssignable collection; rather create separate ScopeAssignable collections for each unique type. The objects held within each ScopeAssignable collection should therefore be homogenous.
ExceptionHandlers are one example of such ScopeAssignable instances, which maintain a handle back to the enclosing Scope instance.
3.7 Scope
The basic unit of encapsulation, isolation and functional context is provided by the Scope class.This is a straightforward class which offers a storage location for the items required to run a block of business logic. Such items are referred to as 'ScopeAssignables'.
So we have a scope (S1) taking responsibility for running a unit of business logic (BL1). This business logic may interact with a number of Business Entities. Similarly, it may also interact with some Resources (for example, a database or queue). These business entities and resources can be 'attached' to scope S1, to form a complete execution environment for BL1.
Scopes are arranged within a parent/child hierarchy. The top-most scope within this hierarchy is called the 'default-scope' and is created automatically during system initialisation during construction of the Language instance. Each subsequently created scope will take its place within the hierarchy either as a child of the default-scope or as a child of some other pre-existing scope in the hierarchy.
When a new child scope is created for a given parent, the child scope will automatically inherit certain characteristics from the parent. This inheritance process is configurable by overriding the 'configureInheritableScopeAssignables()' method within the base Scope class. See also the 'Scope.inheritBusinessEntities' flag as well as the'ScopeAssignable.isInheritable(boolean)' method.
Since the low-level infrastructure components underlying the business logic cannot (and should not) attempt to self-handle any exceptions or error conditions, exception handlers can also be attached to the running scope instance (S1). These exception handlers will be used to deal with any exceptions thrown during invocation of the enclosed business logic (BL1). However if no exception handlers have been defined within the scope, or if none of the defined exception handlers have been able to handle the given exception, this same error handling process will be attempted on the parent of this scope. If the exception has still not been handled, then the next higher-level parent will be checked (ie grand-parent). This process will continue either until we locate an exception handler capable of handing this exception, or until the top-level default-scope has been reached. Exceptions are thus propagated upwards through the hierarchy until successfully handled, or until we have exhausted all options, at which point the default exception handler will be called. This is a top-level safety net which catches all exceptions, logs them, then terminates the application.
The full range of ScopeAssignables which can be attached to a Scope are detailed below.
3.7.1 Environment Objects
This is a placeholder class allowing an environment object to be defined which can then be attached to either a specific scope, or made available within the 'global' scope and hence accessible from every Scope instance.As an implementation note, adding an EnvironmentObject to the global scope means that it is added to a 'static' container within the Language class. Hence it is accessible from all scopes. Whereas EnvironmentObjects added to individual scope instances are only available within that same scope.
An environment variable is simply a key/value pair, where both the 'key' part and the 'value' part may be any Object. So whilst a datatype of String may be the norm for both the key and value, this is not a requirement.
Note that the key associated with an EnvironmentObject cannot be null, however the value component may be null. But when using an EnvironmentObject to wrap an existing object - that is when calling "new EnvironmentObject(object)", the 'object' parameter cannot be null.
3.7.2 Business Entities
Business Entities can be attached to any scope. Actually there is no reason why the same business entity cannot be attached to more than one scope. This is actually the default behaviour, with Business Entities being inherited from parent to child. However it should be noted that a given Business Entity could also be shared across non-related scopes.This inheritance process is configurable by overriding the 'configureInheritableScopeAssignables()' method within the base Scope class. See also the 'Scope.inheritBusinessEntities' flag.
Business Entities can consist of any combination of Entity, OwningEntity (ie Actor), ActiveEntity or PassiveEntity derived classes, with these forming base classes from which any required business objects can be constructed.
Typically we wish to iterate over all such Business Entities and perform some processing on each one, in turn. Although we may equally wish to search for a given Business Entity by key, within a given scope, and perform some Action on that specific entity.
3.7.3 Resources
Resources can be attached to any scope. Actually there is no reason why the same resource cannot be attached to more than one scope, provided that resource is capable of handing multiple (potentially concurrent) interactions. Given that the abillity to share a resource across scopes is highly resource-specific, resources are NOT explicitly inherited from parent to child scope (unless specifically configured to do so). See the 'Scope.configureInheritableScopeAssignables()' method for further details.Therefore, by default, resources are NOT inherited from parent to child scopes, however this behaviour can be altered by changing the inheritance characteristics of the scope.
A resource could be something like a database, or message queue for example.
To create a new resource, extend the Resource (or CloseableResource) base class. Also consider creating an interface to define the key public methods (see the 'TransactionXAResource' interface for an example).
A common approach is to declare a 'doAction()' method, as an entry point to your resource. Then to actually interact with your new resource, create a (set of) actions which extend the Action base class. To invoke some specific functionality within your resource, call the 'doAction()' method and pass in the required action to trigger the required functionality. Additional public methods can of course also be added to your resource, as necessary. But try to limit the public methods to allow more generic resource interfaces to be created and reused. See the 'InMemoryXAResource' class for an example.
A resource may be closed by directly calling a suitable close method on the required resource. However, as an alternative, a CloseableResource may be created. A CloseableResource is simply a standard resource which additionally exposes a 'closeResource()' method (via the Closeable interface), which will be called automatically once the enclosing scope closes. This offers a convenient mechanism to close resources during system termination or simply when the enclosing scope closes. This closeable nature is internally synchronised, so can be safely invoked from more than one scope, with the first call causing the resource to be closed and any further 'close' calls being ignored. Care should be taken however since once a 'shared' resource has been closed within one scope, it can no longer be used within any other scope.
Therefore new resources may be created by either extending the Resource base class or the CloseableResource base class.
Note that to aid reuse, one of standard principles is to try to put as much functionality as possible behind a single interface. For example, rather than creating one specific interface for use solely with a database, say, we would prefer to re-think this interface and try to generalise the required functionality. Separating this into two interfaces, such as DataSource and DataSink, would fully support the notion of a database but does not limit its use solely to a database. Consider that many resources could sit behind both a DataSource and/or a DataSink interface. Possible examples of a DataSource resource could include a database, a message queue, a web-service, a flat-file or anywhere else from which data could be read. Possible examples of a DataSink could also include a database, a message queue, a web-service, a flat-file, writing to a log-file, sending an email or anywhere else we may wish to send data.
It is therefore prudent to attempt to limit the interfaces between your application and the outside world. Whilst it would be impractical to create a single interface to cover all needs, the number of such resources should always be kept to an absolute minimum. We therefore prefer to create more general interfaces which can be shared, rather than creating specific interfaces applicable for a single use-case only.
3.7.4 Component Package Names
This holds the optional set of package names which will be searched to locate externally defined component classes to be invoked via the 'call()' methods.The 'call()' method takes a String parameter of the form: "className::methodName"
The (list of) Component Package Names will be searched to locate 'className'.
Note that only the package names defined for the current scope will be used to locate such classes.
Each scope can therefore define separate packages to be searched to locate the external business functionality required within that particular scope.
We deliberately avoid relying solely on the classpath to allow a more granular level of logical name-space separation and functional isolation for business components, permitting the creation of a cleaner code structure.
Component Package Names are inherited properties which are passed on from parent to child scopes, although each child scope may subsequently augment its own list of Component Package Names.
Note that a number of 'withComponentPackageNames()' methods are available witin the Scope class, allowing component package names to be defined. Each of these methods take one or more String parameters. Each such string can contain either a single fully qualified package name, or a colon-separated list of fully qualified package names, such as: "org.logicmachine.rebl.components:org.logicmachine.rebl.resources".
3.7.5 State Machines
The State Machine class provides support for a standard finite state machine. This is a templated class, with the template representing an enumerated set of states. The various states should be defined within an enumeration, with transitions between states defined by means of the builder methods contained within the StateMachine class.One or more state machines can be used to track the various possible logical states of an application, or the status of a specific block of business logic.
Optional 'Actions' can be triggered by state transitions. This class supports both 'entryActions', which are triggered when entering a give state and 'exitActions', which are triggered when leaving a given state.
One general use-case for entry/exit Actions is to consider an error condition as simply placing the state machine into a particular 'error' state, with suitable actions being triggered upon entering this state. Such Actions might include a logging action, for example, to log the error condition as well as potentially triggering additional remedial actions to recover from the error and return the state machine back to some other 'good' processing state.
The normal flow is therefore:
A.state -> A.exitActions -> B.entryActions -> B.state -> B.exitActions -> C.entryActions -> C.state Where: A, B and C are any states for which legal state transitions have been defined.
In other words, a state transition from state A to state B has been defined and a state transition from state B to state C has also been defined.
The concept of super states are also supported. A super state is a state which can be transitioned to from any other state without requiring explicit configuration of such state transition. Upon entry to the super state, any entry actions associated with the super state will be invoked. Similarly, when transitioning from the super state, any exit actions associated with the super state will also be invoked.
Note that NO exit nor entry actions associated with the previous state will be invoked whilst transitioning either to or from the super state. However any 'suspend' actions WILL be invoked when transitioning from a given source state to a super state and similarly any 'resume' actions will be invoked when transitioning from a super state back to any other destination state. So any suspend or resume actions associated with the original source state will be invoked when transitioning to or from a super state.
The flow for super-state transitions is therefore:
A.state -> A.suspendActions -> B.entryActions -> B.state -> B.exitActions -> C.resumeActions -> C.state Where: A is the original source state, B is a super state and C is the next destination state. But note that (typically) states A and C will be the SAME state (but there is no enforcement of this and C can be any other suitable state).
Note:
- NO state transitions should be explicitly defined between any source state and any super state. Such transitions are always implicitly allowed.
- All functionality associated with a super state must be contained within the entry and/or exit actions for the super state.
- If no exit actions are associated with the super state, upon exit from the super state, the next state will be the state which was active immediately prior to the transition to the super state. This means that (by default) we always return control to the previous state once we exit the super state.
- A transition from a super state back to the original prior state will therefore be automatically invoked if there are no exit actions associated with the super state.
- This default behaviour can be overridden by associating exit action(s) with the super state. In this instance, it is expected that any such exit actions for the super state will include a transition back to an appropriate processing state. The default action of automatically resuming the prior state is therefore suppressed.
- Super states are particularly helpful for error handling if multiple states are using the same error state transition. This means that this error state can be defined as a super state, so that explicit transition configuration is not required.
Similarly to all other entities, it is possible to create an 'empty' finite state machine (which would be used in those instances when a null value might otherwise be returned). To facilitate the creation of an 'empty' finite state machine, we include the "EmptyEnum" class. This is simply an enumeration class containing no actual values. It can therefore be used to create an empty instance of the templated finite state machine class.
3.7.6 Monitors
This package provides a base class which denotes an element supporting the addition of a monitor. A range of derived classes are included which can be used to monitor the activities of other entities by generating various metrics.A monitor provides convenience hooks which can be used to attach monitoring functionality to an object to permit the gathering of key metrics. Various standard monitors are provided; however these can be extended easily by any derived class. Note that multiple monitors can be attached to the same target location and each such monitor will be triggered in the order of definition.
This package also provides classes which are used to monitor the health status of other entities.
The full range of monitors provided by the platform is shown in the following table:
HealthMonitor |
This class provides a monitor which can be used to monitor the health of a resource.
Each specific health state can have an (optional) reason, which represents the cause of this health state. The 'monitorGet()' method will return a 'Health' instance which will hold the current 'HealthStatus' value. See also the 'Health' class and corresponding 'HealthStatus' enumeration. The 'HealthStatus' enumeration defines the health of a given entity. For example, a web-service may be UP or DOWN or a database connection may have TIMED_OUT, etc. |
DurationMonitor |
This class provides a monitor which can be used to time the duration of an activity.
The 'monitorGet()' method will return the elapsed time in milliseconds between invocations of the 'monitorBefore()' and 'monitorAfter()' methods, provided the 'wasSuccessful' parameter supplied to the 'monitorAfter()' method is true; otherwise the 'monitorGet()' method will return '-1L', as will the 'toString()' methods. |
ThroughputMonitor |
This class provides a monitor which can be used to count the number of invocations of
an activity.
The 'monitorGet()' method will return the total number of invocations of the 'monitorBefore()' method. Note that for this implementation, the 'monitorAfter()' method is a 'no-op' operation which does nothing. Note that this implementation is NOT thread-safe, but see also the equivalent class 'ThreadsafeThroughputMonitor'. |
ThreadsafeThroughputMonitor |
This class provides a monitor which can be used to count the number of
invocations of an activity.
The 'monitorGet()' method will return the total number of invocations of the 'monitorBefore()' method. Note that for this implementation, the 'monitorAfter()' method is a 'no-op' operation which does nothing. Note that this implementation IS thread-safe. but see also the equivalent class 'ThroughputMonitor'. |
3.7.7 Nested Scopes
Given the parent/child relationship of scopes, it is clear that a Scope can 'contain' other nested scope instances. Therefore we may have scope S1 which 'contains' nested scopes S2, S3 and S4. Each of these scopes may (optionally) contain further scopes. Apart from system memory limits, there is no upper-bound on the level of nesting or overall size of the resultant scope hierarchy.Since the scope hierarchy is created by storing references to other scopes, the full hierarchy can be depicted as an inverted tree, with the 'default-scope' located at the top-most root node and all other child scopes growing downwards from each parent to subsequent child.
An alternative (but equally valid) representation of the scope hierarchy can be depicted as a child scope physically residing within a parent, in a Russion-Doll fashion. We then have the notion of a series of scopes nested one within the other. This may be written as an expression of the form: S1(S2(S3, S4)). This shows that sibling scopes S3 and S4 are nested within scope S2, which is itself nested within scope S1. We are not limited to single scopes though, so any number of sibling scopes may be nested within a parent, to any depth (limited only by system resources).
The business logic associated with each scope can be invoked either sequentially or in parallel. This process is described below.
3.7.8 Sequential Scopes
For sequential invocation of the business logic within each scope, we start at the parent scope and invoke the business logic associated with that scope before sequentially invoking the business logic within each immediate child scope, based on the order of child definition. This process will then repeat within each child scope.By default, every scope is sequential. A scope can be flagged as parallel by calling the 'parallel()' method.
A 'sequential()' method is also available, but has no real affect, since this is the default behaviour.
Note though that the 'parallel()' method can only be called once per scope. Further, once the 'parallel()' method has been called, any subsequent calls to either the 'sequential()' or 'parallel()' methods will have no affect.
3.7.9 Parallel Scopes
Any scope can be flagged as 'parallel', meaning that the enclosed business logic will run in parallel alongside any other business logic that may be currently running.The key differences between parallel scopes and sequential scopes are that parallel scopes:
- will run within a new thread
- will detach from its parent, so that this scope becomes a new (isolated) top-level scope
- will not propagate any thrown exceptions beyond this isolated top-level scope instance
- can define a callback method within the original parent scope which will be invoked once the (now detached) child completes; thus a parent can create a child, define a callback method for the child, then flag that child as parallel so that the business logic within the child will run in parallel within its own thread before invoking the callback method (within the parent) upon completion
With the exception of the above points, Parallel and Sequential scopes are identical in every other respect.
A scope can hold any number of active entities. By default, all active entities will run sequentially. However any active entity within a parallel scope, will itself (by default) become 'parallel' automatically.
Thus whilst active entities can be individually flagged as sequential or parallel, once the enclosing scope is flagged as parallel, then each enclosed active entity will (by default) run in parallel - unless it has been explicitly flagged as sequential.
Flagging a scope as parallel therefore also changes the default behaviour of any enclosed active entities. This default behaviour can be changed by explicitly calling the 'sequential()' or 'parallel()' methods on the relevant active entities. Such explicit method calls will be honoured, regardless of the status of the enclosing scope.
Note that if any ActiveEntities are flagged as running in parallel within a Scope, the lifecycle clean-up methods of the Scope class will wait until all outstanding threads complete. This is necessary to ensure that these threads have completed before any attempt is made to remove the associated Scope details. In particular, the 'Scope.closeScope()' method will block until all outstanding threads for this Scope complete.
3.8 Exception Handling
This class forms a base-class from which all other ExceptionHandler classes are derived.An ExceptionHandler which has been attached to a scope will be automatically called to potentially handle any exception raised within the processing logic of that scope.
ExceptionMatcher instances can be added to any exception handler to ensure that this handler will only attempt to handle exceptions of the correct type.
Each ExceptionHandler can therefore decide if it is capable of handling a specific exception. If the exception is not handled, the next ExceptionHandler in the set will be given the opportunity.
If no ExceptionHandler within the scope can handle it, the parent scope (if any) will be queried and the ExceptionHandlers within the enclosing parent scope will be called.
As the hierarchy of scopes is traversed, each ExceptionHandler will be called in turn. If no ExceptionHandler can handle this exception, once the top-most scope has been checked, the default system ExceptionHandler will be used (which simply logs the exception and terminates). However the expectation is that some other exception handler should handle the exception before it gets as far as the default exception handler; which is merely a catch-all safety-net.
Two distinct types of exceptions are possible:
Any sub-type of the Exception class | Should be used for system-level exceptions. This will indicate an error within the lower-level infrastructure code. |
Any sub-type of the included BusinessMessage class | Should be used for business-level exceptions within the business logic. This will indicate a deviation from the expected business flow. |
It should never be necessary to explicitly invoke an exception handler. Rather a suitable exception handler should be located and invoked automatically by the platform based on an exception condition caught within a block of code within a specific scope. Therefore business logic code should throw exceptions whose corresponding class extends the BusinessMessage class and all infrastructure code should throw exceptions whose corresponding class extends the Exception class.
So the correct way to define an ExceptionHandler is:
ExceptionHandler exceptionHandler = new ExceptionHandler().withKey("myExceptionHandler") .withMatcher(new ExceptionMatcher(BusinessMessage.class, "foo bar"));
The above code snippet defines an exception handler which will only attempt to handle BusinessMessage exceptions (thrown within the current scope) whose corresponding exception message CONTAINS the string "foo bar".
The 'canHandle()' method in the ExceptionHandler class can be used to verify that a given exception handler is capable of dealing with a given exception.
Whilst processing an exception, the 'getException()' method will return a handle to the exception currently being processed by an ExceptionHandler instance.
3.8.1 Exception Filtering
Any number of ExceptionMatcher instances can be added to an ExceptionHandler. This means that a given ExceptionHandler can specify which exceptions it is prepared to handle.ExceptionMatchers can match either on just the class of the exception or on a combination of exception class and error message. If an error message is specified as a matching criteria, a match will be successful if the class of the exception matches AND at least ONE of the following messages CONTAINS the specified error string:
- exception.getMessage()
- exception.getLocalizedMessage()
We could therefore define an ExceptionMatcher as follows:
ExceptionMatcher matcher = new ExceptionMatcher(IllegalArgumentException.class, "foo"); assertTrue(matcher.matches(new IllegalArgumentException("foo bar")));
The above assertion will succeed since both the type of exception class matches AND the exception message "foo bar" CONTAINS the specified matching criteria string "foo".
Whereas none of the following exceptions would match:
new IllegalArgumentException(); | Whilst the exception class matches, the error message will not |
new IllegalArgumentException("testing"); | Whilst the exception class matches, the error message will not |
new SecurityException("bar foo"); | Whilst the error message will match (on "foo"), the exception class will not |
new SecurityException("testing"); | Neither the error message nor the exception class match |
Note that if no error message criteria is defined, then the matching will be limited to the exception class only, regardless of any corresponding error message.
3.8.2 Exception Classes
Within the infrastructure code, any thrown exception should extend the Exception class.Within the business logic, any thrown exception should extend the BusinessMessage class.
There is a third type of exception class included in the platform, namely "EmptyOrNullArgumentException". This class extends the IllegalArgumentException class and is used internally within the platform to raise exceptions associated with validation checks on objects being unexpectedly null or empty instances. This is simply a convenience class which removes the need to explicitly define an externally visible error message within the Locale-specific bundle. If an error message is supplied to this class, then that error message will be explicitly used. However if no such error message is supplied, then a suitable error message will be constructed based on the stack-trace associated with this exception being thrown.
Note that receiving an "EmptyOrNullArgumentException" means your business logic is broken or malformed.
3.8.3 State Machine Exception Handling
It is particularly useful to think of an application as simply being in a specific state at any given moment in time. Such states might include:- one or more initialisation states
- idle state(s)
- a variety of processing states
- one or more finalisation states
- an end state
The above list should also contain one other state classification though; error states
If you think of an application as simply transitioning from state to state during its normal operation, it is a small step to think of an error or exception as being a trigger which causes a state transition into some error state.
In this model, the concept of handing an error is reduced to taking whatever steps are required to allow the application to transition back from the current error state into some known 'good' processing state.
So what we have is a state machine which mirrors the current state of the application. As the application advances through its standard processing activities, state transitions are invoked to reflect the 'next' application state and hence trigger the next processing activity. In the event of an error being detected or an exception being thrown, we simply transition from the 'current' state into a previously defined 'error' state. Since the act of entering a given state will cause any 'entryActions' associated with that state to be invoked, it is easy to see how (in the case of an error state) such 'entryActions' could include those remedial actions required to deal with the error/exception, thereby allowing us to transition the application back into a known 'good' processing state. The actual error handling is therefore performed within the entry actions attached to the given error state.
Within a typical application, multiple error states should be defined for each 'normal' state, providing suitable error handling for each stage of the application logic.
For this purpose, this platform includes an exception handler which is backed by a finite state machine. See the JavaDocs for the 'StateMachineExceptionHandler' class.
See also the 'State Machine' section for a discussion on 'super' states; which were largely added to aid this exception handling mechanism.
3.8.4 Repeatable
For non-critical exceptions, a less intrusive exception handling mechanism has been included. This allows blocks of logic to be repeated on receipt of specific exception types.This could be useful for something like a TimedOut exception, whereby we may wish to retry some block of logic up to a certain maximum number of attempts.
The Repeatable class has been included for this purpose.
This class is used to store the details associated with a group of repeatable actions.
Such actions can then be repeated a defined number of times, with the option to pause for a configurable time period between iterations. The default setting is to have NO sleep period between iterations.
The Repeatable constructor takes a handle to an ActiveEntity instance as a parameter. It is therefore the Actions associated with this ActiveEntity which will be repeated upon error.
Setter methods are included to allow a maximum number of retries to be defined as well as an (optional) sleep time (in milliseconds) which defines the length of the pause between repeated iterations.
Since this class is triggered upon receipt of an exception, additional setter methods are included to allow specific exception types to be defined. This means that the repeatable functionality will only be triggered upon receipt of specific exception types (for example we may wish to retry a 'read' operation a certain number of times if we receive a IOException).
If no specific exception types are defined, the 'repeatable' will be repeated for ANY exception.
All non-matching exceptions will be directed to the standard exception handling mechanism via the exception handlers attached to the enclosing scope(s).
Further, an optional set of "undo" Actions can also be defined for a given Repeatable. These undo Actions will be invoked if the maximum number of retries has been reached without success. This therefore allows back-out actions to be performed in the event of retry-failure.
A Repeatable instance can be associated with any ActiveEntity. It is the 'apply()' methods within the ActiveEntity class which will trigger any defined retry logic.
3.9 Transactions
This package holds a range of classes which together provide support for the definition and usage of Transactions.This ranges from basic JDBC database Transactions to full XA Transactions to full XA Transactions with a write-ahead transaction log.
User transactions can be created within a scope, with all open transactions being committed automatically when the scope is closed.
Note that, where supported, transactions can be nested within other transactions.
This package provides basic implementations - specifically an implementation of TransactionActions.
This permits database transactions to participate as regular Actions which can be applied to an ActiveEntity running within a transaction aware scope (eg JdbcTransactionAwareScope).
3.9.1 SupportedDatabases
This enumeration specifies the databases supported by the platform.Currently HSQL, MariaDB, MySql and Postgres databases are all supported, however it is expected that support for additional databases will be added over time. Note that any JDBC-compliant database can be added easily, however the platform has been specifically tested against each of these currently supported databases.
Note that unit tests have been added for all of the supported databases (and the pom file pulls in the correct drivers for all supported databases also). However only the HSQL unit tests are configured to actually run as part of the default unit tests. Currently the MariaDB, MySql and Postgres unit tests are ignored - since successfully running these tests would require actual databases to be configured for each, along with login credentials. To run any of these additional unit tests, simply remove the JUnit "@Ignore" annotation from the top of the relevant unit test class and update the username/password placeholders within the configuration properties to match your database installation parameters.
3.9.2 TransactionAction
The TransactionAction interface provides the ability to perform an action within the context of a transaction.Multiple actions may be performed sequentially within a single transaction.
The TransactionActionImpl class provides an implementation of the TransactionAction interface.
To create an instance of this class, an instance of the JdbcTransactionAwareScope must be passed into the class constructor, since this class operates on JDBC-aware scopes.
The main 'doAction(TransactionDetails details)' method can handle basic database CRUD operations (create, read, update, delete) based on the TransactionDetails and TransactionOperation classes.
For more complex operations, the 'withSql()' and 'withValues()' methods can be called directly before invoking the no-arg 'doAction()' method.
Note that any string value passed into the 'withSql()' method will be turned into a JDBC PreparedStatement.
3.9.3 TransactionDetails
The TransactionDetails class acts as a placeholder for all of the attributes associated with one transaction.See also the TransactionAction class, which can use a TransactionDetails instance to create a JDBC PreparedStatement.
This class holds the following items:
Xid | Holds the full transaction id associated with this operation. This value holds an instance of the 'XidImpl' class, providing an identifier for the current transaction. |
TransactionOperation | Specifies the CRUD (create, read, update, delete) nature of this operation. |
Entity (Object) | Used to identify the entity on which this operation will be performed. |
Attributes (List<Object>) | Holds the (optional) attribute(s) which will be used to invoke this 'operation' on the given 'entity'. This represents attributes of the entity. For example, if 'entity' refers to a database table, then the 'attributes' would hold the relevant fieldnames. |
Predicate (Object) | Holds the (optional) predicate used to filter/select the eligibility of entries on which this 'operation' will be performed. |
Values (List<Object>) | Holds the (optional) value(s) which will be used to invoke this 'operation' on the given 'entity'. |
3.9.4 XidImpl
This class provides an implementation of the Xid interface, offering support for XA transactions.Such XA transaction identifiers include a 'formatId', 'globalTransactionId' and 'branchQualifier'.
3.9.5 TransactionOperation
The TransactionOperation enumeration specifies the CRUD operations (create, read, update, delete) which can be applied within a transaction.See also the TransactionAction class, which can use a TransactionOperation instance to create a JDBC PreparedStatement.
3.9.6 TransactionStatus
The TransactionStatus enumeration represents the various states of a transaction running within a scope.Initially all transactions are set to STATUS_NO_TRANSACTION.
When the 'Scope.beginTransaction()' method is invoked, the status is changed to STATUS_ACTIVE.
A call to the 'setRollbackOnly()' method will change the status to STATUS_MARKED_ROLLBACK.
A call to the 'Scope.commitTransaction()' method will change the status to either STATUS_PREPARING, STATUS_PREPARED, STATUS_COMMITTING, STATUS_COMMITTED or ultimately STATUS_NO_TRANSACTION, or the rollback lifecycle values if previously in the STATUS_MARKED_ROLLBACK state.
Similarly, a call to the 'Scope.rollbackTransaction()' method will change the status to either STATUS_ROLLING_BACK, STATUS_ROLLEDBACK or ultimately STATUS_NO_TRANSACTION.
See also: javax.transaction.Status
3.9.7 ScopedTransaction
This class represents one transaction running within a scope.Note that, if the underlying resource can support nested transactions, each ScopedTransaction can have nested transactions, which will either atomically all commit or all rollback (as appropriate) when this transaction instance is committed or rolled-back.
This class links together the following items:
transactionId (XidImpl) | Holds the unique transaction ID for this instance. |
transactionStatus (StateMachine<TransactionStatus>) | A state machine holding the status of this transaction. |
resources (List<TransactionResource>) | Holds the list of resources enlisted for this transaction. |
scope (TransactionAwareScope) |
Reference back to the enclosing TransactionAwareScope which created this transaction.
Note that the transaction manager will be this same enclosing Scope instance since TransactionAwareScope implements the TransactionManager interface. |
In addition to the above, an (optional) 'javax.transaction.Synchronization' object is available. If this object is non-null, the 'beforeCompletion() method on this object will be invoked prior to starting the two-phase commit process. Then after the transaction is completed, the 'afterCompletion()' method on this object will be invoked.
3.9.8 Pool
This class provides a basic implementation of a resource pool structure.Note that the pool can either be fixed sized or dynamically sized and that it is possible to define attributes such as initialPoolSize, poolIncrementSize and maxPoolSize.
Note that this implementation is NOT synchronised. Therefore if you require synchronisation you will need to handle this externally.
The pool can be created either immediately or lazily. If lazy creation is specified, pool entries will not be created until they are needed. This may be useful for something like a pool of database connections, for example, where new connections are only created when needed.
This is an abstract base class. To create a concrete sub-class, extend 'Pool' and implement the single abstract method:
protected abstract T createNewEntry();
This method should execute the required steps to physically instantiate one element to be added to the pool. So, for example, if the pool were to be used as a pool of database connections, then the 'createNewEntry()' method should create a connection to the database and return this new connection.
Whilst not mandatory, derived classes can also override the 'tearDown()' method, which is called automatically from the 'clear()' method, for each entry in the pool. This method can be used to invoke any required clean-up functionality. Note that the default implementation does nothing.
A pool can be either fixed sized or dynamically sized. If the pool is dynamically sized it will be extended when the pool is exhausted and an additional pool resource is requested. Additional entries will be added to the pool in batches of 'poolInrementSize'. Dynamically sized pools can also be defined to grow from an initial size up to an optional upper limit. Therefore it is possible to define attributes such as initialPoolSize, poolIncrementSize and maxPoolSize.
The current number of entries in a pool can be determined by calling the 'currentSize()' method.
The 'size()' method will return one of:
- the max pool size (if a max pool size has been defined)
- the current pool size (if no max pool size has been defined)
So, if no max pool size has been defined, the 'size()' and 'currentSize()' method will return the same value.
Since pool entries can be taken from and returned to the pool, the pool maintains an internal list of available entries. The size of this internal list of available entries can be determined by calling the 'stillAvailable()' method.
The 'getEntry()' method will return the next available pool entry, or null if no such pool entry is available.
The 'releaseEntry()' method allows a previously allocated entry to be returned to the pool.
By default there is no upper limit on how big the pool can grow. However an upper limit on the pool size can also be defined.
Unless otherwise specified, the default 'poolIncrementSize' is calculated as 1/10th of the specified initialPoolSize parameter, which itself defaults to 10.
The 'clear()' method can be used to remove all entries from the pool, prior to shutdown. This will remove all those entries currently in use as well as any available entries remaining in the pool. Care should be taken, as required, to acquiesce such entries prior to invoking the 'clear()' method.
This is a templated class, with the template defining the type of resource entries to be held within this pool
3.9.9 ConnectionPool
This class maintains a pool of database connections.This class extends the Pool class, where each pool entry is an instance of the 'java.sql.Connection' class.
See also the Pool class for further details.
3.9.10 Resource
This class allows a single business resource to be defined.Such resources can be attached to, and made available from, a specific scope.
For example, a resource could be a database, or a message queue etc.
Since the resultant API will be highly dependent on the nature of the actual resource, the Resource class itself provides little functionality directly, so must be extended to deliver the functionality associated with the nature of the underlying resource (eg database or queue etc).
So to actually define a particular resource, extend the Resource base class and add in the required functionality.
3.9.11 TransactionResource
This class wraps a resource capable of participating in an XA Transaction.Internally, this class maintains a handle to the actual underlying XA resource which is wrapped by this instance.
This class also maintains two arrays, which hold the list of global transaction identifiers and branch transactions, respectively.
A branch is a part of the work in support of a global transaction for which the TransactionManager and the ResourceManager engage in a separate but coordinated transaction commitment protocol.
Each of the ResouceManager’s internal units of work in support of a global transaction is part of exactly one branch.
After the TransactionManager begins the transaction commitment protocol, the ResourceManager receives no additional work to do on that transaction branch.
The ResourceManager may receive additional work, on behalf of the same transaction, from different branches. The different branches are related in that they must be completed atomically.
Each transaction branch identifier that the TransactionManager gives the ResourceManager identifies both a global transaction and a specific branch.
The ResourceManager may use this information to optimise its use of shared resources and locks.
This class is a CloseableResource, meaning that it will be closed automatically when the enclosing scope closes. This will also automatically commit any outstanding transactions, prior to closing this resource.
3.9.12 TransactionXAResource
This interface identifies a resource as being able to participate in an XA transaction.A single 'doAction(TransactionDetails details)' method is declared.
An example of an implementing class can be seen in the InMemoryXAResource class.
3.9.13 InMemoryXAResource
This class represents a simple implementation of the XAResource interface. More specifically, it implements the TransactionXAResource interface.This class is meant to be used for testing purposes only as the corresponding data is simply held in-memory and is never persisted. Therefore this class is not intended for production use.
Basic CRUD (create, read, update, delete) operations are supported, as are both nested and distributed transactions, as per the XA specification.
This class is a CloseableResource, meaning that it will be closed automatically when the enclosing scope closes. This will also automatically commit any outstanding transactions, prior to closing this resource.
3.9.14 TransactionLogFilenameFilter
This helper class is used to filter transaction log filenames based on the name of the enclosing scope instance, so that we only try to recover the transaction logs for that scope instance.Such log files will contain an initial timestamp followed by a filename suffix which includes the scope name.
This class matches on this filename suffix.
3.10 Scope Types
The Scope class forms a base-class from which other Scope classes may be derived.Whilst any specialised Scope type may be created, the following variants are provided:
Scope | The most basic scope type, which provides separation and isolation of business objects and business logic. |
JdbcTransactionAwareScope | Extends the basic scope functionality to include support for JDBC transactions. See also the 'AbstractTransactionAwareScope' class. |
TransactionAwareScope | Extends the basic scope functionality to include support for XA transactions. See also the 'AbstractTransactionAwareScope' class. |
TransactionAwareWithWriteAheadScope | Extends the TransactionAwareScope XA transaction functionality to include support for a write-ahead transaction log. See also the 'AbstractTransactionAwareScope' class. |
Any of these scope classes can be used as a base-class from which other specialised scope types are derived.
It is expected that such derived classes will be defined to cope with specific use-cases.
3.10.1 Basic Scope
Nested scopes provide isolation for blocks of business logic.Each scope can hold any combination of the following ScopeAssignables:
- exception handlers
- environment objects
- resources
- state machines
- business entities
- component package names
- monitors
Derived classes can add additional scoped data.
Note that any Scope flagged as 'parallel' will become standalone. This means that parallel scopes are intended to handle their own exceptions and will not become part of the Scope hierarchy.
They can however access the default scope, which in particular holds a catch-all exception handler which will simply log any unhandled exceptions before termination. Although the expectation is for each such parallel scope to successfully handle its own exceptions.
Each scope instance MUST be assigned a 'scopeName', which cannot be null and must be unique. We therefore encourage a canonical naming convention to be adopted for scope names.
A scope instance can be requested to create another (nested) Scope instance. In this case, the original scope (S1) will become the parent of child scope (S2). Similarly, the inner scope (S2) can be asked to create another nested inner scope (S3). S2 will therefore be the parent of scope S3.
When scopes are created in this parent/child manner, by default a number of scope attributes will be inherited from parent to child. The exact set of attributes which will be inherited is defined and controlled by the 'Scope.configureInheritableScopeAssignables()' method. Derived classes should override this method if the default inheritance logic requires modification.
The following attributes ARE inherited (by default):
- exception handlers
- environment objects
- state machines
- business entities
- component package names
The following attributes are NOT inherited (by default):
- resources
- monitors
Note that all four of the provided scope classes (Scope, JdbcTransactionAwareScope, TransactionAwareScope and TransactionAwareWithWriteAheadScope) share identical default inheritance characteristics.
3.10.2 Scope Initialisation Properties
Some scopes require some configurable properties to be defined prior to an instance of the scope being created. These properties are called 'Scope Initialisation Properties'.One example is the 'JdbcTransactionAwareScope' which requires the prior definition of the JDBC connection properties before the 'Scope.newInstance()' method is invoked. This is required since creating an instance of this scope type will also create a connection to the underlying JDBC database. Therefore properties such as the database connection URL and database username and password must be defined before an instance of this scope can be created.
See the following static methods within the Scope class:
- setScopeInitialisationProperties(Class<? extends Scope> scopeClass, Properties properties)
- setScopeInitialisationProperties(Object key, Properties properties)
- getScopeInitialisationProperties(Class<? extends Scope> scopeClass, Object key)
These properties are therefore associated with either the stated scope class and/or scope key.
Attempting to create an instance of such a scope without a matching entry within the scope initialisation properties will result in an exception being thrown.
Scope properties are retrieved in the following order:
- search by scope class type
- search by scope key
To be clear, any properties associated with a given scope class type will be used by ALL scopes created matching that particular type. Any properties defined for a specific scope key will ONLY be used by a scope matching that exact key.
If any properties are defined for BOTH scope class type and specific scope key, then the property associated with the stated scope key will take precedence. This means that any properties defined by scope class type can be overridden by properties defined for a specific scope key.
See the specific scope classes for details of any required scope initialisation properties.
3.10.3 AbstractTransactionAwareScope
Nested scopes provide isolation for blocks of business logic.Each scope can hold any combination of the following:
- exception handlers
- environment objects
- resources
- state machines
- business entities
- component package names
Additionally, this derived class offers support for:
- Transactions
This abstract base class acts as a 'transaction manager' for any underlying Transactions. Two derived classes are included; namely JdbcTransactionAwareScope and TransactionAwareScope. A third variant, TransactionAwareWithWriteAheadScope, extends the TransactionAwareScope class.
When a derived class is instantiated, a new global transaction is automatically created. Therefore do not explicitly call the 'beginNewGlobalTransaction()' or 'beginTransaction()' methods unless an additional nested transaction is required (which seems unlikely).
However it is appropriate to call the 'begin()' method to create new local transaction(s), which will share the currently active global transaction.
Please refer to the derived classes to determine if nested transactions are supported. In general, XA transactions support nesting, whereas JDBC does not.
3.10.4 JdbcTransactionAwareScope
Nested scopes provide isolation for blocks of business logic.Each scope can hold any combination of the following:
- exception handlers
- environment objects
- resources
- state machines
- business entities
- component package names
Additionally, this derived class offers support for:
- JDBC Transactions
To create an instance of this class, JDBC connection details must first be defined within the scope initialisation properties, similar to the following:
import static org.logicmachine.rebl.common.i18n.ExternalStrings.DATABASE_HOSTNAME_KEY; import static org.logicmachine.rebl.common.i18n.ExternalStrings.DATABASE_NAME_KEY; import static org.logicmachine.rebl.common.i18n.ExternalStrings.DATABASE_NAME_SEPARATOR; import static org.logicmachine.rebl.common.i18n.ExternalStrings.DATABASE_PORT_KEY; import static org.logicmachine.rebl.common.i18n.ExternalStrings.DATABASE_PW_KEY; import static org.logicmachine.rebl.common.i18n.ExternalStrings.DATABASE_TYPE_KEY; import static org.logicmachine.rebl.common.i18n.ExternalStrings.DATABASE_USERNAME_KEY; import java.util.Properties; ... final SupportedDatabases databaseFlavour = SupportedDatabases.MARIA_DB; final int port = 0; // database port number, or zero final Properties properties = new Properties(); properties.setProperty(DATABASE_TYPE_KEY, databaseFlavour.name() ); properties.setProperty(DATABASE_NAME_KEY, "databaseName" ); properties.setProperty(DATABASE_PORT_KEY, port ); properties.setProperty(DATABASE_HOSTNAME_KEY, "localhost" ); properties.setProperty(DATABASE_NAME_SEPARATOR, Constants.FORWARD_SLASH); properties.setProperty(DATABASE_USERNAME_KEY, "username" ); properties.setProperty(DATABASE_PW_KEY, "password" ); Scope.setScopeInitialisationProperties(JdbcTransactionAwareScope.class, properties); // or: Scope.setScopeInitialisationProperties("myScopeKey", properties); final Scope myMariaDbScope = Scope.newInstance(JdbcTransactionAwareScope.class, "myScopeKey");
NOTE: Failure to define the JDBC scope initialisation properties BEFORE attempting to create an instance of this class will result in an exception being thrown within the 'Scope.newInstance()' method.
This derived class acts as a 'transaction manager' for any underlying Transactions.
Creating an instance of this class automatically creates a JDBC transaction. Therefore do not explicitly call the 'beginNewGlobalTransaction()', 'beginTransaction()' or 'begin()' methods.
Note that nested JDBC transactions are NOT supported. Attempting to create a subsequent transaction will cause any current open transaction to commit, before the new transaction is created. This is probably not what you intend.
If you require additional transactions, simply create a new scope (ie a new instance of this class), which will open a new connection to the database, starting a new transaction.
See also the 'TransactionAwareScope' and 'TransactionAwareWithWriteAheadScope' classes which understand XA transactions and which DO support nested transactions.
This class creates a pool of database connections to the underlying JDBC database. Connection pools are associated with the base name of the associated scope. Therefore if we have scopes named "A.B", "A.B.C" and "A.B.D" (created in that order) then the connection pool will be tagged with the name "A.B" and will be shared with all 3 scopes (since the canonical names of these scopes all start with the key "A.B".
So the canonical name of this scope will be used to access the map of connection pools. If the canonical name of this scope either equals or starts with the key of an existing entry in the map, then that same connection pool map entry will be used.
If no existing connection pool entry exists in the map for this canonical scope name, a new connection pool will be created and added to the connection pool map.
3.10.5 TransactionAwareScope
This package provides XA Transaction Managers which are scope aware.Nested scopes provide isolation for blocks of business logic.
Each scope can hold any combination of the following:
- exception handlers
- environment objects
- resources
- state machines
- business entities
- component package names
Additionally, this base class offers support for:
- XA Transactions
This derived class acts as a 'transaction manager' for any underlying XA Transactions.
Creating an instance of this class automatically creates an XA transaction. Therefore do not explicitly call the 'beginNewGlobalTransaction()' or 'beginTransaction()' methods unless an additional nested transaction is required.
Note that nested XA transactions are supported.
3.10.6 TransactionAwareWithWriteAheadScope
Nested scopes provide isolation for blocks of business logic.Each scope can hold any combination of the following:
- exception handlers
- environment objects
- resources
- state machines
- business entities
- component package names
Additionally, this derived class offers:
- XA Transactions
Note that this derived class acts as as a 'transaction manager' for any underlying XA Transactions.
This class enhances the TransactionAwareScope class with the inclusion of a write-ahead transaction log.
Creating an instance of this class automatically creates an XA transaction. Therefore do not explicitly call the 'beginNewGlobalTransaction()' or 'beginTransaction()' method unless an additional nested transaction is required.
Given the fact that each defined TransactionAwareWithWriteAheadScope instance will generate its own unique transaction log, there are some optimisations which can be made; namely, support for the push/pop operations.
The push operation allows us to capture the details of the current inner-most transaction, whilst the pop operation allows us to remove the last file entry. We can therefore guarantee that only one entry will ever exist within the file, for the top-most committing transaction.
So, at most, the transaction log for this scope will contain a single committing transaction.
Note that nested XA transactions are supported.
3.11 Actors
This package provides base classes which can be used to define the OwningEntities (ie Actors) which own some ActiveEntities.The Actor class provides a concrete implementation of the 'OwningEntity' interface, with ActiveEntities being the items "owned" by an Actor (OwningEntity). So it is the Actor class which implements the OwningEntity interface.
Once we have selected an owner (Actor), we can perform Actions on the corresponding ActiveEntities, within a given Business Language.
An Actor is therefore an entity which has ownership of some ActiveEntity.
An example of an Actor is that of a Customer instance which owns a bank account. In this case, the Customer instance is the Actor.
3.12 Entities
This package provides a number of base-classes used to create a range of business entities, as required to construct a Business Language.This class forms the base-class of all Entities.
Sub-classes then form the range of entities which are required to create a Business Language. The three derived sub-classes are OwningEntities, PassiveEntities and ActiveEntities, which are detailed below.
3.12.1 OwningEntities
An OwningEntity 'owns' one or more ActiveEntities.Once an owner has been selected, actions can subsequently be applied to the corresponding ActiveEntity instance.
An example of an OwningEntity is that of a Customer who 'owns' a bank account. In this example, the BankAccount would be an Entity which is owned by the Customer. It is the customer therefore which would be the OwningEntity of the bank Account instance.
Note that 'OwningEntity' is an interface and 'Actor' is a concrete implementation of this interface.
3.12.2 PassiveEntities
PassiveEntities are embedded within ActiveEntities and cannot be addressed directly. Rather they are manipulated by the controlling ActiveEntity.The ActiveEntity is therefore the object on which Actions are applied, which may then cause any number of PassiveEntities to be modified.
An example of a PassiveEntity is that of a bank balance. In this example, we never apply actions directly to the AccountBalance. Rather we apply actions (ie bank transactions) to the Account instance. It is therefore up to the Account processing logic to modify the AccountBalance entity, as required. Therefore the Account instance is the ActiveEntity and the AccountBalance is a PassiveEntity.
But note that a single ActiveEntity may be responsible for handling many PassiveEntities.
3.12.3 ActiveEntities
ActiveEntities are owned by OwningEntities (also known as Actors).In other words, the Actor class provides a concrete implementation of the 'OwningEntity' interface, with ActiveEntities being the items "owned" by an OwningEntity.
Actions can subsequently be applied to ActiveEntites.
An example of an ActiveEntity is that of a bank account. In this example, the bank Account instance is an ActiveEntity which is owned by an OwningEntity (ie a Customer). Bank transactions will be performed against this Account instance, with each transaction triggering an Action which is applied to the ActiveEntity instance (ie the Account). An ActiveEntity can be responsible for PassiveEntities, in which case the act of applying an Action to an ActiveEntity may cause one or more PassiveEntities to be modified.
So in a banking example, the Customer (OwningEntity/Actor) owns an Account (ActiveEntity) against which transactions (Actions) are applied, which may cause the AccountBalance (PassiveEntity) to be modified.
Actions can only be applied to an ActiveEntity.
All Actions are held within a namespace. A new namespace can be created by calling the 'createNewNameSpace()' method. Once all Actions within the current namespace have been applied by the 'apply()' method, the current namespace is removed and the prior namespace becomes the current namespace (if one exists) for this ActiveEntity.
The 'createNewNameSpace()' method prepares the ActiveEntity instance to receive a new set of Actions which will be stored within a new namespace. This method is invoked automatically as a consequence of calling the 'OwningEntity::withActiveEntity()' method. Once any of the 'ActiveEntity::apply()' methods have subsequently been invoked, the Actions within this namespace will be automatically removed.
The purpose of the namespace is therefore to provide separation of multiple sets of Actions defined within a single scope for a given ActiveEntity. Note that each ActiveEntity instance maintains the details of its own namespaces and Actions.
A "Repeatable" can also be assigned to an ActiveEntity. A Repeatable instance stores details enabling a set of Actions to be repeated in the event of an exception being thrown within a specific code block. Specific exceptions types can be declared, so that the Actions will only be repeated for those specific exception types. For example, we may have some code which should be retried up to 3 times in the event of a TimedOut exception. In this case we could create a Repeatable instance matching that particular exception type and defining both the maximum number of permitted retries along with an (optional) sleep time between iterations. Note that multiple exception types may be mapped within a single Repeatable, so that the relevant code will be repeated upon receipt of any of the matching exception types.
Each Repeatable can also store a set of "undo" Actions. Such undo Actions will be invoked automatically once the maximum number of retries have been attempted without success. These "undo" Actions therefore provide a simple back-out option. Undo Actions are an optional component of the Repeatable class and a Repeatable is an optional component of the ActiveEntity class.
It should be noted that the 'toString()' method within the ActiveEntity class is also namespace aware. So that in addition to the normal operation of this method, this implementation will also generate details of any Actions associated with the current namespace. Hence if other Actions are defined for this ActiveEntity instance which are associated with some other namespace(s), those Actions will NOT be included in the returned String. Therefore only those Actions within the current namespace will be included. It is important to be aware of this fact to avoid surprises when using the 'toString()' method - either directly or indirectly via a debugger within an IDE.
Any ActiveEntity can be flagged as Parallel, meaning that the Actions associated with that ActiveEntity will run in parallel within a newly created thread. The Common class maintains a list of such parallel ActiveEntities for each Scope. This is required to ensure that all outstanding threads have completed for each Scope prior to attempting to close that scope instance. Therefore the Scope clean-up lifecycle methods will block until all outstanding threads for that scope complete. In particular, this means that the 'Scope.closeScope()' method will block pending completion of any outstanding threads.
Note however that whilst the 'parallel()' method will flag an ActiveEntity as being parallel, the ActiveEntity instance is not actually registered with the Common class until the 'apply()' method is invoked, since it is the 'apply()' method which actually creates the new thread (if required). The ActiveEntity instance is therefore only registered with the Common class when a new thread has actually been created. Once registered, the enclosing Scope will confirm that this thread has completed prior to any clean-up operations being invoked on that scope instance. This is important since we may create a large number of (parallel) ActiveEntity instances, but may never need to actually create a new thread for all, depending on the business logic.
3.13 Actions
This package provides base classes which can be used to define Actions to be performed on ActiveEntities within a given Business Language. Many such action classes can be derived, with each Action being applied to an ActiveEntity at some suitable point within the business logic. A number of useful Actions have been pre-defined, as follows:Action | This class forms a base-class for all Actions which can be applied to ActiveEntity instances. |
Callable | This class allows 'Callable' statements to participate in the Actions which can be applied to an ActiveEntity instance. This means that such actions can invoke arbitrary business functionality contained in separate components, where each component is a specific method within a specific class (for example "MySimpleClassName::MyMethod)". |
ObservableAction |
This class allows observable notifications to participate in the Actions which can be applied to an
ActiveEntity instance.
This class will be notified of any changes applied to the specified entity. All defined Observers will then be notified of this change. One such usage example is that of a StateMachine instance changing state. Observers will then be notified of these state transitions. |
StateTransitionAction |
This class allows 'StateTransition' objects to participate in the Actions which can be applied to an
ActiveEntity instance.
This means that such an action can trigger a state machine to transition to a new state. |
LogExceptionAction |
This class allows 'LoggableAction' objects to participate in the Actions which can be applied to an
ActiveEntity instance.
This means that such an action can trigger a message to be logged to the standard output stream and/or an exception to be logged to the error stream. Note that it is possible for EITHER or BOTH a log message and an exception to be logged. |
FlagExceptionHandledAction |
This class allows 'FlagExceptionHandledAction' objects to participate in the Actions which can be applied
to an ActiveEntity instance.
This means that such an action can trigger an exception or BusinessMessage to be flagged as having been successfully handled by some exception handler. |
Each of the above classes provide a 'doAction()' method.
Where appropriate, derived classes should invoke the 'verifyPreConditions()' method from within their 'doAction()' method to verify the existence of the associated ActiveEntity and Scope. Refer to the above classes for further details.
3.14 Actives
It is convenient to think in terms of currently active items. So, for a given location within the business logic, we will be working within a specific Scope, interacting with a specific Entity and perhaps a specific Resource. Each scope therefore maintains the notion of certain objects being "current", as detailed below.3.14.1 Current Scope
As we follow the flow through the business logic, we will effectively be transitioning from the realm of one Scope into the realm of another. We therefore have the notion of a 'CurrentScope', which is simply just a convenient handle to whichever Scope instance we are currently focused on.Bear in mind though that (for parallel Scopes), there could be logic being executed within several Scopes concurrently. The idea of 'CurrentScope' should therefore be thought of from the perspective of the code currently being executed. So, for a given piece of code (C1), it will be executing within a Scope instance (S1) and from the point-of-view of that code piece, the associated Scope (S1) will be the 'CurrentScope'. However, some other piece of code (C2) which is also currently being executed, could be associated with a different Scope instance (S2) and from the point-of-view of this other piece of code, this other Scope instance (S2) will be the 'CurrentScope'.
3.14.2 Active Resource
Each Scope instance can have a number of Resources assigned to it.So within a given Scope (S1) we may be currently interacting with a specific Resource (R1). From the point-of-view of this Scope (S1), the Resource (R1) will be the current 'ActiveResource'.
3.14.3 Active Entity
Each Scope instance can have a number of Entities assigned to it. Entities are one of the inherited Scope properties and so the same Entity can be shared amongst multiple Scope instances.But within a given Scope (S1) we may be currently interacting with a specific Entity (E1). From the point-of-view of this Scope (S1), the Entity (E1) will be the current 'ActiveEntity'.
3.15 Language Definitions
Since this platform concerns itself with the creation of Domain-Specific Languages, the top-level class is the Language class. This class should be used to initialise the platform and create a new language instance of a given name.Therefore each instance of the Language class represents the definition of one business language.
The language will include a limited Vocabulary and Grammar, but note that these classes provide the vocabulary and grammar required by this platform; rather than the requirements of any other given business language. However these classes may be extended if additional constructs are to be made available.
3.16 Miscellaneous Helper Classes
The classes described in this section are a collection of miscellaneous classes responsible for providing specific helper functionality to the platform.3.16.1 Common
The Common class is a general utility class, holding a range of functionality used extensively within the platform, but having no other specific home.Along with the Scope base class, the Common class is a LanguageAssignable. This means that it maintains an internal handle back to the Language instance. Further, convenience helper methods are defined to provide shortcuts to interact with this Language instance.
Since it is the Language class which maintains a list of defined Scopes, the Common class provides some convenience methods to interact with the Scopes within the Language class; in particular both Scope creation and Scope removal methods as well as interaction with the DefaultScope instance.
The Common class also holds a map of Parallel Scopes (indexed by thread name).
The available functionality can be grouped as shown:
Language interaction |
|
Scope and DefaultScope interaction |
|
Parallel Scope interaction |
|
Parallel ActiveEntity interaction |
|
toString() helper methods |
|
String evaluation methods |
|
Localisation helper methods |
|
Logging helper methods |
|
Unit testing support |
|
3.16.2 KeyValue
This helper class denotes support for an element which can be referenced by a 'key' value.Additionally this can represent an 'empty' value. See also the 'setEmpty()' and 'isEmpty()' methods.
Note that this class only provides support for the 'key' part of a key/value pair.
A range of methods are available to interact with the 'key' component and to check if this instance represents an 'empty' value.
This class extends the Observable class and implements the Maybe interface.
This is a surprisingly useful class, used extensively throughout the platform.
3.16.3 Loggable
The Loggable interface is a small helper interface denoting an element which supports logging.A single 'log()' method is declared, which provides the actual logging functionality.
The exact logging details are implementation dependent.
Multiple classes within the platform implement this interface.
3.16.4 SafeIterable
This class provides a null-safe alternative to the standard Iterable class.This class allows for the safe use of the construct:
if (null != myCollection) { for (final Object object : myCollection) { final MyType myVar = (MyType)object; ... } }
without having to firstly check if 'myCollection' is null.
It also removes the need to cast the returned Object to the correct type prior to use.
The above code can simply be replaced with:
for (final MyType myVar : new SafeIterable<MyType>(myCollection)) { ... }
3.16.5 ResponseCode
This enumeration holds the response values which can be returned by the 'execute()', 'onSuccess()' and 'onFailure()' methods within the ActiveEntiity class.These codes determine how exceptions are propagated.
Available values include:
COMPLETE_SUCCESS | Signifies that the operation completed successfully. |
FAILED_WITH_HANDLED_EXCEPTION | Signifies that the operation failed due to an exception, although this exception was handled successfully and therefore should not be propagated. |
FAILED_WITH_UNHANDLED_EXCEPTION | Signifies that the operation failed due to an unhandled exception which must be propagated. |
PART 4 Project Web Site
This web site is built by Maven.The following Maven command may be used to rebuild the site:
mvn clean install test package site site:stage
The above command should be run from the top-most "rebl" installation directory and once built, the site will be staged under the directory: rebl/tmp/site.
Open the "rebl/tmp/site/index.html" file in a browser window to view the generated site.
The following sections highlight the more important site files.
4.1 site.xml
Maven uses the 'site.xml' file to define the Modules, Reports and additional items of documentation to include in the generated menu created during production of this project web site.The 'site.xml' file is located in the 'reblDocs' project, under the directory:
reblDocs: src/site/site.xml
4.2 Resources
The 'resources' directory contains sub-directories which hold the resources required to build this web site.The 'resources' directory is located in the 'reblDocs' project, under the directory:
reblDocs: src/site/resources
Sub-directories hold:
- the images used by the site (under 'resources/images' and 'resources/images/logos').
- the small javascript file used by the site (under 'resources/js').
A sibling directory (under 'src/site/xdoc') holds a copy of this user guide.
The required resources are lightweight and have been deliberately kept to a minimum.
Note that 2 images are included in the resources directory which originate from the Free Software Foundation (FSF) and which are used within this user guide to highlight the work of the FSF and to acknowledge our commitment to upholding the ideals of Free Software. Both of these images are under copyright of the Free Software Foundation.
4.3 site.css
The 'site.css' file is contained within the 'resources' directory, described above.However, given the significance of this file, it is appropriate to explicitly define its location and use.
The 'site.css' file is located in the 'reblDocs' project, under the directory:
reblDocs: src/site/resources/css/site.css
This file defines the styling and layout used to display this web site. It is deliberately lightweight in nature, keeping the defined attributes to a minimum and offering both ease of modification and extension.
4.4 Site Layout
Various standard static analysis tools are invoked by the Maven build including CheckStyle, SpotBugs, CPD and PMD.The build will also run all of the unit tests and integration tests.
The resultant web-site will include the reports generated by the static analysis tools as well as the standard pages generated by the Maven site plugin.
The full web-site contains the following projects:
Parent: rebl |
Module: reblDocs |
Module: reblCore |
Module: reblUnitTests |
Module: reblIntegrationTests |
For each of the above projects, the following standard Maven Project Information details are generated:
- Distribution Management
- About
- Dependencies
- Issue Tracking
- Project Plugins
- Continous Integration
- Project License
- Dependency Management
- Mailing Lists
- Project Team
- Source Repository
- Plugin Management
- Project Summary
For each of the above projects, the following Project Reports are generated:
- Surefire Report (reblUnitTests only)
- Navigatible JavaDocs
- Navigatible Source Code
- Tag List
- Checkstyle
- SpotBugs
- CPD
- PMD
PART 5 Installation Guide
5.1 System Requirements
This platform is designed to be lightweight, both in terms of storage and memory usage. It can therefore be installed on a minimal machine or virtual-machine by simply copying a single Java JAR file.The reblCore JAR file containing the class files is less than 200Kb in size.
Even the reblCore JAR file which includes all of the sources and JavaDocs is less than 1Mb in size.
No specific system requirements are thus defined.
However the code-base is written entirely in Java, requiring a Java Runtime Environment supporting JSE 7, at a minimum.
If you wish to clone the entire Mercurial repository, you will need to install the Mercurial distributed source control system (see https://mercurial-scm.org).
To compile the code locally, you will need a Java SDK supporting JSE 7 or above, as well as the Maven build system (see https://maven.apache.org).
5.2 Install
The platform can be installed by simply copying the reblCore JAR file onto your system and adding the corresponding installation directory to the Java Classpath.Alternatively, the entire set of Mercurial repositories can be cloned, by running the following script:
#!/bin/sh hg clone https://logicmachine.co.uk/rebl cd rebl hg clone https://logicmachine.co.uk/rebl/reblDocs hg clone https://logicmachine.co.uk/rebl/reblCore hg clone https://logicmachine.co.uk/rebl/reblUnitTests hg clone https://logicmachine.co.uk/rebl/reblIntegrationTests cd ..
5.3 Build
Once cloned, the code can be built locally by the Maven build system, by running the following command from the top-most 'rebl' directory:mvn clean install test package
The above command will recursively build all of the sub-directories. Note that an internet connection will be required to complete the build initially, since Maven will need to download all of the project dependencies and Maven plug-ins etc. Once the initial build has been completed, subsequent builds can be invoked offline, by including the "-o" option within the above build command.
Or, to additionally build a local copy of the platform web site:
mvn clean install test package site site:stage
The local copy of the platform web site will be staged under the directory: rebl/tmp/site
To view the web site, simply locate the "index.html" file within the "rebl/tmp/site" directory and open it in a web-browser.
A full clean build will take roughly 30 seconds to complete. The full build will compile all of the source code and package 3 different JAR files; one containing class files only, one containing both class and source files and one containing the JavaDocs only. Various standard static analysis tools will also be invoked by the build, including CheckStyle, SpotBugs, CPD and PMD. The build will also run all of the unit tests and integration tests. If the build includes the 'site' options, the resultant web-site will include the reports generated by the static analysis tools as well as the standard pages generated by the Maven site plugin.
5.4 Uninstall
The platform is entirely standalone, and can be uninstalled by simply deleting the reblCore JAR file from its installation directory.If the full Mercurial repository has been cloned, simply delete the entire repository directory (rebl) and all sub-directories.
If a local copy of the platform web site has been built, removing the repository directory will also delete the sub-directory: rebl/tmp/site
Since Maven is used as the project build tool, local copies of the pom and jar files will likely be cached in the local Maven repository, therefore the following directory can also be removed: $HOME/.m2/repository/org/logicmachine
No other files or directories are created or modified by installing this software.
PART 6 Error Messages
Each of the runtime error messages which may be generated by the platform are described in detail below.6.1 Hard-Coded Error Messages
There is a single hard-coded error message within the platform, which is defined within the 'Constants' class.However this error message cannot be externalised into a resource bundle since it is used to generate an error message for an I/O exception whilst accessing a resource bundle. Since such an error could occur whilst accessing I18N resource bundle values, this error message must be hard-coded.
This error message is defined as follows:
ResourceBundle I/O error ->
If you receive the above error message, it means there is some issue with reading the resource bundles for your stated locale. Note that this may be a permissions issue, or simply that the corresponding file(s) do not exist or have been corrupted. These files are located within the directory: "resources/locale/XX" (where XX refers to the Locale name, for example "en" for the general English locale).
6.2 Scope Error Messages
There are a number of potential error messages which will be generated due to errors within the definition of Scopes. These error messages are listed below:Duplicate scope name | All scopes MUST be assigned a unique (non-null) name. Attempting to create a duplicate will result in this error. A canonical naming convention is recommended, so that related scopes can be grouped by similar name components, such as "my.project.initialisation.scope". |
Invalid Scope class | All derived Scope classes MUST ultimately extend the default Scope base class (or extend another scope class which itself ultimately extends the default Scope base class). Failure to adhere to this object hierarchy will result in this error message. |
MyScope has no public constructor like MyScope(String scopeName) |
All derived scope classes MUST define a public constructor which takes a single String 'scopeName'
parameter. Failure to adhere to this requirement will result in this error message. Note
however that such derived classes MAY choose to offer additional constructors in addition to
this mandatory constructor.
Note that a number of Scope derived classes are provided by the platform. Therefore this error message is used for user-defined Scope sub-classes which have not defined the required constructor. |
Scope - sequential failure - Scope is already flagged as parallel | Scopes can be declared as Sequential or Parallel. Once a scope has been flagged as parallel it CANNOT be subsequently re-declared as sequential. This is due to the fact that declaring a scope to be parallel causes that scope to be removed from the parent/child scope hierarchy, and instead becomes standalone. It cannot therefore be subsequently re-added into the existing hierarchy. |
No scope defined |
The error message generated if a scope is expected but not present.
This is used in two locations:
|
No Scope declared - you must declare a Scope prior to defining Actions | Actions can be attached to ActiveEntities. ActiveEntities can be associated with Scopes. However before an Action can be defined, the corresponding ActiveEntity MUST be associated with a Scope instance. This is due to the fact that ActiveEntities MAY be shared between multiple scopes and the act of defining an Action implies that Action is applicable to one specific scope only. Each ActiveEntity records those Actions assigned to it, but these Actions are keyed to a specific scope. Hence the requirement to pre-select a specific scope (for an ActiveEntity) prior to assigning an Action to that ActiveEntity. |
No available scope - suppressed |
The error message used within an informational log message stating that an action has been
suppressed because there is no available scope.
Note that this error message is advisory only and will not result in an exception being thrown, however (as suggested by the wording of the message) the corresponding behaviour will be suppressed, probably resulting in abnormal or incorrect operation of your logic. |
6.3 Resource Bundle Error Messages
These error messages relate to interactions with locale-specific resource bundles:Failed to open resource bundle | The error message used for file I/O exceptions caught whilst accessing locale-specific resource bundles. |
Missing property | The error message used to highlight a missing resource within a locale-specific resource bundle. |
6.4 State Machine Error Messages
The following error messages are related to the use of Finite State Machines:No such StateMachine | State Machines are referenced by name. This error message is generated if an attempt is made to reference a state machine which does not exist. |
Invalid state data | The error message used for invalid state transition definitions within a state machine. |
Invalid state transition | The error message used for invalid state transitions within the StateTransitionActions for a given state machine. |
Invalid action definition | The error message used for invalid Action definitions within a state machine. |
6.5 Observable Error Messages
This error message relates to objects defined as being Observable:No Observable | The error message generated if an attempt is made to observe an observable which does not exist. |
6.6 Resource Error Messages
The following error messages are related to the handling of Resources:No such Resource | The error message generated if an attempt is made to reference a resource which does not exist. |
Error closing resource | The error message generated if an exception is caught when trying to automatically close a CloseableResource instance. |
6.7 Database Error Messages
There are a number of potential error messages which relate to database operations, as detailed below:Invalid database connection details | The error message generated if an attempt is made to perform a database interaction via an invalid connection. |
No open connection to database | The error message generated if an attempt is made to perform a database interaction via a null connection. |
Empty SQL statement | The error message generated if an attempt is made to perform a database interaction with an empty SQL statement. |
Failed to create new DB connection pool entry | The error message generated if an exception is caught when trying to create a new database connection for the connection pool. |
Failed to close DB connection pool entry | The error message generated if an exception is caught when trying to close an existing database connection within the connection pool. |
6.8 Transaction Error Messages
There are a number of potential error messages which relate to operations associated with Transactions, as detailed below:Transaction cannot be added | This error message is used if a transaction cannot be added to a branch within an XA transaction. |
Duplicate transaction XID | This error message is used if an attempt is made to add a transaction with a duplicate XID to a branch within an XA transaction. |
Failed to close transaction |
This error message is used if an attempt to close a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to commit transaction |
This error message is used if an attempt to commit a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to end transaction |
This error message is used if an attempt to end a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to forget transaction |
This error message is used if an attempt to forget a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to join transaction |
This error message is used if an attempt to join a transaction which has not yet started.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to prepare transaction |
This error message is used if an attempt to prepare a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to recover transaction |
This error message is used if an attempt to close a transaction recovery operation
generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to resume transaction |
This error message is used if an attempt to resume a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to rollback transaction |
This error message is used if an attempt to rollback a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to start transaction |
This error message is used if an attempt to start a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to suspend transaction |
This error message is used if an attempt to suspend a transaction generates an error.
This is part of the lifecycle of a Transaction. See also the javadocs for javax.transaction.Transaction and javax.transaction.TransactionManager. |
Failed to create directory | This error message is used on failure to create the transaction logfile directory. |
Failed to delete transaction log | This error message is used on failure to remove a transaction logfile. |
Invalid transaction | This error message is used if an attempt is made to resume a local transaction without an existing global transaction. |
No global transaction | This error message is used if an attempt is made to begin a local transaction without an existing global transaction. |
Failed to begin an unknown global transaction | This error message is used if an attempt is made to begin an unknown global transaction. |
Nested transactions are unsupported | This error message is used if an attempt is made to create a nested transaction whilst using a Transaction Manager which does not support nested transactions. |
PART 7 Free Software
We are committed to the notion of Free Software. For a description of what this means, we refer to the following statement from the GNU web site (see https://gnu.org):"Free software" means software that respects users' freedom and community. Roughly, it means that the users have the freedom to run, copy, distribute, study, change and improve the software. Thus, "free software" is a matter of liberty, not price.
"Open source" is something different: it has a very different philosophy based on different values. Its practical definition is different too, but nearly all open source programs are in fact free. We explain the difference in Why "Open Source" misses the point of Free Software.
7.1 Free Software
To understand why Free Software is important, it is essential to understand the underlying philosophy of freedom on which it is based. From the Free Software Foundation web site (see https://fsf.org):The four essential freedoms
A program is free software if the program's users have the four essential freedoms:
- The freedom to run the program as you wish, for any purpose (freedom 0).
- The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1).
Access to the source code is a precondition for this.
- The freedom to redistribute copies so you can help others (freedom 2).
- The freedom to distribute copies of your modified versions to others (freedom 3).
By doing this you can give the whole community a chance to benefit from your changes.
Access to the source code is a precondition for this.
So how does this differ from other terms commonly (and mistakenly) used to refer to Free Software and why does this matter?
Again, from the Free Software Foundation web site (see https://fsf.org):
Others use the term "open source" to mean something close (but not identical) to "free software".
We prefer the term "free software" because, once you have heard that it refers to freedom rather than price, it calls to mind freedom.
The word "open" never refers to freedom.
It is clear therefore that "open source" misses the point.

7.2 Why Open Source misses the point
We are committed to the notion of Free Software. This means free, as in freedom.We purposely and deliberately use the term Free Software rather than "open source". For a detailed discussion of why this is important, please refer to the following article from the "Free Software Foundation":
When we call software "free" we mean that it respects the users' essential freedoms: the freedom to run it, to study and change it and to redistribute copies with or without changes. This is a matter of freedom, not price; so think of "free speech", not "free beer".
These freedoms are vitally important. They are essential, not just for the individual users' sake, but for society as a whole because they promote social solidarity — that is, sharing and cooperation. They become even more important as our culture and life activities are increasingly digitised. In a world of digital sounds, images, and words, free software becomes increasingly essential for freedom in general.
Read this essay, by Richard Stallman, in full at: why-open-source-misses-the-point.
7.3 Free Software, Free Society
From the Free Software Foundation web site (see https://fsf.org):Free software is software that gives you the user the freedom to share, study and modify it. We call this free software because the user is free.
To use free software is to make a political and ethical choice asserting the right to learn, and share what we learn with others. Free software has become the foundation of a learning society where we share our knowledge in a way that others can build upon and enjoy.
Currently, many people use proprietary software that denies users these freedoms and benefits. If we make a copy and give it to a friend, if we try to figure out how the program works, if we put a copy on more than one of our own computers in our own home, we could be caught and fined or put in jail. That’s what’s in the fine print of the license agreement you accept when using proprietary software.
The corporations behind proprietary software will often spy on your activities and restrict you from sharing with others. And because our computers control much of our personal information and daily activities, proprietary software represents an unacceptable danger to a free society.

7.4 Important Links
We strongly encourage you to support the following organisations.Check out the links to gain an understanding of the important issues being addressed.
The following introductions are copied directly from each corresponding web site.
Free Software Foundation (fsf.org)
The Free Software Foundation, founded in 1985, is dedicated to promoting computer users' right to use, study, copy, modify, and redistribute computer programs. The FSF promotes the development and use of free (as in freedom) software -- particularly the GNU operating system and its GNU/Linux variants -- and free documentation for free software. The FSF also helps to spread awareness of the ethical and political issues of freedom in the use of software, and its Web sites, located at fsf.org and gnu.org, are an important source of information about GNU/Linux.
GNU Operating System (gnu.org)
GNU is a Unix-like operating system. That means it is a collection of many programs: applications, libraries, developer tools, even games. The development of GNU, started in January 1984, is known as the GNU Project. Many of the programs in GNU are released under the auspices of the GNU Project; those we call GNU packages.
The name "GNU" is a recursive acronym for "GNU's Not Unix". "GNU" is pronounced g'noo, as one syllable, like saying "grew" but replacing the r with n.
The program in a Unix-like system that allocates machine resources and talks to the hardware is called the "kernel". GNU is typically used with a kernel called Linux. This combination is the GNU/Linux operating system. GNU/Linux is used by millions, though many call it "Linux" by mistake.
Electronic Frontier Foundation (eff.org)
The Electronic Frontier Foundation is the leading nonprofit organisation defending civil liberties in the digital world. Founded in 1990, EFF champions user privacy, free expression, and innovation through impact litigation, policy analysis, grassroots activism, and technology development. We work to ensure that rights and freedoms are enhanced and protected as our use of technology grows.
APPENDIX A Configuration
Within this platform, the primary configurable values are the Component Package Names. These packages define the location of blocks of business logic. Each scope instance can maintain its own set of such package names from which it will attempt to locate the business logic specified within "Callable()" statements.The "Callable" class holds a key of the form: "className::methodName"
Here, the Component Package Names defined for the current scope will be searched in an attempt to locate a class of the name "className". Once found, reflection is used to actually invoke the 'methodName' method within the class 'className'.
We deliberately do not wish to merely use the Classpath to locate these classes, since we wish to provide a finer level of granularity to the structure of these business logic components. So we may wish to re-use the same 'className' across multiple implementations (held within different packages), then configure the relevant Scope instances to locate the required class at runtime, based on the supplied Component Package Names.
In particular, this mechanism can aid the creation of test classes, comprising mocks or stubs.
See the corresponding unit tests as well as the included 'bank' integration test for usage examples of the "Callable" functionality.
APPENDIX B Internationalisation
The internationalisation package (reblCore: rebl.common.i18n) defines the following classes:- The ResourceBundles class defines helper methods allowing error messages and externally visible strings to be extracted into locale-specific resource bundles.
- The ExternalStrings class holds all of the locale-specific externally visible string constants.
- The ErrorMessages class holds all of the locale-specific externally visible error messages.
-
The resource bundle files are located in the directory: resources/local/{LOCALE}.
Currently, only 'en' (ie English) resources are included, but this can be extended easily by creating translations of the enclosed files for any other required locales.
The actual resource files (which are included in the base distribution) include:
- errorMessagesBundle_en.properties
- externalStringsBundle_en.properties
Additionally, the "reblCore: rebl.common.Constants" class defines those values which comprise:
- symbol character sequences
- system-specific values (such as NEWLINE, defined via the "line.separator" property)
- a small number of String constants which do NOT require internationalisation
- a single hard-coded error message ("ResourceBundle I/O error -> ") which is used upon error whilst reading any other locale-specific resource bundles
- the transaction log date/time format
- filenames and file suffix values
APPENDIX C Localisation
The "reblCore: rebl.common.Common" class contains a number of helper methods which can assist with localisation.See the JavaDocs for this class, in particular, the methods:
- withLocale()
- dateToLocaleString()
- currencyToLocaleString()
Any additional localisation functionality must be defined externally.
APPENDIX D GNU Free Documentation License
GNU Free Documentation License Version 1.3, 3 November 2008 Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc. [https://fsf.org/] Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 0. PREAMBLE The purpose of this License is to make a manual, textbook, or other functional and useful document "free" in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others. This License is a kind of "copyleft", which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software. We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. 1. APPLICABILITY AND DEFINITIONS This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The "Document", below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as "you". You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law. A "Modified Version" of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. A "Secondary Section" is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document's overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The "Invariant Sections" are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none. The "Cover Texts" are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words. A "Transparent" copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not "Transparent" is called "Opaque". Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only. The "Title Page" means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, "Title Page" means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. The "publisher" means any person or entity that distributes copies of the Document to the public. A section "Entitled XYZ" means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as "Acknowledgements", "Dedications", "Endorsements", or "History".) To "Preserve the Title" of such a section when you modify the Document means that it remains a section "Entitled XYZ" according to this definition. The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License. 2. VERBATIM COPYING You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. 3. COPYING IN QUANTITY If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document's license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects. If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. 4. MODIFICATIONS You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: A. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission. B. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement. C. State on the Title page the name of the publisher of the Modified Version, as the publisher. D. Preserve all the copyright notices of the Document. E. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices. F. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below. G. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document's license notice. H. Include an unaltered copy of this License. I. Preserve the section Entitled "History", Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled "History" in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence. J. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the "History" section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission. K. For any section Entitled "Acknowledgements" or "Dedications", Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein. L. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles. M. Delete any section Entitled "Endorsements". Such a section may not be included in the Modified Version. N. Do not retitle any existing section to be Entitled "Endorsements" or to conflict in title with any Invariant Section. O. Preserve any Warranty Disclaimers. If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. You may add a section Entitled "Endorsements", provided it contains nothing but endorsements of your Modified Version by various parties--for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. 5. COMBINING DOCUMENTS You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. In the combination, you must combine any sections Entitled "History" in the various original documents, forming one section Entitled "History"; likewise combine any sections Entitled "Acknowledgements", and any sections Entitled "Dedications". You must delete all sections Entitled "Endorsements". 6. COLLECTIONS OF DOCUMENTS You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects. You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. 7. AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an "aggregate" if the copyright resulting from the compilation is not used to limit the legal rights of the compilation's users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document's Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate. 8. TRANSLATION Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail. If a section in the Document is Entitled "Acknowledgements", "Dedications", or "History", the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title. 9. TERMINATION You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License. However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it. 10. FUTURE REVISIONS OF THIS LICENSE The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See https://www.gnu.org/licenses/. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License "or any later version" applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Document. 11. RELICENSING "Massive Multiauthor Collaboration Site" (or "MMC Site") means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A "Massive Multiauthor Collaboration" (or "MMC") contained in the site means any set of copyrightable works thus published on the MMC site. "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization. "Incorporate" means to publish or republish a Document, in whole or in part, as part of another Document. An MMC is "eligible for relicensing" if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008. The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing. ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page: Copyright (c) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the "with...Texts." line with this: with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST. If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.
APPENDIX E GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. [https://fsf.org/] Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.
APPENDIX F GNU GENERAL PUBLIC LICENSE
GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. [https://fsf.org/] Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. []one line to give the program's name and a brief idea of what it does.] Copyright (C) []year] []name of author] This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see [https://www.gnu.org/licenses/]. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: [program] Copyright (C) [year] [name of author] This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see [https://www.gnu.org/licenses/]. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read [https://www.gnu.org/licenses/why-not-lgpl.html].