incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r606479 [2/30] - in /incubator/imperius/trunk/trunk: ./ modules/ modules/imperius-javaspl/ modules/imperius-javaspl/resources/ modules/imperius-javaspl/resources/samples/ modules/imperius-javaspl/resources/samples/computersystem/ modules/im...
Date Sat, 22 Dec 2007 19:34:03 GMT
Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/ComplexPolicy.spl
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/ComplexPolicy.spl?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/ComplexPolicy.spl (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/ComplexPolicy.spl Sat Dec 22 11:33:46 2007
@@ -0,0 +1,113 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Demonstrates a large variety of built in operators that ship with SPL 
+
+Import Class org.apache.imperius.javaspl.samples.simplepolicies.TestElement:te;
+Strategy Execute_All_Applicable;
+Policy 
+{
+    Declaration
+    {
+        integervar = 4000;
+        stringtxt1 = "neeraj";
+        stringtxt2 = "joshi";
+  
+    }
+    Condition  // Arithmetic operators
+    {  
+        Power(200,2) + Abs(Ln(5) - Floor(2.4)) - Ceiling(7.1 + Ln(8)) - Max(2,5,10) - Min(4,2,9)* Round(4.2) == 4 
+    }   
+    Decision 
+    {   
+        Set(te.s32 = 30) 
+    }
+}:1;
+
+Policy 
+{
+
+    Declaration
+    {
+        somestr = "-520";
+    }
+    Condition // String operators
+    {  
+       Contains(SubString(Concatenate("abc","def"),3),"ef") 
+       || LeftSubString(RightSubString("neerajramchandrajoshi",6,"LeftToRight"),3,"LeftToRight") == "ram" 
+       || Contains(MiddleSubString("neerajramchandrajoshi",7,10,"LeftToRight"),"ram") 
+                       
+    }
+    Decision 
+    {   
+       
+        Set(te.s = somestr) == 0
+
+    }
+}:4;
+Policy
+{
+    Declaration
+    {
+        oddarray = [1,3,5,7];
+        evenarray = [2,4,6,8];
+        allarray = [1,2,3,4,5,6,7,8];
+        
+    
+    }
+    Condition // Collection operators
+    {
+        EqCollection(Union(oddarray,evenarray),allarray) 
+        && SubCollection(oddarray,allarray) 
+        && AllInCollection(Sum(evenarray),"LESS",allarray) 
+        && (CollectionSize(oddarray) == 4) && AnyInCollection(3, "GREATER",evenarray) 
+        && (Sum(ApplyToCollection(4, "PLUS", allarray)) >= 32)
+
+    } 
+    Decision
+    {
+        Set(te.s = "x") == 0
+
+
+    }
+
+}:3;
+Policy
+{
+    Declaration
+    {
+        todaysdate = "20070615164020.000000-300";
+        tomorrowsdate = "20070616164020.000000-300";
+        yesterdaysdate = "20070614164020.000000-300";
+      
+    }
+    Condition // Date time operators
+    {
+        GetDayOfMonth(todaysdate) == GetDayOfMonth(tomorrowsdate) - 1 
+        && GetDayOfWeek(todaysdate) == 6 
+        && GetDayOfWeekInMonth(todaysdate) == 3
+        && GetHour24(todaysdate) == 16
+        && GetMonth(todaysdate) == 5
+        
+
+    } 
+    Decision
+    {
+        Set(te.s = "x") == 0
+
+
+    }
+
+}:6;
+        
+

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/DateTime.spl
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/DateTime.spl?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/DateTime.spl (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/DateTime.spl Sat Dec 22 11:33:46 2007
@@ -0,0 +1,43 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Demonstrates various DateTime operators
+Import Class org.apache.imperius.javaspl.samples.simplepolicies.TestElement:te;
+Strategy Execute_All_Applicable;
+Policy
+{
+    Declaration
+    {
+        todaysdate = "20071013143920.000000-300";
+        tomorrowsdate = "20071014143920.000000-300";
+        yesterdaysdate = "20071012143920.000000-300";
+      
+    }
+    Condition
+    {
+        GetDayOfMonth(todaysdate) == GetDayOfMonth(tomorrowsdate) - 1 
+        && GetDayOfWeek(todaysdate) == 3 
+        && GetDayOfWeekInMonth(todaysdate) == 2
+        && GetHour24(todaysdate) == 14
+        && GetMonth(todaysdate) == 10
+        
+
+    } 
+    Decision
+    {
+        Set(te.s = "x") == 0
+
+
+    }
+
+}:6;
\ No newline at end of file

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/InvokeMethodSample.spl
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/InvokeMethodSample.spl?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/InvokeMethodSample.spl (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/InvokeMethodSample.spl Sat Dec 22 11:33:46 2007
@@ -0,0 +1,33 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Demonstrates how to invoke a method on the anchor instance
+Import Class org.apache.imperius.javaspl.samples.simplepolicies.TestElement:te;
+Strategy Execute_All_Applicable;
+
+Policy
+{
+        Declaration
+        {
+            excpectedReturnValue = 10;
+        
+        }
+        Condition
+        {
+            true
+        }
+        Decision
+        { 
+            te.testMethod(1,2) <= 4
+        }
+}:1;
\ No newline at end of file

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MacroSample.spl
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MacroSample.spl?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MacroSample.spl (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MacroSample.spl Sat Dec 22 11:33:46 2007
@@ -0,0 +1,62 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+/* Demonstrates use of Macro statement */
+/* Anchor class declaration */
+Import Class org.apache.imperius.javaspl.samples.simplepolicies.TestElement:te;
+Strategy Execute_All_Applicable;  /* Execute all policies */
+Declaration     /* Global Declaration */
+{
+     Macro   /* macro that calculates avrg of 2 nos */
+     {
+             Name = GetAverage; /* Name of the macro */
+             type = Real64; /* Return type */
+             argument = number1:Sint64,number2:Sint64; /* Input parameters and types */
+             procedure = (number1 + number2) / 2 /* Actual code */
+     }
+}
+Policy 
+{
+        Declaration
+        {      /* constants used in t condition */
+                NoToAvrg1 = 8;
+                NoToAvrg2 = 2;
+                TwentyFive = 25;
+        }
+        Condition 
+        {  
+
+                SquareRoot(TwentyFive) == GetAverage(NoToAvrg1,NoToAvrg2) && AnyInCollection(5,"GREATER",[6,7,8])
+        }
+        Decision 
+        {       /* set testElement.s32 to 3 */
+                Set(te.s32 = 4) 
+        }
+        
+}:1;  /* Priority of the policy */
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MultiplePolicySample.spl
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MultiplePolicySample.spl?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MultiplePolicySample.spl (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/MultiplePolicySample.spl Sat Dec 22 11:33:46 2007
@@ -0,0 +1,90 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// Demonstrates how to define multiple sub policies
+
+/* Anchor class declaration */
+Import  Class org.apache.imperius.javaspl.samples.simplepolicies.TestElement:te;
+Strategy Execute_All_Applicable;  /* Execute all policies */
+Declaration     /* Global Declaration */
+{
+     Macro   /* macro that calculates avrg of 2 nos */
+     {
+             Name = GetAverage;
+             type = Real64;
+             argument = number1:Uint64,number2:Uint64;
+             procedure = (number1 + number2) / 2
+     }
+}
+Policy // Policy 1 
+{
+        Declaration
+        {      /* constants used in t condition */
+                NoToAvrg1 = 8;
+                NoToAvrg2 = 2;
+                TwentyFive = 25;
+        }
+        Condition 
+        {  
+
+                SquareRoot(TwentyFive) == GetAverage(NoToAvrg1,NoToAvrg2)
+        }
+        Decision 
+        {       /* set testElement.s32 to 3 */
+                Set(te.s32 = 3) 
+        }
+        
+}:2;  /* Priority of the policy */
+Policy // Policy 2
+{
+        Declaration
+        {      /* even and odd array constants */
+                evenArray = [0,2,4,6,8];
+                oddArray = [1,3,5,7,9];
+                sumOfnumbersTill9 = 45; 
+                
+                Macro  /* macro to add all elements of passed array */
+                {
+                        Name = Add2Arrays;
+                        type = Uint32;
+                        argument = array1:Uint32[],array2:Uint32[];
+                        procedure =  sum(array1) + sum(array2)
+                
+                }
+        }
+        Condition
+        {
+                Add2Arrays(evenArray,oddArray) == sumOfnumbersTill9
+        
+
+        }
+        Decision 
+        {       /* set testElement.s32 to 3 */
+                Set(te.s32 = 3) 
+        }
+
+}:1;
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/SimplePolicy.spl
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/SimplePolicy.spl?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/SimplePolicy.spl (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/policies/SimplePolicy.spl Sat Dec 22 11:33:46 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+// 
+Import  Class org.apache.imperius.javaspl.samples.simplepolicies.TestElement:te;
+Strategy Execute_All_Applicable;
+Policy 
+{
+Declaration
+{
+    four = 4;
+}
+Condition 
+{  
+
+     SquareRoot(16) == four
+}
+Decision 
+{   
+Set(te.s32 = 3) 
+}
+}:1;
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/readme.txt
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/readme.txt?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/readme.txt (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/readme.txt Sat Dec 22 11:33:46 2007
@@ -0,0 +1,77 @@
+Overview:
+---------
+The Imperius binding for Java (JavaSPL) processor currently operates in 
+an embedded mode only. Which means you need to write the wrapper code 
+that interacts with the processor.
+JavaSPL ships with a sample wrapper under 
+org/apache/imperius/samples/simplepolicies/RunSamples.java 
+
+The runsamples script simple invokes this wrapper.
+
+The /policies folder contains some simple JavaSPL policies that showcase
+the various features of the language.
+
+
+Prerequisites:
+--------------
+1. ANTLR 2.7.7 : Can be downloaded from http://www.antlr2.org. Make sure to set 
+		 the ANTLR_HOME environment variable
+2. JDK 142 : The java executable must be on the PATH
+
+Running the Samples:
+--------------------
+
+Open a command prompt and execute the runsamples script
+
+This script will execute all the policies one by one. It will first try to delete
+the policy, then create it and finally run it.
+Note: If the policy does not exist an exception will be thrown ignore the exception
+
+To run a single policy invoke the script as follows:
+
+runsamples <policyname>
+
+
+The Policies:
+--------------
+
+1. Basic Policy: 
+
+A simple policy that demonstrates:
+
+-Importing multiple classes with multiple instances.
+-Invoking methods of imported instances
+-Returning values as part of decision
+
+2. MacroSample:
+
+-Demonstrates how to define and use a Macro within a policy
+
+3. MultiplePolicySample:
+
+-Demonstrates how to define multiple sub-policies
+
+4. ComplexPolicy:
+
+-Demonstrates the use of several built-in operators including
+String, Numeric, DateTime and Collection
+
+5. DateTime
+
+-Demonstrates several datetime operators
+
+6. InvokeMethodSample
+
+-Demonstrates how to invoke a method on the imported instance
+as part of the decision
+
+7. SimplePolicy
+
+-A very simple poliy
+
+
+
+
+
+
+

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.bat
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.bat?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.bat (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.bat Sat Dec 22 11:33:46 2007
@@ -0,0 +1,4 @@
+
+echo "Running Test policies..."
+set CLASSPATH=%CLASSPATH%;%ANTLR_HOME%/lib/antlr.jar;../../lib/imperius-javaspl-1.0.0.jar;../../lib/imperius-splcore-1.0.0.jar
+java org.apache.imperius.javaspl.samples.simplepolicies.RunSamples %1

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.sh
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.sh?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.sh (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/resources/samples/simple/runsamples.sh Sat Dec 22 11:33:46 2007
@@ -0,0 +1,2 @@
+#!/bin/sh
+java -classpath $ANTLR_HOME/antlr.jar:../../lib/imperius-javaspl-1.0.0.jar:../../lib/imperius-splcore-1.0.0.jar org.apache.imperius.javaspl.samples.simplepolicies.RunSamples

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaActuatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaActuatorImpl.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaActuatorImpl.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaActuatorImpl.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,207 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jneeraj@us.ibm.com>
+ * 
+ * This class implements the Actuator interface for the JAVA binding
+ * of SPL
+ *
+ */
+
+package org.apache.imperius.javaspl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Iterator;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.apache.imperius.spl.external.Actuator;
+import org.apache.imperius.spl.external.Argument;
+import org.apache.imperius.spl.parser.exceptions.*;
+import org.apache.imperius.spl.parser.util.*;
+
+
+public class JavaActuatorImpl implements Actuator {
+
+	//private static final String sourceClass="JavaActuatorImpl";
+	//private static Logger logger = SPLLogger.getCIMSPLLogger().getLogger();
+
+	private URL[] fUrls = null;
+	
+	public JavaActuatorImpl() {
+		
+	}
+	
+	public JavaActuatorImpl(URL[] urls) {
+		fUrls = urls;
+	}
+	
+	
+	/**
+	 * Invokes the given method on the given instance 
+	 */
+	public Object invokeMethod(String className, String qualifier,
+			Object instance, String methodName, List arguments)	throws SPLException {
+		Class c;
+		Object result = null;
+		try {
+			// Load class
+			
+			//c = Class.forName(instance.getClass().getName());
+			
+			// modified by naidu to enable URL class loading
+			if(fUrls == null) {
+				c = Class.forName(instance.getClass().getName());
+			} else {
+				URLClassLoader uc = new URLClassLoader(fUrls);
+				c = uc.loadClass(instance.getClass().getName());
+			}
+			
+
+			// Get an array of formal parameter class types
+			Class[] arrayOfParameterTypes = _getParameterTypeArray(arguments);
+
+			// Load the method using reflection
+			Method method = c.getMethod(methodName, arrayOfParameterTypes);
+
+			// If No. of formal params > 0
+			if (arguments.size() != 0) {
+				List paramValues = new ArrayList();
+				Iterator it = arguments.iterator();
+				// Iterate over the passed parameters
+				while (it.hasNext()) {
+					Argument arg = (Argument) it.next();
+					//Add the values of the passed parameters to a list
+					paramValues.add(arg.getValue());
+				}
+
+				// Convert list to an array
+				Object[] arrayOfParameters = paramValues.toArray();
+
+				// Invoke the method on the passed object
+				result = method.invoke(instance, arrayOfParameters);
+			} else {
+				Object[] arrayOfParameters = new Object[0];
+				result = method.invoke(instance, arrayOfParameters);
+			}
+		} catch (ClassNotFoundException e) {
+			throw new SPLException(e.getMessage());
+		} catch (SecurityException e) {
+			throw new SPLException(e.getMessage());
+		} catch (NoSuchMethodException e) {
+			throw new SPLException(e.getMessage());
+		} catch (IllegalArgumentException e) {
+			throw new SPLException(e.getMessage());
+		} catch (IllegalAccessException e) {
+			throw new SPLException(e.getMessage());
+		} catch (InvocationTargetException e) {
+			throw new SPLException(e.getMessage());
+		}
+		return result;
+	}
+
+	/**
+	 * @param className : fully qualified name of the class whoose instance is to be modified
+	 * @param instance : instance to be modified
+	 * @param memberMap: A map of the form (String member Name ->  Object value to be set to)
+	 * 
+	 */
+
+	public void modifyInstance(String className, String qualifier,
+			Object instance, Map memberMap) throws SPLException {
+		Class c;
+		try {
+			// Load class
+			//c = Class.forName(className);
+			
+			// modified by naidu to enable URL class loading
+			if(fUrls == null) {
+				c = Class.forName(className);
+			} else {
+				URLClassLoader uc = new URLClassLoader(fUrls);
+				c = uc.loadClass(className);
+			}
+
+			// Iterate over the property map for the instance
+			Iterator keyIt = memberMap.keySet().iterator();
+			while (keyIt.hasNext()) {
+				String propName = (String) keyIt.next();
+				// Retrieve value of the property
+				Object value = memberMap.get(propName);
+
+				// Load field
+				Field member = c.getField(propName);
+
+				// Set the value of the field
+				member.set(instance, value);
+
+			}
+		} catch (ClassNotFoundException e) {
+			throw new SPLException(e.getMessage());
+
+		} catch (SecurityException e) {
+			throw new SPLException(e.getMessage());
+		} catch (NoSuchFieldException e) {
+			throw new SPLException(e.getMessage());
+		} catch (IllegalArgumentException e) {
+			throw new SPLException(e.getMessage());
+		} catch (IllegalAccessException e) {
+			throw new SPLException(e.getMessage());
+		}
+
+	}
+
+	/**
+	 * Iterate over the list of Argument objects to retrieve an
+	 * array of the class types
+	 * @param inParameterList
+	 * @return
+	 * @throws SPLException 
+	 */
+
+	private Class[] _getParameterTypeArray(List inParameterList)
+			throws SPLException {
+		int listSize = inParameterList.size();
+		int i = 0;
+		Class[] paramTypeArray = new Class[listSize];
+		try {
+			Iterator it = inParameterList.iterator();
+			// Iterate over the arguments
+			while (it.hasNext()) {
+				Argument arg = (Argument) it.next();
+				TypeInfo tp = arg.getType();
+				boolean isArray = arg.getIsArray();
+				String referenceName = arg.getReferenceTypeName();
+
+				// convert internal type to java type
+				Class c = JavaSPLTypeConstants.convertInternalTypeToJavaType(tp.getType(), isArray, referenceName);
+
+				// Add to array
+				paramTypeArray[i++] = c;
+			}
+		} catch (ClassNotFoundException e) {
+			e.printStackTrace();
+			throw new SPLException(e.getMessage());
+		}
+		return paramTypeArray;
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaDataCollectorImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaDataCollectorImpl.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaDataCollectorImpl.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaDataCollectorImpl.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,287 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jneeraj@us.ibm.com>
+ *
+ */
+
+package org.apache.imperius.javaspl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.spl.external.Argument;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.compiler.symboltable.MethodSymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.PropertySymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.ArgumentImpl;
+
+
+
+public class JavaDataCollectorImpl implements DataCollector {
+	
+	private URL[] fUrls = null;
+	
+	public JavaDataCollectorImpl() {
+		
+	}
+	
+	public JavaDataCollectorImpl(URL[] urls) {
+		fUrls = urls;
+	}
+	
+	/**
+	 * Use reflection to retrieve properties of the given class and load them into
+	 * the symbol map
+	 * @param className
+	 * @param symbolMap
+	 * @throws SPLException
+	 */
+	private void _populateClassMembers(String className, Map symbolMap)
+			throws SPLException {
+		Class c;
+
+		try {
+			// Load class
+			if(fUrls == null) {
+				c = Class.forName(className);
+			} else {
+				URLClassLoader uc = new URLClassLoader(fUrls);
+				c = uc.loadClass(className);
+			}
+
+			// Iterate over it's fields
+			Field[] fields = c.getFields();
+			for (int i = 0; i < fields.length; i++) {
+				Field f = fields[i];
+
+				String fieldName = f.getName();
+				String javaType = f.getType().toString();
+
+				// Retrieve the SPL type constant corresponding to the java type
+				int internalType = JavaSPLTypeConstants.convertJavaTypeToInternalType(javaType);
+
+				// check if its an array
+				boolean isArray = JavaSPLTypeConstants.getIsArray(javaType);
+
+				// if type is reference get the class name
+				String referenceTypeName = "";
+				if (internalType == TypeConstants.referenceType) {
+					referenceTypeName = JavaSPLTypeConstants.getReferenceTypeName(javaType);
+				}
+				boolean isPropertyOfClass = true;
+				boolean isKey = false;
+
+				// create a new property symbol object
+				Symbol s = new PropertySymbol(f.getName(), internalType,
+						referenceTypeName, isArray, isKey, isPropertyOfClass);
+
+				// insert into map
+				symbolMap.put(fieldName, s);
+
+			}
+		} catch (Exception e) {
+
+			e.printStackTrace();
+			throw new SPLException(e.getMessage());
+		}
+
+	}
+
+	/**
+	 * Use reflection to retrieve the public methods supported by the given class
+	 * and populate into the given Map
+	 * @param className
+	 * @param symbolMap
+	 * @throws SPLException
+	 */
+	private void _populateClassMethods(String className, Map symbolMap)
+			throws SPLException {
+		Class c;
+		try {
+			// Load Class
+			if(fUrls == null) {
+				c = Class.forName(className);
+			} else {
+				URLClassLoader uc = new URLClassLoader(fUrls);
+				c = uc.loadClass(className);
+			}
+
+			// Iterate over the methods
+			Method[] methods = c.getMethods();
+
+			for (int j = 0; j < methods.length; j++) {
+				Method m = methods[j];
+				String methodName = m.getName();
+				String returnType = m.getReturnType().getName();
+
+				// Retrieve the SPL type constant corresponding to the java method return type
+				int internalReturnType = JavaSPLTypeConstants.convertJavaTypeToInternalType(returnType);
+
+				// In case of type reference retrieve the class name
+				String returnReferenceTypeName = "";
+				if (internalReturnType == TypeConstants.referenceType) {
+					returnReferenceTypeName = JavaSPLTypeConstants.getReferenceTypeName(returnType);
+				}
+
+				// Check if returning an array
+				boolean isReturnArray = JavaSPLTypeConstants.getIsArray(returnType);
+
+				// Get the list of formal parameters to the method
+				Class[] paramTypes = m.getParameterTypes();
+				List argTypeList = new ArrayList();
+
+				// Iterate over the formal parameters
+				for (int k = 0; k < paramTypes.length; k++) {
+					Class p = paramTypes[k];
+					String javaType = p.getName();
+
+					// Get the SPL type constant for the java type of the paramter 
+					int internalType = JavaSPLTypeConstants.convertJavaTypeToInternalType(javaType);
+
+					// Get the class name in case of Reference type
+					String referenceTypeName = "";
+					if (internalType == TypeConstants.referenceType) {
+						referenceTypeName = JavaSPLTypeConstants
+								.getReferenceTypeName(javaType);
+					}
+
+					// check if array
+					boolean isArray = JavaSPLTypeConstants.getIsArray(javaType);
+
+					// Construct an argument object
+					Argument param;
+					String paramName = "";
+					try {
+						param = new ArgumentImpl(internalType, paramName, isArray, referenceTypeName);
+						argTypeList.add(param);
+					} catch (SPLException e) {
+						e.printStackTrace();
+						throw new SPLException(e.getMessage());
+					}
+				}
+
+				// construct a method symbol 
+				Symbol s = new MethodSymbol(methodName, internalReturnType, isReturnArray, returnReferenceTypeName, argTypeList, null);
+
+				// Insert into map
+				symbolMap.put(methodName, s);
+			}
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw new SPLException(e.getMessage());
+		}
+
+	}
+
+	public Map getSymbolsForClass(String className, String qualifier) throws SPLException {
+		String formattedClass = null;
+		if (className.startsWith("\"")) // string of form ""lkasdlk""
+		{
+			formattedClass = className.substring(1, className.length() - 1);
+		} else {
+			formattedClass = className;
+		}
+
+		Map symbolMap = new Hashtable();
+		_populateClassMembers(formattedClass, symbolMap);
+		_populateClassMethods(formattedClass, symbolMap);
+
+		return symbolMap;
+
+	}
+
+	/**
+	 * Get symbols for the given instance
+	 */
+
+	public Map getSymbolsForInstance(String className, String qualifier, Object instance) throws SPLException {
+		Map instanceMemberValues = new Hashtable();
+
+		Class c;
+		try {
+			// Load the class
+			if(fUrls == null) {
+				c = Class.forName(className);
+			} else {
+				URLClassLoader uc = new URLClassLoader(fUrls);
+				c = uc.loadClass(className);
+			}
+			
+			Field[] fields = c.getFields();
+
+			// Iterate over the fields
+			for (int i = 0; i < fields.length; i++) {
+				Field f = fields[i];
+
+				// Get the instance value of the current field
+				Object value = f.get(instance);
+				String fieldName = f.getName();
+
+				// Insert into map
+				instanceMemberValues.put(fieldName, value);
+			}
+		} catch (ClassNotFoundException e) {
+			e.printStackTrace();
+			throw new SPLException(e.getMessage());
+
+		} catch (IllegalArgumentException e) {
+			e.printStackTrace();
+			throw new SPLException(e.getMessage());
+		} catch (IllegalAccessException e) {
+			e.printStackTrace();
+			throw new SPLException(e.getMessage());
+		}
+		return instanceMemberValues;
+
+	}
+
+	/**
+	 * Not applicable for java spl
+	 */
+	public boolean associationExists(String nameSpace, String className,
+			String resultClass, String assocClass, String role, String resultRole) throws SPLException {
+		throw new SPLException("associationExists not supported in JAVA-SPL");
+	}
+
+	public List getAssociatedInstanceReferences(Object srcReference,
+			String classPath, String resultInstancesClassFilter,
+			String assocClass, String role, String resultRole) throws SPLException {
+		
+		throw new SPLException("getAssociatedInstanceReferences not supported in JAVA-SPL");
+	}
+
+	public List enumerateInstanceNames(String className, String qualifier) throws SPLException {
+		throw new SPLException("enumerateInstanceNames not supported in JAVA-SPL");
+
+	}
+
+	public String getReferenceTypeName(String reference) {
+		String refTypeNm = JavaSPLTypeConstants.getReferenceTypeName(reference);
+		return refTypeNm;
+	}
+
+}
\ No newline at end of file

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaSPLTypeConstants.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaSPLTypeConstants.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaSPLTypeConstants.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/JavaSPLTypeConstants.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,323 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Neeraj Joshi <jneeraj@us.ibm.com>
+ *
+ *  This class provides methods to map java types to SPL types and vice
+ *  versa
+ */
+package org.apache.imperius.javaspl;
+
+
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.*;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class JavaSPLTypeConstants
+{
+
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+    private static final String sourceClass="JavaSPLTypeConstants";
+    
+    public static boolean getIsArray(String type)
+    {
+    	if(type.startsWith("["))
+    	{
+    		return true;
+    	}
+    	return false;
+    	
+    }
+    public static Class convertInternalTypeToJavaType(int type, boolean isArray, 
+    		String referenceName) throws ClassNotFoundException
+    {
+    	Class javaType = null;
+    	if(type == TypeConstants.byteType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[B");
+    		}
+    		else
+    		{
+    			
+    			javaType = Byte.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.shortType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[S");
+    		}
+    		else
+    		{
+    			javaType = Short.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.intType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[I");
+    		}
+    		else
+    		{
+    			javaType = Integer.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.longType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[J");
+    		}
+    		else
+    		{
+    			javaType = Long.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.floatType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[F");
+    		}
+    		else
+    		{
+    			javaType = Float.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.doubleType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[D");
+    		}
+    		else
+    		{
+    			javaType = Double.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.booleanType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[Z");
+    		}
+    		else
+    		{
+    			javaType = Boolean.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.charType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[C");
+    		}
+    		else
+    		{
+    			javaType = Character.TYPE;
+    		}
+    	}
+    	else if(type == TypeConstants.stringType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[Ljava.lang.String;");
+    		}
+    		else
+    		{
+    			javaType = Class.forName("java.lang.String");
+    		}
+    	}
+    	else if(type == TypeConstants.dateTime)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[Ljava.util.Calendar;");
+    		}
+    		else
+    		{
+    			javaType = Class.forName("Ljava.util.Calendar");
+    		}
+    	}
+    	else if(type == TypeConstants.referenceType)
+    	{
+    		if(isArray)
+    		{
+    			javaType = Class.forName("[L" + referenceName + ";");
+    		}
+    		else
+    		{
+    			javaType = Class.forName(referenceName);
+    		}
+    	}
+    	return javaType;
+    	
+    		
+    	
+    }
+    
+    public static int convertJavaTypeToInternalType(String type)
+    {
+               
+        
+        int retTp = TypeConstants.INVALID;
+        
+        if (type.equals("byte") || type.equals("[B"))
+        {
+            retTp = TypeConstants.byteType;
+        }
+        else if (type.equals("short") || type.equals("[S"))
+        {
+            retTp = TypeConstants.shortType;
+        }
+        else if (type.equals("int") || type.equals("[I"))
+        {
+            retTp = TypeConstants.intType;
+        }
+        else if (type.equals("long") || type.equals("[J"))
+        {
+            retTp = TypeConstants.longType;
+        }
+        else if (type.equals("float") || type.equals("[F"))
+        {
+            retTp = TypeConstants.floatType;
+        }
+        else if (type.equals("double") || type.equals("[D"))
+        {
+            retTp = TypeConstants.doubleType;
+        }
+        else if (type.equals("boolean") || type.equals("[Z"))
+        {
+            retTp = TypeConstants.booleanType;
+        }
+        else if (type.equals("char") || type.equals("[C"))
+        {
+            retTp = TypeConstants.charType;
+        }
+        else if (type.equals("java.lang.String") 
+        		|| type.equals("[Ljava.lang.String;")
+        		|| type.equals("class java.lang.String"))
+        {
+            retTp = TypeConstants.stringType;
+        }
+        else if (type.equals("java.util.Calendar") || type.equals("[Ljava.util.Calendar;"))
+       	{
+        	retTp = TypeConstants.dateTime;
+       	}
+        else 
+        {
+            retTp = TypeConstants.referenceType;
+            
+        }
+        return retTp;
+        
+    }
+    
+    
+    
+    public static int getTypeOfObject(Object ob) throws TypeMismatchException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getTypeOfObject");
+        
+        int currentLocaltype = -1;
+        if (ob instanceof java.lang.Boolean)
+        {	
+            currentLocaltype = TypeConstants.booleanType;
+        }    
+        else if (ob instanceof java.lang.String)
+        {	
+            currentLocaltype = TypeConstants.stringType;
+        }    
+        else if (ob instanceof java.util.Calendar || ob instanceof java.util.Date)
+        {	
+            currentLocaltype = TypeConstants.dateTime;
+        }    
+        else if (ob instanceof java.lang.Byte)
+        {	
+            currentLocaltype = TypeConstants.byteType;
+        }    
+        else if (ob instanceof java.lang.Character)
+        {	
+            currentLocaltype = TypeConstants.charType;
+        }    
+        else if (ob instanceof java.lang.Short)
+        {	
+            currentLocaltype = TypeConstants.shortType;
+        }    
+        else if (ob instanceof java.lang.Integer)
+        {	
+            currentLocaltype = TypeConstants.intType;
+        }    
+        else if (ob instanceof java.lang.Long)
+        {	
+            currentLocaltype = TypeConstants.longType;
+        }    
+        else if (ob instanceof java.lang.Float)
+        {	
+            currentLocaltype = TypeConstants.floatType;
+        }    
+        else if (ob instanceof java.lang.Double)
+        {	
+            currentLocaltype = TypeConstants.doubleType;
+        }    
+        else 
+        {	
+            currentLocaltype = TypeConstants.referenceType;
+        }    
+       
+           
+        return currentLocaltype;
+    }
+	public static String getReferenceTypeName(String javaType) 
+	{
+		
+		//extract class name and return
+		String referenceType = null;
+		if(convertJavaTypeToInternalType(javaType) == TypeConstants.referenceType)
+		{	
+			if(javaType.startsWith("["))
+			{
+				referenceType = javaType.substring(1);
+			
+			}
+			else
+			{
+				if(javaType.startsWith("class ")) // of type class com.ibm.xxx
+				{
+					int ind = javaType.indexOf(' ');
+					referenceType = javaType.substring(ind + 1);
+				}
+				else
+				{
+					referenceType = javaType;
+				}	
+			}
+		}
+		else
+		{
+			System.out.println("Only reference types have referenceType names" + javaType);
+		}
+		return referenceType;
+	}
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/Java_SPLPolicyRuleProvider.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,146 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.javaspl;
+
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.spl.external.Actuator;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.manager.PolicyManager;
+import org.apache.imperius.spl.manager.impl.PolicyManagerImpl;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+
+
+
+
+public class Java_SPLPolicyRuleProvider 
+{
+
+	
+	private PolicyManager _policyManager= null;
+	
+	
+	public Java_SPLPolicyRuleProvider() throws SPLException
+	{
+		initialize();
+		
+	}
+	
+	public void cleanup() throws SPLException {
+		
+        
+		
+	}
+
+	public void initialize() throws SPLException
+	{
+	 
+		
+		DataCollector dc = new JavaDataCollectorImpl();
+		Actuator ac = new JavaActuatorImpl();
+		
+		
+		_policyManager= new PolicyManagerImpl(dc,ac);
+			
+		
+	}
+
+
+	public boolean createPolicy(String name, String policyString) throws SPLException 
+	{
+		
+        boolean result = _policyManager.createPolicy(name,policyString);
+       
+		return result;
+	}
+	
+	public boolean validatePolicyString(String policyString) throws SPLException 
+	{
+		
+        boolean result = _policyManager.validatePolicyString(policyString);
+       
+		return result;
+	}
+
+	public void deletePolicy(String name) throws SPLException 
+	{
+		
+		_policyManager.deletePolicy(name);
+		
+		return;
+	}
+
+	public List enumeratePolicyNames() throws SPLException 
+	{
+
+        List policyNames = _policyManager.getAllPolicyNames();
+		
+		return policyNames;
+	}
+
+	public Map enumeratePolicies() throws SPLException 
+	{
+
+        Map policyInstances = _policyManager.getAllPolicies();
+		
+		return policyInstances;
+
+	}
+
+	
+	public String getPolicy(String policyName) throws SPLException 
+	{
+
+        String policy = _policyManager.getPolicy(policyName);
+		
+		return policy;
+
+	}
+
+	public void modifyPolicy(String name, String policyString) throws SPLException {
+
+		
+		_policyManager.updatePolicy(name,policyString);
+        
+
+	}
+
+	public Object executePolicy(String policyName, Map instanceObjectMap) throws SPLException 
+	{
+	 
+        
+		Object retVal = _policyManager.evaluatePolicy(policyName,instanceObjectMap);
+    
+        
+		return retVal;
+	}
+	
+	public static void main(String [] args)
+	{
+		
+
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/AnotherClass.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/AnotherClass.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/AnotherClass.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/AnotherClass.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,44 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.javaspl.samples.simplepolicies;
+
+public class AnotherClass {
+	public int anotherClassProperty1;
+	public int anotherClassProperty2;
+	public AnotherClass(int a1, int b1)
+	{
+		this.setAnotherClassProperty1(a1);
+		this.setAnotherClassProperty2(b1);
+	}
+	public int getAnotherClassProperty1() {
+		return anotherClassProperty1;
+	}
+	public void setAnotherClassProperty1(int a) {
+		this.anotherClassProperty1 = a;
+	}
+	public int getAnotherClassProperty2() {
+		return anotherClassProperty2;
+	}
+	public void setAnotherClassProperty2(int b) {
+		this.anotherClassProperty2 = b;
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/EmbeddedClass1.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/EmbeddedClass1.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/EmbeddedClass1.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/EmbeddedClass1.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,46 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.javaspl.samples.simplepolicies;
+
+public class EmbeddedClass1 {
+	
+	public String embeddedClassProperty1;
+	public String embeddedClassProperty2;
+	
+	public EmbeddedClass1(String a1, String b1)
+	{
+		embeddedClassProperty1 = a1;
+		embeddedClassProperty2 = b1;
+	}
+	public String getEmbeddedClassProperty1() {
+		return embeddedClassProperty1;
+	}
+	public void setEmbeddedClassProperty1(String a1) {
+		this.embeddedClassProperty1 = a1;
+	}
+	public String getEmbeddedClassProperty2() {
+		return embeddedClassProperty2;
+	}
+	public void setEmbeddedClassProperty2(String b1) {
+		this.embeddedClassProperty2 = b1;
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/RunSamples.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,177 @@
+package org.apache.imperius.javaspl.samples.simplepolicies;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider;
+import org.apache.imperius.spl.external.InstanceInfo;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+public class RunSamples {
+	
+	public static String policyFolder = "policies/";
+
+	/**
+	 * @param args
+	 */
+	public static void main(String[] args) 
+	{
+		if(args.length == 0)
+		{	
+			RunSamples.test();
+		}
+		else
+		{
+			RunSamples.testPolicy(args[0]);
+		}
+
+	}
+	
+	public static void _test(String policyName, Map objMap)
+	{
+		try 
+		{
+			
+			Java_SPLPolicyRuleProvider jspl = new Java_SPLPolicyRuleProvider();
+			String aFile = policyFolder + policyName + ".spl";
+			//System.out.println("starting test");
+			StringBuffer contents = new StringBuffer();
+			BufferedReader input = null;
+			try
+			{
+				input = new BufferedReader( new FileReader(aFile) );
+				String line = null; 
+		     
+				while (( line = input.readLine()) != null)
+				{
+					contents.append(line);
+					contents.append(System.getProperty("line.separator"));
+				}
+				input.close();
+		    }
+		    catch (FileNotFoundException ex) 
+		    {
+		      ex.printStackTrace();
+		    }
+		    catch (IOException ex){
+		      ex.printStackTrace();
+		    }
+		    try
+		    {
+		    	jspl.deletePolicy(policyName);
+		    }
+		    catch(Exception e)
+		    {
+		    	
+		    }
+		    
+		    boolean createReturn=jspl.createPolicy(policyName, contents.toString());
+		    System.out.println("Policy Created : " + policyName +createReturn);
+		    System.out.println("");
+		    Object result = jspl.executePolicy(policyName, objMap);
+			System.out.println("Result is " + result);
+		}   
+		catch (SPLException e) 
+		{				// TODO Auto-generated catch block
+			e.printStackTrace();
+		}  
+		
+	}
+	public static void testPolicy(String policyToExecute)
+	{
+		TestElement te=new TestElement();
+	
+		
+	    Map objMap = new Hashtable();
+	    
+	    List instanceInfoList = new ArrayList();
+	    
+	    InstanceInfo ii1 = new InstanceInfo("te",te);
+	    instanceInfoList.add(ii1);	    
+    
+	    objMap.put("org.apache.imperius.javaspl.samples.simplepolicies.TestElement", instanceInfoList);
+		    
+		_test(policyToExecute,objMap);      
+			
+				
+		
+	}
+	
+	public static void testBasicPolicy() 
+	{
+	
+		String policyToExecute = "BasicPolicy";	
+			
+			
+	    Map objMap = new Hashtable();
+	    
+	    List instanceInfoList1 = new ArrayList();
+	 
+	    SampleClass sc1 = new SampleClass(1,2);
+		InstanceInfo ii1 = new InstanceInfo("sc1", sc1);
+		
+		instanceInfoList1.add(ii1);
+		
+		SampleClass sc2 = new SampleClass(3,4);
+		InstanceInfo ii2 = new InstanceInfo("sc2",sc2);
+		
+		instanceInfoList1.add(ii2);
+		
+		objMap.put("org.apache.imperius.javaspl.samples.simplepolicies.SampleClass", instanceInfoList1);
+			   
+		List instanceInfoList2 = new ArrayList();
+		AnotherClass ac1 = new AnotherClass(5,6);
+		InstanceInfo ii3 = new InstanceInfo("ac1",ac1);
+		instanceInfoList2.add(ii3);
+		
+		objMap.put("org.apache.imperius.javaspl.samples.simplepolicies.AnotherClass", instanceInfoList2);
+		
+		_test(policyToExecute,objMap);
+		
+		
+	}	
+	public static void test()
+	{
+		String [] policiesToTest = {"SimplePolicy","ComplexPolicy",
+				"MultiplePolicySample","InvokeMethodSample","DateTime","MacroSample"};
+		
+		String policyToExecute = null;
+		/*if(args.length == 1)
+		{
+			policyToExecute = args[0];
+			if(!policyToExecute.equals("BasicPolicy"))
+			{
+				testPolicy(policyToExecute);
+			}	
+			else
+			{	
+				testBasicPolicy();
+			}	
+		}
+		else
+		{*/
+			for (int i=0 ; i < policiesToTest.length; i++)
+			{
+				String policy = policiesToTest[i];
+				testPolicy(policy);
+			}
+			testBasicPolicy();
+//		}
+		
+	}
+
+	public static void test(String pFolder) {
+		
+		policyFolder = pFolder;
+		test();
+		// TODO Auto-generated method stub
+		
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/SampleClass.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/SampleClass.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/SampleClass.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/SampleClass.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.javaspl.samples.simplepolicies;
+
+public class SampleClass {
+	public int sampleClassProperty1;
+	public int sampleClassProperty2;
+	public EmbeddedClass1 ec = new EmbeddedClass1("ec1","ec2");
+	public SampleClass(int a1, int b1)
+	{
+		sampleClassProperty1 = a1;
+		sampleClassProperty2 = b1;
+	}
+	public int getSampleClassProperty1() {
+		return sampleClassProperty1;
+	}
+	public void setSampleClassProperty1(int a) {
+		this.sampleClassProperty1 = a;
+	}
+	public int getSampleClassProperty2() {
+		return sampleClassProperty2;
+	}
+	public void setSampleClassProperty2(int b) {
+		this.sampleClassProperty2 = b;
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestElement.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,61 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.imperius.javaspl.samples.simplepolicies;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+public class TestElement 
+{
+	public String ElementName;
+
+	public String s; 
+	public char c;
+	public double r64;
+	public float r32;
+	public Calendar d;
+	public long s64;
+	public int s32;
+	public short s16;
+	public byte s8;
+	public boolean b;
+
+	public String childProperty;
+    
+    public int testMethod(int a, int b)
+    {
+    	return a + b;
+    }
+    
+    public TestElement()
+    {
+    	ElementName = "Element1";
+
+    	s="string5"; 
+    	c='d';
+       	r64=54.0;
+    	r32=54.0f;
+    	d= new GregorianCalendar();
+    	s64=-530;
+    	s32=-530;
+    	s16=-50;
+    	s8=-10;
+    	b=false;
+    	childProperty="child property5";
+
+    	
+    }
+
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/simplepolicies/TestSimplePolicies.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,81 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.imperius.javaspl.samples.simplepolicies;
+import junit.extensions.TestSetup;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+public class TestSimplePolicies extends TestCase 
+{
+	
+	public TestSimplePolicies(String arg0) {
+		super(arg0);
+	}
+
+	public static Test suite() {
+		TestSuite suite = new TestSuite(TestSimplePolicies.class);
+		TestSetup wrapper = new TestSetup(suite) {
+
+			protected void setUp() throws Exception {
+				oneTimeSetUp();
+			}
+
+			protected void tearDown() throws Exception {
+				oneTimeTearDown();
+			}
+		};
+		return wrapper;
+	}
+
+	public static void main(String[] args) {
+		junit.textui.TestRunner.run(suite());
+	}
+
+	
+	protected static void oneTimeSetUp() throws Exception {
+	}
+
+	protected static void oneTimeTearDown() throws Exception {
+
+	}
+	
+	
+	/**
+	 * @param args
+	 */
+	public static void testMain() 
+	{
+		String userDir = System.getProperty("user.dir");
+		System.out.println("user dir is " + userDir);
+		RunSamples.test(userDir + "/resources/samples/simple/policies/");
+		
+		
+	}
+
+
+
+
+	
+
+}
+
+
+
+
+
+
+
+

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/CommandLineExecution.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/CommandLineExecution.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/CommandLineExecution.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/CommandLineExecution.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**/
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.javaspl.samples.userdefinedmethods;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class CommandLineExecution implements Expression 
+{
+
+	private List inputParams =null;
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+
+	public CommandLineExecution(List input, boolean boo)
+	{
+		System.out.println(" creating sendMail action");
+		this.inputParams=input;
+	}
+	public Object evaluate() throws SPLException 
+	{
+		
+		Expression commandExpression=(Expression)this.inputParams.get(0);
+		Object command=commandExpression.evaluate();
+		System.out.println("command :"+command);
+
+		Runtime runtime=Runtime.getRuntime();
+		try{
+			runtime.exec((String)command);
+			System.out.println("command execution completed :"+command);
+			System.out.println("");
+
+			
+		}
+		catch(IOException e){
+			logger.severe(Thread.currentThread().getName()+" "+e.getMessage());
+            e.printStackTrace();
+		}
+		
+		return new Boolean(true);
+	}
+
+
+
+
+	public String getReferenceTypeName() throws SPLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public TypeInfo getType() throws SPLException {
+		// TODO Auto-generated method stub
+		return new TypeInfo(TypeConstants.booleanType,null,false);
+	}
+
+	public boolean isArray() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public boolean validate() throws SPLException {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/SendMail.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/SendMail.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/SendMail.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/userdefinedmethods/SendMail.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,190 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**/
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.javaspl.samples.userdefinedmethods;
+
+import java.util.List;
+import java.util.Properties;
+import java.util.logging.Logger;
+import javax.mail.Authenticator;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.PasswordAuthentication;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.TypeConstants;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class SendMail implements Expression 
+{
+
+	private List inputParams =null;
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+
+	public SendMail(List input, boolean boo)
+	{
+		//System.out.println(" creating sendMail action");
+		this.inputParams=input;
+	}
+	public Object evaluate() throws SPLException 
+	{
+		
+		Expression fromExpression=(Expression)this.inputParams.get(0);
+		Object from=fromExpression.evaluate();
+		System.out.println("from :"+from);
+
+
+		Expression toExpression=(Expression)this.inputParams.get(1);
+		Object to=toExpression.evaluate();
+		System.out.println("to :"+to);
+
+
+		Expression subjectExpression=(Expression)this.inputParams.get(2);
+		Object subject=subjectExpression.evaluate();
+		System.out.println("subject :"+subject);
+
+
+		Expression messageExpression=(Expression)this.inputParams.get(3);
+		Object message=messageExpression.evaluate();
+		System.out.println("message :"+message);
+
+		try {
+			//System.out.println("trying to send mail");
+
+			//System.out.println("trying to create service object ");
+	        
+			boolean ret=postMail((String)from,(String)to,(String)subject,(String)message);
+	        System.out.println("Sent mail, return value='" + ret + "'");
+	        System.out.println("");
+	      } catch (Exception e) {
+	    	  System.out.println("send mail exception block");
+	    	  logger.severe(Thread.currentThread().getName()+" "+e.getMessage());
+	            
+	    	  e.printStackTrace();
+	        System.out.println(e.toString());
+	      }
+		 
+		// TODO Auto-generated method stub
+		return new Boolean(true);
+	}
+
+
+	public boolean postMail( String from,String recipients, String subject,
+			String message) throws MessagingException
+			{
+		//System.out.println("post mail");
+		 String JAVAX_MAIL_PROTOCOL = "smtp";
+		   String SMTP_HOST_NAME = "relay.de.ibm.com";
+//		   String SMTP_AUTH_USER = "anonymous";
+//		   String SMTP_AUTH_PWD  = "anonymous";
+		   String SMTP_AUTH_ENABLED  = "false";
+//		   int SEVERITY = 50;
+//		   int NO_ACTION_SEVERITY = 50;
+		  
+		boolean debug = false;
+//		Set the host smtp address
+		Properties props = new Properties();
+		props.put( "mail.transport.protocol", JAVAX_MAIL_PROTOCOL);
+		props.put("mail.smtp.host", SMTP_HOST_NAME);
+		Session session = null;
+		//System.out.println("post mail1");
+		if(SMTP_AUTH_ENABLED.equals("true"))
+		{
+			props.put("mail.smtp.auth", "true");
+			Authenticator auth = new SMTPAuthenticator();
+			session = Session.getDefaultInstance(props, auth);
+			//System.out.println("post mail2");
+		}
+		else 
+			session = Session.getDefaultInstance(props);
+		//System.out.println("post mail3");
+		session.setDebug(debug);
+
+//		create a message
+		Message msg = new MimeMessage(session);
+		//System.out.println("post mail4");
+		msg.setFrom(new InternetAddress(from));
+		//System.out.println("post mail5");
+		msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse( recipients ));
+		//System.out.println("post mail6");
+
+//		Setting the Subject and Content Type
+		msg.setSubject(subject);
+		msg.setContent(message, "text/plain");
+		//System.out.println("post mail7");
+		try{
+			//System.out.println("post mail8");
+			Transport.send(msg);
+			//System.out.println("post mail9");
+		}catch(Exception e)
+		{
+			e.printStackTrace();
+			
+		}
+		
+		//System.out.println("messsage sent");
+		return true;
+		}
+
+
+	public String getReferenceTypeName() throws SPLException {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	public TypeInfo getType() throws SPLException {
+		// TODO Auto-generated method stub
+		return new TypeInfo(TypeConstants.booleanType,null,false);
+	}
+
+	public boolean isArray() {
+		// TODO Auto-generated method stub
+		return false;
+	}
+
+	public boolean validate() throws SPLException {
+		// TODO Auto-generated method stub
+		return true;
+	}
+
+	
+	
+	private class SMTPAuthenticator extends javax.mail.Authenticator
+	{
+	    public PasswordAuthentication getPasswordAuthentication()
+	    {
+	    	 String SMTP_AUTH_USER = "anonymous";
+	    	  String SMTP_AUTH_PWD  = "anonymous";
+	    	  
+	        String username = SMTP_AUTH_USER;
+	        String password = SMTP_AUTH_PWD;
+	        return new PasswordAuthentication(username, password);
+	    }
+	}
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsComputerSystem.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsComputerSystem.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsComputerSystem.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsComputerSystem.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,129 @@
+//(c) Copyright IBM Corp. 2007
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.javaspl.samples.windowscomputersystem;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.util.StringTokenizer;
+
+
+public class WindowsComputerSystem {
+
+	public float freeSpace=0;
+	public long totalSpace=0;
+	public String osArchitecture="";
+	public String osName="";
+	public String osVersion="";
+	public String osPatchLevel="";
+	public String userCountry="";
+	public String userLanguage="";
+	public String ownerName="";
+	public String javaVersion="";
+	
+	public static long getFreeSpace() throws IOException
+	  {
+	    long bytesFree = -1;
+	 
+	    if (System.getProperty("os.name").startsWith("Windows")) {
+	      // create a .bat file to run a directory command
+	      File script = new File(System.getProperty("java.io.tmpdir"), "script.bat");
+	      PrintWriter writer = new PrintWriter(new FileWriter(script, false));
+	      writer.println("dir \"" + "." + "\"");
+	      writer.close();
+	 
+	      // get the output from running the .bat file
+	      Process p = Runtime.getRuntime().exec(script.getAbsolutePath());
+	      InputStream reader = new BufferedInputStream(p.getInputStream());
+	      StringBuffer buffer = new StringBuffer();
+	      for (; ; ) {
+	        int c = reader.read();
+	        if (c == -1)
+	          break;
+	        buffer.append( (char) c);
+	      }
+	      String outputText = buffer.toString();
+	      reader.close();
+	      script.delete();
+	 
+	      // parse the output text for the bytes free info
+	      StringTokenizer tokenizer = new StringTokenizer(outputText, "\n");
+	      while (tokenizer.hasMoreTokens()) {
+	        String line = tokenizer.nextToken().trim();
+	        // see if line contains the bytes free information
+	        if (line.endsWith("bytes free")) {
+	          tokenizer = new StringTokenizer(line, " ");
+	          tokenizer.nextToken();
+	          tokenizer.nextToken();
+	          bytesFree = Long.parseLong(tokenizer.nextToken().replaceAll(",",""));
+	        }
+	      }
+	    }
+	 
+	    if (bytesFree == -1)
+	      throw new UnsupportedOperationException(
+	          "The method getFreeSpace(File) has not been implemented for this operating system.");
+	 
+	    return bytesFree;
+	  }
+	
+	public WindowsComputerSystem() throws IOException
+	{
+		freeSpace=getFreeSpace();
+		freeSpace = freeSpace/1000000000l;
+		//totalSpace=javaFile.getTotalSpace();
+		osArchitecture=System.getProperty("os.arch");
+		osName=System.getProperty("os.name");
+		osPatchLevel=System.getProperty("sun.os.patch.level");
+		osVersion=System.getProperty("os.version");
+		ownerName=System.getProperty("user.name");	
+		userCountry=System.getProperty("user.country");
+		userLanguage=System.getProperty("user.language");
+		javaVersion=System.getProperty("java.specification.version");
+	}
+
+	public boolean deleteFiles(String flavour) throws IOException{
+		Runtime runtime=Runtime.getRuntime();
+		if(flavour.equalsIgnoreCase("TemporarySetupFiles")){
+			//32
+			runtime.exec("CLEANMGR /sagerun:32");
+		}
+		else if(flavour.equalsIgnoreCase("TemporaryInternetFiles")){
+			//64
+			runtime.exec("CLEANMGR /sagerun:64");
+		}
+		else if(flavour.equalsIgnoreCase("TemporaryFiles")){
+			//128
+			runtime.exec("CLEANMGR /sagerun:128");
+		}
+		else if(flavour.equalsIgnoreCase("RecycleBin")){
+			//256
+			runtime.exec("CLEANMGR /sagerun:256");
+		}
+		
+		
+		
+		return true;
+	}
+	
+	public static void main(String [] args)
+	{
+		WindowsComputerSystem ws;
+		try {
+			ws = new WindowsComputerSystem();
+			System.out.println("free space" + ws.freeSpace);
+		} catch (IOException e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+		
+	}
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsSystemManager.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsSystemManager.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsSystemManager.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-javaspl/src/org/apache/imperius/javaspl/samples/windowscomputersystem/WindowsSystemManager.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,98 @@
+//(c) Copyright IBM Corp. 2007
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+
+package org.apache.imperius.javaspl.samples.windowscomputersystem;
+
+import java.io.BufferedReader;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.javaspl.Java_SPLPolicyRuleProvider;
+import org.apache.imperius.spl.external.InstanceInfo;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+public class WindowsSystemManager 
+{
+	
+	public static void main(String[] args) throws IOException, SPLException
+	{
+				
+		WindowsComputerSystem system1=new WindowsComputerSystem();
+		String policyToExecute = "Java_FileSystem";	
+		
+		try 
+		{
+			if(args.length == 1)
+			{
+				policyToExecute = args[0];
+			}
+			Java_SPLPolicyRuleProvider jspl = new Java_SPLPolicyRuleProvider();
+			String aFile = "policies/" + policyToExecute + ".spl";
+			//System.out.println("starting test");
+			StringBuffer contents = new StringBuffer();
+			BufferedReader input = null;
+			try
+			{
+				input = new BufferedReader( new FileReader(aFile) );
+				String line = null; 
+		     
+				while (( line = input.readLine()) != null)
+				{
+					contents.append(line);
+					contents.append(System.getProperty("line.separator"));
+				}
+				input.close();
+		    }
+		    catch (FileNotFoundException ex) 
+		    {
+		      ex.printStackTrace();
+		    }
+		    catch (IOException ex){
+		      ex.printStackTrace();
+		    }
+		    try
+		    {
+		    	jspl.deletePolicy(policyToExecute);
+		    }
+		    catch(Exception e)
+		    {
+		    	
+		    }
+		    
+		    boolean createReturn=jspl.createPolicy(policyToExecute, contents.toString());
+		    System.out.println("Policy Created : " + policyToExecute +createReturn);
+		    System.out.println("");
+		    
+		    Map objMap = new Hashtable();
+		    
+		    List instanceInfoList = new ArrayList();
+		    
+		    InstanceInfo ii1 = new InstanceInfo("system1",system1);
+		    instanceInfoList.add(ii1);	    
+	    
+		    objMap.put("org.apache.imperius.javaspl.samples.windowscomputersystem.WindowsComputerSystem", instanceInfoList);
+		    
+		      
+		    Object result = jspl.executePolicy(policyToExecute, objMap);
+		   System.out.println("Result is " + result);
+			
+		} 
+		catch (SPLException e) 
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
+	}
+
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/pom.xml
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/pom.xml?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/pom.xml (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/pom.xml Sat Dec 22 11:33:46 2007
@@ -0,0 +1,41 @@
+<!--
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>imperius</groupId>
+  <artifactId>imperius-splcore</artifactId>
+  <packaging>jar</packaging>
+  <version>1.0.0-SNAPSHOT</version>
+  <name>imperius-splcore</name>
+  <url>http://maven.apache.org</url>
+  <dependencies>
+  <dependency>
+	<groupId>antlr</groupId>
+	<artifactId>antlr</artifactId>
+	<version>2.7.7</version>
+    </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+   
+    </dependency>
+  </dependencies>
+  <build>
+	<sourceDirectory>src</sourceDirectory>
+	<testSourceDirectory>src</testSourceDirectory> 
+		
+	</build>
+</project>

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyDataStore.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyDataStore.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyDataStore.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyDataStore.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.datastore;
+
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.PolicyInfo;
+import org.apache.imperius.spl.parser.statements.impl.SPLPolicy;
+
+
+public interface PolicyDataStore
+{
+    
+    public String getPolicy(String policyName)
+            throws SPLException;
+    
+    public PolicyInfo getPolicyInfo(String policyName)
+    throws SPLException;
+    
+    public boolean createPolicy(String policyName, String policyString) throws SPLException;
+    
+    public boolean validatePolicyString(String policyString) throws SPLException;
+    
+    
+    public SPLPolicy createSPLPolicyObject(String policyName, String policyString) 
+	throws SPLException;
+	
+    public void updatePolicy(String policyName, String policyString) throws SPLException;
+    
+    public void deletePolicy(String policyName)
+            throws SPLException;
+    
+    public Map getAllPolicies() throws SPLException;
+    
+    public List getAllPolicyNames() throws SPLException;
+    
+    public void init() throws SPLException;
+    
+    public void shutdown();
+    
+       
+    public SPLPolicy getInternalPolicyObject(String PolicyRuleName)
+            throws SPLException;
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyParser.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyParser.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyParser.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyParser.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,41 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+//
+
+/**
+ * @author Prashant Baliga <prabalig@in.ibm.com>
+ *
+ */
+
+package org.apache.imperius.spl.datastore;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.SPLPolicy;
+
+
+public interface PolicyParser
+{
+    
+    public SPLPolicy createInternalPolicyObject(String PolicyRuleName,
+            String PolicyString) throws SPLException;
+    
+    public boolean validate(String PolicyRuleName, String PolicyString);
+    
+    public void init() throws SPLException;
+    
+    public void shutDown();
+    
+    public boolean validatePolicyString(String policyString) throws SPLException;
+    
+}



Mime
View raw message