Overview: --------- The ComputerSystem sample demonstrates a more realistic example of how JavaSPL can be used to write system management policies for a WinXP system. It also shows how custom expressions can be added. The org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsComputerSystem.java class encapsulates all the relevant information about the system that is required to make a policy based decision. The org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsSystemManager.java is the driver class that embeds the JavaSPL processor. Custom Expressions: ------------------- We define a new action operator called SendMail that sends out an email using javax.mail APIs. The custom operator is defined in org/apache/imperius/samples/userdefinedmethods/SendMail.java The customexpressions.properties has an entry that tells the SPL processor that it needs to add SendMail to its list of available operators. If SendMail is packaged as a seperate jar then it needs to be on the classpath for the SPL processor to load it at runtime. Policies: --------- 1. Java_compliance: This policy checks for the JDK and WinXP versions for compliance. In case of a violation it sends out an email. 2. Java_FileSystem: This policy checks for the amount of free space on the file system. If it falls below a specified threshold then it kicks off the windows cleanup mgr and sends out an email. Prerequisites: -------------- 1. ANTLR 2.7.7 : Can be downloaded from http://www.antlr2.org. Make sure to set the ANTLR_HOME environment variable 2. Java mail API: Can be downloaded from http://www.javaworld.com/jw-10-2001/jw-1026-javamail.html 3. JavaBeans activation framework: Can be downloaded from http://java.sun.com/products/javabeans/jaf/downloads/index.html 4. Java 142: The java executable must be on the path. 5. Ensure that an JAVA_MAIL_HOME is set to the folder where the mail.jar and activation.jar are downloaded. Configuring the Windows Cleanup manager: --------------------------------------- We setup different profiles for the Windows cleanup manager that will get invoked during policy execution depending on amount of free space remaining. 1. Open a command prompt and run - cleanmgr /sageset:256 From the dialog box that pops up select Recycle Bin and deselect others. Close the window - cleanmgr /sageset:64 and choose Temporary Internet files only. Close the window -cleanmgr /sageset:32 and choose Temporary setup files only Running the samples: -------------------- For the compliance sample execute the runcompliance.bat For the free space on filesystem sample execute runfilesystemdemo.bat