r2271 - trunk/topia-persistence/src/main/java/org/nuiton/topia/generator
Author: fdesbois Date: 2011-05-04 12:57:35 +0200 (Wed, 04 May 2011) New Revision: 2271 Url: http://nuiton.org/repositories/revision/topia/2271 Log: #1466 : remove noLog flag. Logs will no longer been generated. Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java Modified: trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java =================================================================== --- trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2011-04-28 12:47:32 UTC (rev 2270) +++ trunk/topia-persistence/src/main/java/org/nuiton/topia/generator/ServiceTransformer.java 2011-05-04 10:57:35 UTC (rev 2271) @@ -195,14 +195,6 @@ protected String exceptionName; - /** - * flag to not use any logger code inside service method, globally set - * for all the incoming model. - * - * @since 2.5 - */ - protected boolean noLog; - private static final String OP_NAME_BEGIN_TRANSACTION = "beginTransaction"; private static final String OP_NAME_COMMIT_TRANSACTION = "commitTransaction"; @@ -222,7 +214,6 @@ exceptionName = TopiaGeneratorUtil.getExceptionClassTagValue(model); modelName = model.getName(); - noLog = isNoLog(null, model); } @Override @@ -233,14 +224,12 @@ // global transaction needed (if set to false then never use transaction) boolean needTransaction = isTransactionNeeded(input); - boolean noLog = this.noLog || isNoLog(input,null); ObjectModelInterface serviceContract = createServiceContract(input); createServiceAbstract(input, serviceContract, - needTransaction, - noLog); + needTransaction); } /** @@ -370,12 +359,10 @@ * @param source interface from model * @param serviceContract to implement * @param needTransaction flag to know if service globally use transaction - * @param noLog a flag to not add any log code in body of methods */ protected void createServiceAbstract(ObjectModelInterface source, ObjectModelInterface serviceContract, - boolean needTransaction, - boolean noLog) { + boolean needTransaction) { ObjectModelClass serviceAbstract = createAbstractClass( getServiceAbstractClassName(serviceContract.getName()), @@ -386,23 +373,7 @@ addImport(serviceAbstract, TopiaContext.class); } addImport(serviceAbstract, I18n.class); -// addImport(serviceAbstract, ArrayList.class); - - if (!noLog) { - addImport(serviceAbstract, DurationFormatUtils.class); - // Add Logger attribute - addAttribute(serviceAbstract, "log", - Log.class, - "LogFactory.getLog(" + source.getName() + ".class)", - ObjectModelModifier.PRIVATE, - ObjectModelModifier.STATIC, - ObjectModelModifier.FINAL); - - addImport(serviceAbstract, Log.class); - addImport(serviceAbstract, LogFactory.class); - } - // Implements contract interface addInterface(serviceAbstract, serviceContract.getQualifiedName()); @@ -454,8 +425,7 @@ executeOperation, operation, source.getName(), - needTransaction, - noLog + needTransaction ); } } @@ -522,7 +492,6 @@ * @param source ObjectModelOperation from model * @param serviceContractName where the signature method is defined * @param needTransaction flag to know if service globally use transaction - * @param noLog a flag to not add any log inside method * @see #isErrorArgsNeeded(ObjectModelOperation) * @see #isTransactionNeeded(ObjectModelInterface) */ @@ -531,8 +500,7 @@ ObjectModelOperation abstOp, ObjectModelOperation source, String serviceContractName, - boolean needTransaction, - boolean noLog) { + boolean needTransaction) { // boolean to specify if the method need a transaction or not // Default set to true but can be override by a tagvalue on the @@ -559,13 +527,6 @@ for (ObjectModelParameter param : source.getParameters()) { String paramName = param.getName(); addParameter(implOp, param.getType(), paramName); - if (!noLog) { - // Prepare Log - toStringAppend += - "\n\t\t\t.append(\"" + separatorLog + paramName + " = \")" + - ".append(" + paramName + ")"; - separatorLog = " _ "; - } } // Use buffer for operation body @@ -629,43 +590,11 @@ } String implName = StringUtils.capitalize(implOp.getName()); String first = modelName.substring(0, 1); - - if (!noLog) { - buffer.append("" - /*{ - long startTime = 0; - if (log.isDebugEnabled()) { - log.debug("<%=first%>:[ begin <%=implName%> ]"); - startTime = System.currentTimeMillis(); - } - if (log.isTraceEnabled()) { - String message = new StringBuilder("# ARGS >")<%=toStringAppend%>. - toString(); - log.trace(message); - } - }*/); - } - buffer.append("" /*{ <%=abstReturnType%><%=abstName%>(<%=abstParams%>);}*/); - if (!noLog) { - - buffer.append("" - /*{ - - if (log.isDebugEnabled()) { - long stopTime = System.currentTimeMillis(); - Runtime runtime = Runtime.getRuntime(); - long mem = (runtime.totalMemory() - runtime.freeMemory()) / 1048576; - log.debug("<%=first%>:[ end <%=implName%> ] Time = " + - DurationFormatUtils.formatDurationHMS( - stopTime - startTime) + " _ Memory = " + mem + " Mo"); - }}*/ - ); - } if (needTransaction && isCommit(source, model)) { // add the commit instruction @@ -758,29 +687,6 @@ } /** - * boolean to specify if inside the method body we should add log informations. - * - * @param anInterface model element where the tagvalue is set - * @param model model where to tagvalue can be also set - * @return {@code true} if no log will be generated insde body's method - * @see TopiaTagValues#TAG_NO_LOG_IN_SERVICE - */ - protected boolean isNoLog(ObjectModelInterface anInterface, - ObjectModel model) { - boolean noLog = false; - - String tagValue = TopiaGeneratorUtil.getNoLogInServiceTagValue( - anInterface, - model - ); - - if (tagValue != null) { - noLog = Boolean.parseBoolean(tagValue); - } - return noLog; - } - - /** * boolean to specify if method needs a commit after the executeXXX code invoked. * * @param op model element where the tagvalue is set
participants (1)
-
fdesbois@users.nuiton.org