You are viewing a plain text version of this content. The canonical link for it is here.
Posted to imperius-commits@incubator.apache.org by ke...@apache.org on 2008/01/11 18:57:14 UTC
svn commit: r611261 [6/43] - in /incubator/imperius/trunk: ./
imperius-javaspl/ imperius-javaspl/src/main/java/org/apache/imperius/javaspl/
imperius-splcore/
imperius-splcore/src/main/antlr/org/apache/imperius/spl/parser/compiler/
imperius-splcore/src/...
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/InternalClient.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/InternalClient.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/InternalClient.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/InternalClient.java Fri Jan 11 10:56:30 2008
@@ -1,233 +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 <pr...@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");
-
-
- }
-
-
-
-
-}
+/*
+ * 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 <pr...@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");
+
+
+ }
+
+
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/InternalClient.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/TypeConstants.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/TypeConstants.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/TypeConstants.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/TypeConstants.java Fri Jan 11 10:56:30 2008
@@ -1,121 +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 <jn...@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;
- }
-
-
-
-}
+/*
+ * 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 <jn...@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;
+ }
+
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/TypeConstants.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/PolicyManager.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/PolicyManager.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/PolicyManager.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/PolicyManager.java Fri Jan 11 10:56:30 2008
@@ -1,145 +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 <pr...@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;
-
-
-}
+/*
+ * 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 <pr...@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;
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/PolicyManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/impl/PolicyManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/impl/PolicyManagerImpl.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/impl/PolicyManagerImpl.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/impl/PolicyManagerImpl.java Fri Jan 11 10:56:30 2008
@@ -1,283 +1,283 @@
-/*
- * 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 <pr...@in.ibm.com>
- *
- */
-
-
-
-package org.apache.imperius.spl.manager.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.impl.PolicyDataStoreImpl;
-import org.apache.imperius.spl.evaluator.PolicyEvaluator;
-import org.apache.imperius.spl.evaluator.impl.PolicyEvaluatorImpl;
-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.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.spl.parser.util.ActuatorFactory;
-import org.apache.imperius.spl.parser.util.DataCollectorFactory;
-import org.apache.imperius.util.SPLLogger;
-
-
-
-public class PolicyManagerImpl implements PolicyManager
-{
-
-
- private PolicyDataStore _policyDataStore = null;
- private PolicyEvaluator _policyEvaluator = null;
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="PolicyManagerImpl";
-
- private static Logger auditLogger = SPLLogger.getSPLLogger().getAuditLogger();
-
-
-
-
- public PolicyManagerImpl(DataCollector dc, Actuator ac)
- {
- init(dc,ac);
- }
- public void init(DataCollector dc, Actuator ac)
- {
-
-
- ActuatorFactory.registerActuator(ac);
- DataCollectorFactory.registerDataCollector(dc);
- _policyDataStore = new PolicyDataStoreImpl();
- _policyEvaluator = new PolicyEvaluatorImpl();
-
-
-
- }
-
-
-
- public Map getAllPolicies() throws SPLException
- {
-
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicies");
- Map allPolicies = _policyDataStore.getAllPolicies();
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"getAllPolicies invoked");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicies");
- return allPolicies;
- }
-
- public List getAllPolicyNames() throws SPLException
- {
-
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicyNames");
- List allPolicyNames = _policyDataStore.getAllPolicyNames();
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"getAllPolicyNames invoked");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicyNames");
- return allPolicyNames;
-
- }
-
- public String getPolicy(String policyName) throws SPLException
- {
-
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
- String ci = _policyDataStore.getPolicy(policyName);
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"getPolicy invoked :"+policyName);
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
- return ci;
-
- }
-
-
-
- public void shutdown()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"Policy Manager Shut Down initiated");
-
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
-
-
- }
-
- public void updatePolicy(String policyName, String policyString) throws SPLException
- {
-
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "updatePolicy");
- System.out.println("***********"+"UpdatePolicy : "+policyName+"***********");
- _policyDataStore.updatePolicy(policyName, policyString);
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"updatePolicy invoked :"+policyName);
- System.out.println("***********"+"UpdatePolicy complete"+"***********");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "updatePolicy");
-
-
- }
-
- public boolean createPolicy(String policyName, String policyString) throws SPLException
- {
- try
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
- System.out.println("***********"+"CreatePolicy : "+policyName+"***********");
-
- boolean res = _policyDataStore.createPolicy(policyName,policyString);
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"createPolicy invoked :"+policyName);
- System.out.println("***********"+"CreatePolicy complete"+"***********");
-
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
-
- return res;
- }
- catch (SPLException e){
- logger.severe(e.getLocalizedMessage());
- e.printStackTrace();
- throw new SPLException(e.getLocalizedMessage());
-
- }
-
-
- }
-
- public void deletePolicy(String policyName) throws SPLException
- {
- try
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
- System.out.println("***********"+"DeletePolicy : "+policyName+"***********");
-
- _policyDataStore.deletePolicy(policyName);
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"deletePolicy invoked :"+policyName);
-
- System.out.println("***********"+"DeletePolicy complete"+"***********");
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
- }
- catch (SPLException e)
- {
- logger.severe(e.getLocalizedMessage());
- e.printStackTrace();
- throw new SPLException(e.getLocalizedMessage());
-
- }
-
- }
-
- public Object evaluatePolicy(String policyName, Map instances) throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicy");
-
- SPLPolicy internalPolicyObject = _policyDataStore.getInternalPolicyObject(policyName);
-
-
- Object result = _policyEvaluator.evaluatePolicy(internalPolicyObject,instances);
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicy");
-
- return result;
- }
- public PolicyInfo getPolicyInfo(String policyName) throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName() + " " + "getPolicyInfo");
- PolicyInfo pi=this._policyDataStore.getPolicyInfo(policyName);
- logger.exiting(sourceClass,Thread.currentThread().getName() + " " + "getPolicyInfo");
-
- return pi;
- }
-
-
- public Object evaluatePolicyString(String policyName, String policyString, Map instances) throws SPLException
- {
- try
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
- Object result;
-// boolean res = _policyDataStore.createPolicy(policyName,policyString);
-// if(res)
-// {
-// SPLPolicy internalPolicyObject = _policyDataStore.getInternalPolicyObject(policyName);
-
-
-// result = _policyEvaluator.evaluatePolicy(internalPolicyObject,instances);
- SPLPolicy cp=_policyDataStore.createSPLPolicyObject(policyName, policyString);
- result=_policyEvaluator.evaluatePolicy(cp, instances);
- if(auditLogger.isLoggable(Level.FINE))
- auditLogger.fine(Thread.currentThread().getName()+"evaluatePolicyString invoked :"+policyName);
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
-
-// }
-// else
-// {
-// result=null;
-// }
-
- return result;
- }
- catch (SPLException e){
- logger.severe(e.getLocalizedMessage());
- e.printStackTrace();
- throw new SPLException(e.getLocalizedMessage());
-
- }
-
-
- }
- public void setSPLHome(String location)
- {
- SPLLogger.SPL_HOME = location;
-
- }
- public String getSPLHome()
- {
- return SPLLogger.SPL_HOME;
- }
- public void enableLogging(boolean enableOrDisable)
- {
- SPLLogger.ENABLE_SPL_LOGGING = enableOrDisable;
-
- }
-
- public boolean validatePolicyString(String policyString) throws SPLException
- {
- logger.entering(sourceClass,Thread.currentThread().getName() + " " + "validatePolicyString");
- boolean pi=this._policyDataStore.validatePolicyString(policyString);
- logger.exiting(sourceClass,Thread.currentThread().getName() + " " + "validatePolicyString");
-
- return pi;
- }
-
-
-}
+/*
+ * 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 <pr...@in.ibm.com>
+ *
+ */
+
+
+
+package org.apache.imperius.spl.manager.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.impl.PolicyDataStoreImpl;
+import org.apache.imperius.spl.evaluator.PolicyEvaluator;
+import org.apache.imperius.spl.evaluator.impl.PolicyEvaluatorImpl;
+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.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.spl.parser.util.ActuatorFactory;
+import org.apache.imperius.spl.parser.util.DataCollectorFactory;
+import org.apache.imperius.util.SPLLogger;
+
+
+
+public class PolicyManagerImpl implements PolicyManager
+{
+
+
+ private PolicyDataStore _policyDataStore = null;
+ private PolicyEvaluator _policyEvaluator = null;
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="PolicyManagerImpl";
+
+ private static Logger auditLogger = SPLLogger.getSPLLogger().getAuditLogger();
+
+
+
+
+ public PolicyManagerImpl(DataCollector dc, Actuator ac)
+ {
+ init(dc,ac);
+ }
+ public void init(DataCollector dc, Actuator ac)
+ {
+
+
+ ActuatorFactory.registerActuator(ac);
+ DataCollectorFactory.registerDataCollector(dc);
+ _policyDataStore = new PolicyDataStoreImpl();
+ _policyEvaluator = new PolicyEvaluatorImpl();
+
+
+
+ }
+
+
+
+ public Map getAllPolicies() throws SPLException
+ {
+
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicies");
+ Map allPolicies = _policyDataStore.getAllPolicies();
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"getAllPolicies invoked");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicies");
+ return allPolicies;
+ }
+
+ public List getAllPolicyNames() throws SPLException
+ {
+
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicyNames");
+ List allPolicyNames = _policyDataStore.getAllPolicyNames();
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"getAllPolicyNames invoked");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAllPolicyNames");
+ return allPolicyNames;
+
+ }
+
+ public String getPolicy(String policyName) throws SPLException
+ {
+
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
+ String ci = _policyDataStore.getPolicy(policyName);
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"getPolicy invoked :"+policyName);
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getPolicy");
+ return ci;
+
+ }
+
+
+
+ public void shutdown()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"Policy Manager Shut Down initiated");
+
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "shutdown");
+
+
+ }
+
+ public void updatePolicy(String policyName, String policyString) throws SPLException
+ {
+
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "updatePolicy");
+ System.out.println("***********"+"UpdatePolicy : "+policyName+"***********");
+ _policyDataStore.updatePolicy(policyName, policyString);
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"updatePolicy invoked :"+policyName);
+ System.out.println("***********"+"UpdatePolicy complete"+"***********");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "updatePolicy");
+
+
+ }
+
+ public boolean createPolicy(String policyName, String policyString) throws SPLException
+ {
+ try
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
+ System.out.println("***********"+"CreatePolicy : "+policyName+"***********");
+
+ boolean res = _policyDataStore.createPolicy(policyName,policyString);
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"createPolicy invoked :"+policyName);
+ System.out.println("***********"+"CreatePolicy complete"+"***********");
+
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
+
+ return res;
+ }
+ catch (SPLException e){
+ logger.severe(e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new SPLException(e.getLocalizedMessage());
+
+ }
+
+
+ }
+
+ public void deletePolicy(String policyName) throws SPLException
+ {
+ try
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
+ System.out.println("***********"+"DeletePolicy : "+policyName+"***********");
+
+ _policyDataStore.deletePolicy(policyName);
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"deletePolicy invoked :"+policyName);
+
+ System.out.println("***********"+"DeletePolicy complete"+"***********");
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "deletePolicy");
+ }
+ catch (SPLException e)
+ {
+ logger.severe(e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new SPLException(e.getLocalizedMessage());
+
+ }
+
+ }
+
+ public Object evaluatePolicy(String policyName, Map instances) throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicy");
+
+ SPLPolicy internalPolicyObject = _policyDataStore.getInternalPolicyObject(policyName);
+
+
+ Object result = _policyEvaluator.evaluatePolicy(internalPolicyObject,instances);
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "evaluatePolicy");
+
+ return result;
+ }
+ public PolicyInfo getPolicyInfo(String policyName) throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName() + " " + "getPolicyInfo");
+ PolicyInfo pi=this._policyDataStore.getPolicyInfo(policyName);
+ logger.exiting(sourceClass,Thread.currentThread().getName() + " " + "getPolicyInfo");
+
+ return pi;
+ }
+
+
+ public Object evaluatePolicyString(String policyName, String policyString, Map instances) throws SPLException
+ {
+ try
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
+ Object result;
+// boolean res = _policyDataStore.createPolicy(policyName,policyString);
+// if(res)
+// {
+// SPLPolicy internalPolicyObject = _policyDataStore.getInternalPolicyObject(policyName);
+
+
+// result = _policyEvaluator.evaluatePolicy(internalPolicyObject,instances);
+ SPLPolicy cp=_policyDataStore.createSPLPolicyObject(policyName, policyString);
+ result=_policyEvaluator.evaluatePolicy(cp, instances);
+ if(auditLogger.isLoggable(Level.FINE))
+ auditLogger.fine(Thread.currentThread().getName()+"evaluatePolicyString invoked :"+policyName);
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "createPolicy");
+
+// }
+// else
+// {
+// result=null;
+// }
+
+ return result;
+ }
+ catch (SPLException e){
+ logger.severe(e.getLocalizedMessage());
+ e.printStackTrace();
+ throw new SPLException(e.getLocalizedMessage());
+
+ }
+
+
+ }
+ public void setSPLHome(String location)
+ {
+ SPLLogger.SPL_HOME = location;
+
+ }
+ public String getSPLHome()
+ {
+ return SPLLogger.SPL_HOME;
+ }
+ public void enableLogging(boolean enableOrDisable)
+ {
+ SPLLogger.ENABLE_SPL_LOGGING = enableOrDisable;
+
+ }
+
+ public boolean validatePolicyString(String policyString) throws SPLException
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName() + " " + "validatePolicyString");
+ boolean pi=this._policyDataStore.validatePolicyString(policyString);
+ logger.exiting(sourceClass,Thread.currentThread().getName() + " " + "validatePolicyString");
+
+ return pi;
+ }
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/manager/impl/PolicyManagerImpl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/ASTWithLineNumber.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/ASTWithLineNumber.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/ASTWithLineNumber.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/ASTWithLineNumber.java Fri Jan 11 10:56:30 2008
@@ -1,63 +1,63 @@
-/*
- * 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.spl.parser.compiler;
-
-
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-
-import antlr.*;
-import antlr.collections.*;
-import antlr.debug.misc.ASTFrame;
-
-/**
- * CommonAST(default) from Antlr does not store line information.
- * So we extend it, so use setASTNodeClass() to set it up in parser.
- */
-public class ASTWithLineNumber extends CommonAST {
-
- private static final long serialVersionUID = 1L;
- private int line_ = 0;
-
- public void initialize(Token tok) {
- super.initialize(tok);
- line_ = tok.getLine();
- }
-
- public void initialize (AST ast) {
- super.initialize(ast);
- if (ast instanceof ASTWithLineNumber){
- line_ = ((ASTWithLineNumber)ast).getLine();
- }
- }
-
- public int getLine() {
- return line_;
- }
-
- public void displayTree(AST r){
- final ASTFrame frame = new ASTFrame("Java AST", r);
- frame.setVisible(true);
- frame.addWindowListener(
- new WindowAdapter() {
- public void windowClosing (WindowEvent e) {
- frame.setVisible(true); // hide the Frame
- frame.dispose();
- System.exit(0);
- }
- }
- );
- }
-}
+/*
+ * 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.spl.parser.compiler;
+
+
+
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+
+import antlr.*;
+import antlr.collections.*;
+import antlr.debug.misc.ASTFrame;
+
+/**
+ * CommonAST(default) from Antlr does not store line information.
+ * So we extend it, so use setASTNodeClass() to set it up in parser.
+ */
+public class ASTWithLineNumber extends CommonAST {
+
+ private static final long serialVersionUID = 1L;
+ private int line_ = 0;
+
+ public void initialize(Token tok) {
+ super.initialize(tok);
+ line_ = tok.getLine();
+ }
+
+ public void initialize (AST ast) {
+ super.initialize(ast);
+ if (ast instanceof ASTWithLineNumber){
+ line_ = ((ASTWithLineNumber)ast).getLine();
+ }
+ }
+
+ public int getLine() {
+ return line_;
+ }
+
+ public void displayTree(AST r){
+ final ASTFrame frame = new ASTFrame("Java AST", r);
+ frame.setVisible(true);
+ frame.addWindowListener(
+ new WindowAdapter() {
+ public void windowClosing (WindowEvent e) {
+ frame.setVisible(true); // hide the Frame
+ frame.dispose();
+ System.exit(0);
+ }
+ }
+ );
+ }
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/ASTWithLineNumber.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java Fri Jan 11 10:56:30 2008
@@ -1,224 +1,224 @@
-/*
- * 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 <jn...@us.ibm.com>
- *
- */
-
-
-
-package org.apache.imperius.spl.parser.compiler;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.imperius.spl.external.DataCollector;
-import org.apache.imperius.spl.external.Expression;
-import org.apache.imperius.spl.external.InstanceInfo;
-import org.apache.imperius.spl.parser.compiler.symboltable.MethodSymbol;
-import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
-import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.spl.parser.statements.actions.impl.AnchorMethodInvokeAction;
-import org.apache.imperius.spl.parser.util.DataCollectorFactory;
-import org.apache.imperius.spl.parser.util.TypeInfo;
-import org.apache.imperius.spl.parser.util.TypeResolver;
-
-
-public class IdentPrimaryTuple
-{
- private Expression _arrExp = null;
- private List _paramList ;
- private String _identifier = "";
- private boolean _isMethod = false;
- private SPLSymbolTable _symbolTable;
- private String _classType = null;
-
- public IdentPrimaryTuple(Expression arrExp,
- List paramList, String id, boolean isMethod,
- SPLSymbolTable sTab)
- {
- _arrExp = arrExp;
- _paramList = paramList;
- _identifier = id;
- _isMethod = isMethod;
- _symbolTable = sTab;
-
- }
-
- public String getPropertyName()
- {
- return _identifier;
- }
-
- public void setSymbolTable(SPLSymbolTable spt)
- {
- _symbolTable = spt;
- }
- // no input object means that the symbol table already has anchor object
- // populated
- public Object evaluate() throws SPLException
- {
- Object returnValue = null;
- if(_isMethod)
- {
- Object instance = _symbolTable.getInstance(_classType);
- String qualifier = _symbolTable.getQualifierForClass(_classType);
- returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable,
- _classType, qualifier, _identifier, _paramList,instance);
- }
- else
- {
- Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
- returnValue = sym.getValue();
- }
-
-
- return returnValue;
-
- }
- public Object evaluate(Object parentObject) throws SPLException
- {
- Object returnValue = null;
-
- DataCollector dc = DataCollectorFactory.getDataCollector();
- String qualifier = _symbolTable.getQualifierForClass(_classType);
- Map symbolsofInstance = dc.getSymbolsForInstance(_classType,
- qualifier,
- parentObject);
- Map instanceMap = new HashMap();
- instanceMap.put(_classType, parentObject);
- _symbolTable.populateInstanceValuesForInstance(_classType,
- _classType,
- parentObject,
- symbolsofInstance);
-
- Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
-
- //_symbolTable.setAnchors(mapOfAnchorClassToInstance);
- if(_isMethod)
- {
-
- returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable,
- _classType, qualifier, _identifier, _paramList, parentObject);
- }
- else
- {
-
- //Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
- returnValue = sym.getValue();
-
- }
-
- return returnValue;
- }
-
- public TypeInfo validate(String classTypeOrVariableName) throws SPLException
- {
- TypeInfo typeInfo = new TypeInfo();
- _classType = classTypeOrVariableName;
- // ensure symbol table is populated
- _populateSymbolTable(_classType);
-
- Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
-
- if(_isMethod)
- {
- if(sym instanceof MethodSymbol)
- {
- typeInfo = _validateActualParameters(sym,classTypeOrVariableName);
-
- }
- else
- {
- throw new SPLException("Symbol " + _identifier + "is not a method");
- }
- }
- else
- {
- TypeInfo tp = sym.getType();
- boolean isArray = sym.isArray();
- if(_arrExp != null) // expression is like A.b[2] which means
- { // the result is not an array
- isArray = false;
- }
- String resultClass = null;
- if(TypeResolver.isReference(tp))
- {
- resultClass = sym.getReferenceTypeName();
- typeInfo.setReferenceTypeName(resultClass);
- typeInfo.setType(tp.getType());
- typeInfo.setIsArray(isArray);
- }
- else
- {
- typeInfo.setType(tp.getType());
- typeInfo.setIsArray(isArray);
- }
-
- }
-
-
-
- return typeInfo;
-
- }
-
- private TypeInfo _validateActualParameters(Symbol sym,
- String classType) throws SPLException
- {
- TypeInfo returnTypeInfo = new TypeInfo();
- String returnClassName = null;
- AnchorMethodInvokeAction.validateActualParameters(_symbolTable,
- classType, _identifier, _paramList);
- TypeInfo returnType = sym.getType();
- boolean isArray = sym.isArray();
- if(TypeResolver.isReference(returnType))
- {
- returnClassName = sym.getReferenceTypeName();
- returnTypeInfo.setIsArray(isArray);
- returnTypeInfo.setReferenceTypeName(returnClassName);
- returnTypeInfo.setType(returnType.getType());
-
- }
- else
- {
- returnTypeInfo.setIsArray(isArray);
- returnTypeInfo.setType(returnType.getType());
- }
- return returnTypeInfo;
-
-
-
- }
-
- private void _populateSymbolTable(String classType) throws SPLException
- {
- String qualifierName = null;
- if(_symbolTable.getAnchorData() == null)
- {
- List instanceInfoList = new ArrayList();
- instanceInfoList.add(new InstanceInfo(classType, new Object()));
- _symbolTable.addAnchor(classType,qualifierName,instanceInfoList);
-
- }
-
- }
-
-
-}
+/*
+ * 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 <jn...@us.ibm.com>
+ *
+ */
+
+
+
+package org.apache.imperius.spl.parser.compiler;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.imperius.spl.external.DataCollector;
+import org.apache.imperius.spl.external.Expression;
+import org.apache.imperius.spl.external.InstanceInfo;
+import org.apache.imperius.spl.parser.compiler.symboltable.MethodSymbol;
+import org.apache.imperius.spl.parser.compiler.symboltable.SPLSymbolTable;
+import org.apache.imperius.spl.parser.compiler.symboltable.Symbol;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.spl.parser.statements.actions.impl.AnchorMethodInvokeAction;
+import org.apache.imperius.spl.parser.util.DataCollectorFactory;
+import org.apache.imperius.spl.parser.util.TypeInfo;
+import org.apache.imperius.spl.parser.util.TypeResolver;
+
+
+public class IdentPrimaryTuple
+{
+ private Expression _arrExp = null;
+ private List _paramList ;
+ private String _identifier = "";
+ private boolean _isMethod = false;
+ private SPLSymbolTable _symbolTable;
+ private String _classType = null;
+
+ public IdentPrimaryTuple(Expression arrExp,
+ List paramList, String id, boolean isMethod,
+ SPLSymbolTable sTab)
+ {
+ _arrExp = arrExp;
+ _paramList = paramList;
+ _identifier = id;
+ _isMethod = isMethod;
+ _symbolTable = sTab;
+
+ }
+
+ public String getPropertyName()
+ {
+ return _identifier;
+ }
+
+ public void setSymbolTable(SPLSymbolTable spt)
+ {
+ _symbolTable = spt;
+ }
+ // no input object means that the symbol table already has anchor object
+ // populated
+ public Object evaluate() throws SPLException
+ {
+ Object returnValue = null;
+ if(_isMethod)
+ {
+ Object instance = _symbolTable.getInstance(_classType);
+ String qualifier = _symbolTable.getQualifierForClass(_classType);
+ returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable,
+ _classType, qualifier, _identifier, _paramList,instance);
+ }
+ else
+ {
+ Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
+ returnValue = sym.getValue();
+ }
+
+
+ return returnValue;
+
+ }
+ public Object evaluate(Object parentObject) throws SPLException
+ {
+ Object returnValue = null;
+
+ DataCollector dc = DataCollectorFactory.getDataCollector();
+ String qualifier = _symbolTable.getQualifierForClass(_classType);
+ Map symbolsofInstance = dc.getSymbolsForInstance(_classType,
+ qualifier,
+ parentObject);
+ Map instanceMap = new HashMap();
+ instanceMap.put(_classType, parentObject);
+ _symbolTable.populateInstanceValuesForInstance(_classType,
+ _classType,
+ parentObject,
+ symbolsofInstance);
+
+ Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
+
+ //_symbolTable.setAnchors(mapOfAnchorClassToInstance);
+ if(_isMethod)
+ {
+
+ returnValue = AnchorMethodInvokeAction.invokeClassMethod(_symbolTable,
+ _classType, qualifier, _identifier, _paramList, parentObject);
+ }
+ else
+ {
+
+ //Symbol sym = _symbolTable.getSymbol(_classType + "." + _identifier);
+ returnValue = sym.getValue();
+
+ }
+
+ return returnValue;
+ }
+
+ public TypeInfo validate(String classTypeOrVariableName) throws SPLException
+ {
+ TypeInfo typeInfo = new TypeInfo();
+ _classType = classTypeOrVariableName;
+ // ensure symbol table is populated
+ _populateSymbolTable(_classType);
+
+ Symbol sym = _symbolTable.getSymbol(classTypeOrVariableName + "." + _identifier);
+
+ if(_isMethod)
+ {
+ if(sym instanceof MethodSymbol)
+ {
+ typeInfo = _validateActualParameters(sym,classTypeOrVariableName);
+
+ }
+ else
+ {
+ throw new SPLException("Symbol " + _identifier + "is not a method");
+ }
+ }
+ else
+ {
+ TypeInfo tp = sym.getType();
+ boolean isArray = sym.isArray();
+ if(_arrExp != null) // expression is like A.b[2] which means
+ { // the result is not an array
+ isArray = false;
+ }
+ String resultClass = null;
+ if(TypeResolver.isReference(tp))
+ {
+ resultClass = sym.getReferenceTypeName();
+ typeInfo.setReferenceTypeName(resultClass);
+ typeInfo.setType(tp.getType());
+ typeInfo.setIsArray(isArray);
+ }
+ else
+ {
+ typeInfo.setType(tp.getType());
+ typeInfo.setIsArray(isArray);
+ }
+
+ }
+
+
+
+ return typeInfo;
+
+ }
+
+ private TypeInfo _validateActualParameters(Symbol sym,
+ String classType) throws SPLException
+ {
+ TypeInfo returnTypeInfo = new TypeInfo();
+ String returnClassName = null;
+ AnchorMethodInvokeAction.validateActualParameters(_symbolTable,
+ classType, _identifier, _paramList);
+ TypeInfo returnType = sym.getType();
+ boolean isArray = sym.isArray();
+ if(TypeResolver.isReference(returnType))
+ {
+ returnClassName = sym.getReferenceTypeName();
+ returnTypeInfo.setIsArray(isArray);
+ returnTypeInfo.setReferenceTypeName(returnClassName);
+ returnTypeInfo.setType(returnType.getType());
+
+ }
+ else
+ {
+ returnTypeInfo.setIsArray(isArray);
+ returnTypeInfo.setType(returnType.getType());
+ }
+ return returnTypeInfo;
+
+
+
+ }
+
+ private void _populateSymbolTable(String classType) throws SPLException
+ {
+ String qualifierName = null;
+ if(_symbolTable.getAnchorData() == null)
+ {
+ List instanceInfoList = new ArrayList();
+ instanceInfoList.add(new InstanceInfo(classType, new Object()));
+ _symbolTable.addAnchor(classType,qualifierName,instanceInfoList);
+
+ }
+
+ }
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/IdentPrimaryTuple.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/symboltable/AnchorData.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/symboltable/AnchorData.java?rev=611261&r1=611260&r2=611261&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/symboltable/AnchorData.java (original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/symboltable/AnchorData.java Fri Jan 11 10:56:30 2008
@@ -1,163 +1,163 @@
-/*
- * 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.spl.parser.compiler.symboltable;
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-import org.apache.imperius.spl.external.InstanceInfo;
-import org.apache.imperius.spl.parser.exceptions.SPLException;
-import org.apache.imperius.util.SPLLogger;
-
-
-public class AnchorData
-{
- private static Logger logger = SPLLogger.getSPLLogger().getLogger();
- private static final String sourceClass="AnchorData";
-
- private Map _classNameToQualifierMap;
- private Map _classNameToInstanceInfoListMap;
-
- public AnchorData()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "AnchorData");
- _classNameToQualifierMap = new Hashtable();
- _classNameToInstanceInfoListMap = new Hashtable();
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "AnchorData");
-
- }
-
- public List getAnchorClassList()
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAnchorClassList");
- List anchorClassList = new ArrayList();
- Iterator anchorKeySetIt = _classNameToInstanceInfoListMap.keySet().iterator();
- while(anchorKeySetIt.hasNext())
- {
- String className = (String)anchorKeySetIt.next();
- anchorClassList.add(className);
- }
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAnchorClassList");
- return anchorClassList;
-
- }
-
- public Object getInstance(String instanceName)
- {
- logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getInstance");
- Object instance = null;
- Iterator anchorKeySetIt = _classNameToInstanceInfoListMap.keySet().iterator();
- while(anchorKeySetIt.hasNext())
- {
- String className = (String)anchorKeySetIt.next();
- List instanceInfoList = (List)_classNameToInstanceInfoListMap.get(className);
- Iterator instanceInfoListIt = instanceInfoList.iterator();
- while(instanceInfoListIt.hasNext())
- {
- InstanceInfo ii = (InstanceInfo)instanceInfoListIt.next();
- if(ii.getInstanceName().equals(instanceName))
- {
- instance = ii.getInstance();
- return instance;
-
- }
- }
- }
-
- logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getInstance");
- return instance;
-
-
- }
-
- public void insertInstanceObject(String className,
- String instanceName,
- Object instance) throws SPLException
- {
-
- List instanceInfoList = (List)_classNameToInstanceInfoListMap.get(className);
-
-
- boolean instanceFound = false;
-
- Iterator instanceInfoListIt = instanceInfoList.iterator();
- while(instanceInfoListIt.hasNext())
- {
- InstanceInfo instanceInfo = (InstanceInfo) instanceInfoListIt.next();
- //System.out.println(" instanceInfo.getInstanceName() "+instanceInfo.getInstanceName());
- //System.out.println(" instanceName "+instanceName);
-
- if(instanceInfo.getInstanceName() != null)
- {
- if(instanceInfo.getInstanceName().equalsIgnoreCase(instanceName))
- {
- //System.out.println(" instanceInfo.getInstanceName() "+instanceInfo.getInstanceName());
- instanceInfo.setInstance(instance);
- instanceFound = true;
- break;
- }
- }
- else
- {
-
-
-// break;
- }
-
-
- }
- if(!instanceFound)
- {
- throw new SPLException("Invalid instance Name " + instanceName);
- }
-
-
- }
-
- public String getQualifierForClass(String className)
- {
- String qualifier = (String)_classNameToQualifierMap.get(className);
- return qualifier;
- }
-
- public List getInstanceInfoList(String className)
- {
- List instanceInfoList = (List)_classNameToInstanceInfoListMap.get(className);
- return instanceInfoList;
-
- }
-
- public void addInstanceInfoListForClass(String className, List instanceInfoList)
- {
- //System.out.println("className "+className);
- //System.out.println("instanceInfoList "+instanceInfoList);
- _classNameToInstanceInfoListMap.put(className, instanceInfoList);
-
- }
-
- public void addQualifierForClass(String className, String qualifier)
- {
- if(qualifier != null)
- {
- _classNameToQualifierMap.put(className, qualifier);
- }
-
- }
-
-
-}
+/*
+ * 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.spl.parser.compiler.symboltable;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.logging.Logger;
+
+import org.apache.imperius.spl.external.InstanceInfo;
+import org.apache.imperius.spl.parser.exceptions.SPLException;
+import org.apache.imperius.util.SPLLogger;
+
+
+public class AnchorData
+{
+ private static Logger logger = SPLLogger.getSPLLogger().getLogger();
+ private static final String sourceClass="AnchorData";
+
+ private Map _classNameToQualifierMap;
+ private Map _classNameToInstanceInfoListMap;
+
+ public AnchorData()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "AnchorData");
+ _classNameToQualifierMap = new Hashtable();
+ _classNameToInstanceInfoListMap = new Hashtable();
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "AnchorData");
+
+ }
+
+ public List getAnchorClassList()
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getAnchorClassList");
+ List anchorClassList = new ArrayList();
+ Iterator anchorKeySetIt = _classNameToInstanceInfoListMap.keySet().iterator();
+ while(anchorKeySetIt.hasNext())
+ {
+ String className = (String)anchorKeySetIt.next();
+ anchorClassList.add(className);
+ }
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getAnchorClassList");
+ return anchorClassList;
+
+ }
+
+ public Object getInstance(String instanceName)
+ {
+ logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "getInstance");
+ Object instance = null;
+ Iterator anchorKeySetIt = _classNameToInstanceInfoListMap.keySet().iterator();
+ while(anchorKeySetIt.hasNext())
+ {
+ String className = (String)anchorKeySetIt.next();
+ List instanceInfoList = (List)_classNameToInstanceInfoListMap.get(className);
+ Iterator instanceInfoListIt = instanceInfoList.iterator();
+ while(instanceInfoListIt.hasNext())
+ {
+ InstanceInfo ii = (InstanceInfo)instanceInfoListIt.next();
+ if(ii.getInstanceName().equals(instanceName))
+ {
+ instance = ii.getInstance();
+ return instance;
+
+ }
+ }
+ }
+
+ logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "getInstance");
+ return instance;
+
+
+ }
+
+ public void insertInstanceObject(String className,
+ String instanceName,
+ Object instance) throws SPLException
+ {
+
+ List instanceInfoList = (List)_classNameToInstanceInfoListMap.get(className);
+
+
+ boolean instanceFound = false;
+
+ Iterator instanceInfoListIt = instanceInfoList.iterator();
+ while(instanceInfoListIt.hasNext())
+ {
+ InstanceInfo instanceInfo = (InstanceInfo) instanceInfoListIt.next();
+ //System.out.println(" instanceInfo.getInstanceName() "+instanceInfo.getInstanceName());
+ //System.out.println(" instanceName "+instanceName);
+
+ if(instanceInfo.getInstanceName() != null)
+ {
+ if(instanceInfo.getInstanceName().equalsIgnoreCase(instanceName))
+ {
+ //System.out.println(" instanceInfo.getInstanceName() "+instanceInfo.getInstanceName());
+ instanceInfo.setInstance(instance);
+ instanceFound = true;
+ break;
+ }
+ }
+ else
+ {
+
+
+// break;
+ }
+
+
+ }
+ if(!instanceFound)
+ {
+ throw new SPLException("Invalid instance Name " + instanceName);
+ }
+
+
+ }
+
+ public String getQualifierForClass(String className)
+ {
+ String qualifier = (String)_classNameToQualifierMap.get(className);
+ return qualifier;
+ }
+
+ public List getInstanceInfoList(String className)
+ {
+ List instanceInfoList = (List)_classNameToInstanceInfoListMap.get(className);
+ return instanceInfoList;
+
+ }
+
+ public void addInstanceInfoListForClass(String className, List instanceInfoList)
+ {
+ //System.out.println("className "+className);
+ //System.out.println("instanceInfoList "+instanceInfoList);
+ _classNameToInstanceInfoListMap.put(className, instanceInfoList);
+
+ }
+
+ public void addQualifierForClass(String className, String qualifier)
+ {
+ if(qualifier != null)
+ {
+ _classNameToQualifierMap.put(className, qualifier);
+ }
+
+ }
+
+
+}
Propchange: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/compiler/symboltable/AnchorData.java
------------------------------------------------------------------------------
svn:eol-style = native