directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: rev 55184 - incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema
Date Wed, 20 Oct 2004 21:53:27 GMT
Author: akarasulu
Date: Wed Oct 20 14:53:26 2004
New Revision: 55184

Modified:
   incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
Log:
Added code to now check if the producer class exists within the src/java 
directory before creating one from scratch in the target/schema directory.  
This is done to prevent collisions when static producers are hand woven which
is usually the case for anything which is not an AttributeType or ObjectClass
producer.


Modified: incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
==============================================================================
--- incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
(original)
+++ incubator/directory/eve/trunk/backend/maven-eve-plugin/src/java/org/apache/eve/tools/schema/EveSchemaTool.java
Wed Oct 20 14:53:26 2004
@@ -330,31 +330,45 @@
 
     protected boolean exists( ProducerTypeEnum type )
     {
-        boolean exists = true;
-
-        String defaultClass = schema.getFullDefaultBaseClassName(
-                ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER );
-        String targetClass = schema.getFullDefaultBaseClassName(
-                ProducerTypeEnum.ATTRIBUTE_TYPE_PRODUCER );
+        String defaultClass = schema.getFullDefaultBaseClassName( type );
+        String targetClass = schema.getFullDefaultBaseClassName( type );
 
+        // first check and see the classes are in the classpath
+        // although this is highly unlikely since we probably have
+        // not even compiled the classes yet
         try
         {
-            exists = Class.forName( defaultClass ) != null;
+            Class.forName( defaultClass );
+            return true;
         }
         catch ( ClassNotFoundException e )
         {
-            exists = false;
         }
 
         try
         {
-            exists = Class.forName( targetClass ) != null;
+            Class.forName( targetClass );
+            return true;
         }
         catch ( ClassNotFoundException e )
         {
-            exists = false;
         }
 
-        return exists;
+        // now we check to see if any of the classes are available
+        // in the java source directory, if so we return true
+        File defaultFile = new File( "src" + File.separator + "java"
+                + File.separator + getFilePath( defaultClass ) );
+        File targetFile = new File( "src" + File.separator + "java"
+                + File.separator + getFilePath( targetClass ) );
+
+        return defaultFile.exists() || targetFile.exists();
+    }
+
+
+    private String getFilePath( String fqcn )
+    {
+        String path = fqcn.replace( '.', File.separatorChar );
+        path += ".java";
+        return path;
     }
 }

Mime
View raw message