incubator-imperius-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jnee...@apache.org
Subject svn commit: r627869 - in /incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl: external/DataCollector.java external/InternalClient.java parser/statements/impl/SPLPolicy.java
Date Thu, 14 Feb 2008 21:04:11 GMT
Author: jneeraj
Date: Thu Feb 14 13:04:08 2008
New Revision: 627869

URL: http://svn.apache.org/viewvc?rev=627869&view=rev
Log:
1. Updated datacollector to have a new method to check if the given object is type compatible
with an interface
2. Updated internalclient and splpolicy to not use instanceinfolist

Modified:
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/DataCollector.java
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/InternalClient.java
    incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/DataCollector.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/DataCollector.java?rev=627869&r1=627868&r2=627869&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/DataCollector.java
(original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/external/DataCollector.java
Thu Feb 14 13:04:08 2008
@@ -121,6 +121,11 @@
 //    
 //    public String getReferenceTypeName(String reference);
 //    
-  
+    
+    /**
+     * Checks if the given object is an instance of the given class
+     */
+    public boolean isInstance(String className, Object instance)
+    throws SPLException;
     
 }

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=627869&r1=627868&r2=627869&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
Thu Feb 14 13:04:08 2008
@@ -153,12 +153,12 @@
 						
 						String objectName=className;
 						
-						InstanceInfo iI=new InstanceInfo(objectName,copI);
+						//InstanceInfo iI=new InstanceInfo(objectName,copI);
 						
-						List instanceInfoList = new ArrayList();
-						instanceInfoList.add(iI);
+						//List instanceInfoList = new ArrayList();
+						//instanceInfoList.add(iI);
 
-						objectMap.put(objectName, instanceInfoList);
+						objectMap.put(objectName, copI);
 						
 						Integer retVal=(Integer)pm.evaluatePolicy(policyName,objectMap);
 						if (logger.isLoggable(Level.FINE))
@@ -178,7 +178,7 @@
 						}
 			            if(logger.isLoggable(Level.FINE))
 			                logger.fine(Thread.currentThread().getName()+" Internal client return
value="+returnValue);
-			            objectMap.remove(instanceInfoList);
+			            objectMap.remove(copI);
 						
 					}
 					logger.fine("internal client finished iterating over all instances ");

Modified: incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java
URL: http://svn.apache.org/viewvc/incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java?rev=627869&r1=627868&r2=627869&view=diff
==============================================================================
--- incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java
(original)
+++ incubator/imperius/trunk/imperius-splcore/src/main/java/org/apache/imperius/spl/parser/statements/impl/SPLPolicy.java
Thu Feb 14 13:04:08 2008
@@ -77,7 +77,6 @@
 	{
 		logger.entering(sourceClass,Thread.currentThread().getName()+" "+ "sortPoliciesByPriority");
 
-
 		for(int i=0; i<list.size(); i++)
 		{
 			for(int j=i+1; j<list.size()-1; j++)
@@ -89,16 +88,9 @@
 					PolicyStatement temp = pStatement;
 					pStatement = pStatementNext;
 					pStatementNext = temp;
-
-
 				}
-
-
-
 			}
 		}
-
-
 		logger.exiting(sourceClass,Thread.currentThread().getName()+" "+ "sortPoliciesByPriority");
 		return list;
 	}
@@ -326,12 +318,12 @@
 		
 		while(it.hasNext()){
 			Object inst=it.next();
-			InstanceInfo iinfo=new InstanceInfo(targetclassnm,inst);
+			//InstanceInfo iinfo=new InstanceInfo(targetclassnm,inst);
 			List instanceInfoList=new ArrayList();
-			instanceInfoList.add(iinfo);
+			//instanceInfoList.add(iinfo);
 
 			Map objMap=new HashMap();
-			objMap.put(targetclassnm, instanceInfoList);
+			objMap.put(targetclassnm, inst);
 			result = evaluate(dc,ac,objMap);
 
 		}
