Skip to content

Instantly share code, notes, and snippets.

@dimovelev
Last active February 14, 2016 12:42
Show Gist options
  • Save dimovelev/aa4edf654227e956ec45 to your computer and use it in GitHub Desktop.
Save dimovelev/aa4edf654227e956ec45 to your computer and use it in GitHub Desktop.
@WebService
public class FacadeJaxWs implements FacadeWebService {
@EJB(lookup = "FrontendEjb")
protected FrontendEjbHome frontendEjbHome;
public void updateCustomer() {
Context ctxBackend = null;
try {
Properties envBackend = new Properties();
envBackend.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
envBackend.put(Context.PROVIDER_URL, "t3://backend:7001");
envBackend.put(Context.SECURITY_PRINCIPAL, "backend_user");
envBackend.put(Context.SECURITY_CREDENTIALS, "backend_password");
ctxBackend = new InitialContext(envBackend);
BackendEjbHome home = (BackendEjbHome) ctxBackend.lookup("BackendEjb");
BackendEjb remote = home.create();
remote.updateCustomerInBackend(mode);
} finally {
if (ctxBackend != null) {
ctxBackend.close()
} catch (NamingException e) {
// do not rethrow as this might swallow any exception thrown before that
// at least log it...
}
}
FrontendEjb remote = frontendEjbHome.create();
remote.updateCustomerInFrontend(mode);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment