Patches item #446889, was opened at 2001-08-01 11:39
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=402706&aid=446889&group_id=31602

Category: None
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: serialVersionUID Patch

Initial Comment:
This patch would allow you to generate the:
public final static long serialVersionUID = xxx;
line that would help out with avoiding getting 
marshalling errors every time you do a new buil d of 
an EJB.  

The serialVersionUID value is calculated based on the 
method signatures of the interface file that is being 
generated.

A patch of the *.j files would be trivial to implement 
if you guys need it.

Regards,
Hiram

Index: AbstractEjbSubTask.java
=======================================================
============
RCS 
file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/ejb/Abs
tractEjbSubTask.java,v
retrieving revision 1.4
diff -u -r1.4 AbstractEjbSubTask.java
--- AbstractEjbSubTask.java     2001/08/01 00:26:30
        1.4
+++ AbstractEjbSubTask.java     2001/08/01 18:12:34
@@ -195,6 +195,99 @@
                }
        }
 
+       /**
+        *  Calculates a SerialVersionUID based on the 
method signatures for a given
+        *  interface. The 'type' attribute should be 
set to the interface that you
+        *  want to calculate the SerialVersionUID on. 
types are: home, remote, pk,
+        *  persistent, or all
+        *
+        * @param  attributes  Description of Parameter
+        * @return             The SerialVersionUID 
value
+        */
+       public String getSerialVersionUID( Properties 
attributes )
+       {
+
+               int type;
+               String interfaceType = 
attributes.getProperty( "type" );
+               if( interfaceType == null )
+               {
+                       type = 0;
+                       // calc on all methods
+               }
+               else if( interfaceType.equals
( "all" ) )
+               {
+                       type = 0;
+                       // calc on all methods
+               }
+               else if( interfaceType.equals
( "home" ) )
+               {
+                       type = 1;
+                       // calc on home methods
+               }
+               else if( interfaceType.equals
( "remote" ) )
+               {
+                       type = 2;
+                       // calc on remote methods
+               }
+               else if( interfaceType.equals( "pk" ) )
+               {
+                       type = 3;
+                       // calc on pk methods
+               }
+               else if( interfaceType.equals
( "persistent" ) )
+               {
+                       type = 4;
+                       // calc on peristent fields 
methods
+               }
+               else
+               {
+                       type = 0;
+                       // calc on all methods
+               }
+
+               ClassDoc oldClass = getCurrentClass();
+               long versionID = Long.MIN_VALUE;
+               do
+               {
+                       MethodDoc[] methods = 
getCurrentClass().methods();
+                       for( int j = 0; j < 
methods.length; j++ )
+                       {
+                               switch ( type )
+                               {
+                                       case 1:
+                                               if( 
isHomeMethod( methods[j] ) )
+                                               {
+                                               
        versionID += methods[j].signature().hashCode();
+                                               }
+                                               break;
+                                       case 2:
+                                               if( 
isRemoteMethod( methods[j] ) )
+                                               {
+                                               
        versionID += methods[j].signature().hashCode();
+                                               }
+                                               break;
+                                       case 3:
+                                               if( 
isPkField( methods[j] ) )
+                                               {
+                                               
        versionID += methods[j].signature().hashCode();
+                                               }
+                                               break;
+                                       case 4:
+                                               if( 
isPersistentField( methods[j] ) )
+                                               {
+                                               
        versionID += methods[j].signature().hashCode();
+                                               }
+                                       default:
+                                       
        versionID += methods[j].signature().hashCode();
+                               }
+                       }
+                       // Add super class info
+                       pushCurrentClass( 
getCurrentClass().superclass() );
+               }while ( getCurrentClass() != null );
+               setCurrentClass( oldClass );
+               return "" + versionID + "L";
+       }
+
        public void init( DocletContext context, 
RootDoc root ) throws Exception
        {
                super.init( context, root );
@@ -848,7 +941,7 @@
        public void forAllSuper( String template, 
String methodName )
        {
                ClassDoc oldClass = getCurrentClass();
-        List already = new ArrayList();
+               List already = new ArrayList();
 
                // Begin at the first super class
                pushCurrentClass( getCurrentClass
().superclass() );
@@ -862,35 +955,35 @@
                                if( methods[i].name
().equals( methodName ) )
                                {
                                        methodFound = 
methods[i];
-                }
-                if (methodFound != null)
-                {
-                        break;
+                               }
+                               if( methodFound != 
null )
+                               {
+                                       break;
+                               }
+                       }
+                       if( methodFound != null )
+                       {
+                               // We can not use 
contains because it is based on equals() and
+                               // we need to compare 
based on compareTo()
+                               Iterator i = 
already.iterator();
+                               boolean contained = 
false;
+                               while( i.hasNext() )
+                               {
+                                       if( ( ( 
MethodDoc ) i.next() ).compareTo( methodFound ) == 0 )
+                                       {
+                                       
        contained = true;
+                                       }
+                                       if( contained )
+                                       {
+                                               break;
+                                       }
+                               }
+                               if( contained == 
false )
+                               {
+                                       generate( 
template );
+                                       already.add( 
methodFound );
                                }
                        }
-            if (methodFound != null)
-            {
-                // We can not use contains because it 
is based on equals() and
-                // we need to compare based on 
compareTo()
-                Iterator i = already.iterator();
-                boolean contained = false;
-                while (i.hasNext())
-                {
-                    if ( ((MethodDoc)i.next
()).compareTo(methodFound) == 0 )
-                    {
-                        contained = true;
-                    }
-                    if ( contained )
-                    {
-                        break;
-                    }
-                }
-                if ( contained == false )
-                {
-                    generate(template);
-                    already.add(methodFound);
-                }
-            }
                        pushCurrentClass( 
getCurrentClass().superclass() );
                }while ( getCurrentClass() != null );
                setCurrentClass( oldClass );
@@ -930,7 +1023,7 @@
 
        public String persistenceType()
        {
-               if( isEntityCmp( getCurrentClass() ) 
&& ! isEntityBmp( getCurrentClass() ) )
+               if( isEntityCmp( getCurrentClass() ) 
&& !isEntityBmp( getCurrentClass() ) )
                {
                        return "Container";
                }

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=402706&aid=446889&group_id=31602

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to