private static function checkAccess($object,$errorMessage){
    	
    	if(is_string($object)){
    		$className = $object;
    		$object = null;
    	}else{
    		$className = get_class($object);
    	}
    	
    	if(TransactionManager::isSuperUser()){
    		return true;
    	}
    	
    	$hasAccess = false;
    	$hasAccessChecks = false;
    	try{
    		TransactionManager::startTransaction(null,true);
    		
    		$debugBacktraces = debug_backtrace(false);
    		$args = null;
    		$function = null;
    		foreach($debugBacktraces as $debugBacktrace){
    			if($debugBacktrace["class"] == $className){
    				$args = $debugBacktrace["args"];
    				$function = $debugBacktrace["function"];
    				break;
    			}
    		}
    		
    		$accessAnnotations = self::getAccessAnnotation($className, $function);
    		
    		if(is_array($accessAnnotations) && count($accessAnnotations) > 0){
    			$hasAccessChecks = true;
    			
    			//
    			// access annotations will be of the form 
    			// array(
    			//      "key1|value1",
    			//      "key2|value2",
    			//      ...
    			//      "function|functionName"
    			// )
    			// 
    			// Access is granted if session contains value for the specified key
    			// "function" is the special reserved key for which a function mentioned as value is called instead of checking for the value in session
    			
    			
    			// group access annotations by key
    			$accessMasks = array();
    			foreach ($accessAnnotations as $accessMask){
    				$accessMaskArr = preg_split('/\|/', $accessMask);
    				$accessMaskKey = $accessMaskArr[0];
    				$accessMaskValue = $accessMaskArr[1];
    				if(!array_key_exists($accessMaskKey, $accessMasks)){
    					$accessMaskValues = array();
    				}else{
    					$accessMaskValues = $accessMasks[$accessMaskKey];
    				}
    				$accessMaskValues[] = $accessMaskValue;
    				$accessMasks[$accessMaskKey] = $accessMaskValues;
    			}
    			
    			$session = Factory::getSession();
    			foreach ($accessMasks as $accessKey=>$accessValues){
    				if($accessKey == "function"){
    					continue;
    				}
    				$sessionValues = $session->get($accessKey);
    				
    				if(count(array_intersect($sessionValues, $accessValues)) > 0){
    					$hasAccess = true;
    					break;
    				}
    			}
    			
    			if(!$hasAccess && array_key_exists("function", $accessMasks)){
    				foreach ($accessMasks["function"] as $function){
    					$result = Reflection::invokeArgs($className, $function, $object, $args);
    					if($result instanceof Expression){
    						$hasAccess = $result;
    						break;
    					}else if(isset($result) && $result){
    						$hasAccess = true;
    						break;
    					}
    				}
    			}
    		}
    		
    		TransactionManager::commitTransaction();
    	}catch (\Exception $e){
    		TransactionManager::abortTransaction();
    		throw $e;
    	}
    	
    	if($hasAccessChecks){
    		if($hasAccess === false){
    			throw new NoAccessException($errorMessage);
    		}
    		return $hasAccess;
    	}
    	return true;
    }