dims 01/09/08 04:46:00 Modified: . Tag: cocoon_20_branch build.xml src/org/apache/cocoon Tag: cocoon_20_branch Cocoon.java src/org/apache/cocoon/transformation Tag: cocoon_20_branch I18nTransformer.java xdocs Tag: cocoon_20_branch i18n-transformer.xml Log: - Patch for I18nTransformer from Enke Michael <[EMAIL PROTECTED]> - Patch for Copy sample java classes for Parent Component Manager from "Leo Sutic" <[EMAIL PROTECTED]> - Patch for logging active requests from Marcus Crafter <[EMAIL PROTECTED]> Revision Changes Path No revision No revision 1.8.2.34 +1 -0 xml-cocoon2/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/build.xml,v retrieving revision 1.8.2.33 retrieving revision 1.8.2.34 diff -u -r1.8.2.33 -r1.8.2.34 --- build.xml 2001/09/06 20:56:32 1.8.2.33 +++ build.xml 2001/09/08 11:46:00 1.8.2.34 @@ -426,6 +426,7 @@ <mkdir dir="${build.war}/WEB-INF/classes"/> <copy todir="${build.war}/WEB-INF/classes" filtering="off"> <fileset dir="${build.dest}" includes="org/apache/cocoon/samples/**"/> + <fileset dir="${build.src}" includes="org/apache/cocoon/samples/**"/> </copy> <copy todir="${build.war}" filtering="on"> No revision No revision 1.9.2.17 +104 -64 xml-cocoon2/src/org/apache/cocoon/Cocoon.java Index: Cocoon.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/Cocoon.java,v retrieving revision 1.9.2.16 retrieving revision 1.9.2.17 diff -u -r1.9.2.16 -r1.9.2.17 --- Cocoon.java 2001/09/05 22:18:10 1.9.2.16 +++ Cocoon.java 2001/09/08 11:46:00 1.9.2.17 @@ -57,7 +57,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a> (Apache Software Foundation, Exoffice Technologies) * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a> * @author <a href="mailto:[EMAIL PROTECTED]">Leo Sutic</a> - * @version CVS $Revision: 1.9.2.16 $ $Date: 2001/09/05 22:18:10 $ + * @version CVS $Revision: 1.9.2.17 $ $Date: 2001/09/08 11:46:00 $ */ public class Cocoon extends AbstractLoggable @@ -109,6 +109,12 @@ /** flag for disposed or not */ private boolean disposed = false; + /** active request count */ + private static int activeRequestCount = 0; + + /** maximum request count */ + private static int maxRequestCount = 0; + /** Create a new <code>Cocoon</code> instance. */ public Cocoon() throws ConfigurationException { // Set the system properties needed by Xalan2. @@ -389,71 +395,71 @@ protected void debug(Environment environment, StreamPipeline pipeline, EventPipeline eventPipeline) { - if (this.getLogger().isDebugEnabled() == true) { - String lineSeparator = System.getProperty("line.separator"); - Map objectModel = environment.getObjectModel(); - Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT); - Session session = request.getSession(false); - StringBuffer msg = new StringBuffer(); - msg.append("DEBUGGING INFORMATION:").append(lineSeparator); - if (pipeline != null && eventPipeline != null) { - msg.append("INTERNAL "); + String lineSeparator = System.getProperty("line.separator"); + Map objectModel = environment.getObjectModel(); + Request request = (Request) objectModel.get(Constants.REQUEST_OBJECT); + Session session = request.getSession(false); + StringBuffer msg = new StringBuffer(); + msg.append("DEBUGGING INFORMATION:").append(lineSeparator); + if (pipeline != null && eventPipeline != null) { + msg.append("INTERNAL "); + } + msg.append("REQUEST: ").append(request.getRequestURI()).append(lineSeparator).append(lineSeparator); + msg.append("CONTEXT PATH: ").append(request.getContextPath()).append(lineSeparator); + msg.append("SERVLET PATH: ").append(request.getServletPath()).append(lineSeparator); + msg.append("PATH INFO: ").append(request.getPathInfo()).append(lineSeparator).append(lineSeparator); + + msg.append("REMOTE HOST: ").append(request.getRemoteHost()).append(lineSeparator); + msg.append("REMOTE ADDRESS: ").append(request.getRemoteAddr()).append(lineSeparator); + msg.append("REMOTE USER: ").append(request.getRemoteUser()).append(lineSeparator); + msg.append("REQUEST SESSION ID: ").append(request.getRequestedSessionId()).append(lineSeparator); + msg.append("REQUEST PREFERRED LOCALE: ").append(request.getLocale().toString()).append(lineSeparator); + msg.append("SERVER HOST: ").append(request.getServerName()).append(lineSeparator); + msg.append("SERVER PORT: ").append(request.getServerPort()).append(lineSeparator).append(lineSeparator); + + msg.append("METHOD: ").append(request.getMethod()).append(lineSeparator); + msg.append("CONTENT LENGTH: ").append(request.getContentLength()).append(lineSeparator); + msg.append("PROTOCOL: ").append(request.getProtocol()).append(lineSeparator); + msg.append("SCHEME: ").append(request.getScheme()).append(lineSeparator); + msg.append("AUTH TYPE: ").append(request.getAuthType()).append(lineSeparator).append(lineSeparator); + msg.append("CURRENT ACTIVE REQUESTS: ").append(activeRequestCount).append(lineSeparator); + msg.append("MAXIMUM ACTIVE REQUESTS: ").append(maxRequestCount).append(lineSeparator).append(lineSeparator); + + // log all of the request parameters + Enumeration e = request.getParameterNames(); + + msg.append("REQUEST PARAMETERS:").append(lineSeparator).append(lineSeparator); + + while (e.hasMoreElements()) { + String p = (String) e.nextElement(); + + msg.append("PARAM: '").append(p).append("' ") + .append("VALUES: '"); + String[] params = request.getParameterValues(p); + for (int i = 0; i < params.length; i++) { + msg.append("["+params[i]+"]"); + if (i != params.length-1) + msg.append(", "); } - msg.append("REQUEST: ").append(request.getRequestURI()).append(lineSeparator).append(lineSeparator); - msg.append("CONTEXT PATH: ").append(request.getContextPath()).append(lineSeparator); - msg.append("SERVLET PATH: ").append(request.getServletPath()).append(lineSeparator); - msg.append("PATH INFO: ").append(request.getPathInfo()).append(lineSeparator).append(lineSeparator); - - msg.append("REMOTE HOST: ").append(request.getRemoteHost()).append(lineSeparator); - msg.append("REMOTE ADDRESS: ").append(request.getRemoteAddr()).append(lineSeparator); - msg.append("REMOTE USER: ").append(request.getRemoteUser()).append(lineSeparator); - msg.append("REQUEST SESSION ID: ").append(request.getRequestedSessionId()).append(lineSeparator); - msg.append("REQUEST PREFERRED LOCALE: ").append(request.getLocale().toString()).append(lineSeparator); - msg.append("SERVER HOST: ").append(request.getServerName()).append(lineSeparator); - msg.append("SERVER PORT: ").append(request.getServerPort()).append(lineSeparator).append(lineSeparator); - - msg.append("METHOD: ").append(request.getMethod()).append(lineSeparator); - msg.append("CONTENT LENGTH: ").append(request.getContentLength()).append(lineSeparator); - msg.append("PROTOCOL: ").append(request.getProtocol()).append(lineSeparator); - msg.append("SCHEME: ").append(request.getScheme()).append(lineSeparator); - msg.append("AUTH TYPE: ").append(request.getAuthType()).append(lineSeparator).append(lineSeparator); + + msg.append("'").append(lineSeparator); + } - // log all of the request parameters - Enumeration e = request.getParameterNames(); + msg.append(lineSeparator).append("SESSION ATTRIBUTES:").append(lineSeparator).append(lineSeparator); - msg.append("REQUEST PARAMETERS:").append(lineSeparator).append(lineSeparator); + // log all of the session attributes + if (session != null) { + e = session.getAttributeNames(); while (e.hasMoreElements()) { String p = (String) e.nextElement(); - - msg.append("PARAM: '").append(p).append("' ") - .append("VALUES: '"); - String[] params = request.getParameterValues(p); - for (int i = 0; i < params.length; i++) { - msg.append("["+params[i]+"]"); - if (i != params.length-1) - msg.append(", "); - } - - msg.append("'").append(lineSeparator); - } - - msg.append(lineSeparator).append("SESSION ATTRIBUTES:").append(lineSeparator).append(lineSeparator); - // log all of the session attributes - if (session != null) { - e = session.getAttributeNames(); - - while (e.hasMoreElements()) { - String p = (String) e.nextElement(); - - msg.append("PARAM: '").append(p).append("' ") - .append("VALUE: '").append(session.getAttribute(p)).append("'").append(lineSeparator); - } + msg.append("PARAM: '").append(p).append("' ") + .append("VALUE: '").append(session.getAttribute(p)).append("'").append(lineSeparator); } - - getLogger().debug(msg.toString()); } + + getLogger().debug(msg.toString()); } /** @@ -462,9 +468,18 @@ public boolean process(Environment environment) throws Exception { if (disposed) throw new IllegalStateException("You cannot process a Disposed Cocoon engine."); - this.debug(environment, null, null); - return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName, - this.checkSitemapReload, this.reloadSitemapAsynchron); + + try { + if (this.getLogger().isDebugEnabled()) { + incRequestCount(); + this.debug(environment, null, null); + } + return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName, this.checkSitemapReload, this.reloadSitemapAsynchron); + } finally { + if (this.getLogger().isDebugEnabled()) { + decRequestCount(); + } + } } /** @@ -474,10 +489,18 @@ public boolean process(Environment environment, StreamPipeline pipeline, EventPipeline eventPipeline) throws Exception { if (disposed) throw new IllegalStateException("You cannot process a Disposed Cocoon engine."); - this.debug(environment, pipeline, eventPipeline); - return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName, - this.checkSitemapReload, this.reloadSitemapAsynchron, - pipeline, eventPipeline); + + try { + if (this.getLogger().isDebugEnabled()) { + incRequestCount(); + this.debug(environment, pipeline, eventPipeline); + } + return this.sitemapManager.invoke(this.componentManager, environment, "", this.sitemapFileName, this.checkSitemapReload, this.reloadSitemapAsynchron, pipeline, eventPipeline); + } finally { + if (this.getLogger().isDebugEnabled()) { + decRequestCount(); + } + } } /** @@ -544,4 +567,21 @@ if (sourceHandler != null) this.componentManager.release((Component) sourceHandler); } } + + /** + * Increment active request count for incoming requests, and save this + * result if it's the maximum. + */ + private static synchronized void incRequestCount() { + if (++activeRequestCount > maxRequestCount) + maxRequestCount = activeRequestCount; + } + + /** + * Decrement active request count. + */ + private static synchronized void decRequestCount() { + --activeRequestCount; + } + } No revision No revision 1.8.2.9 +29 -1 xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java Index: I18nTransformer.java =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/transformation/I18nTransformer.java,v retrieving revision 1.8.2.8 retrieving revision 1.8.2.9 diff -u -r1.8.2.8 -r1.8.2.9 --- I18nTransformer.java 2001/09/05 22:18:15 1.8.2.8 +++ I18nTransformer.java 2001/09/08 11:46:00 1.8.2.9 @@ -245,7 +245,8 @@ /** * <code>sub-type</code> attribute is used with <code>i18:number</code> to - * indicate a sub-type: <code>currency</code> or <code>percent</code>. + * indicate a sub-type: <code>currency</code>, <code>int-currency</code> + * or <code>percent</code>. */ public static final String I18N_SUB_TYPE_ATTRIBUTE = "sub-type"; @@ -1051,6 +1052,8 @@ // src format DecimalFormat from_fmt = (DecimalFormat)NumberFormat.getInstance(srcLoc); + int int_currency = 0; + // src-pattern overwrites locale format if (srcPattern != null) { from_fmt.applyPattern(srcPattern); @@ -1058,10 +1061,28 @@ // to format DecimalFormat to_fmt = null; + char dec = from_fmt.getDecimalFormatSymbols().getDecimalSeparator(); + int decAt = 0; + boolean appendDec = false; if (subType == null) { to_fmt = (DecimalFormat)NumberFormat.getInstance(loc); + to_fmt.setMaximumFractionDigits(309); + for(int i=value.length()-1; + i>=0 && value.charAt(i)!=dec;i--,decAt++); + if(decAt < value.length()) to_fmt.setMinimumFractionDigits(decAt); + decAt = 0; + for(int i = 0; i < value.length() && value.charAt(i) != dec; i++) { + if(Character.isDigit(value.charAt(i))) decAt++; + } + to_fmt.setMinimumIntegerDigits(decAt); + if(value.charAt(value.length()-1) == dec) appendDec = true; } else if (subType.equals("currency")) { to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(loc); + } else if (subType.equals("int-currency")) { + to_fmt = (DecimalFormat)NumberFormat.getCurrencyInstance(loc); + int_currency = 1; + for(int i=0;i<to_fmt.getMaximumFractionDigits();i++) + int_currency *= 10; } else if (subType.equals("percent")) { to_fmt = (DecimalFormat)NumberFormat.getPercentInstance(loc); } @@ -1076,6 +1097,12 @@ } else { try { numberValue = from_fmt.parse(value); + if(int_currency > 0) + numberValue = new Double(numberValue.doubleValue()/ + int_currency); + else { + + } } catch (ParseException pe) { throw new SAXException(this.getClass().getName() + "i18n:number - parsing error.", pe); @@ -1084,6 +1111,7 @@ // we have all necessary data here: do formatting. String result = to_fmt.format(numberValue); + if(appendDec) result = result + dec; debug("i18n:number result: " + result); return result; } No revision No revision 1.1.2.7 +1 -0 xml-cocoon2/xdocs/i18n-transformer.xml Index: i18n-transformer.xml =================================================================== RCS file: /home/cvs/xml-cocoon2/xdocs/i18n-transformer.xml,v retrieving revision 1.1.2.6 retrieving revision 1.1.2.7 diff -u -r1.1.2.6 -r1.1.2.7 --- i18n-transformer.xml 2001/09/05 22:18:18 1.1.2.6 +++ i18n-transformer.xml 2001/09/08 11:46:00 1.1.2.7 @@ -189,6 +189,7 @@ </p> <ul> <li><code><![CDATA[<i18n:number sub-type="currency" value="1703.74" />]]></code> will result in localized presentation of the <code>value</code> - $1,703.74 for US locale.</li> + <li><code><![CDATA[<i18n:number sub-type="int-currency" value="170374" />]]></code> will result in localized presentation of the <code>value</code> - $1,703.74 for US locale, 170374 for a currency without subunit.</li> <li><code><![CDATA[<i18n:number sub-type="percent" value="1.2" />]]></code> will result in localized percent <code>value</code> - %120 for most of the locales.</li> </ul> <p> ---------------------------------------------------------------------- In case of troubles, e-mail: [EMAIL PROTECTED] To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]