pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedbug with PGXADataSource in JNDI
6+ messages / 3 participants
[nested] [flat]
* bug with PGXADataSource in JNDI
@ 2007-02-23 20:56 Jonathan Halliday <jonathan.halliday@redhat.com>
0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Halliday @ 2007-02-23 20:56 UTC (permalink / raw)
To: pgsql-jdbc
Hello JDBC driver developers
I have a requirement to store and retrieve PGXADataSource
instances from JNDI, specifically using Sun's fscontext
provider.
I can get instances into JNDI no problem and they are
written out to the .bindings file.
I can't retrieve them because
PGObjectFactory.getObjectInstance does not know about
ClassName=org.postgresql.xa.PGXADataSource
Please would one of the developers address this for the next
8.1 driver release.
Thanks
Jonathan Halliday
JBoss, a division of Red Hat
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: bug with PGXADataSource in JNDI
@ 2007-02-26 16:19 Heikki Linnakangas <heikki@enterprisedb.com>
parent: Jonathan Halliday <jonathan.halliday@redhat.com>
0 siblings, 1 reply; 6+ messages in thread
From: Heikki Linnakangas @ 2007-02-26 16:19 UTC (permalink / raw)
To: Jonathan Halliday <jonathan.halliday@redhat.com>; +Cc: pgsql-jdbc
Jonathan Halliday wrote:
>
> Hello JDBC driver developers
>
> I have a requirement to store and retrieve PGXADataSource instances from
> JNDI, specifically using Sun's fscontext provider.
>
> I can get instances into JNDI no problem and they are written out to the
> .bindings file.
>
> I can't retrieve them because PGObjectFactory.getObjectInstance does not
> know about ClassName=org.postgresql.xa.PGXADataSource
>
> Please would one of the developers address this for the next 8.1 driver
> release.
I can write the patch to fix that. Do you happen to have a simple test
case I can use to test it?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: bug with PGXADataSource in JNDI
@ 2007-02-26 17:02 Heikki Linnakangas <heikki@enterprisedb.com>
parent: Heikki Linnakangas <heikki@enterprisedb.com>
0 siblings, 1 reply; 6+ messages in thread
From: Heikki Linnakangas @ 2007-02-26 17:02 UTC (permalink / raw)
To: Jonathan Halliday <jonathan.halliday@redhat.com>; +Cc: pgsql-jdbc
Heikki Linnakangas wrote:
> Jonathan Halliday wrote:
>>
>> Hello JDBC driver developers
>>
>> I have a requirement to store and retrieve PGXADataSource instances
>> from JNDI, specifically using Sun's fscontext provider.
>>
>> I can get instances into JNDI no problem and they are written out to
>> the .bindings file.
>>
>> I can't retrieve them because PGObjectFactory.getObjectInstance does
>> not know about ClassName=org.postgresql.xa.PGXADataSource
>>
>> Please would one of the developers address this for the next 8.1
>> driver release.
>
> I can write the patch to fix that. Do you happen to have a simple test
> case I can use to test it?
Thanks, I got your test case off-list.
Here's the patch against CVS head. It should apply cleanly to 8.1 branch
as well.
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
Attachments:
xa-PGObjectFactory-fix.patch (text/x-patch, 1.6K) download
? xa-PGObjectFactory-fix.patch
? xa-endthenjoin-2.diff
? xa-endthenjoin.diff
Index: org/postgresql/ds/common/PGObjectFactory.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/ds/common/PGObjectFactory.java,v
retrieving revision 1.5
diff -c -r1.5 PGObjectFactory.java
*** org/postgresql/ds/common/PGObjectFactory.java 11 Jan 2005 08:25:45 -0000 1.5
--- org/postgresql/ds/common/PGObjectFactory.java 26 Feb 2007 16:59:38 -0000
***************
*** 14,19 ****
--- 14,20 ----
import java.util.Hashtable;
import org.postgresql.ds.*;
+ import org.postgresql.xa.PGXADataSource;
/**
* Returns a DataSource-ish thing based on a JNDI reference. In the case of a
***************
*** 42,47 ****
--- 43,52 ----
{
return loadSimpleDataSource(ref);
}
+ else if (className.equals("org.postgresql.xa.PGXADataSource"))
+ {
+ return loadXADataSource(ref);
+ }
else if (className.equals("org.postgresql.ds.PGConnectionPoolDataSource")
|| className.equals("org.postgresql.jdbc2.optional.ConnectionPool")
|| className.equals("org.postgresql.jdbc3.Jdbc3ConnectionPool"))
***************
*** 92,97 ****
--- 97,108 ----
return loadBaseDataSource(ds, ref);
}
+ private Object loadXADataSource(Reference ref)
+ {
+ PGXADataSource ds = new PGXADataSource();
+ return loadBaseDataSource(ds, ref);
+ }
+
private Object loadConnectionPool(Reference ref)
{
PGConnectionPoolDataSource cp = new PGConnectionPoolDataSource();
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: bug with PGXADataSource in JNDI
@ 2007-02-26 17:20 Kris Jurka <books@ejurka.com>
parent: Heikki Linnakangas <heikki@enterprisedb.com>
0 siblings, 1 reply; 6+ messages in thread
From: Kris Jurka @ 2007-02-26 17:20 UTC (permalink / raw)
To: Heikki Linnakangas <heikki@enterprisedb.com>; +Cc: Jonathan Halliday <jonathan.halliday@redhat.com>; pgsql-jdbc
On Mon, 26 Feb 2007, Heikki Linnakangas wrote:
> Here's the patch against CVS head. It should apply cleanly to 8.1 branch as
> well.
>
This fails to compile for the JDBC2-EE driver because it supports
datasources, but not XA.
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: bug with PGXADataSource in JNDI
@ 2007-02-26 18:30 Heikki Linnakangas <heikki@enterprisedb.com>
parent: Kris Jurka <books@ejurka.com>
0 siblings, 1 reply; 6+ messages in thread
From: Heikki Linnakangas @ 2007-02-26 18:30 UTC (permalink / raw)
To: Kris Jurka <books@ejurka.com>; +Cc: Jonathan Halliday <jonathan.halliday@redhat.com>; pgsql-jdbc
Kris Jurka wrote:
> On Mon, 26 Feb 2007, Heikki Linnakangas wrote:
>
>> Here's the patch against CVS head. It should apply cleanly to 8.1
>> branch as well.
>>
>
> This fails to compile for the JDBC2-EE driver because it supports
> datasources, but not XA.
Oh, I see. Here's another patch that introduces a new
PGXADataSourceFactory instead of modifying the existing PGObjectFactory.
It's a bit inconsistent that XADataSources have a factory of their own
while others use the plain PGObjectFactory, but I can't get too excited
about this..
How do you test the different builds? Do you need a separate, older JDK
to build each edition?
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
Attachments:
xa-PGObjectFactory-fix-2.patch (text/x-patch, 3.0K) download
? build.local.properties
? xa-PGObjectFactory-fix-2.patch
? xa-PGObjectFactory-fix.patch
? xa-endthenjoin-2.diff
? xa-endthenjoin.diff
Index: org/postgresql/xa/PGXADataSource.java
===================================================================
RCS file: /usr/local/cvsroot/pgjdbc/pgjdbc/org/postgresql/xa/PGXADataSource.java,v
retrieving revision 1.2
diff -c -r1.2 PGXADataSource.java
*** org/postgresql/xa/PGXADataSource.java 29 Oct 2005 18:59:39 -0000 1.2
--- org/postgresql/xa/PGXADataSource.java 26 Feb 2007 18:24:52 -0000
***************
*** 4,9 ****
--- 4,10 ----
import java.sql.SQLException;
import javax.naming.Referenceable;
+ import javax.naming.Reference;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
***************
*** 50,53 ****
--- 51,64 ----
public String getDescription() {
return "JDBC3 XA-enabled DataSource from " + org.postgresql.Driver.getVersion();
}
+
+ /**
+ * Generates a reference using the appropriate object factory.
+ */
+ protected Reference createReference() {
+ return new Reference(
+ getClass().getName(),
+ PGXADataSourceFactory.class.getName(),
+ null);
+ }
}
Index: org/postgresql/xa/PGXADataSourceFactory.java
===================================================================
RCS file: org/postgresql/xa/PGXADataSourceFactory.java
diff -N org/postgresql/xa/PGXADataSourceFactory.java
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- org/postgresql/xa/PGXADataSourceFactory.java 26 Feb 2007 18:24:53 -0000
***************
*** 0 ****
--- 1,47 ----
+ /*-------------------------------------------------------------------------
+ *
+ * Copyright (c) 2007, PostgreSQL Global Development Group
+ *
+ * IDENTIFICATION
+ * $PostgreSQL$
+ *
+ *-------------------------------------------------------------------------
+ */
+ package org.postgresql.xa;
+
+ import org.postgresql.ds.common.*;
+
+ import javax.naming.*;
+ import java.util.Hashtable;
+
+ /**
+ * An ObjectFactory implementation for PGXADataSource-objects.
+ */
+
+ public class PGXADataSourceFactory extends PGObjectFactory
+ {
+ /* All the other PostgreSQL DataSource use PGObjectFactory directly, but we
+ * can't do that with PGXADataSource because referencing PGXADataSource
+ * from PGObjectFactory would break "JDBC2 Enterprise" edition build which
+ * doesn't include PGXADataSource.
+ */
+
+ public Object getObjectInstance(Object obj, Name name, Context nameCtx,
+ Hashtable environment) throws Exception
+ {
+ Reference ref = (Reference)obj;
+ String className = ref.getClassName();
+ if (className.equals("org.postgresql.xa.PGXADataSource"))
+ {
+ return loadXADataSource(ref);
+ }
+ else
+ return null;
+ }
+
+ private Object loadXADataSource(Reference ref)
+ {
+ PGXADataSource ds = new PGXADataSource();
+ return loadBaseDataSource(ds, ref);
+ }
+ }
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: bug with PGXADataSource in JNDI
@ 2007-02-26 19:26 Kris Jurka <books@ejurka.com>
parent: Heikki Linnakangas <heikki@enterprisedb.com>
0 siblings, 0 replies; 6+ messages in thread
From: Kris Jurka @ 2007-02-26 19:26 UTC (permalink / raw)
To: Heikki Linnakangas <heikki@enterprisedb.com>; +Cc: Jonathan Halliday <jonathan.halliday@redhat.com>; pgsql-jdbc
On Mon, 26 Feb 2007, Heikki Linnakangas wrote:
> Oh, I see. Here's another patch that introduces a new PGXADataSourceFactory
> instead of modifying the existing PGObjectFactory. It's a bit inconsistent
> that XADataSources have a factory of their own while others use the plain
> PGObjectFactory, but I can't get too excited about this..
Applied to 8.1, 8.2, and CVS HEAD.
> How do you test the different builds? Do you need a separate, older JDK to
> build each edition?
>
Unfortunately yes, and finding linux machines I can still run 1.2 JDKs on
is getting tougher and tougher.
Kris Jurka
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2007-02-26 19:26 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-02-23 20:56 bug with PGXADataSource in JNDI Jonathan Halliday <jonathan.halliday@redhat.com>
2007-02-26 16:19 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-02-26 17:02 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-02-26 17:20 ` Kris Jurka <books@ejurka.com>
2007-02-26 18:30 ` Heikki Linnakangas <heikki@enterprisedb.com>
2007-02-26 19:26 ` Kris Jurka <books@ejurka.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox