/**
  * Creates a new operation with from a given annotated php method.
  *
  * @param ReflectionAnnotatedMethod $method An annotated php method
  *
  * @return ckWsdlOperation An operation, which's input corresponds to the parameters and which's output
  *                         corresponds to the return value of the given php method.
  */
 public static function create(ReflectionAnnotatedMethod $method)
 {
     $name = $method->getAnnotation('WSMethod')->getName();
     $result = new ckWsdlOperation();
     $result->setName($name);
     $params = ckDocBlockParser::parseParameters($method->getDocComment());
     $return = ckDocBlockParser::parseReturn($method->getDocComment());
     $headers = $method->getAllAnnotations('WSHeader');
     $result->input = new ckWsdlMessage($name . 'Request');
     $result->output = new ckWsdlMessage($name . 'Response');
     foreach ($headers as $header) {
         $type = ckXsdType::get($header->type);
         $type->setName($header->name);
         ckXsdType::set($header->name, $type);
         ckXsdType::set($header->type, null);
         $result->input->addPart(new ckWsdlPart($header->name, $type, true));
         $result->output->addPart(new ckWsdlPart($header->name, $type, true));
     }
     foreach ($params as $param) {
         $type = ckXsdType::get($param['type']);
         $result->input->addPart(new ckWsdlPart($param['name'], $type));
     }
     if (!empty($return)) {
         $type = ckXsdType::get($return['type']);
         $result->output->addPart(new ckWsdlPart('result', $type));
     }
     return $result;
 }
 /**
  * This method uses reflection to see if the given class uses annotations
  * to define a request handler. It returns a string that contains the
  * serialized Resource.
  * 
  * @param string $file
  * @return string
  */
 private function analyseClass($file)
 {
     //double check we have included addendum
     require_once dirname(__FILE__) . "/../util/addendum/annotations.php";
     $class = pathinfo($file, PATHINFO_FILENAME);
     try {
         $reflection = new ReflectionClass($class);
     } catch (Exception $ex) {
         return;
     }
     $methods = $reflection->getMethods(ReflectionMethod::IS_PUBLIC);
     $string = "";
     foreach ($methods as $method) {
         $annotation = new ReflectionAnnotatedMethod($method->class, $method->name);
         //if it is a request handler
         if ($annotation->hasAnnotation("RequestName")) {
             $requestName = $annotation->getAnnotation("RequestName")->value;
             $requestType = '';
         } else {
             if ($annotation->hasAnnotation("GET")) {
                 $requestName = $annotation->getAnnotation("GET")->value;
                 $requestType = Request::GET;
             } else {
                 if ($annotation->hasAnnotation("POST")) {
                     $requestName = $annotation->getAnnotation("POST")->value;
                     $requestType = Request::POST;
                 } else {
                     if ($annotation->hasAnnotation("DELETE")) {
                         $requestName = $annotation->getAnnotation("DELETE")->value;
                         $requestType = Request::DELETE;
                     } else {
                         if ($annotation->hasAnnotation("PUT")) {
                             $requestName = $annotation->getAnnotation("PUT")->value;
                             $requestType = Request::PUT;
                         } else {
                             continue;
                         }
                     }
                 }
             }
         }
         $mappedParams = $annotation->getAnnotation("RequestParams")->value == null ? array() : $annotation->getAnnotation("RequestParams")->value;
         $cacheLength = $annotation->getAnnotation("CacheLength")->value == null ? false : $annotation->getAnnotation("CacheLength")->value;
         $authenticator = $annotation->getAnnotation("RequestAuthenticator")->value == null ? null : $annotation->getAnnotation("RequestAuthenticator")->value;
         $viewType = $annotation->getAnnotation("ViewType")->value == null ? Registry::get("DEFAULT_VIEW") : $annotation->getAnnotation("ViewType")->value;
         $viewTemplate = $annotation->getAnnotation("ViewTemplate")->value == null ? null : $annotation->getAnnotation("ViewTemplate")->value;
         $customParams = array();
         foreach ($annotation->getAllAnnotations("CustomParam") as $custom) {
             $customParams[$custom->name] = $custom->value;
         }
         $resource = new Resource($requestName, $requestType, $method->class, $method->name, $mappedParams, $authenticator, $cacheLength, $viewType, $viewTemplate, null, $customParams);
         $string .= "Dispatcher::addResource(unserialize('" . serialize($resource) . "'));\n";
     }
     return $string;
 }
 protected function doMethod(BeanDefinition $bean, \ReflectionAnnotatedMethod $method)
 {
     $listAnnotation = $method->getAllAnnotations();
     foreach ($listAnnotation as $annotation) {
         if ($annotation instanceof annotations\PropertyAnnotation) {
             $annotation->doMethodProperty($bean, $method->name);
         }
     }
 }