blob: c4b6273e4e0dee8c78e8b20d55ee7240273ba99b [file] [log] [blame]
h1. Local Client (embedded container)
{code}
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.LocalInitialContextFactory");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
{code}
h1. Local Client (non-default realm name)
h2. Login configuration file (conf/login.config)
{code}
PropertiesLogin {
org.apache.openejb.core.security.jaas.PropertiesLoginModule required
Debug=true
UsersFile="users.properties"
GroupsFile="groups.properties";
};
MyApp {
org.apache.openejb.core.security.jaas.SQLLoginModule required
dataSourceName="MyDataSource"
userSelect="SELECT username, password FROM users WHERE username=?"
groupSelect="SELECT username, grp FROM users WHERE username=?";
};
{code}
h2. Program code
{code}
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.LocalInitialContextFactory");
p.put("openejb.authentication.realmName", "MyApp");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
{code}
h1. Remote Client (openejb standalone)
{code}
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "ejbd://localhost:4201");
// user and pass optional
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
{code}
h1. Remote Client with HTTP (openejb standalone)
{code}
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://localhost:4204/ejb");
// user and pass optional
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
{code}
h1. Remote Client with HTTP (in tomcat)
{code}
Properties p = new Properties();
p.put("java.naming.factory.initial", "org.apache.openejb.client.RemoteInitialContextFactory");
p.put("java.naming.provider.url", "http://127.0.0.1:8080/openejb/ejb");
// user and pass optional
p.put("java.naming.security.principal", "myuser");
p.put("java.naming.security.credentials", "mypass");
InitialContext ctx = new InitialContext(p);
MyBean myBean = (MyBean) ctx.lookup("MyBeanRemote");
{code}