Update of
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb
In directory
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20096/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb
Modified Files:
EjbRuntime.java EjbUtils.java
Added Files:
EjbJavaGeneratingPlugin.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: EjbRuntime.java
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/EjbRuntime.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** EjbRuntime.java 6 Sep 2005 01:50:00 -0000 1.2
--- EjbRuntime.java 13 Sep 2005 02:22:33 -0000 1.3
***************
*** 6,11 ****
package org.xdoclet.plugin.ejb;
- import org.generama.QDoxCapableMetadataProvider;
-
import org.xdoclet.plugin.ejb.descriptor.EjbJarXmlPlugin;
import org.xdoclet.plugin.ejb.entity.PrimaryKeyClassPlugin;
--- 6,9 ----
***************
*** 14,17 ****
--- 12,16 ----
import org.xdoclet.plugin.ejb.interfaces.RemoteHomeInterfacePlugin;
import org.xdoclet.plugin.ejb.interfaces.RemoteInterfacePlugin;
+ import org.xdoclet.plugin.ejb.interfaces.ServiceEndpointPlugin;
/**
***************
*** 33,36 ****
--- 32,36 ----
protected RemoteHomeInterfacePlugin remoteHomeInterfacePlugin;
protected RemoteInterfacePlugin remoteInterfacePlugin;
+ protected ServiceEndpointPlugin serviceEndpointPlugin;
protected EjbRuntime(EjbConfig config) {
***************
*** 66,69 ****
--- 66,81 ----
}
+ public static ServiceEndpointPlugin getServiceEndpointPlugin() throws
ClassNotFoundException {
+ checkInit();
+ return instance._getServiceEndpointPlugin();
+ }
+
+ protected synchronized ServiceEndpointPlugin _getServiceEndpointPlugin()
throws ClassNotFoundException {
+ if (this.serviceEndpointPlugin == null) {
+ this.serviceEndpointPlugin = new ServiceEndpointPlugin(null,
config.getMetadataProvider(), null, config);
+ }
+ return this.serviceEndpointPlugin;
+ }
+
protected synchronized LocalInterfacePlugin _getLocalInterfacePlugin()
throws ClassNotFoundException {
if (this.localInterfacePlugin == null) {
***************
*** 126,129 ****
--- 138,142 ----
}
+
public static void setPlugin(PrimaryKeyClassPlugin plugin) {
if (plugin == null) {
***************
*** 180,183 ****
--- 193,209 ----
}
+ public static void setPlugin(ServiceEndpointPlugin plugin) {
+ if (plugin == null) {
+ throw new Error("NullPointerException");
+ }
+
+ checkInit();
+ instance._setPlugin(plugin);
+ }
+
+ protected synchronized void _setPlugin(ServiceEndpointPlugin plugin) {
+ this.serviceEndpointPlugin = plugin;
+ }
+
protected synchronized void _setPlugin(RemoteInterfacePlugin plugin) {
this.remoteInterfacePlugin = plugin;
--- NEW FILE: EjbJavaGeneratingPlugin.java ---
/*
* Copyright (c) 2005
* XDoclet Team
* All rights reserved.
*/
package org.xdoclet.plugin.ejb;
import org.generama.QDoxCapableMetadataProvider;
import org.generama.TemplateEngine;
import org.generama.WriterMapper;
import org.generama.defaults.JavaGeneratingPlugin;
import com.thoughtworks.qdox.model.JavaClass;
import com.thoughtworks.qdox.model.Type;
/**
* Base JavaGeneratingPlugin for EjbRelated plugins<br>
* Contains code to override filename/classname creation for plugin to be
* able to be set using pattern/package/class tag values
*
* @author Diogo Quintela
*/
public class EjbJavaGeneratingPlugin extends JavaGeneratingPlugin {
/** From Plugin#fileregex (private). Hacked to get a copy of */
private String fileregex;
/** From Plugin#filereplace (private). Hacked to get a copy of */
private String filereplace;
/** From Plugin#packageregex (private). Hacked to get a copy of */
private String packageregex;
/** From Plugin#packagereplace (private). Hacked to get a copy of */
private String packagereplace;
public EjbJavaGeneratingPlugin(TemplateEngine templateEngine,
QDoxCapableMetadataProvider metadataProvider,
WriterMapper writerMapper) {
super(templateEngine, metadataProvider, writerMapper);
}
public void setFileregex(String fileregex) {
if (fileregex == null) {
throw new NullPointerException();
}
this.fileregex = fileregex;
super.setFileregex(fileregex);
}
public void setFilereplace(String filereplace) {
if (filereplace == null) {
throw new NullPointerException();
}
this.filereplace = filereplace;
super.setFilereplace(filereplace);
}
public void setPackageregex(String packageregex) {
if (packageregex == null) {
throw new NullPointerException();
}
this.packageregex = packageregex;
super.setPackageregex(packageregex);
}
public void setPackagereplace(String packagereplace) {
if (packagereplace == null) {
throw new NullPointerException();
}
this.packagereplace = packagereplace;
super.setPackagereplace(packagereplace);
}
protected String getLocalyDefinedFullClassName(JavaClass clazz) {
return null;
}
protected String getLocalyDefinedPackageName(JavaClass clazz) {
return null;
}
protected String getPatternBasedUnqualifiedName(JavaClass clazz) {
return null;
}
/**
* The physical type for the generated java type
*
* @param clazz The source metadata class
*
* @return The type to use
*/
public JavaType getPhysicalType(JavaClass clazz) {
JavaType retType = null;
String fullType = getLocalyDefinedFullClassName(clazz);
if (fullType != null) {
int idx = fullType.lastIndexOf('.');
if (idx != -1) {
retType = new JavaType(fullType.substring(0, idx),
fullType.substring(idx + 1));
} else {
retType = new JavaType(fullType);
}
}
if (retType == null) {
String unqualifiedName = getPatternBasedUnqualifiedName(clazz);
if (unqualifiedName == null) {
unqualifiedName = clazz.getName();
unqualifiedName = unqualifiedName.replaceAll(fileregex,
filereplace);
}
String javaPackage = getLocalyDefinedPackageName(clazz);
if (javaPackage == null) {
javaPackage = clazz.getPackage();
javaPackage = javaPackage.replaceAll(packageregex,
packagereplace);
}
retType = new JavaType(javaPackage, unqualifiedName);
}
return retType;
}
/**
* The type to be referenced to, normally equals to physical generated
type, this should be called when
* some plugin tries to refer to the generate class by this plugin<br>
* This supports a type that extends the physical type to be used.<br>
*
* See @ejb.bean impl-class-name for example
*
* @param clazz The source metadata class
*
* @return The type to use
*/
public JavaType getVirtualType(JavaClass clazz) {
return getPhysicalType(clazz);
}
public String getDestinationFilename(Object metadata) {
return getPhysicalType((JavaClass) metadata).getName() + ".java";
}
public String getDestinationPackage(Object metadata) {
return getPhysicalType((JavaClass) metadata).getPackage();
}
protected static class JavaType {
private String javaPackage;
private String unqualifiedName;
public JavaType(String name) {
setName(name);
}
public JavaType(String javaPackage, String name) {
setPackage(javaPackage);
setName(name);
}
public void setPackage(String javaPackage) {
this.javaPackage = javaPackage;
}
public void setName(String name) {
this.unqualifiedName = name;
}
public String getPackage() {
return (this.javaPackage == null) ? "" : this.javaPackage;
}
public String getName() {
return this.unqualifiedName;
}
public Type getType() {
return new Type(!"".equals(getPackage()) ? getPackage() + "." +
getName() : getName());
}
public String toString() {
return getType().toString();
}
}
}
Index: EjbUtils.java
===================================================================
RCS file:
/cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-ejb/src/main/java/org/xdoclet/plugin/ejb/EjbUtils.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** EjbUtils.java 7 Sep 2005 01:13:08 -0000 1.10
--- EjbUtils.java 13 Sep 2005 02:22:33 -0000 1.11
***************
*** 27,35 ****
import org.xdoclet.plugin.ejb.entity.PrimaryKeyClassPlugin;
! import org.xdoclet.plugin.ejb.qtags.EjbActivationConfigProperty;
import org.xdoclet.plugin.ejb.qtags.EjbBeanTag;
import org.xdoclet.plugin.ejb.qtags.EjbEjbExternalRefTag;
import org.xdoclet.plugin.ejb.qtags.EjbEjbRefTag;
! import org.xdoclet.plugin.ejb.qtags.EjbEjbServiceRef;
import org.xdoclet.plugin.ejb.qtags.EjbFinderTag;
import org.xdoclet.plugin.ejb.qtags.EjbPermissionTag;
--- 27,35 ----
import org.xdoclet.plugin.ejb.entity.PrimaryKeyClassPlugin;
! import org.xdoclet.plugin.ejb.qtags.EjbActivationConfigPropertyTag;
import org.xdoclet.plugin.ejb.qtags.EjbBeanTag;
import org.xdoclet.plugin.ejb.qtags.EjbEjbExternalRefTag;
import org.xdoclet.plugin.ejb.qtags.EjbEjbRefTag;
! import org.xdoclet.plugin.ejb.qtags.EjbEjbServiceRefTag;
import org.xdoclet.plugin.ejb.qtags.EjbFinderTag;
import org.xdoclet.plugin.ejb.qtags.EjbPermissionTag;
***************
*** 100,104 ****
public static final String LOCAL_HOME_INTERFACE = "LocalHome";
public static final String SERVICE_END_POINT_INTERFACE =
"ServiceEndpoint";
-
/**
* Maps primitive types to their wrapper classes
--- 100,103 ----
***************
*** 662,666 ****
public boolean hasActivationConfig(JavaClass javaClass) {
EjbBeanTag beanTag = (EjbBeanTag) javaClass.getTagByName("ejb.bean");
! EjbActivationConfigProperty actTag = (EjbActivationConfigProperty)
javaClass.getTagByName(
"ejb.activation-config-property");
boolean retVal = false;
--- 661,665 ----
public boolean hasActivationConfig(JavaClass javaClass) {
EjbBeanTag beanTag = (EjbBeanTag) javaClass.getTagByName("ejb.bean");
! EjbActivationConfigPropertyTag actTag =
(EjbActivationConfigPropertyTag) javaClass.getTagByName(
"ejb.activation-config-property");
boolean retVal = false;
***************
*** 816,820 ****
if (pkPlugin.shouldGenerate(javaClass)) {
! return
pkPlugin.getDestinationFullyQualifiedClassName(javaClass);
} else {
throw new Error("Cannot resolve primary key class name (" +
javaClass.getFullyQualifiedName() + ")");
--- 815,819 ----
if (pkPlugin.shouldGenerate(javaClass)) {
! return pkPlugin.getVirtualType(javaClass).toString();
} else {
throw new Error("Cannot resolve primary key class name (" +
javaClass.getFullyQualifiedName() + ")");
***************
*** 833,838 ****
String paramName = null;
! if (tag instanceof EjbEjbServiceRef) {
! refType = ((EjbEjbServiceRef) tag).getInterface();
paramName = "interface";
} else if (tag instanceof EjbResourceRefTag) {
--- 832,837 ----
String paramName = null;
! if (tag instanceof EjbEjbServiceRefTag) {
! refType = ((EjbEjbServiceRefTag) tag).getInterface();
paramName = "interface";
} else if (tag instanceof EjbResourceRefTag) {
***************
*** 881,886 ****
String paramName = null;
! if (tag instanceof EjbEjbServiceRef) {
! refName = ((EjbEjbServiceRef) tag).getName_();
paramName = "name";
} else if (tag instanceof EjbResourceRefTag) {
--- 880,885 ----
String paramName = null;
! if (tag instanceof EjbEjbServiceRefTag) {
! refName = ((EjbEjbServiceRefTag) tag).getName_();
paramName = "name";
} else if (tag instanceof EjbResourceRefTag) {
***************
*** 1623,1633 ****
// Lets expand by permission for interface type
- String methodSignature =
EjbRuntime.getLocalHomeInterfacePlugin()
-
.getDestinationFullyQualifiedClassName(javaClass) +
- " findByPrimaryKey()";
-
// Method signature should maybe be unrolled by permType,
but it's not really relevant
// the return type, soo..
! retLst.addAll(MethodPermission.unroll(permType,
getMethodBySignature(methodSignature),
pkTag.getRoleNames()));
}
--- 1622,1628 ----
// Lets expand by permission for interface type
// Method signature should maybe be unrolled by permType,
but it's not really relevant
// the return type, soo..
! retLst.addAll(MethodPermission.unroll(permType,
getMethodBySignature("void findByPrimaryKey()"),
pkTag.getRoleNames()));
}
-------------------------------------------------------
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