Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class EjbLocator {
- private static Context ctx;
- private static EjbLocator instance = new EjbLocator();
- private EjbLocator() {
- }
- public static EjbLocator getLocator() {
- return instance;
- }
- private <T> T getEjb(Class<T> ejbClass, String beanName) {
- try {
- final Hashtable jndiProperties = new Hashtable();
- jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
- final Context context = new InitialContext(jndiProperties);
- final String appName = "hockeyEAR";
- final String moduleName = "hockeyEJB";
- return (T) context.lookup("java:global/"+appName+"/"+moduleName+"/" + beanName + "!" + ejbClass.getName());
- } catch (NamingException e) {
- return null;
- }
- }
- public GestionLancersRemote getGestionLancers() {
- return getEjb(GestionLancersRemote.class, "GestionLancers");
- }
- }
- <persistence-unit name="hockeyUnit" transaction-type="JTA">
- <jta-data-source>java:jboss/datasources/hockey</jta-data-source>
- <properties>
- <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect"/>
- <property name="hibernate.show_sql" value="true"/>
- <property name="hibernate.hbm2ddl.auto" value="update"/>
- </properties>
- </persistence-unit>
- <datasources>
- <datasource jndi-name="java:jboss/datasources/hockey" pool-name="hockey" enabled="true" use-java-context="true">
- <connection-url>jdbc:mysql://localhost:3306/test</connection-url>
- <driver>mysql</driver>
- <security>
- <user-name>something</user-name>
- </security>
- </datasource>
- <drivers>
- <driver name="mysql" module="com.mysql">
- <xa-datasource-class>com.mysql.jdbc.Driver</xa-datasource-class>
- </driver>
- </drivers>
- </datasources>
- java:global/ProjectEJB/Hello!hw.HelloRemote
- java:app/ProjectEJB/Hello!hw.HelloRemote
- java:module/Hello!hw.HelloRemote
- java:jboss/exported/ProjectEJB/Hello!hw.HelloRemote
- java:global/ProjectEJB/Hello!hw.Hello
- java:app/ProjectEJB/Hello!hw.Hello
- java:module/Hello!hw.Hello
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement