## ============================================================================ ## Filename : BusinessObjectTemplate.vm ## Note(s) : This template is used to generate a BusinessObject Java class. ## ## Note: The generated code is dependent on the ThinkUI framework. ## Please refer to the SQL Client documentation for details. ## ## Copyright (c) 2007 ThinkUI Software Inc. All rights reserved. ## ============================================================================ ## ## **************************************************************************** ## The following variables are available in this template. For more ## information on any of the following variable, please refer to the user guide. ## **************************************************************************** ## $projectName ## $authorName ## $headerText ## $className ## $packageName ## $subPackageName ## $prjPkgName ## $prjClassPrefix ## $date ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import thinkui.bo.BusinessContext; import thinkui.bo.BusinessObject; import thinkui.db.jdbc.JDBCDataObjectManager; /** * Implements the business object for the $prjClassPrefix application. */ public class ${className} implements BusinessObject { private BusinessContext businessContext; private JDBCDataObjectManager dataObjectManager; /** * ${className} constructor. */ public ${className}(BusinessContext businessContext) { this.businessContext = businessContext; } public final BusinessContext getBusinessContext() { return businessContext; } public final void setBusinessContext(BusinessContext businessContext) { this.businessContext = businessContext; } /** * Get the DataObjectManager configured for this business object. * The DataObjectManager will use the the specified database connection name. * If the connection name is null, the default database connection specified * in the configuration of the command context. * @return the DataObjectManager configured for this business object. */ public final JDBCDataObjectManager getDataObjectManager() throws Exception { if (dataObjectManager == null) { BusinessContext ctx = getBusinessContext(); JDBCConnectionManager connMgr = new JDBCConnectionManager(ctx.getConfig()); String connectionName = null; // Install the same logger as the one configured in the business context. dataObjectManager = connMgr.getDataObjectManager(connectionName); dataObjectManager.getDatabaseContext().setLogger(ctx.getLogger()); ctx.getLogger().debug( "${className}.getDataObjectManager() - auto commit is " + dataObjectManager.isAutoCommit()); } return dataObjectManager; } /** * Sets the DataObjectManager configured for this business object. */ public final void setDataObjectManager(JDBCDataObjectManager dataObjectManager) { this.dataObjectManager = dataObjectManager; } public final void remove() { if (dataObjectManager != null) { JDBCUtils.close(dataObjectManager); dataObjectManager = null; } } }