Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Properties;
- import javax.naming.Context;
- import javax.naming.InitialContext;
- import javax.naming.NamingException;
- import beans.AccountBean;
- import beans.AccountBeanRemote;
- public class ClientApp {
- private static Context initContext;
- private static final String PKG_INTF = "org.jboss.ejb.client.naming";
- private static Context getInitContext() throws NamingException {
- if (initContext == null) {
- Properties prop = new Properties();
- prop.put(Context.URL_PKG_PREFIXES, PKG_INTF);
- initContext = new InitialContext(prop);
- }
- return initContext;
- }
- private static String getLookupName() {
- final String appName = "PlanerEAR";
- final String moduleName = "PlanerEJB";
- final String distinctName = "";
- final String className = AccountBean.class.getSimpleName();
- final String interfaceName = AccountBeanRemote.class.getName();
- return String.format("ejb:%s/%s/%s/%s!%s", appName, moduleName, distinctName, className, interfaceName);
- }
- private static AccountBeanRemote getBean() {
- Context ctx = null;
- AccountBeanRemote bean = null;
- try {
- ctx = getInitContext();
- String name = getLookupName();
- bean = (AccountBeanRemote) ctx.lookup(name);
- } catch (Exception e) { e.printStackTrace(); }
- return bean;
- }
- public static void main(String[] args) {
- System.out.println(getBean().createAccount("a@b.com", "sifra", "Milanko", "Nikola"));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement