Introducing Acuity Business Rules Composer

acuity_232x264Concentricsys.com has recently launched its flagship product "The Acuity Business Rules Composer" software on 07 May 2013. Acuity Business Rules Composer allows users to create and run declarative business rules of the if-then format.

Introduction


Concentricsys.com has recently launched its flagship product "The Acuity Business Rules Composer" software on 07 May 2013. Acuity Business Rules Composer allows users to create and run declarative business rules of the if-then format. Acuity Business Rules Composer is designed to run on the Amazon AWS cloud. Soon it will be available on other cloud providers like Azure, Rackspace etc.

Acuity has a subscription based business model. There are 2 packages, the Intro Offer and Month-to-Month. The Intro Offer is a Instant Buy package and requires 1-year contract whereas the Month-to-Month package is a pay-as-you-go package and also includes 30-day trial.

Concentricsys.com has also developed the trademark one-button-connect which allows users to start a server instance in the AWS cloud with bundles Acuity Business Rules Composer software in minutes.

Features


Acuity Business Rules composer includes the following features:

Plain English Rules

Dynamic compilation of Java files

Bindings and factstores in rules

Aggregations in rules

Java Bean object model

Built-in Beans and List Editor

Advanced Rules Editor

Advanced Bindings editor

Dashboard

Configurable Result pane tabs

Dynamic Runtime View

Wizard View

File upload facility

Ajax based RIA framework

Runs on standards based J2EE containers

User profile settings

Configurations persisted to database

Role based access control

Custom Edior Configuration for JavaBean Fields

Multiple form layouts

Filesystem classloader

Organize your work into multiple projects

Themes

Multiple Locales (coming soon)

Rule Engines
So what is Acuity and what does it do? How is it different from Jess or Drools or Blaze or Fico.

The answer is Acuity is different. It is not like any of the Rule engines mentioned above. Acuity processes simple if-then type rules that you would find in the banking and financial services industry. Acuity rules are in plain english and easily created by the business users themselves. This does not mean Acuity cannot process and run rules from other rule engines. Effort is under way to add multiple project templates to Acuity with each template capable of running rules from different rule engines.

Drools is on the horizon as it implements the ‘rete’ algorith, is available under the Apache 2.0 license, has its own dialect DRL and also a ‘CLIPS’ plugin that can run rules written in CLIPS. We here at concentricsys.com like CLIPS a lot and have been working with it a lot lately. We think it is simpler than prolog, can captivate the users imagination and has a wealth of examples already that users can get started with.

But I digress. Acuity Business rules composer has 2 main modules:

1. Dashboard - This module allows generation of domain objects, rules authoring, validation, layout setting, editing bindings and workflow.

2. Runtime - This modules executes the rules using 2 views:

a. Dynamic View: a real-time view where rules are executed and results presented in real-time

b. Wizard view: The wizard view collects the information needed to run the rules and executes them.

Acuity Axon Rules
Here’s an example of an Axon rules file that is created using Acuity:

@take.compilerhint.class=SuggestedQuote
@take.compilerhint.slots=car
@take.compilerhint.method=getSuggestedQuote
query suggestedQuote[in,out]
@take.compilerhint.class=SuggestedQuote
@take.compilerhint.slots=car
@take.compilerhint.method=getQuotePerAdditionalFeature
query quotePerAdditionalFeature[in,out]
@take.compilerhint.class=SuggestedQuote
@take.compilerhint.slots=customer, car
@take.compilerhint.method=getSuggestedDiscount
query getSuggestedDiscount[in,in,out]
aggregation quotedPrice = sum x suggestedQuote[car]

d46e72: if car.name=’Merc’ and car.type=’s-class’ then suggestedQuote[car, “37500”]

d46f55: car.hasABSBrakers then suggestedQuote[car, “7500”]

d48x29: if car.hasSatelliteRadio then suggestedQuote[car, “3500”]

d48e37: if contains[car.optionalFeatures, AdditionalFeaturesList] then

quotePerAdditionalfeature[car, “2000”]

d12r76: if suggestedQuote[car] > 45000 and if suggestedQuote[car] < 60000 then suggestedDiscount[customer, car, “12%”]

d19g22: if suggestedQuote[car] > 60000 and if suggestedQuote[car] < 75000 then suggestedDiscount[customer, car, “20%”]

d33u19: if suggestedQuote[car] > 75000 then suggestedDiscount[customer, car, “35%”]

The above rules illustates several aspects of Acuity’s AXON rules.

1. The rules are plain english rules

2. The user of domain objects like car, customer which are POJOs - Plain Old Java Objects

3. Acuity does rules chaining. The last 3 rules are dependent on the result of the execution of the rules above them.

4. The use of bindings in rules. AdditionalFeaturesList is a list of additional features like

Air Conditioner

Leather Interior

Power Driver Seat

Power Passenger Seat etc

5. The use of aggregations in rules. Aggregations are useful for keeping score. For example, the number of reward points or points system for evaluating premiums etc.

6. Each rule is preceded by a rule id which is its unique identifier. Acuity Business rules composer generates them automatically for you.

7. The rules consists of 2 parts:

a. Rule Header: This is the portion that has @take.compilerhint.slots etc

In this section, we define classes, methods and slots for each method.

Each slot has a direction either IN or OUT.

b. The rules body we saw earlier

The Acuity AXON rules in plain english above are compiled in to java class files in the workflow stage. The class files are then loaded and executed at runtime.

Dynamic Refresh

So what is dynamic refresh and why do we need it. As mentioned earlier, Acuity';;s plain english rules are compiled into Java class files which are then loaded into memory and executed. Those familiar with Java and Java';;s classloading mechanism will immediately tell you there';;s a problem with this. In java, a class once loaded into memory cannot be deleted until the parent classloader that loaded the class is also deleted. This means that once the rules have been compiled into java class files, they cannot be changed any further. Even if you change the rules and regenerate the java class files, the application will continue to run the older version of the Java classes it already has in memory. Only when the server is restarted or the application redeployed, will the new changes take effect.

Acuity Business rules composer is available in 2 editions:

a. SaaS - Software-as-a-Service model where many users create accounts in Acuity and use the software ala facebook

b. Stack - Each user gets their own server stack with bundled Acuity Business rules composer and they can do what they want with it subject to Acuity terms and conditions.

Now let';;s see how to solve this problem and what impact it has on the above 2 deployment scenarios.

a. Reboot the system or Restart the server

May be possible in Stack but definitely not in SaaS

b. Use tomcat manager webapp to redeplo

Again may be possible in Stack but definitely not in SaaS

c. Build your application as a OSGi web bundle

Definitely  possible but futuristic and would involve using non-standard containers like eclipse Virgo instead of the tried and tested Tomcat container.

d. Use a third-part software such as JRebel to redeploy the classes at runtime

Viable and probably the best solution till OSGi becomes mainstream. Let us explore this JRebel option further.

JRebel allows redeploying classes at runtime which is exactly what we want. But JRebel is commercial software and requires a license. They do have a 30-day trial and also a JRebel social license which is free to use for non-commercial purposes. So users of Acuity stack version who wish to have dynamic refresh can opt for a JRebel social license.

The problem with JRebel is it doesn';;t provide versioning. You configure a directory as redeployable and JRebel monitors it for changes and redeploys anything that has changed. So there';;s no way you can version the classes and allow going back to a previous version in case you want to.

Fortunately, the people who make JRebel have a companion software LiveRebel which provides versioning facilities. LiveRebel only works for web applications packaged as war files. So each individual rules project you create in Acuity must be bundled as a war file before it can be versioned and redeployed. LiveRebel integration is in our roadmap for the future and you should see it in a future version of Acuity Business Rules composer in the not so distant future.

The Echo2 framework and Hibernate are the 2 most important as without these 2, there would be no Acuity.  Let us discuss some more about RIA frameworks.

Echo2 is a Rich Internet Appliceation RIA framework for writing web applications. There are numerous other RIA frameworks and a complete list is available at https://sites.google.com/site/javawebframeworksgroup/java-web-framework-list

Only Vaadin is a framework similar to Echo2 and has a richer set of components than Echo2 and commercial support is provided by its creators. However, Echo2 is quite adequate for the time being and there are no plans to migrate unless there is an express need to do so.

Acuity Bean generator

Acuity provides a build-in bean generator that generates Java Bean classes from XML. A sample bean.xml is given below:


The above XML contains 3 beans Product, Address and Customer. The Customer beans refers to the Address bean and hence it is a UDT or user-defined type. Acuity processes the above XML and generates Java source files and compiles the sources into java class files on the fly. It addition it maps the type names provided by the user to their real types before the bean generation. For example, users can enter

string as type for property Name

and Acuity would map it to java.lang.String so the user is not expected to know the Java language syntax.

FileSystem Classloader

Where are these generated files located and how are they available to the application. Before using Acuity, each user should visit the ';;General Settings screen';; and set their filestore directory. It is here that all their generated assets are kept. I say assets because they might include Rules files which are plain text, Image files such as logos, other directories meant for java packages, java source files and java class files. A custom webappclassloader takes care of loading these files from the user';;s filestore directory.

This filesystem classloader does not perform dynamic classloading.

User-Defined Types

So what are user-defined types. Aren';;t all JavaBeans user defined types because they are not available as part of java packages. That might be true. But in Acuity Business Rules composer, Java Beans are the primary building blocks for rules and are called domain objects. The term user-defined type is reserved for the special case when a JavaBean refers to another JavaBean in its property such as when the Customer Bean has a Address property or an Order bean has an array of LineItem beans.

Acuity uses a special terms for these beans because considerable effort has to be made to support such types in rules. The Layout screen which allows users to specify an editor for JavaBean fields has been modified to detech when a property is a user-defined type and handle it differently.

Layout Editors
Similarly, if a binding is a javabean or a user-defined type, the bindings editor has a special type of editor called ';UDTPropertEditor';; to edit such beans. Acuity has over 18 different editors for editing bean fields. These are:

