pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki@enterprisedb.com>
To: Kris Jurka <books@ejurka.com>
Cc: Jonathan Halliday <jonathan.halliday@redhat.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: bug with PGXADataSource in JNDI
Date: Mon, 26 Feb 2007 18:30:37 +0000
Message-ID: <45E3274D.2070201@enterprisedb.com> (raw)
In-Reply-To: <Pine.BSO.4.64.0702261218470.8476@leary.csoft.net>
References: <45DF5511.1040601@redhat.com>
	<45E30891.1070102@enterprisedb.com>
	<45E312B2.2090809@enterprisedb.com>
	<Pine.BSO.4.64.0702261218470.8476@leary.csoft.net>

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); + } + }

view thread (6+ messages)  latest in thread

Message-ID: <45E3274D.2070201@enterprisedb.com>
Permalink:  ../45E3274D.2070201@enterprisedb.com/
Also on:    postgresql.org/message-id/45E3274D.2070201@enterprisedb.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: heikki@enterprisedb.com, books@ejurka.com, jonathan.halliday@redhat.com
  Subject: Re: bug with PGXADataSource in JNDI
  In-Reply-To: <45E3274D.2070201@enterprisedb.com>
  References: <45DF5511.1040601@redhat.com> <45E30891.1070102@enterprisedb.com> <45E312B2.2090809@enterprisedb.com> <Pine.BSO.4.64.0702261218470.8476@leary.csoft.net> <45E3274D.2070201@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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