分类:
2008-04-07 10:44:04
package org.flying.ejb;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import weblogic.wtc.jatmi.TPException;
import weblogic.wtc.jatmi.TypedString;
import weblogic.wtc.jatmi.Reply;
import weblogic.wtc.jatmi.TPServiceInformation;
public class WeblogicEjb implements SessionBean {
private static final long serialVersionUID = 1L;
static final boolean VERBOSE = true;
private SessionContext ctx;
/**
* Sets the session context.
* @param ctx
* SessionContext Context for session
*/
public void setSessionContext(SessionContext ctx) {
this.ctx = ctx;
}
/**
* This method is required by the EJB Specification, but is not used by this
* example.
*
*/
public void ejbActivate() {
}
/**
* This method is required by the EJB Specification, but is not used by this
* example.
*
*/
public void ejbPassivate() {
}
/**
* This method is required by the EJB Specification, but is not used by this
* example.
*
*/
public void ejbRemove() {
}
public void ejbCreate() throws CreateException {
}
public Reply service(TPServiceInformation mydata) throws TPException {
TypedString data;
String lowered;
TypedString return_data;
data = (TypedString) mydata.getServiceData();
log("converting " + data);
lowered = data.toString().toLowerCase();
log("converted " + data);
return_data = new TypedString(lowered);
mydata.setReplyBuffer(return_data);
return (mydata);
}
private void log(String s) {
if (VERBOSE) {
System.out.println(s);
}
}
}
EJBHome和Romote接口不用写,稍后处理。
xmlns:xsi=""
xsi:schemaLocation=" /ejb-jar_2_1.xsd"
version="2.1">
重要:配置中
xmlns:j2ee=""
xmlns:xsi=""
xsi:schemaLocation="http://www.bea.com/ns/weblogic/90 http://www.bea.com/ns/weblogic/90/weblogic-ejb-jar.xsd">