db-jdo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erik Bengtson <e...@jpox.org>
Subject Re: [jira] Commented: (JDO-467) Named PMF proposal / JDOHelper enhancements
Date Sat, 03 Mar 2007 08:47:34 GMT
For implementations that support multiple databases in the same PMF, it would be
nice to allow in the XML to define multiple group of properties e.g.

<pmf>
  <config> <!-- default -->
    <property name="connection-driver-name" value="XXX1">
  </config>
  <config name="postgres">
    <property name="connection-driver-name" value="XXX2">
  </config>
  <config name="oracle-legacy-server">
    <property name="connection-driver-name" value="XXX3">
  </config>
</pmf>

The config name is used by JDO metadata to match the database it belongs to,
with adding a kind of config reference to JDO metadata, e.g.

<class config-ref="oracle-legacy-server">

or with vendor extensions:

<class>
    <extension vendor-name="JPOX" key="datastore" value="oracle-legacy-server"/>
</class>

Of course this config reference can be set at jdo, package, class, interface or
field elements.

Quoting "Matthew T. Adams (JIRA)" <jira@apache.org>:

>
>     [
>
https://issues.apache.org/jira/browse/JDO-467?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12477458
> ]
>
> Matthew T. Adams commented on JDO-467:
> --------------------------------------
>
> Proposed answers to question in previous comment.
>
> > Q: The persistence.xml file is required to be in the META-INF/ folder
> within the persistence archive. What is proposed in JDO 2.1 to align with
> JPA's concept of a persistence archive?
> >
> A: There is no longer the notion of "persistence archive" in JPA.  Ignored.
>
> > Q: If both a jdo.xml and persistence.xml are found, which has precedence?
> >
> A: (Note:  Multiple jdo.xml files are allowed.)  This only matters when there
> are multiple persistence units (PMF and/or EMF) found with the same names and
> the user requested a persistence unit of the same name -- if that happens, a
> JDOUserException should be thrown.
>
> > Q: If a jdo.xml is found but there is no persistence-factory-manager
> element whose name attribute matches the resource,
> > should we throw JDOUserException or fall back to JDO 2.0 & prior behavior,
> looking for a properties resource by the given resource?
> >
> A: Fall back to JDO 2.0 behavior.
>
>
> > Named PMF proposal / JDOHelper enhancements
> > -------------------------------------------
> >
> >                 Key: JDO-467
> >                 URL: https://issues.apache.org/jira/browse/JDO-467
> >             Project: JDO
> >          Issue Type: New Feature
> >          Components: api2, api2-legacy
> >    Affects Versions: JDO 2 maintenance release 1
> >            Reporter: Matthew T. Adams
> >         Attachments: jdo-config.xsd.version-01.txt
> >
> >
> > From the email on the expert group & jdo-dev alias:
> > This is a proposal we discussed on the Fri Feb 23 JDO conf call.  Please
> > review and discuss.
> > Overview:
> > Currently, there is no way to bootstrap a JDO implementation completely
> > externally to the source code.  The developer is required to provide at
> > least a resource name that identifies a java.util.Properties file on the
> > classpath that can configure a single PMF.  This makes deployment in
> > different environments more challenging than necessary.
> > Motivation:
> > * Source code is required to be aware of external configuration:
> >     * In all current JDOHelper.getPersistenceManagerFactory APIs and
> >     * in order to configure listeners.
> > * Aligns JDO bootstrapping with JPA bootstrapping concepts.
> > Proposed Solution:
> > * Introduce new API methods and JDO equivalent of the JPA persistence
> > unit concepts, including a jdo.xml file that provides for the
> > configuration of one or more named PMFs.
> > Details:
> > * PersistenceManagerFactory additions
> > /** Returns the persistence unit name of this PMF.  It's the JPA
> > persistence unit name if configured via persistence.xml or the JDO
> > persistence unit name if configured via javax.jdo.xml. */
> > public String getName();
> > * JDOHelper API additions
> > /** The default name of the JDO configuration file. */
> > public static final String DEFAULT_JDO_CONFIG_RESOURCE_NAME =
> > "javax.jdo.xml";
> > /** The name of the default persistence unit. */
> > public static final String DEFAULT_PMF_NAME = "default";
> > /** Gets the PMF named "default" in the resource "javax.jdo.xml" found
> > via the current ClassLoader. */
> > public static PersistenceManagerFactory getPersistenceFactoryManager() {
> >     return getPersistenceFactoryManagerByName(DEFAULT_PMF_NAME);
> > }
> > /** Gets the PMF named pmfName in the resource "javax.jdo.xml" found via
> > the current ClassLoader. */
> > public static PersistenceManagerFactory
> > getPersistenceManagerFactoryByName(String pmfName) {
> >     return getPersistenceFactoryManagerByName(DEFAULT_PMF_NAME,
> > DEFAULT_JDO_CONFIG_RESOURCE_NAME);
> > }
> > /** Gets the PMF named pmfName in the resource named resourceName found
> > via the current ClassLoader. */
> > public static PersistenceManagerFactory
> > getPersistenceManagerFactoryByName(String pmfName, String resourceName)
> > {
> >     return getPersistenceFactoryManagerByName(DEFAULT_PMF_NAME,
> > DEFAULT_JDO_CONFIG_RESOURCE_NAME, getClass().getClassLoader());
> > }
> > /** Gets the PMF named pmfName in the resource named resourceName found
> > via the current ClassLoader. */
> > public static PersistenceManagerFactory
> > getPersistenceManagerFactoryByName(String pmfName, String resourceName,
> > ClassLoader loader) {
> >     // reads resource resourceName via given loader
> >     // configures & returns PMF with the given name
> > }
> > * Possibilities for DEFAULT_JDO_CONFIG_RESOURCE_NAME value:
> >     need to determine file name (similar to persistence.xml)
> >     javax.jdo.xml
> >     jdo.xml
> >     ...
> > * Proposal for JDO persistence unit configuration XML file
> >     * Could be more like Spring beans.xml (supporting references, etc.)
> >     * Note:  Square brackets indicate optional elements/attributes
> > <jdo-config>
> >     [<extension> elements wherever appropriate]
> >
> >     <!-- Can use attributes for standardized properties -->
> >     <!-- Can also support vendor-specific attributes and still validate
> > against schema -->
> >     <persistence-manager-factory
> >         [name="default"] <!-- no name implies only the default PMF,
> > named "default"; can only be one per file -->
> >         [resource="..."] <!-- convenient for backward compatibility -->
> >
> >         [class="xcalia.ic.jdo.PersistenceManagerFactory"]
> >         [connection-driver="..."]
> >         [connection-url="..."]
> >         [connection-user-name="..."]
> >         [connection-password="..."]
> >         [...]
> >     >
> >         <!-- or XML-friendly <property> elements -->
> >         [<property name="javax.jdo...." value="..."/>]
> >         [<property name="javax.jdo...." value="..."/>]
> >         [<property name="xcalia.ic...." value="..."/>]
> >         [...]
> >
> >         <!-- ...and/or properties in java.util.Properties file format?
> > overrides <property> elements? -->
> >         <!-- This allows people to continue to use good, old
> > java.util.Properties format if they want -->
> >         <properties><![CDATA[
> >             javax.jdo....=...
> >             javax.jdo....=...
> >             xcalia.ic....=...
> >             ...
> >         ]]></properties>
> >         <!-- This provides a way (currently, the only way) to configure
> > listeners outside of the code -->
> >         <!-- We'd have to address any class loading issues, since we're
> > only given a class name -->
> >         <!-- These should have javax.jdo.listener.... property &
> > property value equivalents in order to keep old-fashioned
> > java.util.Property-formatted values consistent with these values -->
> >         <!-- Method names default to names of corresponding interfaces;
> > if not present on listener-class, they're a no-op or not even called -->
> >         [<instance-lifecycle-listener
> >             listener-class="my.jdo.InstanceListener"
> >             classes-observed="my.domain.Foo,my.domain.Bar,.."
> >             [static-factory-method="..."]
> >             [pre-attach="preAttach"]
> >             [post-attach="postAttach"]
> >             [pre-store="preStore"]
> >             [...]
> >         />]
> >
> >         <!-- The <instance-lifecycle-listener> element is sufficient,
> > but we could provide elements for each of the listener types -->
> >         [<attach-lifecycle-listener
> >             class="..."
> >             [factory-method="..."]
> >             [pre-attach="preAttach"]
> >             [post-attach="postAttach"]
> >         />]
> >         [...]
> >         <!-- Can optionally include <jdo>, <orm> and <jdoquery>
elements
> > here in order to override annotations, or developer-provided .jdo, .orm,
> > and/or .jdoquery files (from Erik Bengston) -->
> >         <!-- Can add attribute to <jdo>, <orm>, and <jdoquery>
to allow
> > for the specifiation of another resource or set of resources on the
> > classpath (from Craig Russell), for example: -->
> >         <jdo
> > resources="META-INF/production-1;META-INF/production-2;..."/>
> >
> >     </persistence-manager-factory>
> > </jdo-config>
>
> --
> This message is automatically generated by JIRA.
> -
> You can reply to this email to add a comment to the issue online.
>
>




Mime
View raw message