67,550
社区成员




package com.xx.leo;
import javax.ejb.Remote;
@Remote
public interface HelloWorldBusiness {
public String sayHello();
}
package com.xx.leo;
import javax.ejb.Stateless;
@Stateless
public class HelloWorldBean implements HelloWorldBusiness {
public String sayHello(){
return "Hello World.";
}
}
package test;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.xx.leo.HelloWorldBusiness;
public class HelloWorldTest {
/**
* @param args
*/
public static void main(String[] args) {
Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
jndiProperties.put(Context.URL_PKG_PREFIXES,"org.jboss.ejb.client.naming");
try {
Context context = new InitialContext(jndiProperties);
final String appName = "";
final String moduleName = "ejbdemo";
final String distinctName = "";
Object obj = context.lookup("ejb:" + appName + "/" + moduleName
+ "/" + distinctName
+ "/HelloWorldBean!com.xx.leo.HelloWorldBusiness");
HelloWorldBusiness hwr = (HelloWorldBusiness) obj;
String say = hwr.sayHello();
System.out.println(say);
} catch (NamingException e) {
e.printStackTrace();
}
}
}
endpoint.name=client-endpoint
remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED=false
remote.connections=default
remote.connection.default.host=127.0.0.1
remote.connection.default.port=4447
remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS=false