ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Java与模式之门面(Facade)模式

Java与模式之门面(Facade)模式

原创 Linux操作系统 作者:liuzhili3608 时间:2008-04-05 14:59:31 0 删除 编辑

    门面模式是对象的结构模式[GOF95]。外部与一个子系统的通信必须通过一个统一的门面(Facade)对象进行,这就是门面模式。

//门面(Facade)角色
public class Facade {
}
//子系统(Subsystem)角色
public class Subsystem {
}

Session门面模式

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import javax.ejb.EJBException;

public interface SessionFacade extends EJBObject {
    void BusinessMethod2() throws RemoteException, EJBException ;

    void BusinessMethod1() throws RemoteException, EJBException;

    /** @link dependency */
    /*#SessionFacadeBean lnkSession1Bean;*/
}

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.CreateException;

/**
 * @ejbHome <{com.javapatterns.facade.sessionfacade.SessionFacadeHome}>
 * @ejbRemote <{com.javapatterns.facade.sessionfacade.SessionFacade}>
 * @ejbStateful*/
public class SessionFacadeBean implements SessionBean {
    private SessionContext ctx;

    /**
     * @directed
     * @link aggregation
     */
    private Business1Bean lnkBusiness1Bean;

    /**
     * @directed
     * @link aggregation
     */
    private Business2Bean lnkBusiness2Bean;

    public void setSessionContext(SessionContext context) throws RemoteException, EJBException {
        ctx = context;
    }

    public void ejbActivate() throws RemoteException, EJBException {
    }

    public void ejbPassivate() throws RemoteException, EJBException {
    }

    public void ejbRemove() throws RemoteException, EJBException {
    }

    public void ejbCreate() throws CreateException, EJBException, RemoteException {
            // Write your code here
        }

    public void BusinessMethod1() throws RemoteException, EJBException  {
    }

    public void BusinessMethod2() {
    }
}

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

import javax.ejb.EJBHome;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import java.rmi.RemoteException;

public interface SessionFacadeHome extends EJBHome {
SessionFacade create() throws CreateException, EJBException, RemoteException;

    /** @link dependency */
    /*#SessionFacadeBean lnkSession1Bean;*/
}

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.CreateException;

/**
 * @ejbHome <{com.javapatterns.facade.sessionfacade.Business2Home}>
 * @ejbRemote <{com.javapatterns.facade.sessionfacade.Business2}>
 * @ejbStateful
 */
public class Business1Bean implements SessionBean {
    private SessionContext ctx;

    public void setSessionContext(SessionContext context) throws RemoteException, EJBException {
        ctx = context;
    }

    public void ejbActivate() throws RemoteException, EJBException {
    }

    public void ejbPassivate() throws RemoteException, EJBException {
    }

    public void ejbRemove() throws RemoteException, EJBException {
    }

    public void ejbCreate() throws CreateException, EJBException, RemoteException {
            // Write your code here
        }

    public void BusinessMethod1() {
    }

    public void BusinessMethod2() {
    }
}

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

import javax.ejb.EJBObject;
import java.rmi.RemoteException;
import javax.ejb.EJBException;

public interface Business2 extends EJBObject {
    void BusinessMethod1() throws RemoteException, EJBException ;

    void BusinessMethod2()throws RemoteException, EJBException;

    void BusinessMethod3() throws RemoteException, EJBException ;

    /** @link dependency */
    /*#Business1Bean lnkSession1Bean;*/
}

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import java.rmi.RemoteException;
import javax.ejb.EJBException;
import javax.ejb.CreateException;

/**
 * @ejbHome <{com.javapatterns.facade.sessionfacade.Business2Home}>
 * @ejbRemote <{com.javapatterns.facade.sessionfacade.Business2}>
 * @ejbStateful
 */
public class Business2Bean implements SessionBean {
    private SessionContext ctx;

    public void setSessionContext(SessionContext context) throws RemoteException, EJBException {
        ctx = context;
    }

    public void ejbActivate() throws RemoteException, EJBException {
    }

    public void ejbPassivate() throws RemoteException, EJBException {
    }

    public void ejbRemove() throws RemoteException, EJBException {
    }

    public void ejbCreate() throws CreateException, EJBException, RemoteException {
            // Write your code here
        }

    public void BusinessMethod1() {
    }

    public void BusinessMethod2() {
    }
}

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

import javax.ejb.EJBHome;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import java.rmi.RemoteException;

public interface Business2Home extends EJBHome {
Business2 create() throws CreateException, EJBException, RemoteException;

    /** @link dependency */
    /*#Business1Bean lnkSession1Bean;*/
}

/* Generated by Together */

package com.javapatterns.facade.sessionfacade;

public class Client {
    /**
     * @label Uses
     * @directed
     */
    private SessionFacadeBean lnkSessionFacadeBean;
}








来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12993749/viewspace-229945/,如需转载,请注明出处,否则将追究法律责任。

下一篇: 什么是网络
请登录后发表评论 登录
全部评论

注册时间:2008-03-25

  • 博文量
    34
  • 访问量
    57474