Update of 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20096/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces

Modified Files:
        LocalHomeInterfacePlugin.java RemoteInterfacePlugin.vm 
        LocalInterfaceBase.java RemoteHomeInterfacePlugin.java 
        RemoteInterfacePlugin.java LocalInterfacePlugin.java 
        RemoteInterfaceBase.java 
Added Files:
        ServiceEndpointPlugin.vm ServiceEndpointPlugin.java 
Log Message:
- ServiceEndpointPlugin stub created
- Uniformed package/pattern/class tag values for java generation for tags that 
permit default naming override
- Qtags classes name fixed
- Qtags refactorings
- Fixed testcases


Index: LocalHomeInterfacePlugin.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces/LocalHomeInterfacePlugin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** LocalHomeInterfacePlugin.java       6 Sep 2005 01:49:59 -0000       1.3
--- LocalHomeInterfacePlugin.java       13 Sep 2005 02:22:32 -0000      1.4
***************
*** 6,9 ****
--- 6,12 ----
  package org.xdoclet.plugin.ejb.interfaces;
  
+ import java.text.MessageFormat;
+ 
+ import java.util.Arrays;
  import java.util.Collection;
  
***************
*** 15,18 ****
--- 18,23 ----
  import org.xdoclet.plugin.ejb.EjbRuntime;
  import org.xdoclet.plugin.ejb.EjbUtils;
+ import org.xdoclet.plugin.ejb.qtags.EjbHomeTag;
+ import org.xdoclet.plugin.ejb.qtags.EjbInterfaceTag;
  
  import com.thoughtworks.qdox.model.JavaClass;
***************
*** 40,53 ****
          throws ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper, config);
- 
          EjbRuntime.setPlugin(this);
- 
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         setFileregex(config.getEjbReplaceRegex());
          setFilereplace("LocalHome");
!         setMultioutput(true);
      }
      
      public Collection getInterfaceMethods(final JavaClass clazz) {
          return ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT, EjbUtils.LOCAL_HOME);
--- 45,116 ----
          throws ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper, config);
          EjbRuntime.setPlugin(this);
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         super.setFileregex(config.getEjbReplaceRegex());
          setFilereplace("LocalHome");
!         super.setMultioutput(true);
      }
      
+     public boolean shouldGenerate(Object metadata) {
+         JavaClass javaClass = (JavaClass) metadata;
+         boolean generate = super.shouldGenerate(metadata);
+         EjbHomeTag homeTag = (EjbHomeTag) javaClass.getTagByName("ejb.home");
+         if (homeTag != null) {
+             generate &= 
Arrays.asList(homeTag.getGenerate()).contains("local");
+         }
+         return generate;
+     }
+ 
+     protected String getLocalyDefinedFullClassName(JavaClass clazz) {
+         EjbHomeTag homeTag = (EjbHomeTag) clazz.getTagByName("ejb.home");
+         return homeTag != null ? homeTag.getLocalClass() : 
super.getLocalyDefinedFullClassName(clazz);
+     }
+ 
+     protected String getLocalyDefinedPackageName(JavaClass clazz) {
+         EjbHomeTag homeTag = (EjbHomeTag) clazz.getTagByName("ejb.home");
+         String definedPackage = null;
+ 
+         if (homeTag != null) {
+             definedPackage = homeTag.getLocalPackage();
+ 
+             if (definedPackage == null) {
+                 definedPackage = homeTag.getPackage();
+             }
+         }
+ 
+         return definedPackage != null ? definedPackage : 
super.getLocalyDefinedPackageName(clazz);
+     }
+ 
+     protected String getPatternBasedUnqualifiedName(JavaClass clazz) {
+         EjbHomeTag homeTag = (EjbHomeTag) clazz.getTagByName("ejb.home");
+         String pattern = null;
+ 
+         if (homeTag != null) {
+             pattern = homeTag.getLocalPattern();
+ 
+             if (pattern == null && homeTag.getPattern() != null) {
+                 pattern = homeTag.getPattern() + "LocalHome";
+             }
+         }
+ 
+         return pattern != null ? MessageFormat.format(pattern, new String[] 
{ejbUtils.getEjbName(clazz)})
+                                : super.getPatternBasedUnqualifiedName(clazz);
+     }
+ 
+     /**
+      * Don't let multioutput be changed
+      */
+     public void setMultioutput(boolean multioutput) {
+         throw new RuntimeException("Can't set multioutput for plugin");
+     }
+ 
+     /**
+      * Don't let fileregex be changed
+      */
+     public void setFileregex(String fileregex) {
+         throw new RuntimeException("Can't set fileregex for plugin. Try 
setting it in " + EjbConfig.class.getName());
+     }
+ 
      public Collection getInterfaceMethods(final JavaClass clazz) {
          return ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT, EjbUtils.LOCAL_HOME);

--- NEW FILE: ServiceEndpointPlugin.vm ---
#set( $class = $metadata )

// ${dontedit}
// Generated by $plugin.class.name from $class.fullyQualifiedName
package ${plugin.getDestinationPackage($class)};

/**
 * Service-EndPoint interface/or is it a class ?? for $util.getEjbName($class)
 */
public interface ${plugin.getDestinationClassname($class)} extends 
java.rmi.Remote {
        // TODO
}

--- NEW FILE: ServiceEndpointPlugin.java ---
/*
 * Copyright (c) 2005
 * XDoclet Team
 * All rights reserved.
 */
package org.xdoclet.plugin.ejb.interfaces;

import java.util.Map;

import org.generama.QDoxCapableMetadataProvider;
import org.generama.VelocityTemplateEngine;
import org.generama.WriterMapper;

import org.generama.defaults.JavaGeneratingPlugin;

import org.xdoclet.plugin.ejb.EjbConfig;
import org.xdoclet.plugin.ejb.EjbRuntime;
import org.xdoclet.plugin.ejb.EjbUtils;
import org.xdoclet.plugin.ejb.EjbVersion;
import org.xdoclet.plugin.ejb.qtags.TagLibrary;

/**
 * TODO: Stub only. Doesn't even have
 * public boolean shouldGenerate(Object metadata) working!!!
 *
 * @author Diogo Quintela
 */
public class ServiceEndpointPlugin extends JavaGeneratingPlugin {
    private EjbConfig config;
    private EjbUtils ejbUtils;

    public ServiceEndpointPlugin(VelocityTemplateEngine velocityTemplateEngine,
        QDoxCapableMetadataProvider metadataProvider, WriterMapper 
writerMapper, EjbConfig config)
        throws ClassNotFoundException {
        super(velocityTemplateEngine, metadataProvider, writerMapper);
        EjbRuntime.setPlugin(this);
        setPackageregex("beans");
        setPackagereplace("interfaces");
        super.setFileregex(config.getEjbReplaceRegex());
        setFilereplace("Remote");
        super.setMultioutput(true);
        this.config = config;
        this.ejbUtils = new EjbUtils();
        new TagLibrary(metadataProvider);
    }

    /**
     * Don't let multioutput be changed
     */
    public void setMultioutput(boolean multioutput) {
        throw new RuntimeException("Can't set multioutput for plugin");
    }

    /**
     * Don't let fileregex be changed
     */
    public void setFileregex(String fileregex) {
        throw new RuntimeException("Can't set fileregex for plugin. Try setting 
it in " + EjbConfig.class.getName());
    }

    public boolean shouldGenerate(Object metadata) {
        return false;
    }

    protected void populateContextMap(Map map) {
        super.populateContextMap(map);
        map.put("util", getEjbUtils());
        map.put("version", getVersion());
    }

    public EjbVersion getVersion() {
        return getConfig().getVersion();
    }

    public EjbUtils getEjbUtils() {
        return ejbUtils;
    }

    public EjbConfig getConfig() {
        return this.config;
    }
}
Index: LocalInterfaceBase.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces/LocalInterfaceBase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** LocalInterfaceBase.java     6 Sep 2005 01:49:59 -0000       1.2
--- LocalInterfaceBase.java     13 Sep 2005 02:22:32 -0000      1.3
***************
*** 6,18 ****
  package org.xdoclet.plugin.ejb.interfaces;
  
  import org.generama.QDoxCapableMetadataProvider;
  import org.generama.TemplateEngine;
  import org.generama.WriterMapper;
  
- import org.generama.defaults.JavaGeneratingPlugin;
- 
  import org.xdoclet.plugin.ejb.EjbConfig;
! import org.xdoclet.plugin.ejb.EjbRuntime;
  import org.xdoclet.plugin.ejb.EjbUtils;
  import org.xdoclet.plugin.ejb.qtags.TagLibrary;
  
--- 6,19 ----
  package org.xdoclet.plugin.ejb.interfaces;
  
+ import java.util.Map;
+ 
  import org.generama.QDoxCapableMetadataProvider;
  import org.generama.TemplateEngine;
  import org.generama.WriterMapper;
  
  import org.xdoclet.plugin.ejb.EjbConfig;
! import org.xdoclet.plugin.ejb.EjbJavaGeneratingPlugin;
  import org.xdoclet.plugin.ejb.EjbUtils;
+ import org.xdoclet.plugin.ejb.EjbVersion;
  import org.xdoclet.plugin.ejb.qtags.TagLibrary;
  
***************
*** 26,30 ****
   * TODO: Support @ejb.interface to help decide if we are going to generate or 
not
   */
! public abstract class LocalInterfaceBase extends JavaGeneratingPlugin {
      /** TODO: DOCUMENT ME!  */
      protected EjbUtils ejbUtils;
--- 27,31 ----
   * TODO: Support @ejb.interface to help decide if we are going to generate or 
not
   */
! public abstract class LocalInterfaceBase extends EjbJavaGeneratingPlugin {
      /** TODO: DOCUMENT ME!  */
      protected EjbUtils ejbUtils;
***************
*** 43,53 ****
          WriterMapper writerMapper, EjbConfig config) throws 
ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper);
- 
          this.config = config;
          this.ejbUtils = new EjbUtils();
- 
          new TagLibrary(metadataProvider);
      }
  
      /**
       * TODO: DOCUMENT ME!
--- 44,62 ----
          WriterMapper writerMapper, EjbConfig config) throws 
ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper);
          this.config = config;
          this.ejbUtils = new EjbUtils();
          new TagLibrary(metadataProvider);
      }
  
+     protected void populateContextMap(Map map) {
+         super.populateContextMap(map);
+         map.put("util", getEjbUtils());
+         map.put("version", getVersion());
+     }
+ 
+     public EjbVersion getVersion() {
+         return getConfig().getVersion();
+     }
+ 
      /**
       * TODO: DOCUMENT ME!
***************
*** 72,77 ****
      public boolean shouldGenerate(Object metadata) {
          JavaClass javaClass = (JavaClass) metadata;
!         return ejbUtils.shouldGenerate(metadata) &&
!         EjbUtils.hasFlag(ejbUtils.getViewType(javaClass), EjbUtils.LOCAL) &&
          !ejbUtils.isMessageDrivenBean(javaClass);
      }
--- 81,85 ----
      public boolean shouldGenerate(Object metadata) {
          JavaClass javaClass = (JavaClass) metadata;
!         return ejbUtils.shouldGenerate(metadata) && 
EjbUtils.hasFlag(ejbUtils.getViewType(javaClass), EjbUtils.LOCAL) &&
          !ejbUtils.isMessageDrivenBean(javaClass);
      }

Index: RemoteInterfacePlugin.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces/RemoteInterfacePlugin.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** RemoteInterfacePlugin.java  6 Sep 2005 01:49:59 -0000       1.13
--- RemoteInterfacePlugin.java  13 Sep 2005 02:22:32 -0000      1.14
***************
*** 6,19 ****
--- 6,33 ----
  package org.xdoclet.plugin.ejb.interfaces;
  
+ import java.rmi.RemoteException;
+ 
+ import java.text.MessageFormat;
+ 
+ import java.util.ArrayList;
+ import java.util.Arrays;
  import java.util.Collection;
+ import java.util.List;
+ 
+ import org.apache.commons.collections.CollectionUtils;
+ import org.apache.commons.collections.Transformer;
  
  import org.generama.QDoxCapableMetadataProvider;
  import org.generama.VelocityTemplateEngine;
  import org.generama.WriterMapper;
+ 
  import org.xdoclet.plugin.ejb.EjbConfig;
  import org.xdoclet.plugin.ejb.EjbRuntime;
  import org.xdoclet.plugin.ejb.EjbUtils;
+ import org.xdoclet.plugin.ejb.qtags.EjbInterfaceTag;
  
  import com.thoughtworks.qdox.model.JavaClass;
+ import com.thoughtworks.qdox.model.JavaMethod;
+ import com.thoughtworks.qdox.model.Type;
  
  /**
***************
*** 27,42 ****
          throws ClassNotFoundException {
          super(velocityTemplateEngine, metadataProvider, writerMapper, config);
- 
          EjbRuntime.setPlugin(this);
- 
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         setFileregex(config.getEjbReplaceRegex());
          setFilereplace("Remote");
!         setMultioutput(true);
      }
  
      public Collection getInterfaceMethods(final JavaClass clazz) {
!         return ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT, EjbUtils.REMOTE);
      }
  }
\ No newline at end of file
--- 41,165 ----
          throws ClassNotFoundException {
          super(velocityTemplateEngine, metadataProvider, writerMapper, config);
          EjbRuntime.setPlugin(this);
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         super.setFileregex(config.getEjbReplaceRegex());
          setFilereplace("Remote");
!         super.setMultioutput(true);
!     }
! 
!     public String[] getExtends(JavaClass javaClass) {
!         Collection extendsLst = new ArrayList();
!         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
javaClass.getTagByName("ejb.interface");
!         if (interfaceTag != null && interfaceTag.getExtends() != null) {
!             extendsLst.addAll(Arrays.asList(interfaceTag.getExtends()));
!         }
!         if (!extendsLst.contains("javax.ejb.EJBObject")) {
!             extendsLst.add("javax.ejb.EJBObject");
!         }
!         return (String[])extendsLst.toArray(new String[0]);
!     }
!     
!     public boolean shouldGenerate(Object metadata) {
!         JavaClass javaClass = (JavaClass) metadata;
!         boolean generate = super.shouldGenerate(metadata);
!         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
javaClass.getTagByName("ejb.interface");
!         if (interfaceTag != null) {
!             generate &= 
Arrays.asList(interfaceTag.getGenerate()).contains("remote");
!         }
!         return generate;
!     }
!     
!     protected String getLocalyDefinedFullClassName(JavaClass clazz) {
!         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
clazz.getTagByName("ejb.interface");
!         return interfaceTag != null ? interfaceTag.getRemoteClass() : 
super.getLocalyDefinedFullClassName(clazz);
!     }
! 
!     protected String getLocalyDefinedPackageName(JavaClass clazz) {
!         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
clazz.getTagByName("ejb.interface");
!         String definedPackage = null;
! 
!         if (interfaceTag != null) {
!             definedPackage = interfaceTag.getRemotePackage();
! 
!             if (definedPackage == null) {
!                 definedPackage = interfaceTag.getPackage();
!             }
!         }
! 
!         return definedPackage != null ? definedPackage : 
super.getLocalyDefinedPackageName(clazz);
!     }
! 
!     protected String getPatternBasedUnqualifiedName(JavaClass clazz) {
!         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
clazz.getTagByName("ejb.interface");
!         String pattern = null;
! 
!         if (interfaceTag != null) {
!             pattern = interfaceTag.getRemotePattern();
! 
!             if (pattern == null && interfaceTag.getPattern() != null) {
!                 pattern = interfaceTag.getPattern() + "Remote";
!             }
!         }
! 
!         return pattern != null ? MessageFormat.format(pattern, new String[] 
{ejbUtils.getEjbName(clazz)})
!                                : super.getPatternBasedUnqualifiedName(clazz);
!     }
! 
!     /**
!      * Don't let multioutput be changed
!      */
!     public void setMultioutput(boolean multioutput) {
!         throw new RuntimeException("Can't set multioutput for plugin");
!     }
! 
!     /**
!      * Don't let fileregex be changed
!      */
!     public void setFileregex(String fileregex) {
!         throw new RuntimeException("Can't set fileregex for plugin. Try 
setting it in " + EjbConfig.class.getName());
      }
  
      public Collection getInterfaceMethods(final JavaClass clazz) {
!         return CollectionUtils.collect(ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT,
!                 EjbUtils.REMOTE),
!             new Transformer() {
!                 public Object transform(Object arg0) {
!                     DuplicatedJavaMethod retVal = new 
DuplicatedJavaMethod((JavaMethod) arg0);
!                     Type rEx = new Type(RemoteException.class.getName());
! 
!                     if (!retVal.containsException(rEx)) {
!                         retVal.addException(rEx);
!                     }
! 
!                     return retVal;
!                 }
!             });
!     }
! 
!     private static class DuplicatedJavaMethod extends JavaMethod {
!         public DuplicatedJavaMethod(JavaMethod method) {
!             super();
!             setName(method.getName());
!             setComment(method.getComment());
!             setConstructor(method.isConstructor());
!             setLineNumber(method.getLineNumber());
!             setModifiers(method.getModifiers());
!             setParameters(method.getParameters());
!             setParentClass(method.getParentClass());
!             setReturns(method.getReturns());
!             setTags(Arrays.asList(method.getTags()));
!             setExceptions(method.getExceptions());
!         }
! 
!         public boolean containsException(Type type) {
!             return Arrays.asList(getExceptions()).contains(type);
!         }
! 
!         public void addException(Type type) {
!             List exceptions = new ArrayList(Arrays.asList(getExceptions()));
!             exceptions.add(type);
!             setExceptions((Type[]) exceptions.toArray(new Type[0]));
!         }
      }
  }
\ No newline at end of file

Index: RemoteHomeInterfacePlugin.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces/RemoteHomeInterfacePlugin.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** RemoteHomeInterfacePlugin.java      6 Sep 2005 01:49:59 -0000       1.3
--- RemoteHomeInterfacePlugin.java      13 Sep 2005 02:22:32 -0000      1.4
***************
*** 6,9 ****
--- 6,12 ----
  package org.xdoclet.plugin.ejb.interfaces;
  
+ import java.text.MessageFormat;
+ 
+ import java.util.Arrays;
  import java.util.Collection;
  
***************
*** 11,21 ****
  import org.generama.VelocityTemplateEngine;
  import org.generama.WriterMapper;
  import org.xdoclet.plugin.ejb.EjbConfig;
  import org.xdoclet.plugin.ejb.EjbRuntime;
  import org.xdoclet.plugin.ejb.EjbUtils;
  
  import com.thoughtworks.qdox.model.JavaClass;
  
- 
  /**
   * DOCUMENT ME!
--- 14,26 ----
  import org.generama.VelocityTemplateEngine;
  import org.generama.WriterMapper;
+ 
  import org.xdoclet.plugin.ejb.EjbConfig;
  import org.xdoclet.plugin.ejb.EjbRuntime;
  import org.xdoclet.plugin.ejb.EjbUtils;
+ import org.xdoclet.plugin.ejb.qtags.EjbHomeTag;
+ import org.xdoclet.plugin.ejb.qtags.EjbInterfaceTag;
  
  import com.thoughtworks.qdox.model.JavaClass;
  
  /**
   * DOCUMENT ME!
***************
*** 37,54 ****
      public RemoteHomeInterfacePlugin(VelocityTemplateEngine 
velocityTemplateEngine,
          QDoxCapableMetadataProvider metadataProvider, WriterMapper 
writerMapper, EjbConfig config)
!     throws ClassNotFoundException {
          super(velocityTemplateEngine, metadataProvider, writerMapper, config);
- 
          EjbRuntime.setPlugin(this);
- 
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         setFileregex(config.getEjbReplaceRegex());
          setFilereplace("RemoteHome");
!         setMultioutput(true);
      }
      
      public Collection getInterfaceMethods(final JavaClass clazz) {
          return ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT, EjbUtils.REMOTE_HOME);
      }
! }
--- 42,117 ----
      public RemoteHomeInterfacePlugin(VelocityTemplateEngine 
velocityTemplateEngine,
          QDoxCapableMetadataProvider metadataProvider, WriterMapper 
writerMapper, EjbConfig config)
!         throws ClassNotFoundException {
          super(velocityTemplateEngine, metadataProvider, writerMapper, config);
          EjbRuntime.setPlugin(this);
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         super.setFileregex(config.getEjbReplaceRegex());
          setFilereplace("RemoteHome");
!         super.setMultioutput(true);
      }
+ 
+     public boolean shouldGenerate(Object metadata) {
+         JavaClass javaClass = (JavaClass) metadata;
+         boolean generate = super.shouldGenerate(metadata);
+         EjbHomeTag homeTag = (EjbHomeTag) javaClass.getTagByName("ejb.home");
+         if (homeTag != null) {
+             generate &= 
Arrays.asList(homeTag.getGenerate()).contains("remote");
+         }
+         return generate;
+     }    
      
+     protected String getLocalyDefinedFullClassName(JavaClass clazz) {
+         EjbHomeTag homeTag = (EjbHomeTag) clazz.getTagByName("ejb.home");
+         return homeTag != null ? homeTag.getRemoteClass() : 
super.getLocalyDefinedFullClassName(clazz);
+     }
+ 
+     protected String getLocalyDefinedPackageName(JavaClass clazz) {
+         EjbHomeTag homeTag = (EjbHomeTag) clazz.getTagByName("ejb.home");
+         String definedPackage = null;
+ 
+         if (homeTag != null) {
+             definedPackage = homeTag.getRemotePackage();
+ 
+             if (definedPackage == null) {
+                 definedPackage = homeTag.getPackage();
+             }
+         }
+ 
+         return definedPackage != null ? definedPackage : 
super.getLocalyDefinedPackageName(clazz);
+     }
+ 
+     protected String getPatternBasedUnqualifiedName(JavaClass clazz) {
+         EjbHomeTag homeTag = (EjbHomeTag) clazz.getTagByName("ejb.home");
+         String pattern = null;
+ 
+         if (homeTag != null) {
+             pattern = homeTag.getRemotePattern();
+ 
+             if (pattern == null && homeTag.getPattern() != null) {
+                 pattern = homeTag.getPattern() + "RemoteHome";
+             }
+         }
+ 
+         return pattern != null ? MessageFormat.format(pattern, new String[] 
{ejbUtils.getEjbName(clazz)})
+                                : super.getPatternBasedUnqualifiedName(clazz);
+     }
+ 
+     /**
+      * Don't let multioutput be changed
+      */
+     public void setMultioutput(boolean multioutput) {
+         throw new RuntimeException("Can't set multioutput for plugin");
+     }
+ 
+     /**
+      * Don't let fileregex be changed
+      */
+     public void setFileregex(String fileregex) {
+         throw new RuntimeException("Can't set fileregex for plugin. Try 
setting it in " + EjbConfig.class.getName());
+     }
+ 
      public Collection getInterfaceMethods(final JavaClass clazz) {
          return ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT, EjbUtils.REMOTE_HOME);
      }
