X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=test%2Feclipselink%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsupport%2Fpersistence%2Feclipselink%2FJndiSessionCustomizer.java;h=db0b6487a18951af459ebd9b5db0100a072a258c;hb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;hp=d22f326d034563d10042c65b6db1dfd1123a84d5;hpb=89c06d4d52b46c154128c97d6e758fa1f4fc7a6e;p=utils diff --git a/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java b/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java index d22f326d..db0b6487 100644 --- a/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java +++ b/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java @@ -13,17 +13,15 @@ import org.eclipse.persistence.sessions.server.ServerSession; import javax.naming.Context; import javax.naming.InitialContext; - /** - * See - * http://wiki.eclipse.org/Customizing_the_EclipseLink_Application_(ELUG) Use - * for clients that would like to use a JTA SE pu instead of a RESOURCE_LOCAL - * SE pu. This utility also makes sure that using a persistence.xml with a - * JTA datasource works in a standalone Java SE environment together with our - * JNDI stub. + * See http://wiki.eclipse.org/Customizing_the_EclipseLink_Application_(ELUG) + * Use for clients that would like to use a JTA SE pu instead of a + * RESOURCE_LOCAL SE pu. This utility also makes sure that using a + * persistence.xml with a JTA datasource works in a standalone Java SE + * environment together with our JNDI stub. */ public class JndiSessionCustomizer implements SessionCustomizer { -/** + /** * Creates a new JndiSessionCustomizer object. */ public JndiSessionCustomizer() { @@ -33,38 +31,40 @@ public class JndiSessionCustomizer implements SessionCustomizer { /** * Get a dataSource connection and set it on the session with * lookupType=STRING_LOOKUP - * - * @param session DOCUMENT ME! - * - * @throws Exception DOCUMENT ME! + * + * */ public void customize(Session session) throws Exception { JNDIConnector connector = null; - Context context = null; + Context context = null; try { context = new InitialContext(); if (null != context) { - connector = (JNDIConnector) session.getLogin().getConnector(); // possible CCE - // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP - // Note: if both jta and non-jta elements exist this will only change the first one - and may still result in - // the COMPOSITE_NAME_LOOKUP being set - // Make sure only jta-data-source is in persistence.xml with no non-jta-data-source property set + connector = (JNDIConnector) session.getLogin().getConnector(); // possible + // CCE + // Change from COMPOSITE_NAME_LOOKUP to STRING_LOOKUP + // Note: if both jta and non-jta elements exist this will only + // change the first one - and may still result in + // the COMPOSITE_NAME_LOOKUP being set + // Make sure only jta-data-source is in persistence.xml with no + // non-jta-data-source property set connector.setLookupType(JNDIConnector.STRING_LOOKUP); - // Or, if you are specifying both JTA and non-JTA in your persistence.xml then set both connectors to be safe - JNDIConnector writeConnector = (JNDIConnector) session.getLogin() - .getConnector(); + // Or, if you are specifying both JTA and non-JTA in your + // persistence.xml then set both connectors to be safe + JNDIConnector writeConnector = (JNDIConnector) session + .getLogin().getConnector(); writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) session).getReadConnectionPool() - .getLogin()).getConnector(); + JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) session) + .getReadConnectionPool().getLogin()).getConnector(); readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - System.out.println("JndiSessionCustomizer: configured " - + connector.getName()); + System.out.println("JndiSessionCustomizer: configured " + + connector.getName()); } else { throw new Exception("JndiSessionCustomizer: Context is null"); }