continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r546588 - in /maven/continuum/trunk: ./ continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/ continuum-data-management/data-management-jdo/ continuum-data-management/data-management-jdo/src/main...
Date Tue, 12 Jun 2007 18:37:20 GMT
Author: brett
Date: Tue Jun 12 11:37:19 2007
New Revision: 546588

URL: http://svn.apache.org/viewvc?view=rev&rev=546588
Log:
other aspect of CORE-3297 requires a patch to OID instead

Added:
    maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/jpox/store/OID.java
  (with props)
Removed:
    maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/apache/maven/continuum/management/jpox/
    maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/resources/
Modified:
    maven/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java
    maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml
    maven/continuum/trunk/pom.xml

Modified: maven/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java?view=diff&rev=546588&r1=546587&r2=546588
==============================================================================
--- maven/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java
(original)
+++ maven/continuum/trunk/continuum-data-management/data-management-cli/src/main/java/org/apache/maven/continuum/management/DataManagementCli.java
Tue Jun 12 11:37:19 2007
@@ -104,7 +104,6 @@
 
         DatabaseParams params = new DatabaseParams( databaseType.defaultParams );
         params.setUrl( command.jdbcUrl );
-        params.getProperties().setProperty( "org.jpox.cache.level1.type", "SafeguardCache"
);
 
         DefaultPlexusContainer container = new DefaultPlexusContainer();
         List<Artifact> artifacts = new ArrayList<Artifact>();

Modified: maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml?view=diff&rev=546588&r1=546587&r2=546588
==============================================================================
--- maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml (original)
+++ maven/continuum/trunk/continuum-data-management/data-management-jdo/pom.xml Tue Jun 12
11:37:19 2007
@@ -66,7 +66,7 @@
       <groupId>jpox</groupId>
       <artifactId>jpox</artifactId>
       <version>1.1.6</version>
-      <!-- Temporary while we have the cache in there
+      <!-- Temporary while we have the OID patch in there
             <scope>test</scope>
       -->
     </dependency>