! }
\ No newline at end of file

Index: RemoteInterfacePlugin.vm
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces/RemoteInterfacePlugin.vm,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RemoteInterfacePlugin.vm    30 Aug 2005 00:34:33 -0000      1.2
--- RemoteInterfacePlugin.vm    13 Sep 2005 02:22:32 -0000      1.3
***************
*** 5,16 ****
  package ${plugin.getDestinationPackage($class)};
  
! public interface ${plugin.getDestinationClassname($class)} extends 
javax.ejb.EJBObject {
  #foreach( $method in $plugin.getInterfaceMethods($class) )
!     $method.getDeclarationSignature(false)
! #if( $plugin.isEmpty($method.exceptions) )
!       throws java.rmi.RemoteException;
! #else
!       , java.rmi.RemoteException;
! #end
  #end
  }
--- 5,15 ----
  package ${plugin.getDestinationPackage($class)};
  
! /**
!  * Remote interface for $util.getEjbName($class)
!  */
! public interface ${plugin.getDestinationClassname($class)} 
! extends #foreach($interface in $plugin.getExtends($class) )#if($velocityCount 
> 1), #end$interface#end {
  #foreach( $method in $plugin.getInterfaceMethods($class) )
!     $method.getDeclarationSignature(false);
  #end
  }

