FileDocCategorySizeDatePackage
CMPTemplateFormatter.javaAPI DocGlassfish v2 API27013Fri May 04 22:34:48 BST 2007com.sun.jdo.spi.persistence.support.ejb.ejbc

CMPTemplateFormatter

public class CMPTemplateFormatter extends com.sun.jdo.spi.persistence.utility.generator.JavaClassWriterHelper

Fields Summary
private static final String
templateFile
public static final String
ejb_
public static final String
ejbObject_
public static final String
ejbHome_
public static final String
ejbContext_
public static final String
context_
public static final String
key_
public static final String
keys_
public static final String
oid_
public static final String
oids_
public static final String
pc_
public static final String
cmpImplComments_
public static final String
imports_
public static final String
interfaces_
public static final String
helperImports_
public static final String
staticTransientPackageVariables_
public static final String
privateStaticVariables_
public static final String
privateTransientVariables_
public static final String
privateStaticFinalVariables_
public static final String
publicStaticFinalVariables_
public static final String
finderSelectorStaticVariables_
public static final String
finderSelectorStaticFinalVariables_
public static final String
otherVariables_
public static final String
setNull_
public static final String
commonPrivateMethods_
public static final String
commonPublicMethods_
public static final String
otherPublicMethods_
public static final String
jdoLookupPersistenceManagerFactory_
public static final String
helperMethods_
public static final String
getInstance_
public static final String
findByPrimaryKey_
public static final String
ejbFindByPrimaryKey_
public static final String
ejbFinderSelectorBody_
public static final String
ejbQueryExecutionParamConvBody_
public static final String
ejbQueryExecutionParamConvBodyArgument_
public static final String
ejbQueryExecutionBody_
public static final String
ejbAggregateQueryExecutionBody_
public static final String
ejbAggregateQueryExecutionParamConvBody_
public static final String
ejbMultiFinderBody_
public static final String
ejbMultiFinderBodyEnumeration_
public static final String
ejbSingleFinderBody_
public static final String
jdoGetJdoInstanceClass_
public static final String
find_
public static final String
catchClause_
public static final String
ejbSelect_
public static final String
create_
public static final String
remove_
public static final String
ejbCreate_
public static final String
ejbCreateUnknownPK_
public static final String
ejbPostCreate_
public static final String
ejbRemove_
public static final String
ejbLoad_
public static final String
CreateException_
public static final String
DuplicateKeyException_
public static final String
RemoveException_
public static final String
ejbException_
public static final String
finderException_
public static final String
assertInTransaction_
public static final String
assertPersistenceManagerIsNull_
public static final String
assertPersistenceManagerIsNullCall_
public static final String
setEntityContext_
public static final String
EntityContext_
public static final String
castKey_
public static final String
castOid_
public static final String
getPK_
public static final String
getPKClone_
public static final String
newPK_
public static final String
newOid_
public static final String
getPK1_
public static final String
getPK1Clone_
public static final String
getPK1primitive_
public static final String
getOid_
public static final String
getOidString_
public static final String
getOidClone_
public static final String
getOid1_
public static final String
getOid1primitive_
public static final String
getOid1String_
public static final String
getOid1Clone_
public static final String
getObjectId_
public static final String
convertObjectIdToPrimaryKey_
public static final String
convertPrimaryKeyToObjectId_
public static final String
convertPCToEJBObject_
public static final String
convertEJBObjectToPC_
public static final String
convertEJBLocalObjectToPC_
public static final String
jdoPersistenceManager_
public static final String
jdoPersistenceManagerClass_
public static final String
jdoGetPersistenceManager_
public static final String
jdoGetPersistenceManager0_
public static final String
jdoClosePersistenceManager_
public static final String
jdoReleasePersistenceManager_
public static final String
jdoReleasePersistenceManager0_
public static final String
jdoArrayCopy_
public static final String
jdoCleanAllRefs_
public static final String
returnKey_
public static final String
returnOid_
public static final String
helperComments_
public static final String
helperVariables_
public static final String
getHelperInstance_
public static final String
getPCClass_
public static final String
getContainer_
public static final String
assertInstanceOfRemoteInterfaceImpl_
public static final String
assertPKNotNull_
public static final String
assertPKFieldNotNull_
public static final String
assertOidNotNull_
public static final String
afterCompletion_
public static final String
ejb__flush_
public static final String
ejb__refresh_
public static final String
ejb__remove_
public static final String
signature_
public static final String
signatureDelimiter_
public static Properties
helpers
public static MessageFormat
hcomformatter
public static MessageFormat
privatetransientvformatter
public static MessageFormat
privatestaticfinalvformatter
public static MessageFormat
publicstaticfinalvformatter
public static MessageFormat
finderselectorstaticvformatter
public static MessageFormat
finderselectorstaticfinalvformatter
public static MessageFormat
hvformatter
public static MessageFormat
giformatter
public static MessageFormat
goidformatter
public static MessageFormat
intxformatter
public static MessageFormat
jdolookuppmfformatter
public static MessageFormat
jdoarraycopyformatter
public static MessageFormat
finderselectorformatter
public static MessageFormat
queryexecformatter
public static MessageFormat
aggqueryexecformatter
public static MessageFormat
queryexecparamconvformatter
public static MessageFormat
queryexecparamconvargumentformatter
public static MessageFormat
aggqueryexecparamconvformatter
public static MessageFormat
multifinderformatter
public static MessageFormat
multifinderenumerationformatter
public static MessageFormat
singlefinderformatter
public static MessageFormat
pkcformatter
public static MessageFormat
oidcformatter
public static MessageFormat
npkformatter
public static MessageFormat
noidformatter
public static MessageFormat
pkformatter
public static MessageFormat
oidformatter
public static MessageFormat
oidstringformatter
public static MessageFormat
pkcloneformatter
public static MessageFormat
oidcloneformatter
public static MessageFormat
pk1formatter
public static MessageFormat
oid1formatter
public static MessageFormat
pk1pformatter
public static MessageFormat
oid1pformatter
public static MessageFormat
oid1stringformatter
public static MessageFormat
pk1cloneformatter
public static MessageFormat
oid1cloneformatter
public static MessageFormat
assertpkfieldformatter
public static MessageFormat
pcclassgetterformatter
public static String
cmpImplCommentsTemplate
public static String
privateStaticVariablesTemplate
public static String
otherVariablesTemplate
public static String
jdoGetJdoInstanceClassTemplate
public static String
assertPersistenceManagerIsNullTemplate
public static String
assertInstanceOfRemoteInterfaceImplTemplate
public static String
getHelperInstanceTemplate
public static String
catchClauseTemplate
public static String
signatureTemplate
public static String
assertPKNotNullTemplate
public static String
assertOidNotNullTemplate
public static String[]
importsArray
public static String[]
interfacesArray
public static String[]
helperImportsArray
public static String[]
commonPublicMethodsArray
public static String[]
otherPublicMethodsArray
public static String[]
commonPrivateMethodsArray
public static String[]
ejbFindByPrimaryKeyBody
public static String[]
afterCompletionBody
public static String[]
jdoGetPersistenceManagerBody
public static String[]
jdoGetPersistenceManager0Body
public static String[]
assertPersistenceManagerIsNullBody
public static String[]
jdoClosePersistenceManagerBody
public static String[]
jdoReleasePersistenceManagerBody
public static String[]
jdoReleasePersistenceManager0Body
public static String[]
setEntityContextBody
public static String[]
getContainerBody
Constructors Summary
CMPTemplateFormatter()
Constructs a new CMPTemplateFormatter instance.


              
     
    
Methods Summary
private static voidinitFormatters()
Initializes MessageFormats for code generation.

        // JDOHelper comments have the concrete impl name.
        hcomformatter = new MessageFormat(helpers.getProperty(helperComments_));

        // variables
        privatetransientvformatter = new MessageFormat(helpers.getProperty(privateTransientVariables_));
        privatestaticfinalvformatter = new MessageFormat(helpers.getProperty(privateStaticFinalVariables_));
        publicstaticfinalvformatter = new MessageFormat(helpers.getProperty(publicStaticFinalVariables_));
        finderselectorstaticvformatter = new MessageFormat(helpers.getProperty(finderSelectorStaticVariables_));
        finderselectorstaticfinalvformatter = new MessageFormat(helpers.getProperty(finderSelectorStaticFinalVariables_));
        hvformatter = new MessageFormat(helpers.getProperty(helperVariables_));

        // methods
        giformatter = new MessageFormat(helpers.getProperty(getInstance_));
        goidformatter = new MessageFormat(helpers.getProperty(getObjectId_));
        intxformatter = new MessageFormat(helpers.getProperty(assertInTransaction_));
        jdolookuppmfformatter = new MessageFormat(helpers.getProperty(jdoLookupPersistenceManagerFactory_));
        jdoarraycopyformatter = new MessageFormat(helpers.getProperty(jdoArrayCopy_));

        // finder/selector methods
        finderselectorformatter = new MessageFormat(helpers.getProperty(ejbFinderSelectorBody_));
        queryexecparamconvformatter = new MessageFormat(helpers.getProperty(ejbQueryExecutionParamConvBody_));
        queryexecparamconvargumentformatter = new MessageFormat(helpers.getProperty(ejbQueryExecutionParamConvBodyArgument_));
        queryexecformatter = new MessageFormat(helpers.getProperty(ejbQueryExecutionBody_));
        aggqueryexecformatter = new MessageFormat(helpers.getProperty(ejbAggregateQueryExecutionBody_));
        aggqueryexecparamconvformatter = new MessageFormat(helpers.getProperty(ejbAggregateQueryExecutionParamConvBody_));
        multifinderformatter = new MessageFormat(helpers.getProperty(ejbMultiFinderBody_));
        multifinderenumerationformatter = new MessageFormat(helpers.getProperty(ejbMultiFinderBodyEnumeration_));
        singlefinderformatter = new MessageFormat(helpers.getProperty(ejbSingleFinderBody_));

        // PK and Oid handling
        pkcformatter = new MessageFormat(helpers.getProperty(castKey_));
        oidcformatter = new MessageFormat(helpers.getProperty(castOid_));
        npkformatter = new MessageFormat(helpers.getProperty(newPK_));
        noidformatter = new MessageFormat(helpers.getProperty(newOid_));
        pk1formatter = new MessageFormat(helpers.getProperty(getPK1_));
        pk1cloneformatter = new MessageFormat(helpers.getProperty(getPK1Clone_));
        oid1formatter = new MessageFormat(helpers.getProperty(getOid1_));
        pk1pformatter = new MessageFormat(helpers.getProperty(getPK1primitive_));
        oid1pformatter = new MessageFormat(helpers.getProperty(getOid1primitive_));
        oid1stringformatter = new MessageFormat(helpers.getProperty(getOid1String_));
        oid1cloneformatter = new MessageFormat(helpers.getProperty(getOid1Clone_));
        pkformatter = new MessageFormat(helpers.getProperty(getPK_));
        pkcloneformatter = new MessageFormat(helpers.getProperty(getPKClone_));
        oidformatter = new MessageFormat(helpers.getProperty(getOid_));
        oidstringformatter = new MessageFormat(helpers.getProperty(getOidString_));
        oidcloneformatter = new MessageFormat(helpers.getProperty(getOidClone_));

        assertpkfieldformatter = new MessageFormat(helpers.getProperty(assertPKFieldNotNull_));

        // Other JDOHelper methods.
        pcclassgetterformatter = new MessageFormat(helpers.getProperty(getPCClass_));

    
static synchronized voidinitHelpers()
Initializes templates for code generation.

        if (helpers == null) {
            helpers = new Properties();
            loadProperties(helpers, templateFile);
            initFormatters();
            initTemplates();
        }
    
private static voidinitTemplates()
Initializes standard templates for code generation.

        cmpImplCommentsTemplate = helpers.getProperty(cmpImplComments_);
        privateStaticVariablesTemplate = helpers.getProperty(privateStaticVariables_);
        otherVariablesTemplate = helpers.getProperty(otherVariables_);
        jdoGetJdoInstanceClassTemplate = helpers.getProperty(jdoGetJdoInstanceClass_);
        assertPersistenceManagerIsNullTemplate = helpers.getProperty(
            assertPersistenceManagerIsNullCall_);
        assertInstanceOfRemoteInterfaceImplTemplate = helpers.getProperty(
            assertInstanceOfRemoteInterfaceImpl_);
        getHelperInstanceTemplate = helpers.getProperty(getHelperInstance_);
        catchClauseTemplate = helpers.getProperty(catchClause_);
        signatureTemplate = helpers.getProperty(signature_);
        assertPKNotNullTemplate = helpers.getProperty(assertPKNotNull_);
        assertOidNotNullTemplate = helpers.getProperty(assertOidNotNull_);

        importsArray = tokenize(imports_);
        interfacesArray = tokenize(interfaces_);
        helperImportsArray = tokenize(helperImports_);
        commonPublicMethodsArray = tokenize(commonPublicMethods_);
        otherPublicMethodsArray = tokenize(otherPublicMethods_);
        commonPrivateMethodsArray = tokenize(commonPrivateMethods_);

        ejbFindByPrimaryKeyBody = getBodyAsStrings(helpers.getProperty(ejbFindByPrimaryKey_));
        afterCompletionBody = getBodyAsStrings(helpers.getProperty(afterCompletion_));
        jdoGetPersistenceManagerBody = getBodyAsStrings(helpers.getProperty(jdoGetPersistenceManager_));
        jdoGetPersistenceManager0Body = getBodyAsStrings(helpers.getProperty(jdoGetPersistenceManager0_));
        jdoClosePersistenceManagerBody = getBodyAsStrings(helpers.getProperty(jdoClosePersistenceManager_));
        jdoReleasePersistenceManagerBody = getBodyAsStrings(helpers.getProperty(jdoReleasePersistenceManager_));
        jdoReleasePersistenceManager0Body = getBodyAsStrings(helpers.getProperty(jdoReleasePersistenceManager0_));
        setEntityContextBody = getBodyAsStrings(helpers.getProperty(setEntityContext_));
        getContainerBody = getBodyAsStrings(helpers.getProperty(getContainer_));
        assertPersistenceManagerIsNullBody = getBodyAsStrings(helpers.getProperty(assertPersistenceManagerIsNull_));
    
static synchronized voidloadProperties(java.util.Properties helpers, java.lang.String templateFile)
Loads Properties object from the specified template file.


        BufferedInputStream bin = null;
        try {
            final ClassLoader loader = CMPTemplateFormatter.class.getClassLoader();
            InputStream in = (InputStream)java.security.AccessController.doPrivileged(
                new java.security.PrivilegedAction() {
                    public Object run() {
                        if (loader != null) {
                            return loader.getResourceAsStream(templateFile);
                        } else {
                            return ClassLoader.getSystemResourceAsStream(templateFile);
                        }
                    }
                }
            );

            bin = new BufferedInputStream(in);
            helpers.load(bin);
        } finally {
            try {
                bin.close();
            } catch (Exception e) {
                // no action
            }
        }
    
static java.lang.String[]tokenize(java.lang.String template)

        StringTokenizer st = new StringTokenizer(helpers.getProperty(template), delim_);
        String[] rc = new String[st.countTokens()];

        int i = 0;
        while (st.hasMoreElements()) {
            rc[i++] =  st.nextToken();
        }

        return rc;