Added: maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/jpox/store/OID.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/jpox/store/OID.java?view=auto&rev=546588
==============================================================================
--- maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/jpox/store/OID.java
(added)
+++ maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/jpox/store/OID.java
Tue Jun 12 11:37:19 2007
@@ -0,0 +1,221 @@
+/**********************************************************************
+ Copyright (c) 2002 Kelly Grizzle (TJDO) and others. All rights reserved.
+ 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.
+
+
+ Contributors:
+ 2003 Erik Bengtson - Refactored OID
+ 2003 Andy Jefferson - fixed OID(String)
+ 2003 Andy Jefferson - coding standards
+ 2004 Andy Jefferson - fixes to allow full use of long or String OIDs
+ 2005 Erik Bengtson - removed oidType
+ 2007 Brett Porter - changed hashcode algorithm to avoid collisions (see CORE-3297)
+ ...
+ **********************************************************************/
+package org.jpox.store;
+
+import org.jpox.ClassNameConstants;
+import org.jpox.util.Localiser;
+
+/**
+ * An object identifier. OIDs are normally used as object identifiers for
+ * persistent objects that use datastore identity. They're also used for
+ * view objects, which actually use non-datastore identity. The behaviour of
+ * this class is governed by JDO spec 5.4.3.
+ *
+ * @version $Revision: 1.17 $
+ */
+public class OID
+    implements java.io.Serializable
+{
+    private transient static final Localiser LOCALISER = Localiser.getInstance( "org.jpox.store.Localisation"
);
+
+    /**
+     * Separator to use between fields.
+     */
+    private transient static final String oidSeparator = "[OID]";
+
+    // JDO spec 5.4.3 - serializable fields required to be public.
+
+    /**
+     * The identity.
+     */
+    public final Object oid;
+
+    /**
+     * The PersistenceCapable class name
+     */
+    public final String pcClass;
+
+    /**
+     * pre-created toString to improve performance *
+     */
+    public final String toString;
+
+    /**
+     * pre-created hasCode to improve performance *
+     */
+    public final int hashCode;
+
+    /**
+     * Creates an OID with the no value.
+     * Required by the JDO spec
+     */
+    public OID()
+    {
+        oid = null;
+        pcClass = null;
+        toString = null;
+        hashCode = -1;
+    }
+
+    /**
+     * Create a string datastore identity
+     *
+     * @param pcClass The PersistenceCapable class that this represents
+     * @param object  The value
+     */
+    public OID( String pcClass, Object object )
+    {
+        this.pcClass = pcClass;
+        this.oid = object;
+
+        StringBuffer s = new StringBuffer();
+        s.append( this.oid.toString() );
+        s.append( oidSeparator );
+        s.append( this.pcClass );
+        toString = s.toString();
+        hashCode = this.oid.hashCode() * 39 + pcClass.hashCode();
+    }
+
+    /**
+     * Constructs an OID from its string representation that is
+     * consistent with the output of toString().
+     *
+     * @param str the string representation of an OID.
+     * @throws IllegalArgumentException if the given string representation is not valid.
+     * @see #toString
+     */
+    public OID( String str )
+        throws IllegalArgumentException
+    {
+        if ( str.length() < 2 )
+        {
+            throw new IllegalArgumentException( LOCALISER.msg( "OID.InvalidValue", str )
);
+        }
+
+        int start = 0;
+        int end = str.indexOf( oidSeparator, start );
+        String oidStr = str.substring( start, end );
+        Object oidValue = null;
+        try
+        {
+            // Use Long if possible, else String
+            oidValue = new Long( oidStr );
+        }
+        catch ( NumberFormatException nfe )
+        {
+            oidValue = oidStr;
+        }
+        oid = oidValue;
+
+        start = end + oidSeparator.length();
+        this.pcClass = str.substring( start, str.length() );
+
+        toString = str;
+        hashCode = this.oid.hashCode() * 39 + pcClass.hashCode();
+    }
+
+    /**
+     * Returns copy of the requested oid to be accessed by the user.
+     *
+     * @return Copy of the OID.
+     */
+    public Object getNewObjectIdCopy()
+    {
+        return new OID( this.pcClass, this.oid );
+    }
+
+    /**
+     * Provides the OID in a form that can be used by the database as a key.
+     *
+     * @return The key value
+     */
+    public Object keyValue()
+    {
+        return oid;
+    }
+
+    /**
+     * Equality operator.
+     *
+     * @param obj Object to compare against
+     * @return Whether they are equal
+     */
+    public boolean equals( Object obj )
+    {
+        if ( obj == null )
+        {
+            return false;
+        }
+        if ( obj == this )
+        {
+            return true;
+        }
+        if ( !( obj.getClass().getName().equals( ClassNameConstants.OID ) ) )
+        {
+            return false;
+        }
+        if ( hashCode() != obj.hashCode() )
+        {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Accessor for the hashcode
+     *
+     * @return Hashcode for this object
+     */
+    public int hashCode()
+    {
+        return hashCode;
+    }
+
+    /**
+     * Returns the string representation of the OID.
+     * Will be a string such as "1[OID]org.jpox.samples.MyClass"
+     * where
+     * <UL>
+     * <LI>1 is the identity "id"</LI>
+     * <LI>class name is the name of the PersistenceCapable class that it represents</LI>
+     * </UL>
+     *
+     * @return the string representation of the OID.
+     */
+    public String toString()
+    {
+        return toString;
+    }
+
+    /**
+     * Accessor for the PC class name
+     *
+     * @return the PC Class
+     */
+    public String getPcClass()
+    {
+        return pcClass;
+    }
+}
\ No newline at end of file

Propchange: maven/continuum/trunk/continuum-data-management/data-management-jdo/src/main/java/org/jpox/store/OID.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: maven/continuum/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/pom.xml?view=diff&rev=546588&r1=546587&r2=546588
==============================================================================
--- maven/continuum/trunk/pom.xml (original)
+++ maven/continuum/trunk/pom.xml Tue Jun 12 11:37:19 2007
@@ -17,7 +17,8 @@
   ~ specific language governing permissions and limitations
   ~ under the License.
   -->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
   <modelVersion>4.0.0</modelVersion>
   <parent>
     <groupId>org.apache.maven</groupId>
@@ -123,9 +124,7 @@
     <module>continuum-webapp</module>
     <module>continuum-xmlrpc</module>
     <module>continuum-release</module>
-    <!-- Disabled until we can pre-req 2.0.7 - that fixes the bug where it doesn't work
in the reactor
     <module>continuum-data-management</module>
--->
     <module>continuum-configuration</module>
     <module>maven-continuum-plugin</module>
   </modules>



Mime
View raw message