package pl.ibpolsoft.sop.client.service; import javax.naming.Context; import javax.naming.NamingException; /** * * @author witoldsz */ public final class SimpleEjbLookup implements EjbLookup { private final Context ctx; public SimpleEjbLookup(Context ctx) { this.ctx = ctx; } @Override public String defaultBeanName(Class remoteInterface) { return remoteInterface.getName(); } @Override public T getBean(Class remoteInterface) throws NamingException { String beanName = defaultBeanName(remoteInterface); return getBean(remoteInterface, beanName); } @Override public T getBean(Class remoteInterface, String beanName) throws NamingException { @SuppressWarnings("unchecked") T result = (T) ctx.lookup(beanName); return result; } }