Skip to content
Snippets Groups Projects
Commit 3fe63434 authored by Faller's avatar Faller
Browse files

WIP EJB

parent 61df642d
Branches
No related tags found
No related merge requests found
Pipeline #6599 passed with warnings
......@@ -7,5 +7,12 @@
<jndi-name>central-ear/remote</jndi-name>
<local-jndi-name>central-ear/local</local-jndi-name>
</service>
<service>
<ejb-class>uy.edu.fing.tse.central.business.security.SecurityBean</ejb-class>
<local>uy.edu.fing.tse.central.business.security.SecurityLocal</local>
<remote>uy.edu.fing.tse.central.business.security.SecurityRemote</remote>
<jndi-name>central-ear/remote</jndi-name>
<local-jndi-name>central-ear/local</local-jndi-name>
</service>
</enterprise-beans>
</jboss>
\ No newline at end of file
......@@ -21,15 +21,22 @@ public final class LookUp {
}
public static <T> T lookup(final Class<T> clazz, final String beanName) {
return lookup(clazz, beanName, null);
}
public static <T> T lookup(final Class<T> clazz, final String beanName, final Properties properties) {
try {
final String toLookup = buildName(clazz, beanName);
return clazz.cast(createInitialContext().lookup(toLookup));
return clazz.cast(createInitialContext(properties).lookup(toLookup));
} catch (final Exception e) {
throw new RuntimeException("Error Conectandose remotamente al EJB", e);
}
}
private static InitialContext createInitialContext() throws NamingException {
private static InitialContext createInitialContext(final Properties properties) throws NamingException {
if (properties != null) {
return new InitialContext(properties);
}
final Properties prop = new Properties();
prop.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
prop.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
......@@ -40,7 +47,7 @@ public final class LookUp {
return new InitialContext(prop);
}
private static <T> String buildName(final Class<T> clazz, final String beanName) {
public static <T> String buildName(final Class<T> clazz, final String beanName) {
final String appName = "";
final String moduleName = "central-ear";
final String distinctName = "central-ejb";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment