Java/JSP/Servlet Interface
Professional Edition


Installation

The Java interface can be used to build both web-based and stand-alone applications. It consists of 9 files. The first 5 files are in the arulesxl\api\bin_redist directory. The last 4 files are in the arulesxl\api\java directory.

To use the Java interface you need to:

  1. Import amzi.arulesxl.ARulesXL into your application source code.
  2. Add the ...api\java directory to your CLASSPATH (this varies by Java IDE).
  3. Put arulesrt.dll, ar_mysqlrt.lsx, ar_osutilsrt.lsx and arulesjni.dll in a directory where Java can find them (usually on your system PATH).
  4. Put arulesrt.xpl and arulesrt.cfg in your application directory.

API Additions & Changes

Java method names start with a lowercase letter.

QueryRulesToStringList

Description:

Vector queryRulesToStringList(String ruleset, String query) throws Exception

ruleset
The name of the ruleset
query
The query to run in the same format as is used for RQuery()

Remarks:

Queries the named ruleset and returns the result as a Vector where each element in the vector is an array of Strings.

Return Value:

The result of the query as a Java Vector where each element is a Java String[].

Throws an exception on failure.

Example:

Using the Amzi! Logic Server

The method GetLS() returns a LogicServer object that you can use with any of the Logic Server methods as documented in the Amzi! Logic Server Reference Guide.

Advice Samples

There are two samples that use the 'Product Advice.xls' sample. One is a standalone Java application. The other is a Java servlet. They have the same inputs and outputs.

Java Application

Building the Sample

First install the Java interface as outlined above. Then:

  1. Open the 'Product Advice.xls' spreadsheet sample and select ARulesXL | Export from the main menu to export a file named 'advice.axl'.
  2. Copy advice.axl, arulesrt.xpl and arulesrt.cfg to the sample subdirectory.
  3. Edit 'Advice.java' and change the value of SAMPLE_DIR to correspond to your system. To compile:
javac Advice.java

Running the Sample

To run the sample:

java Advice

Enter a value for swing speed, optionally select other choices from the pull-down menus and press 'Go'.

Java Servlet

Building the Sample

First install the Java interface as outlined above. You must configure your server (e.g. Tomcat) so it can find the amzi.* classes at runtime. Then edit 'AdviceServlet.java' and change the value of ARULES_DIR and FORM_URL to correspond to your system. Put advice.axl and the rest of the install files in ARULES_DIR. To compile:

javac AdviceServlet.java  

Running the Sample

A sample web.xml file is provided in the WEB-INF directory. Running the servlet depends on your environment, but in general, a URL of this form is used (assuming the servlet is installed in a directory named 'advice':

http://localhost:8080/advice/AdviceServlet 

Enter a value for swing speed, optionally select other choices from the pull-down menus and press 'Go'.

 


Copyright ©2005-7 Amzi! inc. All Rights Reserved.
ARulesXL and Amzi! are trademarks or registered trademarks of Amzi!
Microsoft and Excel are trademarks or registered trademarks of Microsoft Corporation.