Index: RemoteInterfaceBase.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces/RemoteInterfaceBase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RemoteInterfaceBase.java    6 Sep 2005 01:49:59 -0000       1.2
--- RemoteInterfaceBase.java    13 Sep 2005 02:22:32 -0000      1.3
***************
*** 6,18 ****
  package org.xdoclet.plugin.ejb.interfaces;
  
  import org.generama.QDoxCapableMetadataProvider;
  import org.generama.TemplateEngine;
  import org.generama.WriterMapper;
  
- import org.generama.defaults.JavaGeneratingPlugin;
- 
  import org.xdoclet.plugin.ejb.EjbConfig;
! import org.xdoclet.plugin.ejb.EjbRuntime;
  import org.xdoclet.plugin.ejb.EjbUtils;
  import org.xdoclet.plugin.ejb.qtags.TagLibrary;
  
--- 6,19 ----
  package org.xdoclet.plugin.ejb.interfaces;
  
+ import java.util.Map;
+ 
  import org.generama.QDoxCapableMetadataProvider;
  import org.generama.TemplateEngine;
  import org.generama.WriterMapper;
  
  import org.xdoclet.plugin.ejb.EjbConfig;
! import org.xdoclet.plugin.ejb.EjbJavaGeneratingPlugin;
  import org.xdoclet.plugin.ejb.EjbUtils;
+ import org.xdoclet.plugin.ejb.EjbVersion;
  import org.xdoclet.plugin.ejb.qtags.TagLibrary;
  
***************
*** 26,30 ****
   * TODO: Support @ejb.interface to help decide if we are going to generate or 
not
   */
! public abstract class RemoteInterfaceBase extends JavaGeneratingPlugin {
      /** TODO: DOCUMENT ME!  */
      protected EjbUtils ejbUtils;
--- 27,31 ----
   * TODO: Support @ejb.interface to help decide if we are going to generate or 
not
   */
! public abstract class RemoteInterfaceBase extends EjbJavaGeneratingPlugin {
      /** TODO: DOCUMENT ME!  */
      protected EjbUtils ejbUtils;
***************
*** 43,53 ****
          WriterMapper writerMapper, EjbConfig config) throws 
ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper);
- 
          this.config = config;
          this.ejbUtils = new EjbUtils();
- 
          new TagLibrary(metadataProvider);
      }
  
      public EjbUtils getEjbUtils() {
          return ejbUtils;
--- 44,62 ----
          WriterMapper writerMapper, EjbConfig config) throws 
ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper);
          this.config = config;
          this.ejbUtils = new EjbUtils();
          new TagLibrary(metadataProvider);
      }
  
+     protected void populateContextMap(Map map) {
+         super.populateContextMap(map);
+         map.put("util", getEjbUtils());
+         map.put("version", getVersion());
+     }
+ 
+     public EjbVersion getVersion() {
+         return getConfig().getVersion();
+     }
+ 
      public EjbUtils getEjbUtils() {
          return ejbUtils;
***************
*** 56,61 ****
      public boolean shouldGenerate(Object metadata) {
          JavaClass javaClass = (JavaClass) metadata;
!         return ejbUtils.shouldGenerate(metadata) &&
!         EjbUtils.hasFlag(ejbUtils.getViewType(javaClass), EjbUtils.REMOTE) &&
          !ejbUtils.isMessageDrivenBean(javaClass);
      }
--- 65,69 ----
      public boolean shouldGenerate(Object metadata) {
          JavaClass javaClass = (JavaClass) metadata;
!         return ejbUtils.shouldGenerate(metadata) && 
EjbUtils.hasFlag(ejbUtils.getViewType(javaClass), EjbUtils.REMOTE) &&
          !ejbUtils.isMessageDrivenBean(javaClass);
      }

Index: LocalInterfacePlugin.java
===================================================================
RCS file: 
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/interfaces/LocalInterfacePlugin.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** LocalInterfacePlugin.java   6 Sep 2005 01:49:59 -0000       1.14
--- LocalInterfacePlugin.java   13 Sep 2005 02:22:32 -0000      1.15
***************
*** 6,9 ****
--- 6,12 ----
  package org.xdoclet.plugin.ejb.interfaces;
  
+ import java.text.MessageFormat;
+ 
+ import java.util.Arrays;
  import java.util.Collection;
  
***************
*** 11,17 ****
--- 14,23 ----
  import org.generama.VelocityTemplateEngine;
  import org.generama.WriterMapper;
+ 
  import org.xdoclet.plugin.ejb.EjbConfig;
  import org.xdoclet.plugin.ejb.EjbRuntime;
  import org.xdoclet.plugin.ejb.EjbUtils;
+ import org.xdoclet.plugin.ejb.qtags.EjbHomeTag;
+ import org.xdoclet.plugin.ejb.qtags.EjbInterfaceTag;
  
  import com.thoughtworks.qdox.model.JavaClass;
***************
*** 37,50 ****
          WriterMapper writerMapper, EjbConfig config) throws 
ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper, config);
- 
          EjbRuntime.setPlugin(this);
