de.ispsoft.jaxme.generator.beanwriter
Class EntityBeanClassWriter

java.lang.Object
  extended byde.ispsoft.jaxme.generator.beanwriter.EntityBeanClassWriter
All Implemented Interfaces:
BeanClassWriter
Direct Known Subclasses:
SessionBeanClassWriter

public class EntityBeanClassWriter
extends java.lang.Object
implements BeanClassWriter

Used by the BeanWriter to generate entity beans.

Author:
Jochen Wiedmann

Field Summary
protected  SchemaComplexElement element
           
protected static org.xml.sax.Attributes emptyAttributes
           
protected static SourceWriterImpl sourceWriter
           
 
Constructor Summary
EntityBeanClassWriter(SourceWriterImpl pSourceWriter, SchemaComplexElement pElement)
          Creates a new instance of EntityBeanWriter
 
Method Summary
 JavaSource generateBean()
          Generates the bean class.
protected  JavaMethod generateBeanClassInitializer(JavaSource js)
          Generates the bean classes class constructor.
protected  JavaField generateContextField(JavaSource js)
          Generates the context field.
protected  JavaMethod generateCreateMethod(JavaSource js)
          Generates the create() method.
protected  JavaMethod generateEjbActivateMethod(JavaSource js)
          Generates the ejbActivate() method.
protected  JavaMethod generateEjbLoadMethod(JavaSource js)
          Generates the ejbLoad() method.
protected  JavaMethod generateEjbPassivateMethod(JavaSource js)
          Generates the ejbPassivate() method.
protected  JavaMethod generateEjbPostCreateMethod(JavaSource js)
          Generates the ejbPostCreate() method.
protected  JavaMethod generateEjbRemoveMethod(JavaSource js)
          Generates the ejbRemove() method.
protected  JavaMethod generateEjbStoreMethod(JavaSource js)
          Generates the ejbStore() method.
protected  JavaField generateElementField(JavaSource js)
          Generates the element field.
protected  JavaMethod generateFindByPrimaryKeyMethod(JavaSource js)
          Generates the findByPrimaryKey() method.
protected  JavaMethod generateFindByQueryFourArgsMethod(JavaSource js)
          Generates the findByQuery() method with four arguments.
protected  JavaMethod generateFindByQueryOneArgMethod(JavaSource js)
          Generates the findByQuery() method with one argument.
protected  JavaMethod generateFindByQueryThreeArgsMethod(JavaSource js)
          Generates the findByQuery() method with three arguments.
protected  JavaMethod generateFindByQueryTwoArgsMethod(JavaSource js)
          Generates the findByQuery() method with two arguments.
protected  JavaMethod generateGetXMLMethod(JavaSource js)
          Generates the getXML() method.
 JavaSource generateHome()
          Generates the beans home interface.
protected  JavaMethod generateIsModifiedMethod(JavaSource js)
          Generates the isModified() method.
 JavaSource generatePrimaryKey()
          Generates the primary key class.
protected  java.lang.String generatePrimaryKeyEquals(java.lang.String pVar, java.lang.String pArg)
          Generates a test for equality for update().
protected  java.lang.String generatePrimaryKeyQuery(java.lang.String pArg)
          Generates a query for a primary key for findByPrimaryKey.
protected  java.lang.String generatePrimaryKeyQueryPlaceHolders(java.lang.String pArg)
          Generates a placeholder list for findByPrimaryKey.
protected  java.lang.String generatePrimaryKeyResult(java.lang.String pArg)
          Generates a result for findByPrimaryKey.
protected  java.lang.String generatePrimaryKeyToString(java.lang.String arg)
          Generates a description of the primary key for use in error messages.
 JavaSource generateRemote()
          Generates the beans remote interface.
protected  JavaMethod generateSetContextMethod(JavaSource js)
          Generates the setEntityContext() method.
protected  JavaMethod generateUnsetContextMethod(JavaSource js)
          Generates the unsetEntityContext() method.
protected  JavaMethod generateUpdateMethod(JavaSource js)
          Generates the update() method.
protected  java.lang.String getBeanClassName()
          Returns the name of the generated bean class.
protected  java.lang.String[] getBeanImplementsClass()
          Generates the interface, that the bean class implements.
protected  JdbcListMethod[] getBeanListMethods()
           
protected  java.lang.String getBeanName()
          Returns the beans name for resource references.
protected  java.lang.String getDataSourceName()
          Returns the beans datasource name.
protected  java.lang.String getDeclaredBeanClassName()
          Returns the name of the declared bean class.
