static function __static()
 {
     self::$sources['cookie'] = self::$COOKIE = newinstance(__CLASS__, array(1, 'cookie'), '{
     static function __static() { }
     public function read($name, $target, $request) {
       if (NULL === ($cookie= $request->getCookie($name, NULL))) return NULL;
       return $cookie->getValue();
     }
   }');
     self::$sources['header'] = self::$HEADER = newinstance(__CLASS__, array(2, 'header'), '{
     static function __static() { }
     public function read($name, $target, $request) {
       return $request->getHeader($name, NULL);
     }
   }');
     self::$sources['param'] = self::$PARAM = newinstance(__CLASS__, array(3, 'param'), '{
     static function __static() { }
     public function read($name, $target, $request) {
       return $request->getParam($name, NULL);
     }
   }');
     self::$sources['path'] = self::$PATH = newinstance(__CLASS__, array(4, 'path'), '{
     static function __static() { }
     public function read($name, $target, $request) {
       return isset($target["segments"][$name]) ? rawurldecode($target["segments"][$name]) : NULL;
     }
   }');
     self::$sources['body'] = self::$BODY = newinstance(__CLASS__, array(5, 'body'), '{
     static function __static() { }
     public function read($name, $target, $request) {
       return RestFormat::forMediaType($target["input"])->read($request->getInputStream(), Type::$VAR); 
     }
   }');
 }
 /**
  * Add a webmethod
  *
  * @param  lang.XPClass class
  * @param  lang.reflect.Method method
  * @param  string base
  * @throws lang.IllegalArgumentException
  */
 public function addWebmethod($class, $method, $base = '')
 {
     try {
         $webmethod = $method->getAnnotation('webmethod');
     } catch (ElementNotFoundException $e) {
         throw new IllegalArgumentException('Not a webmethod: ' . $method->toString(), $e);
     }
     // Create route from @webmethod annotation
     $route = $this->addRoute(new RestRoute($webmethod['verb'], $base . (isset($webmethod['path']) ? rtrim($webmethod['path'], '/') : ''), $class, $method, isset($webmethod['accepts']) ? (array) $webmethod['accepts'] : NULL, isset($webmethod['returns']) ? (array) $webmethod['returns'] : NULL));
     // Add route parameters using parameter annotations
     foreach ($method->getParameters() as $parameter) {
         $param = $parameter->getName();
         foreach ($parameter->getAnnotations() as $source => $value) {
             $route->addParam($param, new RestParamSource($value ? $value : $param, ParamReader::forName($source)));
         }
     }
 }
 public function string_representation_with_params()
 {
     $r = new RestRoute('GET', '/resource/{id}/{sub}', $this->handler, $this->target, NULL, NULL);
     $r->addParam('id', new RestParamSource('id', ParamReader::forName('path')));
     $r->addParam('sub', new RestParamSource('sub', ParamReader::forName('path')));
     $this->assertEquals('webservices.rest.srv.RestRoute(GET /resource/{id}/{sub} -> void net.xp_framework.unittest.webservices.rest.srv.RestRouteTest::fixtureTarget(@$id: path(\'id\'), @$sub: path(\'sub\')))', $r->toString());
 }