@@ -400,66 +392,59 @@
 	private Map _buildInstanceMap(Map iMap,DataCollector dc) throws SPLException
     {
 	    Map instMap = new HashMap();
-	    try
+       Iterator instNameIt = iMap.keySet().iterator();
+        while(instNameIt.hasNext())
         {
-            Iterator instNameIt = iMap.keySet().iterator();
-            while(instNameIt.hasNext())
+            String instanceName = (String)instNameIt.next();
+            Object instance = iMap.get(instanceName);
+       //     String instanceClassName = instance.getClass().getName();
+            Iterator importIt = _importStmtList.iterator();
+            while(importIt.hasNext())
             {
-                String instanceName = (String)instNameIt.next();
-                Object instance = iMap.get(instanceName);
-           //     String instanceClassName = instance.getClass().getName();
-                Iterator importIt = _importStmtList.iterator();
-                while(importIt.hasNext())
+                ImportStatement importStmt = (ImportStatement)importIt.next();
+                String anchorClassName = importStmt.getAnchorClassName();
+                                 
+                // check if class of the passed instance has been imported
+                if(dc.isInstance(anchorClassName,instance))
                 {
-                    ImportStatement importStmt = (ImportStatement)importIt.next();
-                    String anchorClassName = importStmt.getAnchorClassName();
-                    Class anchorClass = Class.forName(anchorClassName);
-                   
-                    // check if class of the passed instance has been imported
-                    if(anchorClass.isInstance(instance))
+                    
+                    List instanceList = importStmt.getImportInstanceInfoList();
+                    Iterator instanceListIt = instanceList.iterator();
+                    // iterate over all the instances of this class to see if 
+                    // there is a match
+                    while(instanceListIt.hasNext())
                     {
-                        
-                        List instanceList = importStmt.getImportInstanceInfoList();
-                        Iterator instanceListIt = instanceList.iterator();
-                        // iterate over all the instances of this class to see if 
-                        // there is a match
-                        while(instanceListIt.hasNext())
+                        InstanceInfo iInfo = (InstanceInfo)instanceListIt.next();
+                        if(iInfo.getInstanceName().equals(instanceName))
                         {
-                            InstanceInfo iInfo = (InstanceInfo)instanceListIt.next();
-                            if(iInfo.getInstanceName().equals(instanceName))
+                            InstanceInfo instanceInfo = new InstanceInfo(instanceName,instance);
+                            
+                            String qualifier = _symTab.getQualifierForClass(anchorClassName);
+                            Map symbolsForInstance = dc.getSymbolsForInstance(anchorClassName,
+                                        qualifier,
+                                        instance);
+                            instanceInfo.setInstanceSymbolsMap(symbolsForInstance);
+                            if(instMap.containsKey(anchorClassName))
                             {
-                                InstanceInfo instanceInfo = new InstanceInfo(instanceName,instance);
-                                
-                                String qualifier = _symTab.getQualifierForClass(anchorClassName);
-                                Map symbolsForInstance = dc.getSymbolsForInstance(anchorClassName,
-                                            qualifier,
-                                            instance);
-                                instanceInfo.setInstanceSymbolsMap(symbolsForInstance);
-                                if(instMap.containsKey(anchorClassName))
-                                {
-                                    List instanceInfoList = (List)instMap.get(anchorClassName);
-                                    instanceInfoList.add(instanceInfo);
-                                    
-                                }
-                                else
-                                {
-                                    List instanceInfoList = new ArrayList();
-                                    instanceInfoList.add(instanceInfo);
-                                    instMap.put(anchorClassName, instanceInfoList);
-                                    
-                                }   
+                                List instanceInfoList = (List)instMap.get(anchorClassName);
+                                instanceInfoList.add(instanceInfo);
                                 
                             }
+                            else
+                            {
+                                List instanceInfoList = new ArrayList();
+                                instanceInfoList.add(instanceInfo);
+                                instMap.put(anchorClassName, instanceInfoList);
+                                
+                            }   
+                            
                         }
                     }
-                        
                 }
+                    
             }
         }
-        catch(ClassNotFoundException cnef)
-        {
-            throw new SPLException(cnef.getMessage());
-        }
+                
         return instMap;
         
     }



Mime
View raw message