You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/04/06 11:33:56 UTC

svn commit: r1310262 [10/14] - in /archiva/redback/redback-components/trunk: ./ plexus-command-line/ plexus-command-line/src/ plexus-command-line/src/main/ plexus-command-line/src/main/java/ plexus-command-line/src/main/java/org/ plexus-command-line/sr...

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/AbstractConfigurableJdoFactory.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/AbstractConfigurableJdoFactory.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/AbstractConfigurableJdoFactory.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/AbstractConfigurableJdoFactory.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,177 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * 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.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PostConstruct;
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManagerFactory;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * AbstractConfigurableJdoFactory 
+ *
+ * @version $Id$
+ */
+public abstract class AbstractConfigurableJdoFactory
+    implements ConfigurableJdoFactory
+{
+
+    private Logger logger = LoggerFactory.getLogger( getClass() );
+
+    /**
+     * @plexus.configuration default-value="org.jpox.PersistenceManagerFactoryImpl"
+     */
+    protected String persistenceManagerFactoryClass;
+
+    protected Boolean configured = Boolean.FALSE;
+
+    protected Properties properties;
+
+    private PersistenceManagerFactory pmf;
+
+    protected Properties otherProperties;
+
+    @PostConstruct
+    public void initialize()
+    {
+        if ( otherProperties == null )
+        {
+            otherProperties = new Properties();
+        }
+    }
+
+    public PersistenceManagerFactory getPersistenceManagerFactory()
+    {
+        if ( configured == Boolean.FALSE )
+        {
+            configure();
+        }
+
+        return pmf;
+    }
+
+    public void shutdown()
+        throws Exception
+    {
+    }
+
+    public void setPersistenceManagerFactoryClass( String persistenceManagerFactoryClass )
+    {
+        this.persistenceManagerFactoryClass = persistenceManagerFactoryClass;
+    }
+
+    public void setProperty( String key, String value )
+    {
+        if ( otherProperties == null )
+        {
+            otherProperties = new Properties();
+        }
+        
+        setPropertyInner( otherProperties, key, value );
+    }
+
+    public abstract Properties getProperties();
+
+    private void configure()
+    {
+        synchronized( configured )
+        {
+            if ( configured == Boolean.TRUE )
+            {
+                return;
+            }
+
+            doConfigure();
+        }
+    }
+
+    private void doConfigure()
+    {
+        Properties properties = getProperties();
+
+        if ( logger.isDebugEnabled() )
+        {
+            logger.debug( "Configuring JDO Factory." );
+
+            for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
+            {
+                Map.Entry entry = (Map.Entry) it.next();
+
+                logger.debug( entry.getKey() + "=" + entry.getValue() );
+            }
+        }
+
+        /* TODO: implement these
+        javax.jdo.option.IgnoreCache	true | false	Whether to ignore the cache for queries
+        javax.jdo.option.Multithreaded	true | false	Whether to run the PersistenceManager multithreaded
+        javax.jdo.option.NontransactionalRead	true | false	Whether to allow nontransactional reads
+        javax.jdo.option.NontransactionalWrite	true | false	Whether to allow nontransactional writes. Not supported by JPOX
+        javax.jdo.option.Optimistic	true | false	Whether to use Optimistic transactions
+        javax.jdo.option.RetainValues	true | false	Whether to suppress automatic eviction of persistent instances on transaction completion
+        javax.jdo.option.RestoreValues	true | false	Whether persistent object have transactional field values restored when transaction rollback occurs.
+        javax.jdo.option.Mapping		Name for the ORM MetaData mapping files to use with this PMF. For example if this is set to "mysql" then the implementation looks for MetaData mapping files called "'classname'-mysql.orm" or "package-mysql.orm". If this is not specified then the JDO implementation assumes that all is specified in the JDO MetaData file.
+        javax.jdo.mapping.Catalog		Name of the catalog to use by default for all classes persisted using this PMF. This can be overridden in the MetaData where required, and is optional. JPOX will prefix all table names with this catalog name if the RDBMS supports specification of catalog names in DDL.
+        javax.jdo.mapping.Schema		Name of the schema to use by default for all classes persisted using this PMF. This can be overridden in the MetaData where required, and is optional. JPOX will prefix all table names with this schema name if the RDBMS supports specification of schema names in DDL.
+        */
+
+        pmf = JDOHelper.getPersistenceManagerFactory( properties );
+
+        this.properties = properties;
+
+        configured = Boolean.TRUE;
+    }
+
+    protected void setPropertyInner( Properties properties, String key, String value )
+    {
+        if ( key == null )
+        {
+            throw new IllegalArgumentException( "The key cannot be null." );
+        }
+
+        if ( value == null )
+        {
+            return;
+        }
+
+        properties.setProperty( key, value );
+    }
+
+    public Boolean getConfigured()
+    {
+        return configured;
+    }
+
+    public void setConfigured( Boolean configured )
+    {
+        this.configured = configured;
+    }
+
+    public Properties getOtherProperties()
+    {
+        return otherProperties;
+    }
+
+    public void setOtherProperties( Properties otherProperties )
+    {
+        this.otherProperties = otherProperties;
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/AbstractConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/AbstractConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/ConfigurableJdoFactory.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/ConfigurableJdoFactory.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/ConfigurableJdoFactory.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/ConfigurableJdoFactory.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,32 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public interface ConfigurableJdoFactory
+    extends JdoFactory
+{
+
+    void setPersistenceManagerFactoryClass( String persistenceManagerFactoryClass );
+
+    Properties getProperties();
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/ConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/ConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DataSourceConfigurableJdoFactory.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DataSourceConfigurableJdoFactory.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DataSourceConfigurableJdoFactory.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DataSourceConfigurableJdoFactory.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,119 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * 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.
+ */
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.sql.DataSource;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.sql.SQLException;
+
+/**
+ * @author <a href="mailto:brett@codehaus.org">Brett Porter</a>
+ * @version $Id$
+ */
+public class DataSourceConfigurableJdoFactory
+    extends AbstractConfigurableJdoFactory
+{
+    // ----------------------------------------------------------------------
+    // Configuration
+    // ----------------------------------------------------------------------
+
+    /**
+     * plexus.configuration
+     */
+    private String connectionFactoryName;
+
+    /**
+     * plexus.configuration
+     */
+    private String shutdownConnectionFactoryName;
+
+    public Properties getProperties()
+    {
+        synchronized ( configured )
+        {
+            if ( configured == Boolean.TRUE )
+            {
+                return properties;
+            }
+            else
+            {
+                Properties properties = new Properties();
+
+                Iterator it = otherProperties.entrySet().iterator();
+                while ( it.hasNext() )
+                {
+                    Map.Entry entry = (Map.Entry) it.next();
+                    properties.setProperty( (String) entry.getKey(), (String) entry.getValue() );
+                }
+
+                setPropertyInner( properties, "javax.jdo.PersistenceManagerFactoryClass",
+                                  persistenceManagerFactoryClass );
+                setPropertyInner( properties, "javax.jdo.option.ConnectionFactoryName", connectionFactoryName );
+
+                return properties;
+            }
+        }
+    }
+
+
+    public void shutdown()
+        throws Exception
+    {
+        if ( shutdownConnectionFactoryName != null )
+        {
+            Context ctx = new InitialContext();
+            DataSource ds = (DataSource) ctx.lookup( shutdownConnectionFactoryName );
+            try
+            {
+                ds.getConnection();
+            }
+            catch ( SQLException e )
+            {
+                /*
+                 * In Derby, any request to the DriverManager with a shutdown=true attribute raises an exception.
+                 * http://db.apache.org/derby/manuals/reference/sqlj251.html
+                 */
+            }
+        }
+
+        super.shutdown();
+    }
+
+    public String getConnectionFactoryName()
+    {
+        return connectionFactoryName;
+    }
+
+    public void setConnectionFactoryName( String connectionFactoryName )
+    {
+        this.connectionFactoryName = connectionFactoryName;
+    }
+
+    public String getShutdownConnectionFactoryName()
+    {
+        return shutdownConnectionFactoryName;
+    }
+
+    public void setShutdownConnectionFactoryName( String shutdownConnectionFactoryName )
+    {
+        this.shutdownConnectionFactoryName = shutdownConnectionFactoryName;
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DataSourceConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DataSourceConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactory.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactory.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactory.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactory.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,161 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Copyright 2001-2006 The Codehaus.
+ *
+ * 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.
+ */
+
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class DefaultConfigurableJdoFactory
+    extends AbstractConfigurableJdoFactory
+    implements ConfigurableJdoFactory
+{
+    // ----------------------------------------------------------------------
+    // Configuration
+    // ----------------------------------------------------------------------
+
+    /**
+     * @plexus.configuration
+     */
+    private String driverName;
+
+    /**
+     * @plexus.configuration
+     */
+    private String url;
+
+    /**
+     * @plexus.configuration
+     */
+    private String userName;
+
+    /**
+     * @plexus.configuration
+     */
+    private String password;
+
+    public void setDriverName( String driverName )
+    {
+        this.driverName = driverName;
+    }
+
+    public void setUrl( String url )
+    {
+        this.url = url;
+    }
+
+    public void setUserName( String userName )
+    {
+        this.userName = userName;
+    }
+
+    public void setPassword( String password )
+    {
+        this.password = password;
+    }
+
+    public void shutdown()
+        throws Exception
+    {
+        if ( url != null )
+        {
+
+            if ( url.indexOf( "jdbc:derby:" ) == 0 )
+            {
+                String databasePath = url.substring( "jdbc:derby:".length() );
+
+                if ( databasePath.indexOf( ";" ) > 0 )
+                {
+                    databasePath = databasePath.substring( 0, databasePath.indexOf( ";" ) );
+                }
+
+                try
+                {
+                    /* shutdown the database */
+                    DriverManager.getConnection( "jdbc:derby:" + databasePath + ";shutdown=true" );
+                }
+                catch ( SQLException e )
+                {
+                    /*
+                     * In Derby, any request to the DriverManager with a shutdown=true attribute raises an exception.
+                     * http://db.apache.org/derby/manuals/reference/sqlj251.html
+                     */
+                }
+
+                System.gc();
+            }
+        }
+        super.shutdown();
+    }
+
+    public Properties getProperties()
+    {
+        synchronized( configured )
+        {
+            if ( configured == Boolean.TRUE )
+            {
+                return properties;
+            }
+            else
+            {
+                Properties properties = new Properties();
+
+                Iterator it = otherProperties.entrySet().iterator();
+                while ( it.hasNext() )
+                {
+                    Map.Entry entry = (Map.Entry) it.next();
+                    properties.setProperty( (String) entry.getKey(), (String) entry.getValue() );
+                }
+
+                setPropertyInner( properties, "javax.jdo.PersistenceManagerFactoryClass", persistenceManagerFactoryClass );
+                setPropertyInner( properties, "javax.jdo.option.ConnectionDriverName", driverName );
+                setPropertyInner( properties, "javax.jdo.option.ConnectionURL", url );
+                setPropertyInner( properties, "javax.jdo.option.ConnectionUserName", userName );
+                setPropertyInner( properties, "javax.jdo.option.ConnectionPassword", password );
+
+                return properties;
+            }
+        }
+    }
+
+    public String getDriverName()
+    {
+        return driverName;
+    }
+
+    public String getPassword()
+    {
+        return password;
+    }
+
+    public String getUrl()
+    {
+        return url;
+    }
+
+    public String getUserName()
+    {
+        return userName;
+    }
+
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultJdoFactory.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultJdoFactory.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultJdoFactory.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultJdoFactory.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,136 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Created on Jan 13, 2005
+ *
+ * Copyright STPenable Ltd. (c) 2005
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.PreDestroy;
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManagerFactory;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.util.Properties;
+
+/**
+ * @author David Wynter
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class DefaultJdoFactory
+    implements JdoFactory
+{
+    private Logger logger = LoggerFactory.getLogger( getClass() );
+
+    private static final String CONNECTION_DRIVER_NAME = "javax.jdo.option.ConnectionDriverName";
+
+    /**
+     * @configuration
+     */
+    private Properties properties;
+
+    private PersistenceManagerFactory persistenceManagerFactory;
+
+    public PersistenceManagerFactory getPersistenceManagerFactory()
+    {
+        return persistenceManagerFactory;
+    }
+
+    // ----------------------------------------------------------------------
+    // Component Lifecycle
+    // ----------------------------------------------------------------------
+
+    @PostConstruct
+    public void initialize()
+    {
+        logger.info( "Initializing JDO." );
+
+        persistenceManagerFactory = JDOHelper.getPersistenceManagerFactory( properties );
+
+        String driverClass = null;
+
+        try
+        {
+            driverClass = (String) properties.get( CONNECTION_DRIVER_NAME );
+            
+            if ( driverClass == null )
+            {
+                throw new RuntimeException( "Property " + CONNECTION_DRIVER_NAME + " was not set in JDO Factory." );
+            }
+
+            //TODO: Class.forName is evil
+            Class.forName( driverClass );
+        }
+        catch ( ClassNotFoundException e )
+        {
+            throw new RuntimeException( "Cannot find driver class: " + driverClass, e );
+        }
+    }
+
+    public void shutdown()
+        throws Exception
+    {
+        dispose();
+    }
+
+    @PreDestroy
+    public void dispose()
+    {
+        if ( properties != null )
+        {
+            String databaseUrl = properties.getProperty( "javax.jdo.option.ConnectionURL" );
+
+            if ( databaseUrl != null )
+            {
+
+                if ( databaseUrl.indexOf( "jdbc:derby:" ) == 0 )
+                {
+                    String databasePath = databaseUrl.substring( "jdbc:derby:".length() );
+
+                    if ( databasePath.indexOf( ";" ) > 0 )
+                    {
+                        databasePath = databasePath.substring( 0, databasePath.indexOf( ";" ) );
+                    }
+
+                    try
+                    {
+                        /* shutdown the database */
+                        DriverManager.getConnection( "jdbc:derby:" + databasePath + ";shutdown=true" );
+                    }
+                    catch ( SQLException e )
+                    {
+                        /*
+                         * In Derby, any request to the DriverManager with a shutdown=true attribute raises an exception.
+                         * http://db.apache.org/derby/manuals/reference/sqlj251.html
+                         */
+                    }
+
+                    System.gc();
+                }
+            }
+        }
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultJdoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/DefaultJdoFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/JdoFactory.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/JdoFactory.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/JdoFactory.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/JdoFactory.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,38 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Created on Jan 13, 2005
+ *
+ * Copyright STPenable Ltd. (c) 2005
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import javax.jdo.PersistenceManagerFactory;
+
+/**
+ * @author David Wynter
+ */
+public interface JdoFactory
+{
+    PersistenceManagerFactory getPersistenceManagerFactory();
+
+    void shutdown()
+        throws Exception;
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/JdoFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/JdoFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusJdoUtils.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusJdoUtils.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusJdoUtils.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusJdoUtils.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,534 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import org.apache.commons.lang.StringUtils;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jdo.Extent;
+import javax.jdo.JDOException;
+import javax.jdo.JDOHelper;
+import javax.jdo.JDOObjectNotFoundException;
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class PlexusJdoUtils
+{
+    /**
+     * This operation as opposed to
+     * {@link #updateObject(PersistenceManager, Object)} is an
+     * <em>new school</em> technique, which <em><b>does not</b></em>
+     * requires that the object be previously added using
+     * {@link #addObject(PersistenceManager, Object)} or
+     * {@link #addObject(PersistenceManager, Object, String[])}.
+     * 
+     * @param pm
+     * @param object
+     * @param fetchGroups
+     * @return
+     * @throws PlexusStoreException
+     * @see {@link #updateObject(PersistenceManager, Object)} for old technique.
+     */
+    public static Object saveObject( PersistenceManager pm, Object object, String fetchGroups[] )
+        throws PlexusStoreException
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            if ( ( JDOHelper.getObjectId( object ) != null ) && !JDOHelper.isDetached( object ) )
+            {
+                throw new PlexusStoreException( "Existing object is not detached: " + object );
+            }
+
+            if ( fetchGroups != null )
+            {
+                for ( int i = 0; i >= fetchGroups.length; i++ )
+                {
+                    pm.getFetchPlan().addGroup( fetchGroups[i] );
+                }
+            }
+
+            pm.makePersistent( object );
+
+            object = pm.detachCopy( object );
+
+            tx.commit();
+
+            return object;
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    public static Object addObject( PersistenceManager pm, Object object )
+    {
+        return addObject( pm, object, null );
+    }
+
+    public static Object addObject( PersistenceManager pm, Object object, String fetchGroups[] )
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            if ( fetchGroups != null )
+            {
+                for ( int i = 0; i >= fetchGroups.length; i++ )
+                {
+                    pm.getFetchPlan().addGroup( fetchGroups[i] );
+                }
+            }
+
+            pm.makePersistent( object );
+
+            object = pm.detachCopy( object );
+
+            tx.commit();
+
+            return object;
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    public static void removeObject( PersistenceManager pm, Object o )
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            o = pm.getObjectById( pm.getObjectId( o ) );
+
+            pm.deletePersistent( o );
+
+            tx.commit();
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    /**
+     * This operation is an <em>old school</em> technique, which required that
+     * the object be previously added using
+     * {@link #addObject(PersistenceManager, Object)} or
+     * {@link #addObject(PersistenceManager, Object, String[])}.
+     * 
+     * @param pm
+     * @param object
+     * @return
+     * @throws PlexusStoreException
+     * @see {@link #saveObject(PersistenceManager, Object, String[])}
+     */
+    public static Object updateObject( PersistenceManager pm, Object object ) throws PlexusStoreException
+    {
+        Object ret = object;
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            if ( !JDOHelper.isDetached( object ) )
+            {
+                throw new PlexusStoreException( "Not detached: " + object );
+            }
+
+            try
+            {
+                ret = pm.makePersistent( object );
+            }
+            catch ( NullPointerException npe )
+            {
+                // Do not hide useful error messages.
+                // This exception can occur if you have an object with a List
+                // that isn't initialized yet.
+                throw new PlexusStoreException( "Unable to update object due to unexpected null value.", npe );
+            }
+            catch ( Exception e )
+            {
+                // TODO: Refactor to avoid using Exception catch-all.
+                // We retry if we obtain an exception like a dead lock
+                ret = pm.makePersistent( object );
+            }
+
+            tx.commit();
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+
+        return ret;
+    }
+
+    public static Object makePersistent( PersistenceManager pm, Object object, boolean detach )
+    {
+        pm.makePersistent( object );
+
+        Object id = pm.getObjectId( object );
+
+        Object persistentObject = pm.getObjectById( id );
+
+        if ( detach )
+        {
+            persistentObject = pm.detachCopy( persistentObject );
+        }
+
+        return persistentObject;
+    }
+
+    public static Object getObjectById( PersistenceManager pm, Class clazz, String id )
+        throws PlexusObjectNotFoundException, PlexusStoreException
+    {
+        return getObjectById( pm, clazz, id, null );
+    }
+
+    public static Object getObjectById( PersistenceManager pm, Class clazz, String id, String fetchGroup )
+        throws PlexusStoreException, PlexusObjectNotFoundException
+    {
+        if ( StringUtils.isBlank( id ) )
+        {
+            throw new PlexusStoreException( "Unable to get object '" + clazz.getName() + "' from jdo using null id." );
+        }
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            if ( fetchGroup != null )
+            {
+                pm.getFetchPlan().addGroup( fetchGroup );
+            }
+
+            Object objectId = pm.newObjectIdInstance( clazz, id );
+
+            Object object = pm.getObjectById( objectId );
+
+            object = pm.detachCopy( object );
+
+            tx.commit();
+
+            return object;
+        }
+        catch ( JDOObjectNotFoundException e )
+        {
+            throw new PlexusObjectNotFoundException( clazz.getName(), id );
+        }
+        catch ( JDOException e )
+        {
+            throw new PlexusStoreException( "Error handling JDO", e );
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    /**
+     * @deprecated Use {@link #getObjectById(PersistenceManager,Class,long)}
+     *             instead
+     */
+    public static Object getObjectById( PersistenceManager pm, Class clazz, int id )
+        throws PlexusStoreException, PlexusObjectNotFoundException
+    {
+        return getObjectById( pm, clazz, (long) id );
+    }
+
+    /**
+     * Obtain and return an {@link Object} instance from the underlying data
+     * store based on the passed in identifier.
+     * 
+     * @param pm {@link PersistenceManager} manager to use to query database.
+     * @param clazz Expected {@link Class} of the Object instance to be
+     *            returned.
+     * @param id Object identifier to match in the database.
+     * @return Object instance that matches the passed in identifier.
+     * @throws PlexusStoreException if there was an error querying the database
+     *             for the object.
+     * @throws PlexusObjectNotFoundException if a matching object could not be
+     *             found.
+     */
+    public static Object getObjectById( PersistenceManager pm, Class clazz, long id )
+        throws PlexusStoreException, PlexusObjectNotFoundException
+    {
+        return getObjectById( pm, clazz, id, null );
+    }
+
+    /**
+     * @deprecated Use
+     *             {@link #getObjectById(PersistenceManager,Class,long, String)}
+     *             instead
+     */
+    public static Object getObjectById( PersistenceManager pm, Class clazz, int id, String fetchGroup )
+        throws PlexusStoreException, PlexusObjectNotFoundException
+    {
+        return getObjectById( pm, clazz, (long) id, fetchGroup );
+    }
+
+    /**
+     * Obtain and return an {@link Object} instance from the underlying data
+     * store based on the passed in identifier.
+     * 
+     * @param pm {@link PersistenceManager} manager to use to query database.
+     * @param clazz Expected {@link Class} of the Object instance to be
+     *            returned.
+     * @param id Object identifier to match in the database.
+     * @param fetchGroup TODO: Document!
+     * @return Object instance that matches the passed in identifier.
+     * @throws PlexusStoreException if there was an error querying the database
+     *             for the object.
+     * @throws PlexusObjectNotFoundException if a matching object could not be
+     *             found.
+     */
+    public static Object getObjectById( PersistenceManager pm, Class clazz, long id, String fetchGroup )
+        throws PlexusStoreException, PlexusObjectNotFoundException
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            if ( fetchGroup != null )
+            {
+                pm.getFetchPlan().addGroup( fetchGroup );
+            }
+
+            Object objectId = pm.newObjectIdInstance( clazz, Long.valueOf( id ) );
+
+            Object object = pm.getObjectById( objectId );
+
+            object = pm.detachCopy( object );
+
+            tx.commit();
+
+            return object;
+        }
+        catch ( JDOObjectNotFoundException e )
+        {
+            throw new PlexusObjectNotFoundException( clazz.getName(), Long.toString( id ) );
+        }
+        catch ( JDOException e )
+        {
+            e.printStackTrace();
+            throw new PlexusStoreException( "Error handling JDO", e );
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    public static Object getObjectFromQuery( PersistenceManager pm, Class clazz, String idField, String id,
+                                             String fetchGroup )
+        throws PlexusStoreException, PlexusObjectNotFoundException
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( clazz, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String " + idField );
+
+            query.setFilter( "this." + idField + " == " + idField );
+
+            Collection result = (Collection) query.execute( id );
+
+            if ( result.size() == 0 )
+            {
+                throw new PlexusObjectNotFoundException( clazz.getName(), id );
+            }
+
+            if ( result.size() > 1 )
+            {
+                throw new PlexusStoreException( "A query for object of " + "type " + clazz.getName() + " on the "
+                                + "field '" + idField + "' returned more than one object." );
+            }
+
+            pm.getFetchPlan().addGroup( fetchGroup );
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            tx.commit();
+
+            return object;
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    public static List getAllObjectsDetached( PersistenceManager pm, Class clazz )
+    {
+        return getAllObjectsDetached( pm, clazz, null );
+    }
+
+    public static List getAllObjectsDetached( PersistenceManager pm, Class clazz, String fetchGroup )
+    {
+        return getAllObjectsDetached( pm, clazz, null, fetchGroup );
+    }
+
+    public static List getAllObjectsDetached( PersistenceManager pm, Class clazz, String ordering, String fetchGroup )
+    {
+        if ( fetchGroup != null )
+        {
+            return getAllObjectsDetached( pm, clazz, ordering, Collections.singletonList( fetchGroup ) );
+        }
+        else
+        {
+            return getAllObjectsDetached( pm, clazz, ordering, Collections.EMPTY_LIST );
+        }
+    }
+
+    public static List getAllObjectsDetached( PersistenceManager pm, Class clazz, String ordering,
+                                              List/* <String> */fetchGroups )
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( clazz, true );
+
+            Query query = pm.newQuery( extent );
+
+            if ( ordering != null )
+            {
+                query.setOrdering( ordering );
+            }
+
+            for ( Iterator i = fetchGroups.iterator(); i.hasNext(); )
+            {
+                pm.getFetchPlan().addGroup( (String) i.next() );
+            }
+
+            List result = (List) query.execute();
+
+            result = (List) pm.detachCopyAll( result );
+
+            tx.commit();
+
+            return result;
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    public static void attachAndDelete( PersistenceManager pm, Object object )
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            pm.makePersistent( object );
+
+            pm.deletePersistent( object );
+
+            tx.commit();
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+
+    public static void rollbackIfActive( Transaction tx )
+    {
+        PersistenceManager pm = tx.getPersistenceManager();
+
+        try
+        {
+            if ( tx.isActive() )
+            {
+                tx.rollback();
+            }
+        }
+        finally
+        {
+            closePersistenceManager( pm );
+        }
+    }
+
+    public static void closePersistenceManager( PersistenceManager pm )
+    {
+        try
+        {
+            pm.close();
+        }
+        catch ( JDOUserException e )
+        {
+            // ignore
+        }
+    }
+
+    public static void removeAll( PersistenceManager pm, Class aClass )
+    {
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Query query = pm.newQuery( aClass );
+            query.deletePersistentAll();
+
+            tx.commit();
+        }
+        finally
+        {
+            rollbackIfActive( tx );
+        }
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusJdoUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusJdoUtils.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusObjectNotFoundException.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusObjectNotFoundException.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusObjectNotFoundException.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusObjectNotFoundException.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,14 @@
+package org.codehaus.plexus.jdo;
+
+/**
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class PlexusObjectNotFoundException
+    extends PlexusStoreException
+{
+    public PlexusObjectNotFoundException( String type, String id )
+    {
+        super( "Could not find object. Type '" + type + "'. Id: '" + id + "'." );
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusObjectNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusObjectNotFoundException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusStoreException.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusStoreException.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusStoreException.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusStoreException.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,19 @@
+package org.codehaus.plexus.jdo;
+
+/**
+ * @author <a href="mailto:evenisse@codehaus.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class PlexusStoreException
+    extends Exception
+{
+    public PlexusStoreException( String msg )
+    {
+        super( msg );
+    }
+
+    public PlexusStoreException( String msg, Exception ex )
+    {
+        super( msg, ex );
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusStoreException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/java/org/codehaus/plexus/jdo/PlexusStoreException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/main/resources/META-INF/spring-context.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/main/resources/META-INF/spring-context.xml (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/main/resources/META-INF/spring-context.xml Fri Apr  6 09:33:40 2012
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you 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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans
+           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+           http://www.springframework.org/schema/context 
+           http://www.springframework.org/schema/context/spring-context-3.0.xsd"
+       default-lazy-init="true">
+
+  <context:annotation-config />
+  <context:component-scan 
+    base-package="org.codehaus.plexus.jdo"/>
+
+ 
+</beans>
\ No newline at end of file

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/main/resources/META-INF/spring-context.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Basic.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Basic.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Basic.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Basic.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,138 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * Basic Object (post-processed from modello:java)
+ * 
+ * @version $Id$
+ */
+public class Basic implements java.io.Serializable {
+
+    /**
+     * Field id
+     */
+    private long id = 0;
+
+    /**
+     * Field name
+     */
+    private String name;
+
+    /**
+     * Field description
+     */
+    private String description;
+
+    /**
+     * Method equals
+     * 
+     * @param other
+     */
+    public boolean equals(Object other)
+    {
+        if ( this == other)
+        {
+            return true;
+        }
+        
+        if ( !(other instanceof Basic) )
+        {
+            return false;
+        }
+        
+        Basic that = (Basic) other;
+        boolean result = true;
+        result = result && id== that.id;
+        return result;
+    } 
+
+    /**
+     * Get description
+     */
+    public String getDescription()
+    {
+        return this.description;
+    }  
+
+    /**
+     * Get id
+     */
+    public long getId()
+    {
+        return this.id;
+    }  
+
+    /**
+     * Get name
+     */
+    public String getName()
+    {
+        return this.name;
+    }  
+
+    /**
+     * Method hashCode
+     */
+    public int hashCode()
+    {
+        int result = 17;
+        result = 37 * result + (int) id;
+        return result;
+    } 
+
+    /**
+     * Set description
+     * 
+     * @param description
+     */
+    public void setDescription(String description)
+    {
+        this.description = description;
+    } 
+
+    /**
+     * Set id
+     * 
+     * @param id
+     */
+    public void setId(long id)
+    {
+        this.id = id;
+    }  
+
+    /**
+     * Set name
+     * 
+     * @param name
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }  
+
+    /**
+     * Method toString
+     */
+    public java.lang.String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "id = '" );
+        buf.append( getId() + "'" );
+        return buf.toString();
+    }  
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Basic.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Basic.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Child.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Child.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Child.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Child.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,149 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * modello:java generated file.
+ * 
+ * @author <a href="mailto:mattis@inamo.no">Mathias Bjerke</a>
+ * @version $Id$
+ */
+public class Child
+    implements java.io.Serializable
+{
+
+    /**
+     * Field id
+     */
+    private long id = 0;
+
+    /**
+     * Field name
+     */
+    private String name;
+
+    /**
+     * Field description
+     */
+    private String description;
+
+    /**
+     * Method equals
+     * 
+     * @param other
+     */
+    public boolean equals( Object other )
+    {
+        if ( this == other )
+        {
+            return true;
+        }
+
+        if ( !( other instanceof Child ) )
+        {
+            return false;
+        }
+
+        Child that = (Child) other;
+        boolean result = true;
+        result = result && id == that.id;
+        return result;
+    }
+
+    /**
+     * Get description
+     */
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    /**
+     * Get id
+     */
+    public long getId()
+    {
+        return this.id;
+    }
+
+    /**
+     * Get name
+     */
+    public String getName()
+    {
+        return this.name;
+    }
+
+    /**
+     * Method hashCode
+     */
+    public int hashCode()
+    {
+        int result = 17;
+        result = 37 * result + (int) ( id ^ ( id >>> 32 ) );
+        return result;
+    }
+
+    /**
+     * Set description
+     * 
+     * @param description
+     */
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    /**
+     * Set id
+     * 
+     * @param id
+     */
+    public void setId( long id )
+    {
+        this.id = id;
+    }
+
+    /**
+     * Set name
+     * 
+     * @param name
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    /**
+     * Method toString
+     */
+    public java.lang.String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "id = '" );
+        buf.append( getId() + "'" );
+        return buf.toString();
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Child.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Child.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactoryTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactoryTest.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactoryTest.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactoryTest.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,55 @@
+package org.codehaus.plexus.jdo;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.jdo.PersistenceManager;
+
+import org.jpox.PersistenceManagerFactoryImpl;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * Test for {@link DefaultConfigurableJdoFactory}
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context-configurable.xml" } )
+public class DefaultConfigurableJdoFactoryTest
+    extends DefaultJdoFactoryTest
+{
+
+    @Inject @Named(value = "jdoFactory")
+    DefaultConfigurableJdoFactory jdoFactory;
+
+    @Test
+    public void testLoad()
+        throws Exception
+    {
+        String password = jdoFactory.getProperties().getProperty( "javax.jdo.option.ConnectionPassword" );
+        assertNull( password );
+
+        PersistenceManagerFactoryImpl pmf = (PersistenceManagerFactoryImpl) jdoFactory.getPersistenceManagerFactory();
+        assertTrue( pmf.getAutoCreateTables() );
+    }
+
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultConfigurableJdoFactoryTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultJdoFactoryTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultJdoFactoryTest.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultJdoFactoryTest.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultJdoFactoryTest.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,83 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Created on Jan 13, 2005
+ *
+ * Copyright STPenable Ltd. (c) 2005
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+import junit.framework.TestCase;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+
+/**
+ * @author David Wynter
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class DefaultJdoFactoryTest
+    extends TestCase
+{
+
+    @Inject
+    JdoFactory jdoFactory;
+
+    @Test
+    public void testBasic()
+        throws Exception
+    {
+
+        PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();
+
+        PersistenceManager pm = pmf.getPersistenceManager();
+/*
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Parent parent = new Parent( "Sony Discman", "A standard discman from Sony", 49.99 );
+
+            pm.makePersistent( parent );
+
+            tx.commit();
+        }
+        finally
+        {
+            if ( tx.isActive() )
+            {
+                tx.rollback();
+            }
+
+            pm.close();
+        }
+*/
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultJdoFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/DefaultJdoFactoryTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Parent.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Parent.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Parent.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Parent.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,220 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * The MIT License
+ *
+ * Copyright (c) 2004, The Codehaus
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+/**
+ * modello:java generated file.
+ * 
+ * @author <a href="mailto:mattis@inamo.no">Mathias Bjerke</a> 
+ * @version $Id$
+ */
+public class Parent
+    implements java.io.Serializable
+{
+
+    /**
+     * Field id
+     */
+    private long id = 0;
+
+    /**
+     * Field price
+     */
+    private double price = 0.0;
+
+    /**
+     * Field name
+     */
+    private String name;
+
+    /**
+     * Field description
+     */
+    private String description;
+
+    /**
+     * Field children
+     */
+    private java.util.List children;
+
+    /**
+     * Method addChildren
+     * 
+     * @param child
+     */
+    public void addChildren( Child child )
+    {
+        getChildren().add( child );
+    }
+
+    /**
+     * Method equals
+     * 
+     * @param other
+     */
+    public boolean equals( Object other )
+    {
+        if ( this == other )
+        {
+            return true;
+        }
+
+        if ( !( other instanceof Parent ) )
+        {
+            return false;
+        }
+
+        Parent that = (Parent) other;
+        boolean result = true;
+        result = result && id == that.id;
+        return result;
+    }
+
+    /**
+     * Method getChildren
+     */
+    public java.util.List getChildren()
+    {
+        if ( this.children == null )
+        {
+            this.children = new java.util.ArrayList();
+        }
+
+        return this.children;
+    }
+
+    /**
+     * Get description
+     */
+    public String getDescription()
+    {
+        return this.description;
+    }
+
+    /**
+     * Get id
+     */
+    public long getId()
+    {
+        return this.id;
+    }
+
+    /**
+     * Get name
+     */
+    public String getName()
+    {
+        return this.name;
+    }
+
+    /**
+     * Get price
+     */
+    public double getPrice()
+    {
+        return this.price;
+    }
+
+    /**
+     * Method hashCode
+     */
+    public int hashCode()
+    {
+        int result = 17;
+        result = 37 * result + (int) ( id ^ ( id >>> 32 ) );
+        return result;
+    }
+
+    /**
+     * Method removeChildren
+     * 
+     * @param child
+     */
+    public void removeChildren( Child child )
+    {
+        getChildren().remove( child );
+    }
+
+    /**
+     * Set children
+     * 
+     * @param children
+     */
+    public void setChildren( java.util.List children )
+    {
+        this.children = children;
+    }
+
+    /**
+     * Set description
+     * 
+     * @param description
+     */
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    /**
+     * Set id
+     * 
+     * @param id
+     */
+    public void setId( long id )
+    {
+        this.id = id;
+    }
+
+    /**
+     * Set name
+     * 
+     * @param name
+     */
+    public void setName( String name )
+    {
+        this.name = name;
+    }
+
+    /**
+     * Set price
+     * 
+     * @param price
+     */
+    public void setPrice( double price )
+    {
+        this.price = price;
+    }
+
+    /**
+     * Method toString
+     */
+    public java.lang.String toString()
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "id = '" );
+        buf.append( getId() + "'" );
+        return buf.toString();
+    }
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Parent.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/Parent.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/PlexusJdoUtilsTest.java
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/PlexusJdoUtilsTest.java?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/PlexusJdoUtilsTest.java (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/PlexusJdoUtilsTest.java Fri Apr  6 09:33:40 2012
@@ -0,0 +1,170 @@
+package org.codehaus.plexus.jdo;
+
+/*
+ * Copyright 2001-2006 The Apache Software Foundation.
+ *
+ * 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.
+ */
+
+import junit.framework.TestCase;
+import org.jpox.SchemaTool;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * Tests for PlexusJdoUtilsTest 
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id$
+ */
+@RunWith( SpringJUnit4ClassRunner.class )
+@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath*:/spring-context.xml" } )
+public class PlexusJdoUtilsTest
+    extends TestCase
+{
+    private PersistenceManagerFactory pmf;
+
+    @Inject @Named(value = "jdoUtilsTest")
+    DefaultConfigurableJdoFactory jdoFactory;
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() );
+
+        jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" ); 
+
+        jdoFactory.setDriverName( "org.hsqldb.jdbcDriver" ); 
+
+        jdoFactory.setUrl( "jdbc:hsqldb:mem:" + getName() ); 
+
+        jdoFactory.setUserName( "sa" ); 
+
+        jdoFactory.setPassword( "" ); 
+
+        jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_UNCOMMITTED" );  
+
+        jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_UNCOMMITTED" );  
+
+        jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" );  
+
+        Properties properties = jdoFactory.getProperties();
+
+        for ( Iterator it = properties.entrySet().iterator(); it.hasNext(); )
+        {
+            Map.Entry entry = (Map.Entry) it.next();
+
+            System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
+        }
+
+        SchemaTool.createSchemaTables( new URL[] { getClass().getResource( "/META-INF/package.jdo" ) }, new URL[] {}, null, false, null ); 
+
+        pmf = jdoFactory.getPersistenceManagerFactory();
+        assertNotNull( pmf );
+
+        PersistenceManager pmgr = pmf.getPersistenceManager();
+        pmgr.close();
+    }
+    
+    private PersistenceManager getPersistenceManager()
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        pm.getFetchPlan().setMaxFetchDepth( -1 );
+
+        return pm;
+    }
+
+    @Test
+    public void testAddGetUpdateBasic()
+        throws Exception
+    {
+        Basic basic = new Basic();
+        basic.setName( "Fry" );
+        basic.setDescription( "Addicted to Slurm" );
+
+        Basic added = (Basic) PlexusJdoUtils.addObject( getPersistenceManager(), basic );
+
+        // Ensure that only 1 entry exists.
+        assertEquals( 1, PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), Basic.class ).size() );
+
+        Basic fetched = (Basic) PlexusJdoUtils.getObjectById( getPersistenceManager(), Basic.class, added.getId() );
+
+        long id = fetched.getId();
+        String BRAINSLUG = "Starved a Brain Slug";
+
+        fetched.setDescription( BRAINSLUG );
+
+        PlexusJdoUtils.updateObject( getPersistenceManager(), fetched );
+
+        // Ensure that only 1 still entry exists.
+        assertEquals( 1, PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), Basic.class ).size() );
+
+        Basic actual = (Basic) PlexusJdoUtils.getObjectById( getPersistenceManager(), Basic.class, id );
+        assertEquals( BRAINSLUG, actual.getDescription() );
+    }
+
+    @Test
+    public void testAddGetUpdateParentChild()
+        throws Exception
+    {
+        Parent parent = new Parent();
+        parent.setName( "Doctor Farnsworth" );
+        parent.setDescription( "Great x30 Newphew of Fry");
+        parent.setPrice( 30.00 );
+        
+        Child cubert = new Child();
+        cubert.setName( "Cubert" );
+        cubert.setDescription( "Clone of Farnsworth" );
+        
+        parent.addChildren( cubert );
+
+        Parent added = (Parent) PlexusJdoUtils.addObject( getPersistenceManager(), parent );
+
+        // Ensure that only 1 entry exists.
+        assertEquals( 1, PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), Parent.class ).size() );
+
+        Parent fetched = (Parent) PlexusJdoUtils.getObjectById( getPersistenceManager(), Parent.class, added.getId() );
+        assertNotNull( fetched );
+        assertNotNull( fetched.getChildren() );
+        assertEquals( 1, fetched.getChildren().size() );
+
+        long id = fetched.getId();
+        String PLANETEXPRESS = "Owns Planet Express";
+
+        fetched.setDescription( PLANETEXPRESS );
+
+        PlexusJdoUtils.updateObject( getPersistenceManager(), fetched );
+
+        // Ensure that only 1 still entry exists.
+        assertEquals( 1, PlexusJdoUtils.getAllObjectsDetached( getPersistenceManager(), Parent.class ).size() );
+
+        Parent actual = (Parent) PlexusJdoUtils.getObjectById( getPersistenceManager(), Parent.class, id );
+        assertEquals( PLANETEXPRESS, actual.getDescription() );
+    }
+    
+}

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/PlexusJdoUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/java/org/codehaus/plexus/jdo/PlexusJdoUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/mdo/testobjects.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/mdo/testobjects.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/mdo/testobjects.xml (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/mdo/testobjects.xml Fri Apr  6 09:33:40 2012
@@ -0,0 +1,93 @@
+<model>
+  <id>plexus-jdo2-test-objects</id>
+  <name>Plexus JDO2 Component Test Model</name>
+  <description>Test Object for Plexus JDO2 Component object model.</description>
+  <defaults>
+    <default>
+      <key>package</key>
+      <value>org.codehaus.plexus.jdo</value>
+    </default>
+  </defaults>
+
+  <classes>
+    <class stash.storable="true">
+      <name>Basic</name>
+      <version>1.0.0+</version>
+      <fields>
+        <field>
+          <name>id</name>
+          <identifier>true</identifier>
+          <version>1.0.0+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>name</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+      </fields>
+    </class>
+    <class stash.storable="true">
+      <name>Parent</name>
+      <version>1.0.0+</version>
+      <fields>
+        <field>
+          <name>id</name>
+          <identifier>true</identifier>
+          <version>1.0.0+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>price</name>
+          <version>1.0.0+</version>
+          <type>double</type>
+        </field>
+        <field>
+          <name>name</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>children</name>
+          <version>1.0.0+</version>
+          <association stash.part="true">
+            <type>Child</type>
+            <multiplicity>*</multiplicity>
+          </association>
+        </field>
+      </fields>
+    </class>
+    <class stash.storable="true">
+      <name>Child</name>
+      <version>1.0.0+</version>
+      <fields>
+        <field>
+          <name>id</name>
+          <identifier>true</identifier>
+          <version>1.0.0+</version>
+          <type>int</type>
+        </field>
+        <field>
+          <name>name</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+        <field>
+          <name>description</name>
+          <version>1.0.0+</version>
+          <type>String</type>
+        </field>
+      </fields>
+    </class>
+  </classes>
+</model>

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/mdo/testobjects.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/mdo/testobjects.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/META-INF/package.jdo
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/META-INF/package.jdo?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/META-INF/package.jdo (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/META-INF/package.jdo Fri Apr  6 09:33:40 2012
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!DOCTYPE jdo PUBLIC
+  "-//Sun Microsystems, Inc.//DTD Java Data Objects Metadata 2.0//EN"
+  "http://java.sun.com/dtd/jdo_2_0.dtd">
+
+<jdo>
+  <package name="org.codehaus.plexus.jdo">
+    <class name="Basic" detachable="true" identity-type="application" objectid-class="javax.jdo.identity.LongIdentity">
+      <field name="id" primary-key="true" value-strategy="native"/>
+      <field name="name"/>
+      <field name="description"/>
+    </class>
+    <class name="Parent" detachable="true" identity-type="application" objectid-class="javax.jdo.identity.LongIdentity">
+      <field name="id" primary-key="true" value-strategy="native"/>
+      <field name="price"/>
+      <field name="name"/>
+      <field name="description"/>
+      <field name="children" default-fetch-group="true">
+        <collection element-type="Child" dependent-element="true"/>
+        <join/>
+      </field>
+    </class>
+    <class name="Child" detachable="true" identity-type="application" objectid-class="javax.jdo.identity.LongIdentity">
+      <field name="id" primary-key="true" value-strategy="native"/>
+      <field name="name"/>
+      <field name="description"/>
+    </class>
+  </package>
+</jdo>

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/log4j.properties?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/log4j.properties (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/log4j.properties Fri Apr  6 09:33:40 2012
@@ -0,0 +1,21 @@
+# Define the destination and format of our logging
+log4j.appender.root=org.apache.log4j.ConsoleAppender
+log4j.appender.root.layout=org.apache.log4j.PatternLayout
+log4j.appender.root.layout.ConversionPattern=%d{HH:mm:ss,SSS} (%t) %-5p [%c] - %m%n
+
+# JPOX Categories
+log4j.category.JPOX=INFO, root
+
+#log4j.category.JPOX.JDO=INFO, root
+#log4j.category.JPOX.Cache=INFO, root
+#log4j.category.JPOX.MetaData=INFO, root
+#log4j.category.JPOX.General=INFO, root
+#log4j.category.JPOX.Utility=INFO, root
+#log4j.category.JPOX.Transaction=INFO, root
+#log4j.category.JPOX.RDBMS=DEBUG, root
+#log4j.category.JPOX.RDBMS.Schema=INFO, root
+#log4j.category.JPOX.RDBMS.DDL=INFO, root
+#log4j.category.JPOX.RDBMS.SQL=DEBUG, root
+#log4j.category.JPOX.Enhancer.Parser=INFO, root
+#log4j.category.JPOX.Enhancer=INFO, root
+#log4j.category.JPOX.SchemaTool=INFO, root

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/log4j.properties
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/plexus-jdo-config.xml
URL: http://svn.apache.org/viewvc/archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/plexus-jdo-config.xml?rev=1310262&view=auto
==============================================================================
--- archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/plexus-jdo-config.xml (added)
+++ archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/plexus-jdo-config.xml Fri Apr  6 09:33:40 2012
@@ -0,0 +1,48 @@
+<plexus>
+  <components>
+    <component>
+      <role>org.codehaus.plexus.jdo.JdoFactory</role>
+      <implementation>org.codehaus.plexus.jdo.DefaultJdoFactory</implementation>
+      <configuration>
+        <properties>
+          <property>
+          	<name>usePool</name>
+          	<value>true</value>
+          </property>
+          <property>
+          	<name>javax.jdo.PersistenceManagerFactoryClass</name>
+          	<value>org.jpox.PersistenceManagerFactoryImpl</value>
+          </property>
+          <property>
+          	<name>javax.jdo.option.ConnectionDriverName</name>
+          	<value>org.hsqldb.jdbcDriver</value>
+          </property>
+          <property>
+          	<name>javax.jdo.option.ConnectionURL</name>
+          	<value>jdbc:hsqldb:mem://localhost:/test</value>
+          </property>
+          <property>
+          	<name>javax.jdo.option.ConnectionUserName</name>
+          	<value>test</value>
+          </property>
+          <property>
+          	<name>javax.jdo.option.ConnectionPassword</name>
+          	<value>test</value>
+          </property>
+          <property>
+          	<name>org.jpox.autoCreateSchema</name>
+          	<value>true</value>
+          </property>
+          <property>
+          	<name>org.jpox.validateTables</name>
+          	<value>false</value>
+          </property>
+          <property>
+          	<name>org.jpox.validateConstraints</name>
+          	<value>false</value>
+          </property>
+        </properties>
+      </configuration>
+    </component>
+  </components>
+</plexus>
\ No newline at end of file

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/plexus-jdo-config.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/redback/redback-components/trunk/spring-jdo2/src/test/resources/plexus-jdo-config.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision