From: Ive H. <hel...@us...> - 2006-06-12 06:54:59
|
Update of /cvsroot/xdoclet-plugins/xdoclet-plugins/plugin-weblogic/src/main/java/org/xdoclet/plugin/weblogic/ejb/descriptor In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12277/plugin-weblogic/src/main/java/org/xdoclet/plugin/weblogic/ejb/descriptor Added Files: WeblogicEjbJarXmlPlugin.java WeblogicCmpRdbmsJarXmlPlugin.java WeblogicCmpRdbmsJarXmlPlugin.jelly WeblogicEjbJarXmlPlugin.jelly Log Message: Initial Revision --- NEW FILE: WeblogicEjbJarXmlPlugin.java --- package org.xdoclet.plugin.weblogic.ejb.descriptor; import java.io.File; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import org.generama.JellyTemplateEngine; import org.generama.QDoxCapableMetadataProvider; import org.generama.WriterMapper; import org.generama.defaults.XMLOutputValidator; import org.xdoclet.plugin.ejb.AbstractEjbJarXmlPlugin; import org.xdoclet.plugin.ejb.EjbConfig; import org.xdoclet.plugin.ejb.EjbRuntime; import org.xdoclet.plugin.ejb.EjbUtils; import org.xdoclet.plugin.ejb.interfaces.LocalHomeInterfacePlugin; import org.xdoclet.plugin.ejb.interfaces.RemoteHomeInterfacePlugin; import org.xdoclet.plugin.ejb.util.QDoxCachedMetadataProvider; import org.xdoclet.plugin.weblogic.WebLogicVersion; import org.xdoclet.plugin.weblogic.ejb.WeblogicEjbUtils; import org.xdoclet.plugin.weblogic.qtags.TagLibrary; import com.thoughtworks.qdox.model.AbstractJavaEntity; import com.thoughtworks.qdox.model.JavaClass; /** * @author Ive Hellemans * @version $Revision$ */ public class WeblogicEjbJarXmlPlugin extends AbstractEjbJarXmlPlugin { /** Description to be added to the file. */ private String description = "Generated by XDoclet2"; /** Default name for generated file */ private String fileName = "weblogic-ejb-jar.xml"; private WeblogicEjbUtils ejbUtils = null; public WeblogicEjbJarXmlPlugin(JellyTemplateEngine jellyTemplateEngine, //QDoxCachedMetadataProvider metadataProvider, WriterMapper writerMapper, EjbConfig config) { super(jellyTemplateEngine, /* metadataProvider, */ writerMapper, config); //Disable multi-output super.setMultioutput(false); this.ejbUtils = new WeblogicEjbUtils(config); //Register tags new TagLibrary(metadataProvider); //Register schemas Map schemas = WebLogicVersion.fillEntityResolverMap(new HashMap()); setOutputValidator(new XMLOutputValidator(schemas)); } protected void populateContextMap(Map map) { super.populateContextMap(map); map.put("ejbUtil", ejbUtils); map.put("version", getWeblogicVersion()); } /** * Don't let multioutput be changed */ public void setMultioutput(boolean multioutput) { throw new RuntimeException("Can't set multioutput for plugin"); } /** * Setter for fileName property * * @param fileName The value for the property * * @throws NullPointerException if fileName == null */ public void setFilename(String fileName) { if (fileName == null) { throw new NullPointerException(); } this.fileName = fileName; } /** * Getter or the fileName property. */ public String getFileName() { return this.fileName; } /** * Utility method called from jelly script to resolve a mergeFile reference * * @param mergeFile The mergeFile to look for * @param clazz JavaClass name for name expansion * * @return A File for mergeFile */ public File getMergeFile(String mergeFile, JavaClass clazz) { if (true) throw new RuntimeException("wordt toch aangeroepen :-)"); //TODO remove return getMergeFile(expandFileName(mergeFile, clazz)); } public String expandFileName(String mergeFile, JavaClass clazz) { return MessageFormat.format(mergeFile, new String[] {clazz.getName()}); } public boolean shouldGenerate(Object metadata) { return ejbUtils.shouldGenerate((JavaClass)metadata); } public WebLogicVersion getWeblogicVersion() { return WebLogicVersion.get(WebLogicVersion.WEBLOGIC_9_1_EJB); } /** * Overrides pluggin start. Used for late setting of generated file name, * in case the user whishes to change it */ public void start() { setFilereplace(fileName); super.start(); } /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } public LocalHomeInterfacePlugin getLocalHomeInterfacePlugin() { return EjbRuntime.getLocalHomeInterfacePlugin(); } public RemoteHomeInterfacePlugin getRemoteHomeInterfacePlugin() { return EjbRuntime.getRemoteHomeInterfacePlugin(); } /** * Returns the jndiName of the given bean, reading the jndi-name * property of the ejb.bean tag, and using a default value if this * attribute is not set. * * @param clazz The target class * @return The jndi-name */ public String getJndiName(JavaClass clazz) { String jndiName = ejbUtils.getNamedParameter( (AbstractJavaEntity)clazz, "ejb.bean", "jndi-name", null); if (jndiName == null) jndiName = ejbUtils.getJndiName(clazz, EjbUtils.REMOTE); return jndiName; } /** * Returns the local JNDI name of the given bean, reading the * local-jndi-name property of the ejb.bean tag, and using a default * value if this attribute is not set. * * @param clazz The target class * @return The local JNDI name */ public String getLocalJndiName(JavaClass clazz) { String jndiName = ejbUtils.getNamedParameter( (AbstractJavaEntity)clazz, "ejb.bean", "local-jndi-name", null); if (jndiName == null) jndiName = ejbUtils.getJndiName(clazz, EjbUtils.LOCAL); return jndiName; } } --- NEW FILE: WeblogicEjbJarXmlPlugin.jelly --- <?xml version="1.0" encoding="UTF-8"?> <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl"> <x:element URI="${version.ns}" name="weblogic-ejb-jar"> <x:attribute URI="${version.xsiNs}" name="xsi:schemaLocation" trim="true"> ${version.schemaLocation} </x:attribute> <x:replaceNamespace toURI="${version.ns}"> <j:if test="${!empty(plugin.description)}"> <description>${plugin.description}</description> </j:if> <j:forEach var="class" items="${ejbUtil.getBeans(metadata)}"> <j:if test="${ejbUtil.shouldGenerate(class)}"> <weblogic-enterprise-bean> <ejb-name>${ejbUtil.getEjbName(class)}</ejb-name> <j:if test="${ejbUtil.isEntityBean(class)}"> <entity-descriptor> <!-- weblogic.cache --> <j:set var="wlCacheTag" value="${class.getTagByName('weblogic.cache', true)}"/> <j:if test="${wlCacheTag != null}"> <entity-cache> <j:if test="${!empty(wlCacheTag.maxBeansInCache)}"> <max-beans-in-cache>${wlCacheTag.maxBeansInCache}</max-beans-in-cache> </j:if> <j:if test="${!empty(wlCacheTag.maxQueriesInCache)}"> <max-queries-in-cache>${wlCacheTag.maxQueriesInCache}</max-queries-in-cache> </j:if> <j:if test="${!empty(wlCacheTag.idleTimeoutSeconds)}"> <idle-timeout-seconds>${wlCacheTag.idleTimeoutSeconds}</idle-timeout-seconds> </j:if> <j:if test="${!empty(wlCacheTag.readTimeoutSeconds)}"> <read-timeout-seconds>${wlCacheTag.readTimeoutSeconds}</read-timeout-seconds> </j:if> <j:if test="${!empty(wlCacheTag.concurrencyStrategy)}"> <concurrency-strategy>${wlCacheTag.concurrencyStrategy}</concurrency-strategy> </j:if> <j:if test="${!empty(wlCacheTag.cacheBetweenTransactions)}"> <cache-between-transactions>${wlCacheTag.cacheBetweenTransactions}</cache-between-transactions> </j:if> </entity-cache> </j:if> <!-- weblogic.cache-ref --> <j:set var="wlCacheRefTag" value="${class.getTagByName('weblogic.cache-ref', true)}"/> <j:if test="${wlCacheRefTag != null}"> <entity-cache-ref> <j:if test="${!empty(wlCacheRefTag.cacheName)}"> <entity-cache-name>${wlCacheRefTag.cacheName}</entity-cache-name> </j:if> <j:if test="${!empty(wlCacheRefTag.idleTimeoutSeconds)}"> <idle-timeout-seconds>${wlCacheRefTag.idleTimeoutSeconds}</idle-timeout-seconds> </j:if> <j:if test="${!empty(wlCacheRefTag.readTimeoutSeconds)}"> <read-timeout-seconds>${wlCacheRefTag.readTimeoutSeconds}</read-timeout-seconds> </j:if> <j:if test="${!empty(wlCacheRefTag.concurrencyStrategy)}"> <concurrency-strategy>${wlCacheRefTag.concurrencyStrategy}</concurrency-strategy> </j:if> <j:if test="${!empty(wlCacheRefTag.cacheBetweenTransactions)}"> <cache-between-transactions>${wlCacheRefTag.cacheBetweenTransactions}</cache-between-transactions> </j:if> <j:if test="${!empty(wlCacheRefTag.estimatedBeanSize)}"> <estimated-bean-size>${wlCacheRefTag.estimatedBeanSize}</estimated-bean-size> </j:if> </entity-cache-ref> </j:if> <!-- TODO Persistence? --> <persistence> <persistence-use> <type-identifier>WebLogic_CMP_RDBMS</type-identifier> <type-version>6.0</type-version> <type-storage>META-INF/weblogic-cmp-rdbms-jar.xml</type-storage> </persistence-use> </persistence> <!-- entity-clustering --> <j:set var="wlClusteringTag" value="${class.getTagByName('weblogic.clustering', true)}"/> <j:if test="${wlClusteringTag != null}"> <entity-clustering> <j:if test="${!empty(wlClusteringTag.homeIsClusterable)}"> <home-is-clusterable>${wlClusteringTag.homeIsClusterable}</home-is-clusterable> </j:if> <j:if test="${!empty(wlClusteringTag.homeLoadAlgorithm)}"> <home-load-algorithm>${wlClusteringTag.homeLoadAlgorithm}</home-load-algorithm> </j:if> <j:if test="${!empty(wlClusteringTag.homeCallRouterClassName)}"> <home-call-router-class-name>${wlClusteringTag.homeCallRouterClassName}</home-call-router-class-name> </j:if> <j:if test="${!empty(wlClusteringTag.useServersideStubs)}"> <use-serverside-stubs>${wlClusteringTag.useServersideStubs}</use-serverside-stubs> </j:if> </entity-clustering> </j:if> <!-- enable-dynamic-queries --> <j:set var="wlEnableDynQueriesTag" value="${class.getTagByName('weblogic.enable-dynamic-queries', true)}"/> <j:if test="${wlEnableDynQueriesTag != null}"> <enable-dynamic-queries>${ejbUtil.getNamedParameter(wlEnableDynQueriesTag, 'value', 'true')}</enable-dynamic-queries> </j:if> </entity-descriptor> </j:if> <j:if test="${ejbUtil.isMessageDrivenBean(class)}"> <x:comment>MDB support is not implemented yet</x:comment> </j:if> <j:if test="${ejbUtil.isStateLess(class)}"> <stateless-session-descriptor> <!-- weblogic.pool --> <j:set var="wlPoolTag" value="${class.getTagByName('weblogic.pool', true)}"/> <j:if test="${wlPoolTag != null}"> <pool> <j:if test="${!empty(wlPoolTag.maxBeansInFreePool)}"> <max-beans-in-free-pool>${wlPoolTag.maxBeansInFreePool}</max-beans-in-free-pool> </j:if> <j:if test="${!empty(wlPoolTag.initialBeansInFreePool)}"> <initial-beans-in-free-pool>${wlPoolTag.initialBeansInFreePool}</initial-beans-in-free-pool> </j:if> </pool> </j:if> <!-- TODO timer-descriptor not implemented for now --> <!-- stateless-clustering --> <j:set var="wlClusteringTag" value="${class.getTagByName('weblogic.clustering', true)}"/> <j:if test="${wlClusteringTag != null}"> <stateless-clustering> <j:if test="${!empty(wlClusteringTag.homeIsClusterable)}"> <home-is-clusterable>${wlClusteringTag.homeIsClusterable}</home-is-clusterable> </j:if> <j:if test="${!empty(wlClusteringTag.homeLoadAlgorithm)}"> <home-load-algorithm>${wlClusteringTag.homeLoadAlgorithm}</home-load-algorithm> </j:if> <j:if test="${!empty(wlClusteringTag.homeCallRouterClassName)}"> <home-call-router-class-name>${wlClusteringTag.homeCallRouterClassName}</home-call-router-class-name> </j:if> <j:if test="${!empty(wlClusteringTag.useServersideStubs)}"> <use-serverside-stubs>${wlClusteringTag.useServersideStubs}</use-serverside-stubs> </j:if> <j:if test="${!empty(wlClusteringTag.statelessBeanIsClusterable)}"> <stateless-bean-is-clusterable>${wlClusteringTag.statelessBeanIsClusterable}</stateless-bean-is-clusterable> </j:if> <j:if test="${!empty(wlClusteringTag.statelessBeanLoadAlgorithm)}"> <stateless-bean-load-algorithm>${wlClusteringTag.statelessBeanLoadAlgorithm}</stateless-bean-load-algorithm> </j:if> <j:if test="${!empty(wlClusteringTag.statelessBeanCallRouterClassName)}"> <stateless-bean-call-router-class-name>${wlClusteringTag.statelessBeanCallRouterClassName}</stateless-bean-call-router-class-name> </j:if> </stateless-clustering> </j:if> </stateless-session-descriptor> </j:if> <!-- TODO add transaction-descriptor, iiop-security-descriptor --> <j:forEach var="reference" items="${ejbUtil.findTagsByName(class,'weblogic.resource-description')}"> <j:set var="refTag" value="${reference.tag}"/> <resource-description> <res-ref-name>${refTag.resRefName}</res-ref-name> <j:if test="${!empty(refTag.jndiName)}"> <jndi-name>${refTag.jndiName}</jndi-name> </j:if> <j:if test="${!empty(refTag.resourceLink)}"> <resource-link>${refTag.resourceLink}</resource-link> </j:if> </resource-description> </j:forEach> <!-- TODO weblogic:resource-env-description weblogic:ejb-reference-description weblogic:resource-env-description weblogic:ejb-local-reference-description --> <!-- enable-call-by-reference --> <j:set var="wlEnableCallByRefTag" value="${class.getTagByName('weblogic.enable-call-by-reference', true)}"/> <j:if test="${wlEnableCallByRefTag != null}"> <enable-call-by-reference>${ejbUtil.getNamedParameter(wlEnableCallByRefTag, 'value', 'true')}</enable-call-by-reference> </j:if> <!-- TODO add network-access-point, clients-on-same-server, run-as-principal-name, create-as-principal-name, remove-as-principal-name, passivate-as-principal-name --> <j:if test="${ejbUtil.shouldHaveJndiName(class)}"> <jndi-name>${plugin.getJndiName(class)}</jndi-name> </j:if> <j:if test="${ejbUtil.shouldHaveLocalJndiName(class)}"> <local-jndi-name>${plugin.getLocalJndiName(class)}</local-jndi-name> </j:if> <!-- TODO add dispatch-policy, remote-client-timeout --> </weblogic-enterprise-bean> </j:if> </j:forEach> <!-- merge weblogic-enterprise-beans.xml --> <j:set var="mergeFile" value="${plugin.getMergeFile('weblogic-enterprise-beans.xml')}"/> <j:choose> <j:when test="${mergeFile.exists()}"> <j:import file="${mergeFile.path}" inherit="true"/> </j:when> <j:otherwise> <x:comment trim="true">To add beans for which you have deployment descriptor info, add a file to your XDoclet merge directory called weblogic-enterprise-beans.xml that contains the weblogic-enterprise-bean markup for those beans.</x:comment> </j:otherwise> </j:choose> <!-- merge weblogic-security-role-assignment.xml --> <!-- TODO Create a tag for this? --> <j:set var="mergeFile" value="${plugin.getMergeFile('weblogic-security-role-assignment.xml')}"/> <j:choose> <j:when test="${mergeFile.exists()}"> <j:import file="${mergeFile.path}" inherit="true"/> </j:when> <j:otherwise> <x:comment trim="true">To add a security-role-assignment section, add a file to your XDoclet merge directory called weblogic-security-role-assignment.xml that contains the security-role-assignment markup.</x:comment> </j:otherwise> </j:choose> <!-- Merge weblogic-run-as-role-assignment.xml --> <!-- TODO Create a tag for this? --> <j:set var="mergeFile" value="${plugin.getMergeFile('weblogic-run-as-role-assignment.xml')}"/> <j:choose> <j:when test="${mergeFile.exists()}"> <j:import file="${mergeFile.path}" inherit="true"/> </j:when> <j:otherwise> <x:comment trim="true">To add a run-as-role-assignment section, add a file to your XDoclet merge directory called weblogic-run-as-role-assignment.xml that contains the run-as-role-assignment markup.</x:comment> </j:otherwise> </j:choose> <!-- TODO: Implement security-permission --> <x:comment>Missing implementation of security-permission</x:comment> <!-- TODO transaction-isolation message-destination-descriptor idempotent-methods retry-methods-on-rollback enable-bean-class-redeploy disable-warning work-manager weblogic-compatibility --> </x:replaceNamespace> </x:element> </j:jelly> --- NEW FILE: WeblogicCmpRdbmsJarXmlPlugin.jelly --- <?xml version="1.0" encoding="UTF-8"?> <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl"> <x:element URI="${version.ns}" name="weblogic-rdbms-jar"> <x:attribute URI="${version.xsiNs}" name="xsi:schemaLocation" trim="true"> ${version.schemaLocation} </x:attribute> <x:replaceNamespace toURI="${version.ns}"> <j:forEach var="class" items="${ejbUtil.getCMPBeans(metadata)}"> <weblogic-rdbms-bean> <ejb-name>${ejbUtil.getEjbName(class)}</ejb-name> <data-source-jndi-name>${plugin.getDatasSourceJndiName(class)}</data-source-jndi-name> <!-- TODO unknown-primary-key-field --> <table-map> <table-name>${cmpUtil.getTableNameFor(class)}</table-name> <j:forEach var="method" items="${ejbUtil.getCMPFields(class)}"> <field-map> <cmp-field>${method.propertyName}</cmp-field> <dbms-column>${cmpUtil.getColumnFor(method)}</dbms-column> </field-map> </j:forEach> </table-map> <!-- TODO field-group --> <!-- TODO relationship-caching --> <!-- TODO sql-shape --> <!-- weblogic-query --> <j:forEach var="finderTag" items="${class.getTagsByName('ejb.finder')}"> <weblogic-query> <j:if test="${!empty(finderTag.description)}"> <description>${finderTag.description}</description> </j:if> <j:scope> <j:set var="method" value="${ejbUtil.getFinderMethodBySignature(finderTag.signature)}" /> <query-method> <method-name>${method.name}</method-name> <method-params> <j:forEach var="param" items="${method.parameters}"> <method-param>${param.type}</method-param> </j:forEach> </method-params> </query-method> <j:if test="${!empty(finderTag.query)}"> <ejb-ql-query> <weblogic-ql><![CDATA[${finderTag.query}]]></weblogic-ql> </ejb-ql-query> </j:if> <j:if test="${!empty(finderTag.maxElements)}"> <max-elements>${finderTag.maxElements}</max-elements> </j:if> </j:scope> </weblogic-query> </j:forEach> <!-- weblogic.delay-database-insert-until --> <j:set var="wlDelayTag" value="${class.getTagByName('weblogic.delay-database-insert-until', true)}"/> <j:if test="${wlDelayTag != null}"> <delay-database-insert-until>${wlDelayTag.value}</delay-database-insert-until> </j:if> <!-- use-select-for-update --> <j:set var="wlSelectForUpdateTag" value="${class.getTagByName('weblogic.use-select-for-update', true)}"/> <j:if test="${wlSelectForUpdateTag != null}"> <use-select-for-update>${wlSelectForUpdateTag.value}</use-select-for-update> </j:if> <!-- lock-order --> <j:set var="wlLockOrderTag" value="${class.getTagByName('weblogic.lock-order', true)}"/> <j:if test="${wlLockOrderTag != null}"> <lock-order>${wlLockOrderTag.value}</lock-order> </j:if> <!-- instance-lock-order --> <j:set var="wlInstanceLockOrderTag" value="${class.getTagByName('weblogic.instance-lock-order', true)}"/> <j:if test="${wlInstanceLockOrderTag != null}"> <instance-lock-order>${wlInstanceLockOrderTag.value}</instance-lock-order> </j:if> <!-- automatic-key-generation --> <j:set var="wlKeyGenerationTag" value="${class.getTagByName('weblogic.automatic-key-generation', true)}"/> <j:if test="${wlKeyGenerationTag != null}"> <automatic-key-generation> <j:if test="${!empty(wlKeyGenerationTag.generatorType)}"> <generator-type>${wlKeyGenerationTag.generatorType}</generator-type> </j:if> <j:if test="${!empty(wlKeyGenerationTag.generatorName)}"> <generator-name>${wlKeyGenerationTag.generatorName}</generator-name> </j:if> <j:if test="${!empty(wlKeyGenerationTag.keyCacheSize)}"> <key-cache-size>${wlKeyGenerationTag.keyCacheSize}</key-cache-size> </j:if> </automatic-key-generation> </j:if> <!-- TODO check-exists-on-method --> <!-- TODO cluster-invalidation-disabled --> </weblogic-rdbms-bean> </j:forEach> <!-- Merge weblogic-cmp-rdbms-beans.xml --> <j:set var="mergeFile" value="${plugin.getMergeFile('weblogic-cmp-rdbms-beans.xml')}"/> <j:choose> <j:when test="${mergeFile.exists()}"> <j:import file="${mergeFile.path}" inherit="true"/> </j:when> <j:otherwise> <x:comment trim="true">To add weblogic relationships for beans not managed by XDoclet, add a file to your XDoclet merge directory called weblogic-cmp-rdbms-beans.xml that contains the weblogic-rdbms-bean markups for those beans.</x:comment> </j:otherwise> </j:choose> <!-- weblogic-rdbms-relation --> <j:forEach var="relation" items="${cmpUtil.getRelationships(metadata)}"> <weblogic-rdbms-relation> <relation-name>${relation.name}</relation-name> <j:if test="${cmpUtil.isMany2Many(relation)}"> <table-name>${cmpUtil.getJoinTableNameFor(relation)}</table-name> </j:if> <weblogic-relationship-role> <relationship-role-name>${relation.leftRoleName}</relationship-role-name> <j:set var="groupName" value="${cmpUtil.getLeftGroupNameFor(relation)}"/> <j:if test="${!empty(groupname)}"> <group-name>${groupName}</group-name> </j:if> <relationship-role-map> <j:forEach var="wlColumnMapTag" items="${cmpUtil.getLeftColumnMapsFor(relation)}"> <column-map> <foreign-key-column>${wlColumnMapTag.foreignKeyColumn}</foreign-key-column> <key-column>${wlColumnMapTag.keyColumn}</key-column> </column-map> </j:forEach> </relationship-role-map> <!-- TODO db-cascade-delete --> <!-- TODO enable-query-caching --> </weblogic-relationship-role> <j:if test="${cmpUtil.isMany2Many(relation)}"> <weblogic-relationship-role> <relationship-role-name>${relation.rightRoleName}</relationship-role-name> <j:set var="groupName" value="${cmpUtil.getRightGroupNameFor(relation)}"/> <j:if test="${!empty(groupname)}"> <group-name>${groupName}</group-name> </j:if> <relationship-role-map> <j:forEach var="wlColumnMapTag" items="${cmpUtil.getRightColumnMapsFor(relation)}"> <column-map> <foreign-key-column>${wlColumnMapTag.foreignKeyColumn}</foreign-key-column> <key-column>${wlColumnMapTag.keyColumn}</key-column> </column-map> </j:forEach> </relationship-role-map> <!-- TODO db-cascade-delete --> <!-- TODO enable-query-caching --> </weblogic-relationship-role> </j:if> </weblogic-rdbms-relation> </j:forEach> <!-- Merge weblogic-cmp-rdbms-relationships.xml --> <j:set var="mergeFile" value="${plugin.getMergeFile('weblogic-cmp-rdbms-relationships.xml')}"/> <j:choose> <j:when test="${mergeFile.exists()}"> <j:import file="${mergeFile.path}" inherit="true"/> </j:when> <j:otherwise> <x:comment trim="true">To add weblogic relationships for beans not managed by XDoclet, add a file to your XDoclet merge directory called weblogic-cmp-rdbms-relationships.xml that contains the weblogic-rdbms-relation markups for those beans.</x:comment> </j:otherwise> </j:choose> <!-- order-database-operations --> <j:if test="${!empty(plugin.getOrderDatabaseOperations())}"> <order-database-operations>${plugin.getOrderDatabaseOperations()}</order-database-operations> </j:if> <!-- enable-batch-operations --> <j:if test="${!empty(plugin.getEnableBatchOperations())}"> <enable-batch-operations>${plugin.getEnableBatchOperations()}</enable-batch-operations> </j:if> <!-- create-default-dbms-tables --> <j:if test="${!empty(plugin.getCreateDefaultDbmsTables())}"> <create-default-dbms-tables>${plugin.getCreateDefaultDbmsTables()}</create-default-dbms-tables> </j:if> <!-- validate-db-schema-with --> <j:if test="${!empty(plugin.getValidateDbSchemaWith())}"> <validate-db-schema-with>${plugin.getValidateDbSchemaWith()}</validate-db-schema-with> </j:if> <!-- weblogic.database-type --> <database-type>${plugin.getDatabaseType()}</database-type> <!-- default-dbms-tables-ddl --> <j:if test="${!empty(plugin.getDefaultDbmsTablesDdl())}"> <default-dbms-tables-ddl>${plugin.getDefaultDbmsTablesDdl()}</default-dbms-tables-ddl> </j:if> <!-- TODO compatibility --> </x:replaceNamespace> </x:element> </j:jelly> --- NEW FILE: WeblogicCmpRdbmsJarXmlPlugin.java --- package org.xdoclet.plugin.weblogic.ejb.descriptor; import java.io.File; import java.text.MessageFormat; import java.util.HashMap; import java.util.Map; import org.generama.JellyTemplateEngine; import org.generama.QDoxCapableMetadataProvider; import org.generama.WriterMapper; import org.generama.defaults.XMLOutputValidator; import org.xdoclet.plugin.ejb.AbstractEjbJarXmlPlugin; import org.xdoclet.plugin.ejb.EjbConfig; import org.xdoclet.plugin.ejb.EjbRuntime; import org.xdoclet.plugin.ejb.descriptor.EjbJarXmlPlugin; import org.xdoclet.plugin.ejb.util.QDoxCachedMetadataProvider; import org.xdoclet.plugin.weblogic.WebLogicVersion; import org.xdoclet.plugin.weblogic.ejb.WeblogicCmpUtils; import org.xdoclet.plugin.weblogic.ejb.WeblogicEjbUtils; import org.xdoclet.plugin.weblogic.qtags.TagLibrary; import com.thoughtworks.qdox.model.JavaClass; /** * @author Ive Hellemans * @version $Revision$ */ public class WeblogicCmpRdbmsJarXmlPlugin extends AbstractEjbJarXmlPlugin { /** Description to be added to the file. */ private String description = "Generated by XDoclet2"; /** Description to be added to the file. */ private String dataSourceJndiName = "no default data source set and no datasource defined forthis bean"; /** Database type (ORACLE etc). */ private String databaseType; /** Default name for generated file */ private String fileName = "weblogic-cmp-rdbms-jar.xml"; /** Whether or not db operations should be ordered. */ private Boolean orderDatabaseOperations; /** Whether or not batch operations should be supported. */ private Boolean enableBatchOperations; /** Whether or not default tables should be created. */ private String createDefaultDbmsTables; /** @see #getDefaultDbmsTablesDdl() */ private String defaultDbmsTablesDdl; /** @see #getValidateDbSchemaWith() */ private String validateDbSchemaWith; /** Utility classes. */ private WeblogicEjbUtils ejbUtils = null; private WeblogicCmpUtils cmpUtils = null; public WeblogicCmpRdbmsJarXmlPlugin(JellyTemplateEngine jellyTemplateEngine, //QDoxCachedMetadataProvider metadataProvider, WriterMapper writerMapper, EjbConfig config) { super(jellyTemplateEngine, //config.getMetadataProvider(), writerMapper, config); //Disable multi-output super.setMultioutput(false); //Initialise the utils this.ejbUtils = new WeblogicEjbUtils(config); this.cmpUtils = new WeblogicCmpUtils(this.ejbUtils); //Register tags new TagLibrary(metadataProvider); //Register schemas Map schemas = WebLogicVersion.fillEntityResolverMap(new HashMap()); setOutputValidator(new XMLOutputValidator(schemas)); } /** * @return Returns the databasetype. */ public String getDatabaseType() { return databaseType; } /** * @param databasetype The databasetype to set. */ public void setDatabasetype(String databasetype) { this.databaseType = databasetype; } /** * Don't let multioutput be changed */ public void setMultioutput(boolean multioutput) { throw new RuntimeException("Can't set multioutput for plugin"); } /** * Setter for fileName property * * @param fileName The value for the property * * @throws NullPointerException if fileName == null */ public void setFilename(String fileName) { if (fileName == null) { throw new NullPointerException(); } this.fileName = fileName; } /** * Getter or the fileName property. */ public String getFileName() { return this.fileName; } /** * @return Returns the description. */ public String getDescription() { return description; } /** * @param description The description to set. */ public void setDescription(String description) { this.description = description; } /** * @return Returns the datasourcejndiname. */ public String getDatasSourceJndiName(JavaClass clazz) { return cmpUtils.getDataSourceJndiName(clazz, dataSourceJndiName); } /** * @return Returns the default datasourcejndiname - if set */ public String getDataSourceJndiName() { return dataSourceJndiName; } /** * Sets the default value for <data-source-jndi-name>. * * @param datasourcejndiname The datasourcejndiname to set. */ public void setDatasourcejndiname(String datasourcejndiname) { this.dataSourceJndiName = datasourcejndiname; } public String getCreateDefaultDbmsTables() { return createDefaultDbmsTables; } public void setCreatedefaultdbmstables(String createdefaultdbmstables) { this.createDefaultDbmsTables = createdefaultdbmstables; } /** * Specifies the DDL file name to which the EJB container writes the * table creation scripts. */ public String getDefaultDbmsTablesDdl() { return defaultDbmsTablesDdl; } /** * @see #getDefaultDbmsTablesDdl() */ public void setDefaultdbmstablesddl(String defaultDbmsTablesDdl) { this.defaultDbmsTablesDdl = defaultDbmsTablesDdl; } /** * Specifies how the container verifies whether the database table contains * all of the columns that the bean's deployment descriptor contains. */ public String getValidateDbSchemaWith() { return validateDbSchemaWith; } /** * @see #getValidateDbSchemaWith() */ public void setValidatedbschemawith(String validatedbschemawith) { this.validateDbSchemaWith = validatedbschemawith; } public Boolean getEnableBatchOperations() { return enableBatchOperations; } public void setEnablebatchoperations(Boolean enablebatchoperations) { this.enableBatchOperations = enablebatchoperations; } public Boolean getOrderDatabaseOperations() { return orderDatabaseOperations; } public void setOrderdatabaseoperations(Boolean orderdatabaseoperations) { this.orderDatabaseOperations = orderdatabaseoperations; } public boolean shouldGenerate(Object metadata) { return ejbUtils.shouldGenerate((JavaClass)metadata); } /** * Utility method called from jelly script to resolve a mergeFile reference * * @param mergeFile The mergeFile to look for * @param clazz JavaClass name for name expansion * * @return A File for mergeFile */ public File getMergeFile(String mergeFile, JavaClass clazz) { if (true) throw new RuntimeException("wordt toch aangeroepen :-)"); //TODO remove return getMergeFile(expandFileName(mergeFile, clazz)); } protected String expandFileName(String mergeFile, JavaClass clazz) { return MessageFormat.format(mergeFile, new String[] {clazz.getName()}); } public EjbJarXmlPlugin getEjbJarXmlPlugin() { return EjbRuntime.getEjbJarXmlPlugin(); } protected WebLogicVersion getWeblogicVersion() { return WebLogicVersion.get(WebLogicVersion.WEBLOGIC_9_1_CMP_RDMBS); } protected WeblogicEjbUtils getWeblogicEjbUtils() { return ejbUtils; } protected WeblogicCmpUtils getWeblogicCmpUtils() { return cmpUtils; } /* * @see org.generama.Plugin#populateContextMap(java.util.Map) */ protected void populateContextMap(Map map) { super.populateContextMap(map); map.put("ejbUtil", getWeblogicEjbUtils()); map.put("cmpUtil", getWeblogicCmpUtils()); map.put("version", getWeblogicVersion()); } /** * Overrides pluggin start. Used for late setting of generated file name, * in case the user whishes to change it */ public void start() { setFilereplace(fileName); super.start(); } } |