<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          Struts2 EJB3 Plugin

          聯(lián)合創(chuàng)作 · 2023-09-20 18:28

          該plugin提供struts的Action及Interceptor對EJB組件及Resource的無侵入式依賴注入(DI)。

          安 裝方法: 將 struts-ejb3-plugin.jar 考入 /WEB-INF/lib 目錄中。這時使用的為plugin的默認配置,該配置為 cn/agrael/struts/plugin/ejb3/default-struts-ejb3-plugin.properties中的配置。配 置信息如下:

          #ENC的默認名
          ENCPath=java:comp/env/
          #應用服務器的具體實現(xiàn)類,該類是 cn.agrael.struts.plugin.ejb3.ApplicationServer的實現(xiàn)類
          ejbContainer
          =cn.agrael.struts.plugin.ejb3.JbossApplicationServer
          #是否解析@Resource的標志 true 為解析,false 為不解析
          isParseResource
          =false
          #是否解析@EJB的標志 true 為解析,false 為不解析
          isParseEJB
          =true
          #ear的路徑名,如果沒有則為空字符串
          earFileBaseName
          =
          #為遠程Bean時的JNDI路徑
          remote
          =remote
          #為本地Bean時的JNDI路徑
          local=local

          如 果要修改默認的配置,需要在 classpath 下建立為 struts-ejb3-plugin.properties 的資源文件覆蓋默認的配置。

          除了plugin本身的配置以外,還需要在 classpath 下創(chuàng)建名為 jndi.properties 的資源文件用做 jndi配置 ,plugin 中使用到的jndi查找依賴于該配置。

          使用例子:

          @Interceptors(Interceptor3.class)
          public class EjbTestAction1 extends ActionSupport{

                 
          private static final long serialVersionUID = 4126146938063764047L;

                 
          @EJB
                 
          private TestSessionBean1Local testSessionBean1Local;
                 
                 
          @EJB(name="ejb/sessionBean1")
                 
          private TestSessionBean1Remote sessionBean1;
                 
                 
          private TestSessionBean1Remote session;
                 
                 
          @EJB
                 
          public void setSession(TestSessionBean1Remote session) {
                         
          this.session = session;
                 
          }

                 
          @PostConstruct
                 
          @Interceptors({Interceptor2.class,Interceptor3.class})
                 
          public void init(){
                         
          //...
                 
          }
                 
                 
          @Interceptors({Interceptor3.class,Interceptor1.class,Interceptor2.class})
                 
          public String execute() throws Exception {
                         
          //...
                         
          return SUCCESS;
                 
          }
          }
          在 Interceptor中使用方式和在Action中的使用方式相同。

          需要注意的是,在Action的execute(或者自定義的名稱)方法中同時使用struts2的 Interceptor和@Interceptors時,@Interceptors會在Interceptor之前開始,在Interceptor之后 結束。

          目前的版本暫時不支持@PreDestroy。 現(xiàn)階段只有 jboss 應用服務器的實現(xiàn),在以后的版本中會陸續(xù)增加如 weblogic、glassfish 等應用服務器的實現(xiàn)。如果現(xiàn)在需要 jboss 之外的實現(xiàn),可實現(xiàn) cn.agrael.struts.plugin.ejb3.ApplicationServer 接口,并使用 struts-ejb3-plugin.properties 修改 ejbContainer 為實現(xiàn)類。

          瀏覽 15
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          評論
          圖片
          表情
          推薦
          點贊
          評論
          收藏
          分享

          手機掃一掃分享

          編輯 分享
          舉報
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  成人18禁在线 | 亚洲最大的黄色视频 | 日韩欧美18 | 91丨国产丨白丝 | 国产成人自拍视频在线 |