protected  java.lang.String getDeclaredHomeClassName()
          Returns the name of the declared home interface.
protected  java.lang.String getDeclaredPrimaryKeyClassName()
          Returns the name of the declared primary key class.
protected  java.lang.String getDeclaredRemoteClassName()
          Returns the name of the declared remote interface.
protected  java.lang.String getEJBException(java.lang.String pMsg, java.lang.String pException)
          Creates a piece of JavaSource throwing an EJBException that encapsulates another Exception.
protected  java.lang.String getHomeClassName()
          Returns the name of the generated home interface.
protected  JdbcListMethod[] getHomeListMethods()
           
protected  boolean getImplDeclaresRemoteException()
          Used to determine whether generated implementations should declare a RemoteException or not.
protected  java.util.List getKeyList()
          Generates a list of all parts of the primary key.
protected  java.util.List getKeyList(boolean pAllowZeroSize)
           
protected  JavaMethod getListMethod(JavaSource pJs, JdbcListMethod pMethod)
           
protected  java.lang.String getPrimaryKeyClassName()
          Returns the primary key class.
protected  java.lang.String getRemoteClassName()
          Returns the name of the generated remote interface.
protected  JdbcListMethod[] getRemoteListMethods()
           
 void writeContainerTransactionDeclaration(org.xml.sax.ContentHandler pHandler)
          Writes a method declaration in the ejb-jar file.
 void writeEntityDeclaration(org.xml.sax.ContentHandler pHandler)
          Writes an entity bean declaration in the ejb-jar file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

element

protected SchemaComplexElement element

emptyAttributes

protected static org.xml.sax.Attributes emptyAttributes

sourceWriter

protected static SourceWriterImpl sourceWriter
Constructor Detail

EntityBeanClassWriter

public EntityBeanClassWriter(SourceWriterImpl pSourceWriter,
                             SchemaComplexElement pElement)
Creates a new instance of EntityBeanWriter

Method Detail

getEJBException

protected java.lang.String getEJBException(java.lang.String pMsg,
                                           java.lang.String pException)

Creates a piece of JavaSource throwing an EJBException that encapsulates another Exception. Reason is that new EJBException(msg, e) is available since EJB 2.0 only.


getImplDeclaresRemoteException

protected boolean getImplDeclaresRemoteException()

Used to determine whether generated implementations should declare a RemoteException or not.


getBeanName

protected java.lang.String getBeanName()

Returns the beans name for resource references.


generateCreateMethod

protected JavaMethod generateCreateMethod(JavaSource js)

Generates the create() method.


generateEjbPostCreateMethod

protected JavaMethod generateEjbPostCreateMethod(JavaSource js)

Generates the ejbPostCreate() method.


generateFindByPrimaryKeyMethod

protected JavaMethod generateFindByPrimaryKeyMethod(JavaSource js)

Generates the findByPrimaryKey() method.


generateFindByQueryOneArgMethod

protected JavaMethod generateFindByQueryOneArgMethod(JavaSource js)

Generates the findByQuery() method with one argument.


generateFindByQueryTwoArgsMethod

protected JavaMethod generateFindByQueryTwoArgsMethod(JavaSource js)

Generates the findByQuery() method with two arguments.


generateFindByQueryThreeArgsMethod

protected JavaMethod generateFindByQueryThreeArgsMethod(JavaSource js)

Generates the findByQuery() method with three arguments.


generateFindByQueryFourArgsMethod

protected JavaMethod generateFindByQueryFourArgsMethod(JavaSource js)

Generates the findByQuery() method with four arguments.


generateHome

public JavaSource generateHome()
                        throws SchemaException

Generates the beans home interface.

Specified by:
generateHome in interface BeanClassWriter
Throws:
SchemaException

generateGetXMLMethod

protected JavaMethod generateGetXMLMethod(JavaSource js)

Generates the getXML() method.


generateUpdateMethod

protected JavaMethod generateUpdateMethod(JavaSource js)

Generates the update() method.


generateRemote

public JavaSource generateRemote()
                          throws SchemaException

Generates the beans remote interface.

Specified by:
generateRemote in interface BeanClassWriter
Throws:
SchemaException

generateBeanClassInitializer

protected JavaMethod generateBeanClassInitializer(JavaSource js)

Generates the bean classes class constructor.


generateEjbStoreMethod

protected JavaMethod generateEjbStoreMethod(JavaSource js)

Generates the ejbStore() method.


generateEjbLoadMethod

protected JavaMethod generateEjbLoadMethod(JavaSource js)

Generates the ejbLoad() method.


generateEjbActivateMethod

