/**
  * @param $serviceId
  * @param $class
  * @param $method
  */
 public function map($serviceId, $class, $method)
 {
     $class = new \ReflectionClass($class);
     $method = $class->getMethod($method);
     $annotations = [];
     $annotations[] = $this->reader->getMethodAnnotation($method, self::REGISTER_ANNOTATION_CLASS);
     $annotations[] = $this->reader->getMethodAnnotation($method, self::SUBSCRIBE_ANNOTATION_CLASS);
     $securityAnnotation = $this->reader->getMethodAnnotation($method, self::SECURITY_ANNOTATION_CLASS);
     /* @var $annotation Register */
     foreach ($annotations as $annotation) {
         if ($annotation) {
             /* @var $workerAnnotation Register  */
             $workerAnnotation = isset($this->workerAnnotationsClasses[$class->getName()]) ? $this->workerAnnotationsClasses[$class->getName()] : null;
             if ($workerAnnotation) {
                 $worker = $workerAnnotation->getName();
             } else {
                 $worker = $annotation->getWorker() ?: "default";
             }
             $mapping = new URIClassMapping($serviceId, $method, $annotation);
             if (isset($this->mappings[$worker][$annotation->getName()])) {
                 $uri = $annotation->getName();
                 $className = $this->mappings[$worker][$annotation->getName()]->getMethod()->class;
                 throw new Exception("The URI '{$uri}' has already been registered in '{$className}' for the worker '{$worker}'");
             }
             //Set security Annotation
             $mapping->setSecurityAnnotation($securityAnnotation);
             $this->mappings[$worker][$annotation->getName()] = $mapping;
         }
     }
 }
 /**
  * @param URIClassMapping $mapping
  * @return array
  */
 protected function extractRoles(URIClassMapping $mapping)
 {
     $roles = [];
     $securityAnnotation = $mapping->getSecurityAnnotation();
     if ($securityAnnotation) {
         $expression = $securityAnnotation->getExpression();
         preg_match_all("/'(.*?)'/", $expression, $matches);
         $roles = $matches[1];
     }
     return $roles;
 }