- 
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         setFileregex(config.getEjbReplaceRegex());
          setFilereplace("Local");
!         setMultioutput(true);
      }
      
      public Collection getInterfaceMethods(final JavaClass clazz) {
          return ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT, EjbUtils.LOCAL);
--- 43,114 ----
          WriterMapper writerMapper, EjbConfig config) throws 
ClassNotFoundException {
          super(templateEngine, metadataProvider, writerMapper, config);
          EjbRuntime.setPlugin(this);
          setPackageregex("beans");
          setPackagereplace("interfaces");
!         super.setFileregex(config.getEjbReplaceRegex());
          setFilereplace("Local");
!         super.setMultioutput(true);
!     }
! 
!     public boolean shouldGenerate(Object metadata) {
!         JavaClass javaClass = (JavaClass) metadata;
!         boolean generate = super.shouldGenerate(metadata);
!         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
javaClass.getTagByName("ejb.interface");
!         if (interfaceTag != null) {
!             generate &= 
Arrays.asList(interfaceTag.getGenerate()).contains("local");
!         }
!         return generate;
      }
      
+     protected String getLocalyDefinedFullClassName(JavaClass clazz) {
+         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
clazz.getTagByName("ejb.interface");
+         return interfaceTag != null ? interfaceTag.getLocalClass() : 
super.getLocalyDefinedFullClassName(clazz);
+     }
+ 
+     protected String getLocalyDefinedPackageName(JavaClass clazz) {
+         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
clazz.getTagByName("ejb.interface");
+         String definedPackage = null;
+ 
+         if (interfaceTag != null) {
+             definedPackage = interfaceTag.getLocalPackage();
+ 
+             if (definedPackage == null) {
+                 definedPackage = interfaceTag.getPackage();
+             }
+         }
+ 
+         return definedPackage != null ? definedPackage : 
super.getLocalyDefinedPackageName(clazz);
+     }
+ 
+     protected String getPatternBasedUnqualifiedName(JavaClass clazz) {
+         EjbInterfaceTag interfaceTag = (EjbInterfaceTag) 
clazz.getTagByName("ejb.interface");
+         String pattern = null;
+ 
+         if (interfaceTag != null) {
+             pattern = interfaceTag.getLocalPattern();
+ 
+             if (pattern == null && interfaceTag.getPattern() != null) {
+                 pattern = interfaceTag.getPattern() + "Local";
+             }
+         }
+ 
+         return pattern != null ? MessageFormat.format(pattern, new String[] 
{ejbUtils.getEjbName(clazz)})
+                                : super.getPatternBasedUnqualifiedName(clazz);
+     }
+ 
+     /**
+      * Don't let multioutput be changed
+      */
+     public void setMultioutput(boolean multioutput) {
+         throw new RuntimeException("Can't set multioutput for plugin");
+     }
+ 
+     /**
+      * Don't let fileregex be changed
+      */
+     public void setFileregex(String fileregex) {
+         throw new RuntimeException("Can't set fileregex for plugin. Try 
setting it in " + EjbConfig.class.getName());
+     }
+ 
      public Collection getInterfaceMethods(final JavaClass clazz) {
          return ejbUtils.getInterfaceMethods(clazz, 
EjbUtils.IFACE_METHOD_COMPONENT, EjbUtils.LOCAL);



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
xdoclet-plugins-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xdoclet-plugins-commits

Reply via email to