From 38c307650e5db3d2f09f193ecac06ad1cdcf9d53 Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Wed, 12 May 2010 11:27:05 +0000 Subject: [PATCH] session customizers no longer needed. --- .../eclipselink/JndiSessionCustomizer.java | 82 ------------------- .../toplink/JndiSessionCustomizer.java | 82 ------------------- 2 files changed, 164 deletions(-) delete mode 100644 test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java delete mode 100644 test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java 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 deleted file mode 100644 index 03beb900..00000000 --- a/test/eclipselink/src/main/java/org/wamblee/support/persistence/eclipselink/JndiSessionCustomizer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2005-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wamblee.support.persistence.eclipselink; - -import org.eclipse.persistence.config.SessionCustomizer; -import org.eclipse.persistence.sessions.DatabaseLogin; -import org.eclipse.persistence.sessions.JNDIConnector; -import org.eclipse.persistence.sessions.Session; -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. - */ -public class JndiSessionCustomizer implements SessionCustomizer { - /** - * Creates a new JndiSessionCustomizer object. - */ - public JndiSessionCustomizer() { - // Empty. - } - - /** - * Get a dataSource connection and set it on the session with - * lookupType=STRING_LOOKUP - * - * - */ - public void customize(Session aSession) throws Exception { - JNDIConnector connector = null; - Context context = null; - - try { - context = new InitialContext(); - - connector = (JNDIConnector) aSession.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) aSession.getLogin() - .getConnector(); - writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - - JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) - .getReadConnectionPool().getLogin()).getConnector(); - readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - - System.out.println("JndiSessionCustomizer: configured " + - connector.getName()); - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff --git a/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java b/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java deleted file mode 100644 index 71d95d6f..00000000 --- a/test/toplink-essentials/src/main/java/org/wamblee/support/persistence/toplink/JndiSessionCustomizer.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright 2005-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wamblee.support.persistence.toplink; - -import oracle.toplink.essentials.jndi.JNDIConnector; -import oracle.toplink.essentials.sessions.DatabaseLogin; -import oracle.toplink.essentials.sessions.Session; -import oracle.toplink.essentials.threetier.ServerSession; -import oracle.toplink.essentials.tools.sessionconfiguration.SessionCustomizer; - -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. - */ -public class JndiSessionCustomizer implements SessionCustomizer { - /** - * Creates a new JndiSessionCustomizer object. - */ - public JndiSessionCustomizer() { - // Empty. - } - - /** - * Get a dataSource connection and set it on the session with - * lookupType=STRING_LOOKUP - * - * - */ - public void customize(Session aSession) throws Exception { - JNDIConnector connector = null; - Context context = null; - - try { - context = new InitialContext(); - - connector = (JNDIConnector) aSession.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) aSession.getLogin() - .getConnector(); - writeConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - - JNDIConnector readConnector = (JNDIConnector) ((DatabaseLogin) ((ServerSession) aSession) - .getReadConnectionPool().getLogin()).getConnector(); - readConnector.setLookupType(JNDIConnector.STRING_LOOKUP); - - System.out.println("JndiSessionCustomizer: configured " + - connector.getName()); - } catch (Exception e) { - e.printStackTrace(); - } - } -} -- 2.31.1