Extension Tapestry4`s restart service to clear my login cookies

Extension Tapestry4`s restart service to clear my login cookies

接上篇,自定义一个logout service 把我的login cookies 清楚掉

Tapestry .java

package common.tapestry;

public final  class Tapestry {
  public static final String LOGOUT_SERVICE = "logout";
}

LogoutService.java
package common.tapestry.engine;

import java.io.IOException;

import org.apache.tapestry.IRequestCycle;
import org.apache.tapestry.engine.RestartService;

import common.tapestry.Tapestry;

public class LogoutService extends RestartService {
 private LoginCookiesManager loginCookiesManager;


 public void setLoginCookiesManager(
   LoginCookiesManager loginCookiesManager) {
  this.loginCookiesManager = loginCookiesManager;
 }

 public void service(IRequestCycle cycle) throws IOException {
  loginCookiesManager.removeCookies();
  super.service(cycle);
 }

 public String getName() {
  return Tapestry.LOGOUT_SERVICE;
 }
}

hivemodule.xml
<?xml version="1.0"?>
<module id="common.tapestry" version="1.0.0">

 <!-- extends tapestry RestartService and clear the login cookies info-->
    <service-point id="LogoutService" interface="org.apache.tapestry.engine.IEngineService">
        <invoke-factory>
            <construct class="common.tapestry.engine.LogoutService">
             <set-service property="request" service-id="tapestry.globals.HttpServletRequest" />
                <set-service property="response" service-id="tapestry.globals.HttpServletResponse" />
                <set-object property="servletPath" value="app-property:org.apache.tapestry.servlet-path" />
                <set-object property="linkFactory" value="infrastructure:linkFactory" />
                <set-object property="loginCookiesManager" value="service:common.tapestry.LoginCookiesManager"/>
             </construct>
        </invoke-factory>
    </service-point>

    <contribution configuration-id="tapestry.services.ApplicationServices">
        <service name="logout" object="service:common.tapestry.LogoutService" />
    </contribution>

</module>

in your Pages
<a jwcid="@ServiceLink" href="#" service="ognl:@common.tapestry.Tapestry@LOGOUT_SERVICE" target="_top">退出</a>

系原创
作者其他blog  http://oxyc.spaces.live.com
                        http://hiok.blog.sohu.com

你可能感兴趣的:(Extension Tapestry4`s restart service to clear my login cookies)