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 [3/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-splcore/src/org/apache/imperius/spl/datastore/PolicyRepository.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyRepository.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyRepository.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/PolicyRepository.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+public interface PolicyRepository
+{
+    
+    public String getPolicyString(String PolicyRuleName) throws SPLException;
+            
+    
+    public boolean insertPolicy(String PolicyRuleName, String PolicyString)
+            throws SPLException;
+    
+    public void updatePolicy(String PolicyRuleName, String PolicyString)
+            throws SPLException;
+    
+    public void deletePolicy(String PolicyRuleName) throws SPLException;
+    
+    public Map getAllPolicies() throws SPLException;
+    
+    public List getAllPolicyNames() throws SPLException;
+    
+    public boolean policyExists(String PolicyRuleName) throws SPLException;
+    
+    public void init() throws SPLException;
+    
+    public void shutdown();
+    
+    
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyCache.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyCache.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyCache.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyCache.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,106 @@
+/*
+ * 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.impl;
+
+import java.util.Map;
+import java.util.Hashtable;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.SPLPolicy;
+
+
+public class PolicyCache 
+{
+	private Map _policyCache = new Hashtable();
+	
+	public boolean policyExists(String policyName)
+	{
+		if (!_policyCache.containsKey(policyName))
+        {
+			return false;
+        }
+		return true;
+		
+		
+	}
+	
+	public boolean insertPolicy(String policyName, SPLPolicy policyObject)
+	{
+		if (!policyExists(policyName))
+        {
+            
+            _policyCache.put(policyName,policyObject);
+            return true;
+            
+        }
+        else
+        {
+        	return false;
+            
+        }
+    	
+	}
+	public boolean updatePolicy(String policyName, SPLPolicy policyObject)
+		throws SPLException
+	{
+		if(policyExists(policyName))
+		{
+			_policyCache.remove(policyName);
+			_policyCache.put(policyName, policyObject);
+			return true;
+		}
+		else
+		{
+			throw new SPLException("policy does not exist in cache");
+		}
+		
+	}
+	public boolean deletePolicy(String policyName) throws SPLException
+	{
+		if(policyExists(policyName))
+		{
+			_policyCache.remove(policyName);
+			return true;
+		}
+		else
+		{
+			return false;
+		}
+		
+		
+	}
+	public SPLPolicy getPolicy(String policyName) throws SPLException
+	{
+		if(policyExists(policyName))
+		{
+			SPLPolicy pol = (SPLPolicy)_policyCache.get(policyName);
+			return pol;
+		}
+		else
+		{
+			throw new SPLException("policy does not exist in cache");
+		}
+		
+	}
+	
+	
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyDataStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyDataStoreImpl.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyDataStoreImpl.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyDataStoreImpl.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,497 @@
+/*
+ * 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.impl;
+
+
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.datastore.PolicyDataStore;
+import org.apache.imperius.spl.datastore.PolicyParser;
+import org.apache.imperius.spl.datastore.PolicyRepository;
+import org.apache.imperius.spl.parser.exceptions.InvalidCIMParameterException;
+import org.apache.imperius.spl.parser.exceptions.InvalidPolicyParameterException;
+import org.apache.imperius.spl.parser.exceptions.PolicyAlreadyExistsInRepositoryException;
+import org.apache.imperius.spl.parser.exceptions.PolicyDoesNotExistException;
+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;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class PolicyDataStoreImpl implements PolicyDataStore
+{
+
+
+
+	private PolicyCache _policyCache = null;
+
+	private PolicyParser _policyParser = null;
+
+	private PolicyRepository _policyRepository = null;
+
+
+	private static final String sourceClass = "PolicyDataStoreImpl";
+
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+	public PolicyDataStoreImpl()
+	{
+
+		init();
+	}
+
+	public void init()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "init");
+
+		_policyCache = new PolicyCache();
+		_policyRepository = new PolicyRepositoryImpl();
+		_policyParser = new PolicyParserImpl();
+	
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "init");
+	}
+
+
+	public void shutdown()
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+		_policyParser.shutDown();
+		_policyRepository.shutdown();
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+	}
+
+	public boolean createPolicy(String policyName, String policyString) 
+	throws SPLException
+	{
+
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
+		// check to see if class name and namespace are valid
+		boolean res = false;
+
+		if ((policyName != null) && (policyString != null))
+		{
+			// check if Policy already exists in Repository
+			if (!_policyRepository.policyExists(policyName))
+			{
+				SPLPolicy internalPolicyObject = 
+					_policyParser.createInternalPolicyObject(policyName,policyString);
+
+				if (internalPolicyObject != null)
+				{
+					if (logger.isLoggable(Level.FINE))
+					{	
+						logger.fine(Thread.currentThread().getName() + 
+								" created internal SPLPolicy");
+					}    
+					// create CIMObjectPath that is to be returned
+					res = _policyRepository.insertPolicy(
+							policyName, policyString);
+					if (logger.isLoggable(Level.FINE))
+					{	
+						logger.fine(Thread.currentThread().getName() + 
+								" inserted Policy into PolicyRepository");
+					}    
+					
+					_policyCache.insertPolicy(policyName,internalPolicyObject);
+					
+
+				}
+
+			}
+			else
+			{
+				logger
+				.severe(Thread.currentThread().getName() +" " +
+						"Cannot create new Policy asPolicy already exists . Try updating.");
+				throw new PolicyAlreadyExistsInRepositoryException(
+				"Cannot create new Policy asPolicy already exists");
+			}
+		}
+		else
+		{
+			logger.severe(Thread.currentThread().getName()+" " + 
+			"Policy Parameter is null");
+			throw new InvalidPolicyParameterException( "Policy Parameter is null");
+		}
+
+
+
+
+		return res;
+	}
+
+	public void deletePolicy(String policyName)
+	throws SPLException
+	{
+		// logger.entry("deletePolicy");
+
+		// check to see if they r null
+		// check if it already exists
+		// put in a utility to check a cim object
+
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
+
+		// get name of Policy to be deleted
+
+		if (policyName != null)
+		{
+			//_readSerializedCimPolicyStorage();
+			if (logger.isLoggable(Level.FINE))
+			{	
+				logger.fine(Thread.currentThread().getName() + 
+						" Deleting Policy Object from cache");
+			}    
+			// delete Policy from cache
+			_policyCache.deletePolicy(policyName);
+
+			if (logger.isLoggable(Level.FINE))
+			{	
+				logger.fine(Thread.currentThread().getName() + 
+						" Deleting Policy from policyRepository");
+			}    
+			// delete policy from Repository
+			if (_policyRepository.policyExists(policyName))
+			{
+				_policyRepository.deletePolicy(policyName);
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
+			}
+			else
+			{
+				logger.severe(Thread.currentThread().getName()+" " + 
+				"The Policy cannot be deleted as it does not exist in the Repository");
+				throw new PolicyDoesNotExistException(
+				"The Policy cannot be deleted as it does not exist in the Repository");
+			}
+		}
+		else
+		{
+			logger.severe(Thread.currentThread().getName()+" " + 
+			"The Policy cannot be found due to Invalid Policy Parameters");
+			throw new InvalidPolicyParameterException(
+			"The Policy cannot be found due to Invalid Policy Parameters");
+		}
+
+	}
+
+	public Map getAllPolicies()
+	throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicies");
+
+		// enumerating Policies from policyRepository
+		if (logger.isLoggable(Level.FINE))
+			logger.fine(Thread.currentThread().getName() + 
+					" enumerating Policies from policyRepository");
+		// USE equalscase instead
+
+		Map policies = _policyRepository.getAllPolicies();
+
+		return policies;
+
+
+
+	}
+
+	public List getAllPolicyNames() throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicyNames");
+		List policyNames = _policyRepository.getAllPolicyNames(); 
+
+		return policyNames;
+
+	}
+
+	public SPLPolicy getInternalPolicyObject(String policyRuleName)
+	throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ 
+		"getInternalPolicyObject");
+		if (policyRuleName != null)
+		{
+			//_readSerializedCimPolicyStorage();
+			// get Policy object from Cache
+			if (logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" get Policy object from Cache");
+
+			if (_policyCache.policyExists(policyRuleName))
+			{
+				SPLPolicy policyObject = _policyCache.getPolicy(policyRuleName);
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" " +
+						"getInternalPolicyObject");
+				return policyObject;
+			}
+			// get Policy from Repository,cache it and then return the Policy
+			// Object
+
+			else if (_policyRepository.policyExists(policyRuleName))
+			{
+				if (logger.isLoggable(Level.FINE))
+				{	
+					logger.fine(Thread.currentThread().getName() + 
+							" get Policy from Repository,cache it and then return the Policy Object");
+				}    
+				String PolicyString = _policyRepository.getPolicyString(policyRuleName);
+				SPLPolicy internalPolicyObject = 
+					_policyParser.createInternalPolicyObject(policyRuleName,PolicyString);
+				_policyCache.insertPolicy(policyRuleName, internalPolicyObject);
+				//_serializeCimPolicyStorage();
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" " 
+						+ "getInternalPolicyObject");
+				return internalPolicyObject;
+			}
+			else
+			{
+				logger.severe(Thread.currentThread().getName()+" "+"The Policy does not exist");
+				throw new PolicyDoesNotExistException(
+				"The Policy does not exist");
+			}
+		}
+		else
+		{
+			logger
+			.severe(Thread.currentThread().getName()+" "+"This CIM class is not handled by the Policy Provider");
+			throw new InvalidCIMParameterException(
+			"This CIM class is not handled by the Policy Provider");
+		}
+
+	}
+
+	public String getPolicy(String policyRuleName)
+	throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
+
+
+		if (policyRuleName != null)
+		{
+			// check to see if Policy exists, if so then return it
+			if (_policyRepository.policyExists(policyRuleName))
+			{
+				String policyString = _policyRepository.getPolicyString(policyRuleName);
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
+				return policyString;
+			}
+			else
+			{
+				logger.severe(Thread.currentThread().getName()+" " + 
+				"The Policy does not exist");
+				throw new PolicyDoesNotExistException(
+				"The Policy does not exist");
+			}
+		}
+		else
+		{
+			logger
+			.severe(Thread.currentThread().getName()+" " + 
+					"The Policy cannot be found due to Invalid Policy Parameters");
+			throw new InvalidPolicyParameterException(
+			"The Policy cannot be found due to Invalid Policy Parameters");
+		}
+
+
+	}
+
+
+
+	public void updatePolicy(String policyRuleName, String policyString) throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "updatePolicy");
+
+		if ((policyRuleName != null) && (policyString != null))
+		{
+			//_readSerializedCimPolicyStorage();
+
+			// NEED TO CHECK FOR PRESENCE IN CACHE, DELETE IF ONE EXISTS
+			if (_policyRepository.policyExists(policyRuleName))
+			{
+				if (logger.isLoggable(Level.FINE))
+				{	
+					logger.fine(Thread.currentThread().getName()  + 
+							" Updating Policy in Repository");
+				}    
+				SPLPolicy internalPolicyObject = 
+					_policyParser.createInternalPolicyObject(policyRuleName,policyString);
+				// CALL CREATEINTERNALPOLICYOBJECT validate is for future
+				// use
+				if (internalPolicyObject != null)
+				{
+					_policyRepository.updatePolicy(policyRuleName,
+							policyString);
+					if (_policyCache.policyExists(policyRuleName))
+					{
+						_policyCache.deletePolicy(policyRuleName);
+						//_serializeCimPolicyStorage();
+						if (logger.isLoggable(Level.FINE))
+						{	
+							logger.fine(Thread.currentThread().getName() +
+									" Removing old Policy Object from cache");
+						}    
+					}
+					if (logger.isLoggable(Level.FINE))
+					{	
+						logger.fine(Thread.currentThread().getName() + 
+								" Adding new Policy Object to cache");
+					}    
+					_policyCache.insertPolicy(policyRuleName, internalPolicyObject);
+					//_serializeCimPolicyStorage();
+
+					logger.exiting(sourceClass,Thread.currentThread().getName() + 
+							" "+ "updatePolicy");
+				}
+			}
+			else
+			{
+				logger.severe(Thread.currentThread().getName()+" "+"The Policy does not exist");
+				throw new PolicyDoesNotExistException("The Policy does not exist");
+			}
+		}
+		else
+		{
+			logger
+			.severe(Thread.currentThread().getName()+" "+ 
+					"The Policy cannot be found due to Invalid Policy Parameters");
+			throw new InvalidPolicyParameterException(
+			"The Policy cannot be found due to Invalid Policy Parameters");
+		}
+
+
+
+	}
+
+	public PolicyInfo getPolicyInfo(String policyRuleName) throws SPLException {
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ 
+		"getInternalPolicyObject");
+		
+		if (policyRuleName != null)
+		{
+			
+			if (logger.isLoggable(Level.FINE))
+				logger.fine(Thread.currentThread().getName()+" get Policy object from Cache");
+
+		
+			if (_policyCache.policyExists(policyRuleName))
+			{
+		
+				
+				SPLPolicy policyObject = _policyCache.getPolicy(policyRuleName);
+				List importStmtList=policyObject.getImportStmtList();
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" " +"getInternalPolicyObject");
+				PolicyInfo pi=new PolicyInfo( importStmtList);
+		
+				return pi;
+			}
+			// get Policy from Repository,cache it and then return the Policy
+			// Object
+
+			else if (_policyRepository.policyExists(policyRuleName))
+			{
+			
+				if (logger.isLoggable(Level.FINE))
+				{	
+					logger.fine(Thread.currentThread().getName() + 
+							" get Policy from Repository,cache it and then return the Policy Object");
+				}    
+				String PolicyString = _policyRepository.getPolicyString(policyRuleName);
+				
+				SPLPolicy internalPolicyObject = 
+					_policyParser.createInternalPolicyObject(policyRuleName,PolicyString);
+				
+				_policyCache.insertPolicy(policyRuleName, internalPolicyObject);
+				
+
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" " 
+						+ "getInternalPolicyObject");
+				List importStmtList=internalPolicyObject.getImportStmtList();
+				logger.exiting(sourceClass,Thread.currentThread().getName()+" " +"getInternalPolicyObject");
+				PolicyInfo pi=new PolicyInfo( importStmtList);
+				return pi;
+			}
+			else
+			{
+
+			
+				logger.severe(Thread.currentThread().getName()+" "+"The Policy does not exist");
+				throw new PolicyDoesNotExistException(
+				"The Policy does not exist");
+			}
+		}
+		else
+		{
+
+			logger.severe(Thread.currentThread().getName()+" "+"policy name is null");
+			throw new InvalidCIMParameterException("policy name is null");
+		}
+
+	}
+
+	
+	public SPLPolicy createSPLPolicyObject(String policyName, String policyString) 
+	throws SPLException
+	{
+
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
+		// check to see if class name and name space are valid
+		
+		if ((policyName != null) && (policyString != null))
+		{
+			// check if Policy already exists in Repository
+				SPLPolicy internalPolicyObject = 
+					_policyParser.createInternalPolicyObject(policyName,policyString);
+
+				if (internalPolicyObject != null)
+				{
+					if (logger.isLoggable(Level.FINE))
+					{	
+						logger.fine(Thread.currentThread().getName() + 
+								" created internal SPLPolicy");
+					}    
+					// create CIMObjectPath that is to be returned
+					return internalPolicyObject;
+				}
+
+			
+		}
+		else
+		{
+			logger.severe(Thread.currentThread().getName()+" " + 
+			"Policy Parameter is null");
+			throw new InvalidPolicyParameterException( "Policy Parameter is null");
+		}
+
+
+
+
+		return null;
+	}
+
+	public boolean validatePolicyString(String policyString) throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName() + " " + "validatePolicyString");
+		boolean pi=this._policyParser.validatePolicyString(policyString);
+		logger.exiting(sourceClass,Thread.currentThread().getName() + " " + "validatePolicyString");
+
+		return pi;
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyParserImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyParserImpl.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyParserImpl.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyParserImpl.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,218 @@
+/*
+ * 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.impl;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.datastore.PolicyParser;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.parser.compiler.SPLLexer;
+import org.apache.imperius.spl.parser.compiler.SPLParser;
+import org.apache.imperius.spl.parser.compiler.SPLTreeParser;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.SPLPolicy;
+import org.apache.imperius.spl.parser.util.DataCollectorFactory;
+import org.apache.imperius.util.SPLLogger;
+
+import antlr.RecognitionException;
+import antlr.collections.AST;
+
+//import com.ibm.ac.javaspl.JavaDataCollectorImpl;
+//import com.ibm.ac.cimspl.CIMDataCollectorImpl;
+
+public class PolicyParserImpl implements PolicyParser
+{
+
+   // private CIMOMHandle handle = null;
+
+    private static final String sourceClass = "PolicyParserImpl";
+
+    private static Logger logger = null; //SPLLogger.getSPLLogger().getLogger();
+
+    static boolean showTree = false;
+
+        
+    public PolicyParserImpl()
+    {
+    	//System.out.println("in policyparserimpl ctor");
+    	logger = SPLLogger.getSPLLogger().getLogger();
+    	init();
+    }
+
+    public void init() 
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "init");
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "init");
+
+    }
+
+    public void shutDown()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "shutDown");
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "shutDown");
+
+    }
+
+    public SPLPolicy createInternalPolicyObject(String policyRuleName,
+            String policyString) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "
+        		+ "CreateInternalPolicyObject");
+        try
+        {
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" " 
+            		+ "CreateInternalPolicyObject");
+            StringReader policyStringReader = new StringReader(policyString);
+            SPLPolicy pol =parseFile(policyRuleName, policyStringReader); 
+            return pol;
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            logger.severe(Thread.currentThread().getName()+" " + 
+            		"Error encountered while parsing PolicyString");
+            throw new SPLException("Error encountered while parsing PolicyString");
+
+        }
+
+        // return cimpolicy;
+    }
+
+    public boolean validate(String PolicyRuleName, String PolicyString)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "validate");
+
+        return true;
+    }
+
+    public static SPLPolicy parseFile(String f, Reader r) throws Exception
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "parseFile");
+
+        try
+        {
+            // Create a scanner that reads from the input stream passed to us
+            SPLLexer lexer = new SPLLexer(r);
+            lexer.setFilename(f);
+
+            // Create a parser that reads from the scanner
+            SPLParser parser = new SPLParser(lexer);
+            parser.setASTNodeClass("org.apache.imperius.spl.parser.compiler.ASTWithLineNumber");
+            parser.setFilename(f);
+            if (logger.isLoggable(Level.FINE))
+                logger.fine(Thread.currentThread().getName()+" start parse");
+
+            // start parsing at the compilationUnit rule
+            parser.splpolicy();
+            if (logger.isLoggable(Level.FINE))
+                logger.fine(Thread.currentThread().getName()+" parsing complete");
+            AST t = parser.getAST();
+            if (logger.isLoggable(Level.FINE))
+                logger.fine(Thread.currentThread().getName()+" got AST");
+            if (t != null)
+            {
+                traverseTree(t);
+            }
+            else
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"No tree produced");
+
+            }
+
+            // do something with the tree
+            SPLPolicy pol = doTreeAction(f, parser.getAST(), parser.getTokenNames()); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "parseFile");
+            return pol;
+        }
+        catch (Exception e)
+        {
+            logger.severe(e.getMessage());
+            e.printStackTrace(); // so we can get stack trace
+            throw new SPLException(e.getMessage());
+        }
+    }
+
+    public static void traverseTree(AST t)
+    {
+
+    }
+
+    public static SPLPolicy doTreeAction(String f, AST t, String[] tokenNames) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "doTreeAction");
+  
+        if (t == null)
+        {	
+            return null;
+        }    
+       
+        SPLTreeParser tparse = new SPLTreeParser();
+        tparse.setASTNodeClass("org.apache.imperius.spl.parser.compiler.ASTWithLineNumber");
+        try
+        {
+            DataCollector dc = DataCollectorFactory.getDataCollector();
+            SPLSymbolTable st=new SPLSymbolTable();
+            SPLPolicy cp = tparse.splpolicy(t, dc, st);
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "doTreeAction");
+            return cp;
+        }
+        
+        catch (RecognitionException e)
+        {
+            logger.severe(e.getMessage());
+            e.printStackTrace();
+            throw new SPLException(e.getMessage());
+            //return null;
+        }
+
+    }
+    
+	public boolean validatePolicyString(String policyString) throws SPLException
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName() + " " + "validatePolicyString");
+		try
+        {
+            StringReader policyStringReader = new StringReader(policyString);
+            SPLPolicy pol =parseFile("validate",policyStringReader); 
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" " 
+            		+ "CreateInternalPolicyObject");
+            
+            return true;
+
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+            logger.severe(Thread.currentThread().getName()+" " + 
+            		"Error encountered while parsing PolicyString "+e.getMessage());
+            return false;
+        }
+		
+		
+	}
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyRepositoryImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyRepositoryImpl.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyRepositoryImpl.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/datastore/impl/PolicyRepositoryImpl.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,387 @@
+/*
+ * 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>
+ *
+ * Modified : 11/1/07 
+ * Store policy objects individually
+ */
+
+package org.apache.imperius.spl.datastore.impl;
+
+import java.io.FileInputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.*;
+import java.util.logging.*;
+
+import org.apache.imperius.spl.datastore.PolicyRepository;
+import org.apache.imperius.spl.parser.exceptions.*;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class PolicyRepositoryImpl implements PolicyRepository
+{
+
+    private static HashMap _policyMap = new HashMap();
+
+  
+    private static String _fileName = null;
+
+
+    private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+    private static final String sourceClass = "PolicyRepositoryImpl";
+    
+    PolicyRepositoryImpl()
+    {
+    	init();
+    }
+
+    public void init() 
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "init");
+       _fileName = SPLLogger.SPL_HOME + SPLLogger.fileSeparator
+                + "PolicyStorage.DAT";
+//        POLICY_CLASS_NAME = "CIM_SPLPolicyRule";
+//        NAMESPACE = "root/cimv2";
+        _readSerializedPolicyStorage();
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "init");
+    }
+
+    public void shutdown()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+        // TODO Auto-generated method stub
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+    }
+
+    public Map getAllPolicies() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicies");
+        Map allPolicies = new Hashtable();
+        _readSerializedPolicyStorage();
+        Iterator instanceKeySet = _policyMap.keySet().iterator();
+        while (instanceKeySet.hasNext())
+        {
+            // to allPolicies and return it
+            String key = (String) instanceKeySet.next();
+            String policyString = (String)_policyMap.get(key);
+            allPolicies.put(key, policyString);
+          
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicies");
+        return allPolicies;
+    }
+
+    public List getAllPolicyNames() throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicyNames");
+        List policyNames = new ArrayList();
+        _readSerializedPolicyStorage();
+        
+        Iterator instanceKeySet = _policyMap.keySet().iterator();
+        while (instanceKeySet.hasNext())
+        {
+            // add all Policy names from policyMap to PolicyNames and return it
+            String policyName = (String) instanceKeySet.next();
+            policyNames.add(policyName);
+            
+        }
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicyNames");
+        return policyNames;
+    }
+
+    public void updatePolicy(String policyRuleName, String policyString)
+            throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "updatePolicy");
+        _readSerializedPolicyStorage();
+        
+        if (policyRuleName != null && policyString != null)
+        {
+            
+            if (_policyMap.containsKey(policyRuleName))
+            {
+                if (logger.isLoggable(Level.FINE))
+                {	
+                    logger.fine(Thread.currentThread().getName()+" updating Repository");
+                }    
+                // updating Repository
+                deletePolicy(policyRuleName);
+                insertPolicy(policyRuleName, policyString);
+                _serializePolicyStorage();
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "updatePolicy");
+            }
+            else
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"The Policy does not exist");
+                throw new PolicyDoesNotExistException(
+                        "The Policy does not exist");
+            }
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" " + 
+            		"The Policy cannot be found due to Invalid Policy Parameters");
+            throw new InvalidPolicyParameterException(
+                    "The Policy cannot be found due to Invalid Policy Parameters");
+        }
+    }
+
+    public String getPolicyString(String policyRuleName) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
+        _readSerializedPolicyStorage();
+        
+        if (policyRuleName != null)
+        {
+            if (_policyMap.containsKey(policyRuleName))
+            {
+                if (logger.isLoggable(Level.FINE))
+                {	
+                    logger.fine(Thread.currentThread().getName()+ 
+                    		" return Policy from policyMap");
+                }    
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
+                // return Policy from policyMap
+                String policy = (String) _policyMap.get(policyRuleName);
+                return policy;
+            }
+            else
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"The Policy does not exist");
+                throw new PolicyDoesNotExistException(
+                        "The Policy does not exist");
+            }
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" " + 
+                    		"The Policy cannot be found due to Invalid Policy Parameters");
+            throw new InvalidPolicyParameterException(
+                    "The Policy cannot be found due to Invalid Policy Parameters");
+        }
+    }
+
+    public boolean insertPolicy(String policyRuleName, String policyString)
+            throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "insertPolicy");
+        _readSerializedPolicyStorage();
+        
+        if (policyRuleName != null && policyString != null)
+        {
+            
+            if (_policyMap.containsKey(policyRuleName))
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"The Policy already Exists");
+                throw new PolicyAlreadyExistsInRepositoryException(
+                        "The Policy already Exists");
+            }
+            else
+            {
+                if (logger.isLoggable(Level.FINE))
+                    logger.fine(Thread.currentThread().getName()+" add policy to policyMap ");
+                // add policy to policyMap
+                _policyMap.put((String) policyRuleName, (String) policyString);
+                _serializePolicyStorage();
+
+                
+                
+                return true;
+            }
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" " + 
+            		"The Policy cannot be found due to Invalid Policy Parameters");
+            throw new InvalidPolicyParameterException(
+                    "The Policy cannot be found due to Invalid Policy Parameters");
+        }
+    }
+
+    /**
+     * removes a policy from the Hashtable
+     * 
+     * @param PolicyRuleName
+     * @throws CIMException
+     */
+    public void deletePolicy(String policyRuleName) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
+        _readSerializedPolicyStorage();
+        
+        if (policyRuleName != null)
+        {
+            
+            if (!_policyMap.containsKey(policyRuleName))
+            {
+                logger.severe(Thread.currentThread().getName()+" "+"The Policy does not exist");
+                throw new PolicyDoesNotExistException(
+                        "The Policy does not exist");
+            }
+            else
+            {
+                if (logger.isLoggable(Level.FINE))
+                {	
+                    logger.fine(Thread.currentThread().getName() + 
+                    		" removing policy from policyMap");
+                }    
+                // removing policy from policyMap
+                _policyMap.remove(policyRuleName);
+                _serializePolicyStorage();
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
+            }
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" " + 
+                    		"The Policy cannot be found due to Invalid Policy Parameters");
+            throw new InvalidPolicyParameterException(
+                    "The Policy cannot be found due to Invalid Policy Parameters");
+        }
+    }
+
+    public boolean policyExists(String PolicyRuleName) throws SPLException
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "policyExists");
+        _readSerializedPolicyStorage();
+        
+        if (PolicyRuleName != null)
+        {
+            if (logger.isLoggable(Level.FINE))
+            {	
+                logger.fine(Thread.currentThread().getName()+ 
+                		" check to see if Policy exists in policyMap");
+            }    
+            // check to see if Policy exists in policyMap
+            
+            if (_policyMap.containsKey(PolicyRuleName))
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "policyExists");
+                return true;
+            }
+
+            else
+            {
+                logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "policyExists");
+                return false;
+            }
+
+        }
+        else
+        {
+            logger.severe(Thread.currentThread().getName()+" " + 
+                    		"The Policy cannot be found due to Invalid Policy Parameters");
+            throw new InvalidPolicyParameterException(
+                    "The Policy cannot be found due to Invalid Policy Parameters");
+        }
+    }
+
+  
+
+   
+
+    synchronized private static void _readSerializedPolicyStorage()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" " +
+        		"_readSerializedPolicyStorage");
+        FileInputStream fis = null;
+        ObjectInputStream in = null;
+        File file = new File(_fileName);
+        try
+        {
+            if (logger.isLoggable(Level.FINE))
+            {	
+                logger.fine(Thread.currentThread().getName() + 
+                		" read from the serialized file if it exists, else create" +
+                		"it and serialize an empty policyMap to it");
+            }    
+            // read from the serialized file if it exists, else create it and
+            // serialize an empty policyMap to it
+            if (!file.exists())
+            {
+                
+                FileOutputStream fos = new FileOutputStream(file);
+                ObjectOutputStream out = new ObjectOutputStream(fos);
+                out.writeObject(_policyMap);
+                out.close();
+                fos.close();
+            }
+
+            fis = new FileInputStream(file);
+            in = new ObjectInputStream(fis);
+            _policyMap = (HashMap) in.readObject();
+
+            in.close();
+            fis.close();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" " + 
+            		"_readSerializedPolicyStorage");
+        }
+        catch (IOException ex)
+        {
+            logger.severe(Thread.currentThread().getName()+" " + 
+            		"Error reading serialized policyMap");
+            ex.printStackTrace();
+        }
+        catch (ClassNotFoundException ex)
+        {
+            logger.severe(Thread.currentThread().getName()+" " + 
+                    		"Error reading seralized policyMap Object: class not found");
+            ex.printStackTrace();
+        }
+
+    }
+
+    synchronized private static void _serializePolicyStorage()
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "_serializePolicyStorage");
+        FileOutputStream fos = null;
+        ObjectOutputStream out = null;
+        
+        File file = new File(_fileName);
+        try
+        {
+            if (logger.isLoggable(Level.FINE))
+            {	
+                logger.fine(Thread.currentThread().getName() + 
+                		" serialize an policyMap to File System");
+            }    
+            // serialize an policyMap to File System
+
+            
+            fos = new FileOutputStream(file);
+            out = new ObjectOutputStream(fos);
+            out.writeObject(_policyMap);
+            out.close();
+            fos.close();
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" " +
+            		"_serializePolicyStorage");
+        }
+        catch (IOException ex)
+        {
+            logger.severe(Thread.currentThread().getName()+" "+"Error serializing policyMap");
+            ex.printStackTrace();
+        }
+    }
+
+	
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/PolicyEvaluator.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/PolicyEvaluator.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/PolicyEvaluator.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/PolicyEvaluator.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,39 @@
+/*
+ * 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.evaluator;
+
+
+import java.util.Map;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.SPLPolicy;
+
+
+public interface PolicyEvaluator
+{
+    
+    public Object evaluatePolicy(SPLPolicy cp, Map instances) throws SPLException;
+    
+    public void init() throws SPLException;
+    
+    public void shutdown() ;
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/PolicyEvaluatorImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/PolicyEvaluatorImpl.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/PolicyEvaluatorImpl.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/PolicyEvaluatorImpl.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,188 @@
+/*
+ * 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.evaluator.impl;
+
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.evaluator.PolicyEvaluator;
+import org.apache.imperius.spl.external.Actuator;
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.SPLPolicy;
+import org.apache.imperius.spl.parser.util.ActuatorFactory;
+import org.apache.imperius.spl.parser.util.DataCollectorFactory;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class PolicyEvaluatorImpl implements PolicyEvaluator 
+{
+
+	private static final String sourceClass="PolicyEvaluatorImpl";
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+	private static Logger auditLogger = SPLLogger.getSPLLogger().getAuditLogger();
+	
+	private DataCollector _dataCollector;
+	private Actuator _actuator;
+
+	public static final int SUCCESS = 1;
+	public static final int FAILURE = -1;
+	public static final int NOT_EVALUATED = 0;
+
+	public PolicyEvaluatorImpl()
+	{
+		init();
+	}
+
+	public void init() 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "init");
+		_dataCollector = DataCollectorFactory.getDataCollector();
+
+		_actuator = ActuatorFactory.getActuator();
+
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "init");
+
+	}
+
+	public void shutdown() 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+		//PolicyLogger.log("PolicyEvaluatorImpl::shutdown");
+		// TODO Auto-generated method stub
+		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+
+	}
+
+	public Object evaluatePolicy(SPLPolicy cp, Map instances) throws SPLException 
+	{
+		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicy");
+		try
+		{	
+			//testing out actual datacollector
+
+			if(logger.isLoggable(Level.FINE))
+			{	
+				logger.fine(Thread.currentThread().getName()+
+				" Policy Evaluator calling evaluate method of SPLPolicy");
+			}	
+			int result= FAILURE;
+			if(instances != null)
+			{
+
+				if(logger.isLoggable(Level.FINE))
+				{	
+					logger.fine(Thread.currentThread().getName()+" copList!=null ");
+				}    
+				if(!instances.isEmpty() && instances.size()>0)
+				{
+					if(logger.isLoggable(Level.FINE))
+					{	
+						logger.fine(Thread.currentThread().getName() + 
+								" evaluating policy against instances");
+					}    
+					result = cp.evaluate(_dataCollector,_actuator,instances); 
+					if(auditLogger.isLoggable(Level.FINE))
+					{	
+						auditLogger.fine(Thread.currentThread().getName() + "\n"+ 
+								cp.getAuditLogString());
+					}
+					if(logger.isLoggable(Level.FINE))
+					{	
+						logger.fine(Thread.currentThread().getName() + 
+								" policy evaluation result = "+result);
+					} 
+				}
+				else
+				{
+					if(logger.isLoggable(Level.FINE))
+					{	
+						logger.fine(Thread.currentThread().getName() + 
+								" copList!=null but size="+instances.size()+" "+instances.toString());
+					}    
+				}
+			}
+			else
+			{
+
+				if(logger.isLoggable(Level.FINE))
+				{	
+					logger.fine(Thread.currentThread().getName()+" copList=null");
+				}    
+				throw new SPLException("Zero instances passed for evaluation");
+
+
+			}
+
+			if(logger.isLoggable(Level.FINE))
+			{	
+				logger.fine(Thread.currentThread().getName() + 
+						" PolicyEvaluator is done evaluating, result : "+result);
+			}	
+			logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicy");
+			if(logger.isLoggable(Level.FINE))
+			{	
+				logger.fine(Thread.currentThread().getName()+" returned 1 to client");
+			}	
+			if(result==SUCCESS)
+			{
+
+				if(!ReturnObjectStore.hasReturnValues())
+				{	
+					return new Integer(1);
+				}
+				else
+				{
+					Object returnObjectList = ReturnObjectStore.getReturnValues();
+
+					return returnObjectList;
+				}
+			}
+			else
+			{
+
+
+
+				return new Integer(FAILURE);
+			}
+
+		}
+		catch (SPLException e) 
+		{
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
+		catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+			return null;
+		}
+
+	}
+
+	
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/ReturnObjectStore.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/ReturnObjectStore.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/ReturnObjectStore.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/evaluator/impl/ReturnObjectStore.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,60 @@
+/*
+ * 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.evaluator.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ReturnObjectStore 
+{
+	private static List _returnValues = new ArrayList();
+	public static void addReturnValues(List vals)
+	{
+		
+		_returnValues.addAll(vals);
+	}
+	public static List getReturnValues()
+	{
+		
+		List retValues = new ArrayList(_returnValues);
+		
+		clearList();
+		
+		return retValues;
+	}
+	
+	
+	public static void clearList()
+	{
+		_returnValues.clear();
+	}
+	
+	public static boolean hasReturnValues()
+	{
+		if(_returnValues.size() > 0)
+		{
+			return true;
+		}
+		return false;
+	}
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Actuator.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Actuator.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Actuator.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Actuator.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,78 @@
+/*
+ * 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>
+ * This interface needs to be implemented by 
+ * the binding provider.
+ * The impl is used to perform actions or call
+ * methods
+ */
+
+
+
+package org.apache.imperius.spl.external;
+
+
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+
+
+
+public interface Actuator 
+{
+    /**
+     * Invokes the method on the given object with given argument list
+     * argumentList is a list of Argument objects and  
+     * @param className
+     * @param qualifier
+     * @param instance
+     * @param methodName
+     * @param argTypeList - list of 
+     * @param argumentList
+     * @return
+     * @throws SPLException
+     */
+	public Object invokeMethod(String className, 
+			String qualifier,
+			Object instance, 
+			String methodName, 
+			List argumentList) throws SPLException ;
+	/**
+	 * Modifies the given instance with Map of new property values
+	 * @param className
+	 * @param qualifier
+	 * @param instance
+	 * @param memberMap
+	 * @throws SPLException
+	 */
+	public void modifyInstance(String className,
+			String qualifier,
+			Object instance,
+			Map memberMap) throws SPLException ;
+	
+	/**
+	 * Invokes a policy with the given name and list of input objects
+	 * @param policyName
+	 * @param objects
+	 * @return
+	 * @throws SPLException
+	 */
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Argument.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Argument.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Argument.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Argument.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,51 @@
+/*
+ * 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 interface represents an argument passed to a method call
+ * It used in the DataCollector (while creating a method symbol)
+ * and Actuator (while invoking a method) implementations 
+ * 
+ */
+package org.apache.imperius.spl.external;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+
+
+public interface Argument {
+
+	public abstract String getReferenceTypeName();
+
+	public abstract void setReferenceTypeName(String name);
+
+	public abstract String getName();
+
+	public abstract void setName(String name);
+
+	public abstract TypeInfo getType();
+
+	public abstract void setType(String type) throws SPLException;
+
+	public abstract boolean getIsArray();
+
+	public abstract void setIsArray(boolean a);
+
+	public abstract Object getValue();
+
+	public abstract void setValue(Object value);
+
+}
\ No newline at end of file

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/DataCollector.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/DataCollector.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/DataCollector.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/DataCollector.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,121 @@
+/*
+ * 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>
+ * This interface needs to be implemented by a binding provider.
+ * 
+ * It collects data from the operating environment and formats it
+ * for use by the SPL engine
+ */
+
+package org.apache.imperius.spl.external;
+
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+
+
+
+public interface DataCollector
+{
+   /**
+    * This method is applicable to Domains that support the notion of
+    * associations. Associations are relations between 2 classes where
+    * each object has a role name and the association itself is a class.
+    * 
+    * This method retrieves instances that are associated via a given 
+    * association and roles to a source instance.
+    * 
+    * This method is used to get instances o
+    * @param className
+    * @param classPath
+    * @param resultInstancesClassFilter
+    * @param assocClass
+    * @param role
+    * @param resultRole
+    * @param srcReference
+    * @return
+    * @throws SPLException
+    */ 
+	public List getAssociatedInstanceReferences(Object srcReference,
+			String namespace, 
+			String resultInstancesClassFilter, 
+			String assocClass, 
+			String role, 
+			String resultRole) throws SPLException ;
+	
+	/**
+	 * Returns a Map of all the symbols (Properties and Methods) of the given class
+	 * The Map is of the form String -> Symbol where Symbol can be a PropertySymbol or a MethodSymbol
+	 * 
+	 * @param className
+	 * @param qualifier
+	 * @return Map of symbols 
+	 * @throws SPLException
+	 */
+    public Map getSymbolsForClass(String className, String qualifier)
+            throws SPLException;
+    
+    /**
+     * Returns a Map of instance values for the given instance
+     * The Map is of the form String (name of property or method)  -> Object (instance value)
+     *  
+     * @param className
+     * @param qualifier
+     * @param instance
+     * @return
+     * @throws SPLException
+     */
+    
+    public Map getSymbolsForInstance(String className, String qualifier, Object instance)
+            throws SPLException;
+    
+   
+    /**
+     * Determines whether an association between sourceClass and targetClass with
+     * the specified roles exist. This method is applicable only when associations 
+     * between classes are supported by the operating environment
+     * @param nameSpace
+     * @param className
+     * @param resultClass
+     * @param assocClass
+     * @param role
+     * @param resultRole
+     * @return
+     * @throws SPLException
+     */   
+    public boolean associationExists(String nameSpace, String sourceClassName,
+            String targetClassName, String assocClass, String role,
+            String resultRole) throws SPLException;
+    /**
+     * Get a list of Strings representing names of instances of the given class
+     * in the Operating Environment
+     * @param className
+     * @param qualifier
+     * @return
+     * @throws SPLException
+     */
+    
+    public List enumerateInstanceNames(String className, String qualifier)
+	throws SPLException;
+//    
+//    public String getReferenceTypeName(String reference);
+//    
+  
+    
+}
\ No newline at end of file

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Expression.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Expression.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Expression.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/Expression.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,74 @@
+/*
+ * 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>
+ * All SPL Expressions need to implement this interface
+ */
+
+package org.apache.imperius.spl.external;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+
+
+
+
+public interface Expression
+{
+    /**
+     * Evaluates the expression and return a result
+     * @return
+     * @throws SPLException
+     */
+    Object evaluate() throws SPLException;
+    
+    /**
+     * Get the return type of the expression
+     * @return
+     * @throws SPLException
+     */
+    TypeInfo getType() throws SPLException;
+    
+    /**
+     * Validate the expression for semantic correctness
+     * @return
+     * @throws SPLException
+     */
+    boolean validate() throws SPLException;
+    
+    /**
+     * Provides a string representation of the expression
+     * @return
+     */
+    String toString();
+    
+    /**
+     * is true if the expression evaluates to an array
+     * @return
+     */
+    boolean isArray();
+    
+    /**
+     * Applicable only in the case of complex return types
+     * provides the class name of the complex type
+     * @return
+     * @throws SPLException
+     */
+    
+    String getReferenceTypeName() throws SPLException;
+    
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InstanceInfo.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InstanceInfo.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InstanceInfo.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InstanceInfo.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,85 @@
+/*
+ * 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
+ * This class holds information about the managed resource instances used by
+ * a policy during evaluation
+ */
+package org.apache.imperius.spl.external;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class InstanceInfo 
+{
+	// Name of the instance
+	private String _instanceName = null;
+	// An object referencing the instance
+	private Object _instance = null;
+	// A map of the form propertyName -> Value for the instance
+	private Map _instanceSymbolsMap = new HashMap();
+	
+	private boolean isCollectInstance=false;
+	
+	public InstanceInfo() {	}
+	
+	public InstanceInfo(String name, Object obj)
+	{
+		_instanceName = name;
+		_instance = obj;
+	}
+	public InstanceInfo(String name, Object obj, boolean collectInstance)
+	{
+		_instanceName = name;
+		_instance = obj;
+		isCollectInstance=collectInstance;
+	}
+	
+	public void setInstanceSymbolsMap(Map mp)
+	{
+		_instanceSymbolsMap = mp;
+	}
+	
+	public Map getInstanceSymbolsMap()
+	{
+		return _instanceSymbolsMap;
+	}
+
+	public Object getInstance() {
+		return _instance;
+	}
+
+	public void setInstance(Object _instance) {
+		this._instance = _instance;
+	}
+
+	public String getInstanceName() {
+		return _instanceName;
+	}
+
+	public void setInstanceName(String name) {
+		_instanceName = name;
+	}
+// Should be removed
+	/*public boolean isCollectInstance() {
+		return isCollectInstance;
+	}
+
+	public void setCollectInstance(boolean isCollectInstance) {
+		this.isCollectInstance = isCollectInstance;
+	}*/
+	
+
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InternalClient.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InternalClient.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InternalClient.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/InternalClient.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,233 @@
+/*
+ * 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.external;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.*;
+import org.apache.imperius.spl.manager.PolicyManager;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.PolicyInfo;
+import org.apache.imperius.spl.parser.util.DataCollectorFactory;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+//import org.pegasus.jmpi.CIMObjectPath;
+import org.apache.imperius.util.SPLLogger;
+
+public class InternalClient
+{
+	private List inputParams =null;
+	private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+
+
+//    private static InvokePolicy internalClient=null;
+    
+    public static final int POLICY_EVALUATED_SUCCESSFULLY = 0;
+    public static final int POLICY_NOT_EVALUATED = 1;
+    public static final int POLICY_EVALUATION_FAILED = -1;
+    
+    private PolicyManager pm=null;
+    private DataCollector dc=null;
+//    private Actuator ac=null;
+    private static final String sourceClass="InternalClient";
+    
+
+   
+    public int invokePolicy(String policyName, List paramList, boolean boo)
+    {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+"InvokePolicy");
+        int returnValue=0;
+        List objectrefList=paramList;
+
+        try
+        {
+            if(objectrefList==null )
+            {
+            	Map objectMap=new HashMap();
+            	PolicyInfo policyInfo=pm.getPolicyInfo(policyName);
+				Map classQuaifierMap=policyInfo.getClassQualifierMap();
+				Iterator classit=classQuaifierMap.keySet().iterator();
+				logger.fine("number of classes in policy = "+classQuaifierMap.size());
+
+				
+				if(classQuaifierMap.size()==0 || classQuaifierMap.size()>1)
+				{
+					logger.fine("number of classes in policy should be one");
+				}
+				while(classit.hasNext())
+				{
+					String className=(String)classit.next();
+					String nameSpace=(String)classQuaifierMap.get(className);
+					List copList=dc.enumerateInstanceNames(className, nameSpace);
+					Iterator it=copList.iterator();
+					while(it.hasNext())
+					{	
+						Object copI=(Object)it.next();
+												
+						String objectName=className;
+						
+						InstanceInfo iI=new InstanceInfo(objectName,copI);
+						
+						List instanceInfoList = new ArrayList();
+						instanceInfoList.add(iI);
+
+						objectMap.put(objectName, instanceInfoList);
+						
+						Integer retVal=(Integer)pm.evaluatePolicy(policyName,objectMap);
+						if (logger.isLoggable(Level.FINE))
+							logger.fine(Thread.currentThread().getName()+" return value is = "+retVal);
+						
+						logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"invokePolicy"); 
+						
+						if (retVal.intValue() ==POLICY_EVALUATION_FAILED)
+						{
+							logger.severe("POLICY_EVALUATION_FAILED "+policyName+" "+copI.toString()+" "+retVal);
+							returnValue++;
+						}
+						else
+						{
+							logger.severe("POLICY_EVALUATION_SUCCESSFUL "+policyName+" "+copI.toString()+" "+retVal);
+							
+						}
+			            if(logger.isLoggable(Level.FINE))
+			                logger.fine(Thread.currentThread().getName()+" Internal client return value="+returnValue);
+			            objectMap.remove(instanceInfoList);
+						
+					}
+					logger.fine("internal client finished iterating over all instances ");
+					break;
+				}
+            }
+            else
+            {
+            	
+            	Map objectMap=new HashMap();
+            	PolicyInfo policyInfo=pm.getPolicyInfo(policyName); 
+				Map classQuaifierMap=policyInfo.getClassQualifierMap();
+				Iterator classit=classQuaifierMap.keySet().iterator();
+				logger.fine("number of classes in policy = "+classQuaifierMap.size());
+				
+				if(classQuaifierMap.size()==0 || classQuaifierMap.size()>1)
+				{
+					logger.fine("number of classes in policy should be one");
+				}
+				while(classit.hasNext()){
+					String className=(String)classit.next();
+					String nameSpace=(String)classQuaifierMap.get(className);
+					List copList=objectrefList;
+					Iterator it=copList.iterator();
+					while(it.hasNext())
+					{	
+						Object copI=(Object)it.next();
+						logger.fine("instance objectpath= "+copI.toString());
+						
+						String objectName=className;
+						
+						InstanceInfo iI=new InstanceInfo(objectName,copI);
+						
+						List instanceInfoList = new ArrayList();
+						instanceInfoList.add(iI);
+
+						objectMap.put(objectName, instanceInfoList);
+						
+						Integer retVal=(Integer)pm.evaluatePolicy(policyName,objectMap);
+						if (logger.isLoggable(Level.FINE))
+							logger.fine(Thread.currentThread().getName()+" return value is = "+retVal);
+						
+						logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"invokeMethod"); 
+						
+						if (retVal.intValue() ==POLICY_EVALUATION_FAILED )
+						{
+							logger.fine("POLICY_EVALUATION_FAILED || POLICY_NOT_EVALUATED "+policyName+" "+copI.toString()+" "+retVal);
+							returnValue++;
+						}
+						else
+						{
+							logger.fine("POLICY_EVALUATION_SUCCESSFUL "+policyName+" "+copI.toString()+" "+retVal);
+							
+						}
+			            if(logger.isLoggable(Level.FINE))
+			                logger.fine(Thread.currentThread().getName()+" Internal client return value="+returnValue);
+			            objectMap.remove(instanceInfoList);
+						
+					}
+					logger.fine("internal client finished iterating over all instances ");
+					break;
+				}
+            }
+
+
+			
+			
+			return 0;
+              
+        }
+        catch(SPLException e)
+        {
+            logger.severe(e.getMessage());
+        }
+        
+        logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"InvokeMethod");
+        if(logger.isLoggable(Level.FINE))
+            logger.fine(Thread.currentThread().getName()+" Internal client return value is -1");
+        
+        return -1;
+    }
+    
+    private InternalClient()
+    {
+        
+        
+    }
+    
+    
+    
+    public Object clone() throws CloneNotSupportedException
+    {
+        throw new CloneNotSupportedException();
+    }
+    
+    public InternalClient( PolicyManager policyManager) {
+        logger.entering(sourceClass,Thread.currentThread().getName()+" "+"init");
+        
+            logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "init");
+            
+            
+            dc=DataCollectorFactory.getDataCollector();
+            pm=policyManager;
+            
+            
+            logger.exiting(sourceClass,Thread.currentThread().getName()+" "+"init");
+            
+        
+    }  
+  
+
+
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/TypeConstants.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/TypeConstants.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/TypeConstants.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/external/TypeConstants.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,121 @@
+/*
+ * 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>
+ *
+ * Constants for types supported by SPL
+ */
+package org.apache.imperius.spl.external;
+
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+
+public class TypeConstants
+{
+    
+    public static final int INVALID = -1;
+    public static final int booleanType = 1;
+    
+    public static final int stringType = 2;
+    
+    public static final int numericType = 3;
+    
+    public static final int dateTime = 4;
+    
+    public static final int byteType = 5;
+    
+    public static final int charType = 6;
+    
+    public static final int shortType = 7;
+    
+    public static final int intType = 8;
+    
+    public static final int longType = 9;
+    
+    public static final int floatType = 10;
+    
+    public static final int doubleType = 11;
+    
+    //public static final int dateTime = 12;
+    
+    public static final int referenceType = 13;
+    
+   
+    
+    public static int getActualType(String type) throws SPLException
+    {
+        
+        
+        int retTp = -1;
+        
+        if (type.equals("Uint8") || type.equals("Sint8"))
+        {
+            retTp = TypeConstants.byteType;
+        }
+        else if (type.equals("Uint16") || type.equals("Sint16"))
+        {
+            retTp = TypeConstants.shortType;
+        }
+        else if (type.equals("Uint32") || type.equals("Sint32"))
+        {
+            retTp = TypeConstants.intType;
+        }
+        else if (type.equals("Uint64") || type.equals("Sint64"))
+        {
+            retTp = TypeConstants.longType;
+        }
+        else if (type.equals("Real32"))
+        {
+            retTp = TypeConstants.floatType;
+        }
+        else if (type.equals("Real64"))
+        {
+            retTp = TypeConstants.doubleType;
+        }
+        else if (type.equals("Boolean"))
+        {
+            retTp = TypeConstants.booleanType;
+        }
+        else if (type.equals("Char16"))
+        {
+            retTp = TypeConstants.charType;
+        }
+        else if (type.equals("String"))
+        {
+            retTp = TypeConstants.stringType;
+        } // CHANGED from CIMDateTime to SPLDateTime
+        else if (type.equals("DateTime"))
+        {
+            retTp = TypeConstants.dateTime;
+        }
+        else if (type.equals("Reference") || type.equals("Reference[]"))
+        {
+            retTp = TypeConstants.referenceType;
+        }
+        
+        if(retTp ==-1)
+        {
+           
+            throw new SPLException("invalid type");
+            
+        }
+        
+      
+        return retTp;
+    }
+    
+   
+    
+}

Added: incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/manager/PolicyManager.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/manager/PolicyManager.java?rev=606479&view=auto
==============================================================================
--- incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/manager/PolicyManager.java (added)
+++ incubator/imperius/trunk/trunk/modules/imperius-splcore/src/org/apache/imperius/spl/manager/PolicyManager.java Sat Dec 22 11:33:46 2007
@@ -0,0 +1,145 @@
+/*
+ * 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>
+ * 
+ * This is the primary interface into the SPL Engine
+ *
+ */
+
+package org.apache.imperius.spl.manager;
+
+import java.io.IOException;
+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.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.impl.PolicyInfo;
+
+
+public interface PolicyManager
+{
+    /**
+     * Returns the policy as a String
+     * @param name
+     * @return
+     * @throws SPLException
+     */
+    
+    public String getPolicy(String name)
+    	throws SPLException;
+    
+    /**
+     * Returns a policyInfo object that contains the anchor class names and 
+     * qualifiers.
+     * @param policyName
+     * @return
+     * @throws SPLException
+     */
+    
+    public PolicyInfo getPolicyInfo(String policyName)
+    	throws SPLException;
+    
+    /**
+     * Creates a policy with the specified name and string
+     * @param policyName
+     * @param policyString
+     * @return
+     * @throws SPLException
+     */
+    
+    public boolean createPolicy(String policyName, String policyString) 
+    	throws SPLException;
+    
+    /**
+     * Updates the policy with the given name with the provided string
+     * @param policyName
+     * @param policyString
+     * @throws SPLException
+     */
+    public void updatePolicy(String policyName, String policyString) 
+    	throws SPLException;
+    
+    /**
+     * Deletes the policy with the given name
+     * @param policyName
+     * @throws SPLException
+     */
+    public void deletePolicy(String policyName)
+    	throws SPLException;
+    
+    /**
+     * Returns a map (policyName -> policy String) of all policies 
+     * stored in the repository
+     * @return
+     * @throws SPLException
+     */
+    public Map getAllPolicies()
+    	throws SPLException;
+    
+    /**
+     * Gets a list of names of all policies in the system
+     * @return
+     * @throws SPLException
+     */
+    public List getAllPolicyNames() throws SPLException;
+    
+    /**
+     * Evaluates the policy with the given name. The input map should be of the
+     * following format
+     * <fully qualified classname> -> List of InstanceInfo objects
+     * 
+     * Where InstanceInfo object contains <instance name> and an empty object
+     * @param policyName
+     * @param instance
+     * @return
+     * @throws SPLException
+     */
+    
+    public Object evaluatePolicy(String policyName, Map instance) 
+    	throws SPLException;
+    
+    /**
+     * Initializes the SPL Engine, Inputs are instances of DataCollector and Actuator
+     * @param dc
+     * @param ac
+     * @throws SPLException
+     * @throws IOException
+     */
+    public void init(DataCollector dc, Actuator ac) 
+    	throws SPLException, IOException;
+    
+    public void setSPLHome(String location);
+    
+    public String getSPLHome();
+    
+    public Object evaluatePolicyString(String policyName, String policyString, Map instances) throws SPLException; 
+	
+    
+    public void enableLogging(boolean enableOrDisable);
+    
+    /**
+     * Shutsdown the SPL Engine
+     *
+     */
+    public void shutdown();
+    
+    public boolean validatePolicyString(String policyString) throws SPLException;
+    
+ 
+}



Mime
View raw message