tapestry url 解析

Engine service是实现了IEngineService接口的对象,他包含很多创建和服务应用URL的方法;其主要方法public void service(WebRequest request, WebResponse response)
    cycle = _infrastructure.getRequestCycleFactory().newRequestCycle(this); 获得RequestCycle
     service = cycle.getService();
                // Let the service handle the rest of the request.
      service.service(cycle);


其中newRequestCycle(this) 就是对url 路径的解析处理

public IRequestCycle newRequestCycle(IEngine engine)
    {
        WebRequest request = _infrastructure.getRequest();

        QueryParameterMap parameters = extractParameters(request);//常规处理request参数

        decodeParameters(request.getActivationPath(), request.getPathInfo(), parameters);//调用encoders 来解析路径,例如DirectServiceEncoder,就解析出PAGE,extension,COMPONENT等信息
        //对于DirectServiceEncoder    encoding.setParameterValue(ServiceConstants.SERVICE,
                Tapestry.DIRECT_SERVICE); DIRECT_SERVICE名称在此类是固定值
        String serviceName = findService(parameters);

        IRequestCycle cycle = new RequestCycle(engine, parameters, serviceName, _environment);

        _requestGlobals.store(cycle);

        try {

            _requestGlobals.store(_responseDelegateFactory.getResponseBuilder(cycle));

            cycle.setResponseBuilder(_requestGlobals.getResponseBuilder());

        } catch (IOException e) {
            throw new ApplicationRuntimeException("Error creating response builder.", e);
        }

        return cycle;
    }


从而得出Direct路径格式  /PageName,componetIdPath.ext?otherParam
PageServiceEncoder: /PageName.ext
AssetEncoder: String fullPath = _path + ((digest != null) ? "/" + digest : "/" + DIGEST_STATIC) + path;  即  /static/path

ServiceExtensionEncoder: encoding.setServletPath("/" + service + "." + _extension);

你可能感兴趣的:(ext,REST,tapestry)