Chinaunix首页 | 论坛 | 博客
  • 博客访问: 382519
  • 博文数量: 80
  • 博客积分: 2682
  • 博客等级: 少校
  • 技术积分: 907
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-16 09:55
文章分类

全部博文(80)

文章存档

2012年(80)

分类: Java

2012-07-19 17:07:32


点击(此处)折叠或打开

  1. import javax.ejb.CreateException;

  2. import javax.ejb.SessionBean;

  3. import javax.ejb.SessionContext;

  4. import javax.naming.Context;

  5. import javax.naming.InitialContext;

  6. import javax.naming.NamingException;

  7.  

  8. import weblogic.wtc.jatmi.TPException;

  9. import weblogic.wtc.jatmi.TypedString;

  10. import weblogic.wtc.jatmi.Reply;

  11. import weblogic.wtc.jatmi.TPServiceInformation;

  12.  

  13. public class WeblogicEjb implements SessionBean {

  14.        private static final long serialVersionUID = 1L;

  15.        static final boolean VERBOSE = true;

  16.        private SessionContext ctx;

  17.        /**

  18.         * Sets the session context.

  19.         * @param ctx

  20.         * SessionContext Context for session

  21.         */

  22.        public void setSessionContext(SessionContext ctx) {

  23.               this.ctx = ctx;

  24.        }

  25.        /**

  26.         * This method is required by the EJB Specification, but is not used by this

  27.         * example.

  28.         *

  29.         */

  30.        public void ejbActivate() {

  31.        }

  32.        /**

  33.         * This method is required by the EJB Specification, but is not used by this

  34.         * example.

  35.         *

  36.         */

  37.        public void ejbPassivate() {

  38.        }

  39.        /**

  40.         * This method is required by the EJB Specification, but is not used by this

  41.         * example.

  42.         *

  43.         */

  44.        public void ejbRemove() {

  45.        }

  46.        public void ejbCreate() throws CreateException {

  47.        }

  48.        public Reply service(TPServiceInformation mydata) throws TPException {

  49.               TypedString data;

  50.               String lowered;

  51.               TypedString return_data;

  52.               data = (TypedString) mydata.getServiceData();

  53.               log("converting " + data);

  54.               lowered = data.toString().toLowerCase();

  55.               log("converted " + data);

  56.               return_data = new TypedString(lowered);

  57.               mydata.setReplyBuffer(return_data);

  58.               return (mydata);

  59.        }

  60.        private void log(String s) {

  61.               if (VERBOSE) {

  62.                      System.out.println(s);

  63.               }

  64.        }

  65. }

ejb-jar.xml

点击(此处)折叠或打开

  1. <enterprise-beans>
  2.               <session>
  3.                      <ejb-name>TOLOWEREJB</ejb-name>
  4.                      <home>weblogic.wtc.jatmi.TuxedoServiceHome</home>
  5.                      <remote>weblogic.wtc.jatmi.TuxedoService</remote>
  6.                      <ejb-class>org.flying.ejb.WeblogicEjb</ejb-class>
  7.                      <session-type>Stateless</session-type>
  8.                      <transaction-type>Container</transaction-type>
  9.               </session>
  10.        </enterprise-beans>
  11.        <assembly-descriptor>
  12.               <container-transaction>
  13.                      <method>
  14.                             <ejb-name>TOLOWEREJB</ejb-name>
  15.                             <method-name>*</method-name>
  16.                      </method>
  17.                      <trans-attribute>Supports</trans-attribute>
  18.               </container-transaction>
  19.        </assembly-descriptor>



weblogic-ejb-jar.xml

点击(此处)折叠或打开

  1. <wls:weblogic-enterprise-bean>
  2.         <wls:ejb-name>TOLOWEREJB</wls:ejb-name>
  3.         <wls:stateless-session-descriptor>
  4.             <wls:business-interface-jndi-name-map>
  5.                 <wls:business-remote>org.flying.ejb.WeblogicEjb</wls:business-remote>
  6.                 <wls:jndi-name>TOLOWER</wls:jndi-name>
  7.             </wls:business-interface-jndi-name-map>
  8.         </wls:stateless-session-descriptor>
  9.     </wls:weblogic-enterprise-bean>

阅读(1415) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~