protected JavaMethod generateEjbActivateMethod(JavaSource js)

Generates the ejbActivate() method.


generateEjbPassivateMethod

protected JavaMethod generateEjbPassivateMethod(JavaSource js)

Generates the ejbPassivate() method.


generateEjbRemoveMethod

protected JavaMethod generateEjbRemoveMethod(JavaSource js)

Generates the ejbRemove() method.


generateSetContextMethod

protected JavaMethod generateSetContextMethod(JavaSource js)

Generates the setEntityContext() method.


generateUnsetContextMethod

protected JavaMethod generateUnsetContextMethod(JavaSource js)

Generates the unsetEntityContext() method.


generateIsModifiedMethod

protected JavaMethod generateIsModifiedMethod(JavaSource js)

Generates the isModified() method.


generateContextField

protected JavaField generateContextField(JavaSource js)

Generates the context field.


generateElementField

protected JavaField generateElementField(JavaSource js)

Generates the element field.


getBeanImplementsClass

protected java.lang.String[] getBeanImplementsClass()

Generates the interface, that the bean class implements.


generateBean

public JavaSource generateBean()
                        throws SchemaException

Generates the bean class.

Specified by:
generateBean in interface BeanClassWriter
Throws:
SchemaException

generatePrimaryKey

public JavaSource generatePrimaryKey()

Generates the primary key class.

Specified by:
generatePrimaryKey in interface BeanClassWriter

writeEntityDeclaration

public void writeEntityDeclaration(org.xml.sax.ContentHandler pHandler)
                            throws org.xml.sax.SAXException

Writes an entity bean declaration in the ejb-jar file.

Specified by:
writeEntityDeclaration in interface BeanClassWriter
Throws:
org.xml.sax.SAXException

writeContainerTransactionDeclaration

public void writeContainerTransactionDeclaration(org.xml.sax.ContentHandler pHandler)
                                          throws org.xml.sax.SAXException

Writes a method declaration in the ejb-jar file.

Specified by:
writeContainerTransactionDeclaration in interface BeanClassWriter
Throws:
org.xml.sax.SAXException

getKeyList

protected java.util.List getKeyList()

Generates a list of all parts of the primary key.


getKeyList

protected java.util.List getKeyList(boolean pAllowZeroSize)

generatePrimaryKeyToString

protected java.lang.String generatePrimaryKeyToString(java.lang.String arg)

Generates a description of the primary key for use in error messages.


generatePrimaryKeyQuery

protected java.lang.String generatePrimaryKeyQuery(java.lang.String pArg)

Generates a query for a primary key for findByPrimaryKey.


generatePrimaryKeyQueryPlaceHolders

protected java.lang.String generatePrimaryKeyQueryPlaceHolders(java.lang.String pArg)

Generates a placeholder list for findByPrimaryKey.


generatePrimaryKeyResult

protected java.lang.String generatePrimaryKeyResult(java.lang.String pArg)

Generates a result for findByPrimaryKey.


generatePrimaryKeyEquals

protected java.lang.String generatePrimaryKeyEquals(java.lang.String pVar,
                                                    java.lang.String pArg)

Generates a test for equality for update().


getPrimaryKeyClassName

protected java.lang.String getPrimaryKeyClassName()

Returns the primary key class.


getDataSourceName

protected java.lang.String getDataSourceName()

Returns the beans datasource name.


getBeanClassName

protected java.lang.String getBeanClassName()

Returns the name of the generated bean class.


getHomeClassName

protected java.lang.String getHomeClassName()

Returns the name of the generated home interface.


getRemoteClassName

protected java.lang.String getRemoteClassName()

Returns the name of the generated remote interface.


getDeclaredRemoteClassName

protected java.lang.String getDeclaredRemoteClassName()

Returns the name of the declared remote interface.


getDeclaredHomeClassName

protected java.lang.String getDeclaredHomeClassName()

Returns the name of the declared home interface.


getDeclaredBeanClassName

protected java.lang.String getDeclaredBeanClassName()

Returns the name of the declared bean class.


getDeclaredPrimaryKeyClassName

protected java.lang.String getDeclaredPrimaryKeyClassName()

Returns the name of the declared primary key class.


getHomeListMethods

protected JdbcListMethod[] getHomeListMethods()

getRemoteListMethods

protected JdbcListMethod[] getRemoteListMethods()

getBeanListMethods

protected JdbcListMethod[] getBeanListMethods()

getListMethod

protected JavaMethod getListMethod(JavaSource pJs,
                                   JdbcListMethod pMethod)
                            throws SchemaException
Throws:
SchemaException