BooleanPropertyEditor
BooleanAsCheckBoxPropertyEditor
StringPropertyEditor
DoublePropertyEditor
FloatPropertyEditor
IntegerPropertyEditor
LongPropertyEditor
ShortPropertyEditor
ColorPropertyEditor
DateChooserDatePropertyEditor
SpinnerPropertyEditor
ComboBoxPropertyEditor
UDTPropertyEditor
DateFieldDatePropertyEditor

Runtime Views

Acuity provides the following runtime views:

a. Dynamic view

In this view, all the queries present in the project are run sequentially and the results presented cumulatively. This runtime screen is highly interactive and for each key or button press in the bean pane, the queries execute and results are presented in the result pane. This way users can see what the effect is on the result by changing a input bean parameter which can be very useful for making decisions. When using user-defined types, running the rules on every key press may not be desirable as the user may want to supply all the data before the rules are run. aFor such cases, they can set the ';;runRulesOnTabOut';; parameter to false in Rules Settings screen, and a run button will appear on the runtime screen. Only when the run button is pressed will the rules be executed.

b. Wizard view:

A wizard first collects all the data for performing an operation and then executes the operation. The Wizard view too does the same. The first screen in the wizard view lists the queries available in the project for user to select. When a query is selected, depending on the number of input params in the query, that many panels are created and presented to the user. When the user has provided data for all the panels, the query executes and results are presented.

For example, if the query is

getAdditionalPremium(car, driver, result) which as 2 input params car, driver,

the wizard view has 4 panels,

1. The Names panel for listing all queries

2. The car panel

3. The driver panel

4. The Result Panel

Result Pane Tabs

The user can present the results of all the queries in the same tab or if they wish create any number of tabs and map queries to each tab to present results of those queries in that tab. The ';;queriesToSameTab';; and ';;queriesToSameField';; are also available.

If the user wants a single tab with a single field containing results for all the queries, they can set ';;QueriesToSameTab';; field.

Or if they wish, they can set all queries to same field only for the tab at position n. For this they set ';;queriesToSameField';; for tab n and all query results for tab n will be presented in a single text area.

If no result pane tabs are configured, Acuity will present all results in a single tab, single field layout.

The result pane tabs are valid only for dynamic view. For wizard view, results for a single query is presented at any time.

Tab Indices

There';;s a a catch when using the dynamic view because it presents only 1 tab for each bean param even if it appears more than once in the query.

For example, lets say there';;s the queries,

getAutoEligibility(car, driver, value)

getAdditionalPremium(policy, car, premium)

In the above queries, car bean appears at position 0 in query 1 and in position 1 in query 2. Even though it appears in different positions in these queries, running them in dynamic view is not a problem as there is only 1 car.

But let';;s say there are 2 cars and the query is

getCarHavingBetterMileage(car1, car2, result)

The ';;showTabIndicesInTabTitles';; parameter is available for this purpose.

In dynamic view without setting showTabIndicesInTabTitles,  will display tabs

car, driver, policy

dynamic view with showTabIndicesInTabTitles set,  will display tabs

car_1, car_2, policy_1, driver_2 and so on.

This way, the correct bean object will be passed to the query when it is executed.

This problem does not arise with the wizard view. The choice of when to use dynamic view and when to use wizard view is something the user has to decide.

Themes and Locales

Acuity has support for themes. The user can select from several themes from the themes menu and the application will switch to that theme. Currently there are over 17 themes and more is being added.

Enchanting_Blue
Glorious_Lifestyle
Pristine_Beauty
Strawberry_Delight
Brushes_Grunge
Architecture
Snow_Forest
ecom_fun
Happy_Home
Crazy_Valentine
Business_Sense
Social_Media_Wave
Elegant_Luxury
Maple_Glory
Infinite_Outer_Space
Lost_TVSeries
Blue_Flowers

Presently, there is only English locale but more will be added in not so distant future.

Social Media Integration

There is social media integration but it is quite light such as allowing users to do a facebook ';;like';;, do a google plus +1 or tweet from inside Acuity Business Rules composer. A tag cloud component is also available if needed.

Conclusion

Acuity Business Rules composer is a versatile software that can create and run declarative business rules of the if-then format. It uses plain english rules and a familiar java bean business model that business users can create rules easily. Acuity allows users to manage their rules inside projects, save their settings and workflow state to persistent storage and retrieve them anytime they want. Acuity is fully secure and stores passwords in encrypted format and only permits authorized users to access the application. Acuity also has role based access control and based on the user';;s role, they are allowed either full or read-only access to whole or parts of the application. Acuity has dynamic and wizard runtime views for executing rules. Acuity has a built-in bean generator, beans layout editor and a bindings editor. Acuity also has support for user-defned types in beans, rules and bindings. Acuity has an Advanced rules editor with screens or panels to edit rules header, aggregations, rules class details and rules body. The summary tab presently summary view of the whole rules file the user has created. Acuity provides many enterprise grade features like Usage metering, scheduler, caching, message queues, hibernate orm, logging, cloud integration etc. Acuity Business Rules composer is from Concentricsys.com, a delaware based llc with offices in USA and India.