You can subscribe to this list here.
| 2003 |
Jan
|
Feb
(14) |
Mar
(107) |
Apr
(211) |
May
(93) |
Jun
(158) |
Jul
(159) |
Aug
(368) |
Sep
(188) |
Oct
(151) |
Nov
(115) |
Dec
(98) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
(25) |
Feb
|
Mar
(33) |
Apr
(28) |
May
(116) |
Jun
(2) |
Jul
(117) |
Aug
(19) |
Sep
(9) |
Oct
(2) |
Nov
|
Dec
(4) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(9) |
Dec
|
| 2006 |
Jan
|
Feb
|
Mar
(22) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
(6) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(267) |
Sep
|
Oct
|
Nov
(6) |
Dec
(512) |
| 2008 |
Jan
(187) |
Feb
|
Mar
|
Apr
|
May
|
Jun
(3) |
Jul
(6) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
|
| 2012 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Bruce M. <br...@mc...> - 2003-07-16 01:42:43
|
You want me to make this change? Its not problem - I will do it right away. On Tuesday 15 July 2003 07:07 pm, Leech, Jonathan wrote: > That sounds like a good change to make. > > -Jonathan > > -----Original Message----- > From: Bruce McDonald [mailto:br...@mc...] > Sent: Tuesday, July 15, 2003 4:54 PM > To: bab...@li... > Subject: [Babeldoc-devel] Question about SqlQueryPipelineStage... > > > Jonathan, > > I was looking at the above mentioned pipelinestage and was wondering if was > not better if we output XML that looks like: > > <query> > <row> > <col number="1" name="act_avg_bal">3949.29</col> > <col number="2" name="act_cur_bal">839.23</col> > <col number="3" name="some_thing_else">FJDH</col> > </row> > ... > > </query> > > as opposed to placing the name of the column from the metadata into the XML > as > the element name of the column. The primary reason is that then we can > write > a DTD or a Schema for it. It will also make XSLT a bit easier when the > Tables change. > > regards, > Bruce. > > > ------------------------------------------------------- > This SF.net email is sponsored by: VM Ware > With VMware you can run multiple operating systems on a single machine. > WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the > same time. Free trial click here: http://www.vmware.com/wl/offer/345/0 > _______________________________________________ > Babeldoc-devel mailing list > Bab...@li... > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel |
|
From: Leech, J. <jl...@vi...> - 2003-07-15 23:43:22
|
I've got a couple of things I want to do to DomifyPipelineStage... 1) The first is the DTD cache I mentioned before. I would like to use a config option to control whether DTD's are cached, but its more a global option than a pipeline-specific option... Is looking for it under domify/config the right thing to do, or is there another preferred method? 2) It stores the parsed XML in the document as an attribute, which when trying to journal the document caused me to hit java bug 4152790 - StackOverFlowError serializing / deserializing a large graph of objects. I got to thinking, even if I could get past the java bug, does it make sense to journal the DOM representation? So I have implemented the DOM representation cache as a WeakHashMap in DomifyPipelineStage instead, and it seems to work. Any objections to commiting this? -Jonathan |
|
From: Leech, J. <jl...@vi...> - 2003-07-15 23:08:31
|
That sounds like a good change to make.
-Jonathan
-----Original Message-----
From: Bruce McDonald [mailto:br...@mc...]
Sent: Tuesday, July 15, 2003 4:54 PM
To: bab...@li...
Subject: [Babeldoc-devel] Question about SqlQueryPipelineStage...
Jonathan,
I was looking at the above mentioned pipelinestage and was wondering if was
not better if we output XML that looks like:
<query>
<row>
<col number="1" name="act_avg_bal">3949.29</col>
<col number="2" name="act_cur_bal">839.23</col>
<col number="3" name="some_thing_else">FJDH</col>
</row>
...
</query>
as opposed to placing the name of the column from the metadata into the XML
as
the element name of the column. The primary reason is that then we can
write
a DTD or a Schema for it. It will also make XSLT a bit easier when the
Tables change.
regards,
Bruce.
-------------------------------------------------------
This SF.net email is sponsored by: VM Ware
With VMware you can run multiple operating systems on a single machine.
WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
_______________________________________________
Babeldoc-devel mailing list
Bab...@li...
https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: Bruce M. <br...@mc...> - 2003-07-15 22:53:53
|
Jonathan,
I was looking at the above mentioned pipelinestage and was wondering if was
not better if we output XML that looks like:
<query>
<row>
<col number="1" name="act_avg_bal">3949.29</col>
<col number="2" name="act_cur_bal">839.23</col>
<col number="3" name="some_thing_else">FJDH</col>
</row>
...
</query>
as opposed to placing the name of the column from the metadata into the XML as
the element name of the column. The primary reason is that then we can write
a DTD or a Schema for it. It will also make XSLT a bit easier when the
Tables change.
regards,
Bruce.
|
|
From: Bruce M. <br...@mc...> - 2003-07-15 22:49:14
|
All, I added the header code to the HttpClientPipelineStage and the SqlQueryPipelineStage. Jonathan - I like it! regards, Bruce. |
|
From: <tr...@us...> - 2003-07-15 22:46:59
|
Update of /cvsroot/babeldoc/babeldoc/modules/web/src/com/babeldoc/web/pipeline/stage In directory sc8-pr-cvs1:/tmp/cvs-serv24833/web/src/com/babeldoc/web/pipeline/stage Modified Files: HttpClientPipelineStage.java Log Message: added the header and some small reformattings. Index: HttpClientPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/web/src/com/babeldoc/web/pipeline/stage/HttpClientPipelineStage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HttpClientPipelineStage.java 14 Jul 2003 20:49:47 -0000 1.1 --- HttpClientPipelineStage.java 15 Jul 2003 22:46:56 -0000 1.2 *************** *** 1,2 **** --- 1,67 ---- + /* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact ap...@ap.... + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + * Portions of this software are based upon public domain software + * originally written at the National Center for Supercomputing Applications, + * University of Illinois, Urbana-Champaign. + * ==================================================================== + * + * Babeldoc: The Universal Document Processor + * + * $Header$ + * $DateTime$ + * $Author$ + * + */ package com.babeldoc.web.pipeline.stage; *************** *** 5,29 **** // TODO: handle all http methods - import java.util.ArrayList; - import java.util.Collection; - - import java.io.*; - import java.net.*; - import org.apache.commons.httpclient.*; - import org.apache.commons.httpclient.methods.*; import com.babeldoc.core.I18n; import com.babeldoc.core.option.ConfigOption; - import com.babeldoc.core.option.IConfigInfo; import com.babeldoc.core.option.IConfigOptionType; ! import com.babeldoc.core.option.ComplexConfigOptionType; ! import com.babeldoc.core.pipeline.PipelineDocument; ! import com.babeldoc.core.pipeline.PipelineException; ! import com.babeldoc.core.pipeline.PipelineStage; ! import com.babeldoc.core.pipeline.PipelineStageInfo; ! import com.babeldoc.core.pipeline.PipelineStageResult; ! import com.babeldoc.core.NameValuePair; /** ! * Pipeline stage for http/https client * * @author Jonathan Leech --- 70,90 ---- // TODO: handle all http methods import com.babeldoc.core.I18n; + import com.babeldoc.core.NameValuePair; + import com.babeldoc.core.option.ComplexConfigOptionType; import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; ! import com.babeldoc.core.pipeline.*; ! import org.apache.commons.httpclient.HttpClient; ! import org.apache.commons.httpclient.HttpMethodBase; ! import org.apache.commons.httpclient.methods.GetMethod; ! import org.apache.commons.httpclient.methods.PostMethod; ! ! import java.io.ByteArrayInputStream; ! import java.util.ArrayList; ! import java.util.Collection; /** ! * Pipeline stage for http/https client * * @author Jonathan Leech *************** *** 47,56 **** /* the post parameters as name value pairs */ public final static String HTTP_POST_PARAMETERS = "parameters"; ! /** * Return this stages info */ public HttpClientPipelineStage() { ! super(new PipelineStageInfo() { public String getName() { return "HttpClient"; --- 108,117 ---- /* the post parameters as name value pairs */ public final static String HTTP_POST_PARAMETERS = "parameters"; ! /** * Return this stages info */ public HttpClientPipelineStage() { ! super(new PipelineStageInfo() { public String getName() { return "HttpClient"; *************** *** 65,69 **** // add specific options ! ComplexConfigOptionType ccot = new ComplexConfigOptionType((ConfigOption [])null); // no constant for this in IConfigOptionType options.add(new ConfigOption(HTTP_METHOD, IConfigOptionType.STRING, null, false, I18n.get("web.201"))); options.add(new ConfigOption(HTTP_URL, IConfigOptionType.URL, null, false, I18n.get("web.202"))); --- 126,130 ---- // add specific options ! ComplexConfigOptionType ccot = new ComplexConfigOptionType((ConfigOption[]) null); // no constant for this in IConfigOptionType options.add(new ConfigOption(HTTP_METHOD, IConfigOptionType.STRING, null, false, I18n.get("web.201"))); options.add(new ConfigOption(HTTP_URL, IConfigOptionType.URL, null, false, I18n.get("web.202"))); *************** *** 86,201 **** * @throws PipelineException */ ! public PipelineStageResult[] process() ! throws PipelineException ! { try { ! // get the document ! PipelineDocument document = this.getDocument(); ! ! // get all the options ! String method = getOptions(HTTP_METHOD); ! String url = getOptions(HTTP_URL); ! NameValuePair[] queryString = getOptionList(new String[]{HTTP_QUERY_STRING}); ! boolean followRedirects = "true".equalsIgnoreCase(getOptions(HTTP_FOLLOW_REDIRECTS)); ! boolean oneDotOne = "true".equalsIgnoreCase(getOptions(HTTP_1_1)); ! boolean strictMode = "true".equalsIgnoreCase(getOptions(HTTP_STRICT_MODE)); ! NameValuePair[] headers = getOptionList(new String[]{HTTP_HEADERS}); ! NameValuePair[] postParameters = getOptionList(new String[]{HTTP_POST_PARAMETERS}); ! ! // Create an instance of HttpClient. ! HttpClient client = new HttpClient(); ! ! // Choose the appropriate Http method ! HttpMethodBase httpMethod; ! if ("post".equalsIgnoreCase(method)) { ! httpMethod = new PostMethod(url); ! } ! else if ("get".equalsIgnoreCase(method)) { ! httpMethod = new GetMethod(url); ! } ! else if ("".equals(method) || (method == null)) { ! // default to GET if nothing is specified ! httpMethod = new GetMethod(url); ! } ! else { ! throw new PipelineException("Invalid method: " + method); ! } ! ! // Build the query string if applicable ! if ((queryString != null) && (queryString.length > 0)) { ! // set the query string from the parameters ! httpMethod.setQueryString(babeldocToHttpClient(queryString)); ! } ! ! // set the rest of the options ! httpMethod.setFollowRedirects(followRedirects); ! httpMethod.setHttp11(oneDotOne); // this might be changing the default for HttpClient-what is the default? ! httpMethod.setStrictMode(strictMode); ! ! // set the request headers if applicable ! if (headers != null) { ! for (int i = 0; i < headers.length; i++) { ! httpMethod.setRequestHeader(headers[i].getName(), headers[i].getValue()); ! } ! } ! ! if ("post".equalsIgnoreCase(method)) { ! // if post parameters are passed, use those as the body, else use the document ! if ((postParameters != null) && (postParameters.length > 0)) { ! ((PostMethod)httpMethod).setRequestBody(babeldocToHttpClient(postParameters)); ! } ! else { ! ByteArrayInputStream bais = new ByteArrayInputStream(document.getBytes()); ! ((PostMethod)httpMethod).setRequestBody(bais); ! } ! } ! ! // todo: do something with the status code - write it as an attribute, throw an exception ! // if its something other than OK, etc. ! int statusCode = client.executeMethod(httpMethod); ! ! // Read the response body. ! byte[] responseBody = httpMethod.getResponseBody(); ! // Release the connection. ! httpMethod.releaseConnection(); ! ! String[] results = new String[] {new String(responseBody)}; ! // todo: should this be the content type of the response? ! return super.processHelper("text/xml", results); ! } ! catch (Exception e) { ! throw new com.babeldoc.core.pipeline.PipelineException("HTTPWriter", e); } } ! /** * convert babeldoc NameValuePair[] to HttpClient NameValuePair **/ public static org.apache.commons.httpclient.NameValuePair[] babeldocToHttpClient( ! NameValuePair[] pairs ! ) ! { ! if (pairs == null) { ! return null; ! } ! org.apache.commons.httpclient.NameValuePair[] pairs2 = new org.apache.commons.httpclient.NameValuePair[pairs.length]; ! for (int i = 0; i < pairs.length; i++) { ! pairs2[i] = babeldocToHttpClient(pairs[i]); ! } ! return pairs2; } ! /** * convert babeldoc NameValuePair to HttpClient NameValuePair **/ public static org.apache.commons.httpclient.NameValuePair babeldocToHttpClient( ! NameValuePair pair ! ) ! { ! if (pair == null) { ! return null; ! } ! return new org.apache.commons.httpclient.NameValuePair(pair.getName(), pair.getValue()); } } --- 147,254 ---- * @throws PipelineException */ ! public PipelineStageResult[] process() ! throws PipelineException { try { ! // get the document ! PipelineDocument document = this.getDocument(); ! // get all the options ! String method = getOptions(HTTP_METHOD); ! String url = getOptions(HTTP_URL); ! NameValuePair[] queryString = getOptionList(new String[]{HTTP_QUERY_STRING}); ! boolean followRedirects = "true".equalsIgnoreCase(getOptions(HTTP_FOLLOW_REDIRECTS)); ! boolean oneDotOne = "true".equalsIgnoreCase(getOptions(HTTP_1_1)); ! boolean strictMode = "true".equalsIgnoreCase(getOptions(HTTP_STRICT_MODE)); ! NameValuePair[] headers = getOptionList(new String[]{HTTP_HEADERS}); ! NameValuePair[] postParameters = getOptionList(new String[]{HTTP_POST_PARAMETERS}); ! ! // Create an instance of HttpClient. ! HttpClient client = new HttpClient(); ! ! // Choose the appropriate Http method ! HttpMethodBase httpMethod; ! if ("post".equalsIgnoreCase(method)) { ! httpMethod = new PostMethod(url); ! } else if ("get".equalsIgnoreCase(method)) { ! httpMethod = new GetMethod(url); ! } else if ("".equals(method) || (method == null)) { ! // default to GET if nothing is specified ! httpMethod = new GetMethod(url); ! } else { ! throw new PipelineException("Invalid method: " + method); ! } ! ! // Build the query string if applicable ! if ((queryString != null) && (queryString.length > 0)) { ! // set the query string from the parameters ! httpMethod.setQueryString(babeldocToHttpClient(queryString)); ! } ! ! // set the rest of the options ! httpMethod.setFollowRedirects(followRedirects); ! httpMethod.setHttp11(oneDotOne); // this might be changing the default for HttpClient-what is the default? ! httpMethod.setStrictMode(strictMode); ! ! // set the request headers if applicable ! if (headers != null) { ! for (int i = 0; i < headers.length; i++) { ! httpMethod.setRequestHeader(headers[i].getName(), headers[i].getValue()); ! } ! } ! ! if ("post".equalsIgnoreCase(method)) { ! // if post parameters are passed, use those as the body, else use the document ! if ((postParameters != null) && (postParameters.length > 0)) { ! ((PostMethod) httpMethod).setRequestBody(babeldocToHttpClient(postParameters)); ! } else { ! ByteArrayInputStream bais = new ByteArrayInputStream(document.getBytes()); ! ((PostMethod) httpMethod).setRequestBody(bais); ! } ! } ! ! // todo: do something with the status code - write it as an attribute, throw an exception ! // if its something other than OK, etc. ! int statusCode = client.executeMethod(httpMethod); ! ! // Read the response body. ! byte[] responseBody = httpMethod.getResponseBody(); ! ! // Release the connection. ! httpMethod.releaseConnection(); ! ! String[] results = new String[]{new String(responseBody)}; ! // todo: should this be the content type of the response? ! return super.processHelper("text/xml", results); ! } catch (Exception e) { ! throw new com.babeldoc.core.pipeline.PipelineException("HTTPWriter", e); } } ! /** * convert babeldoc NameValuePair[] to HttpClient NameValuePair **/ public static org.apache.commons.httpclient.NameValuePair[] babeldocToHttpClient( ! NameValuePair[] pairs ! ) { ! if (pairs == null) { ! return null; ! } ! org.apache.commons.httpclient.NameValuePair[] pairs2 = new org.apache.commons.httpclient.NameValuePair[pairs.length]; ! for (int i = 0; i < pairs.length; i++) { ! pairs2[i] = babeldocToHttpClient(pairs[i]); ! } ! return pairs2; } ! /** * convert babeldoc NameValuePair to HttpClient NameValuePair **/ public static org.apache.commons.httpclient.NameValuePair babeldocToHttpClient( ! NameValuePair pair ! ) { ! if (pair == null) { ! return null; ! } ! return new org.apache.commons.httpclient.NameValuePair(pair.getName(), pair.getValue()); } } |
|
From: <tr...@us...> - 2003-07-15 22:46:59
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage In directory sc8-pr-cvs1:/tmp/cvs-serv24833/sql/src/com/babeldoc/sql/pipeline/stage Modified Files: SqlQueryPipelineStage.java Log Message: added the header and some small reformattings. Index: SqlQueryPipelineStage.java =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage/SqlQueryPipelineStage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** SqlQueryPipelineStage.java 14 Jul 2003 22:43:30 -0000 1.1 --- SqlQueryPipelineStage.java 15 Jul 2003 22:46:56 -0000 1.2 *************** *** 1,2 **** --- 1,68 ---- + /* ==================================================================== + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, + * if any, must include the following acknowledgment: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowledgment may appear in the software itself, + * if and wherever such third-party acknowledgments normally appear. + * + * 4. The names "Apache" and "Apache Software Foundation" must + * not be used to endorse or promote products derived from this + * software without prior written permission. For written + * permission, please contact ap...@ap.... + * + * 5. Products derived from this software may not be called "Apache", + * nor may "Apache" appear in their name, without prior written + * permission of the Apache Software Foundation. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * <http://www.apache.org/>. + * + * Portions of this software are based upon public domain software + * originally written at the National Center for Supercomputing Applications, + * University of Illinois, Urbana-Champaign. + * ==================================================================== + * + * Babeldoc: The Universal Document Processor + * + * $Header$ + * $DateTime$ + * $Author$ + * + */ + package com.babeldoc.sql.pipeline.stage; *************** *** 7,15 **** import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; ! import com.babeldoc.core.pipeline.PipelineException; ! import com.babeldoc.core.pipeline.PipelineStage; ! import com.babeldoc.core.pipeline.PipelineStageInfo; ! import com.babeldoc.core.pipeline.PipelineStageResult; ! import com.babeldoc.core.pipeline.PipelineDocument; import com.babeldoc.core.resource.IResource; import com.babeldoc.core.resource.ResourceException; --- 73,77 ---- import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigOptionType; ! import com.babeldoc.core.pipeline.*; import com.babeldoc.core.resource.IResource; import com.babeldoc.core.resource.ResourceException; *************** *** 19,24 **** import java.util.ArrayList; import java.util.Collection; - import java.util.HashMap; - import java.util.Iterator; /** --- 81,84 ---- *************** *** 32,36 **** public final static String SQL = "sql"; public final static String RESOURCE_NAME = "resourceName"; ! //Connection pool private IResource resource = null; --- 92,96 ---- public final static String SQL = "sql"; public final static String RESOURCE_NAME = "resourceName"; ! //Connection pool private IResource resource = null; *************** *** 54,58 **** null, true, I18n.get("sql.901"))); ! IConfigOptionType queries = new ComplexConfigOptionType( new ConfigOption[] { new ConfigOption(SQL, IConfigOptionType.MULTI, null, false, I18n.get("sql.902")) }); --- 114,118 ---- null, true, I18n.get("sql.901"))); ! IConfigOptionType queries = new ComplexConfigOptionType(new ConfigOption[]{ new ConfigOption(SQL, IConfigOptionType.MULTI, null, false, I18n.get("sql.902")) }); *************** *** 74,88 **** // Check that the resource is set ! if (! hasOption(RESOURCE_NAME)) ! { throw new PipelineException(I18n.get("sql.201")); } NameValuePair[] queries = this.getOptionList(new String[]{SQL}); ! StringBuffer xml = new StringBuffer(); xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); xml.append("<queryresults>\n"); ! Connection conn = null; Statement stmt = null; --- 134,147 ---- // Check that the resource is set ! if (!hasOption(RESOURCE_NAME)) { throw new PipelineException(I18n.get("sql.201")); } NameValuePair[] queries = this.getOptionList(new String[]{SQL}); ! StringBuffer xml = new StringBuffer(); xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); xml.append("<queryresults>\n"); ! Connection conn = null; Statement stmt = null; *************** *** 90,121 **** String sql = null; try { ! conn = getConnection(); ! ! // Iterate through sqls ! if ((queries != null) && (queries.length > 0)) { ! for (int i = 0; i < queries.length; ++i) { ! String queryName = queries[i].getName(); ! xml.append("<" + queryName + ">\n"); ! sql = queries[i].getValue(); ! stmt = conn.createStatement(); ! LogService.getInstance().logDebug("Executing " + sql); ! rs = stmt.executeQuery(sql); ! ResultSetMetaData metaData = rs.getMetaData(); ! while (rs.next()) { ! xml.append("<row>\n"); ! for (int j = 1, count = metaData.getColumnCount(); j <= count; j++) { ! String name = metaData.getColumnLabel(j).toLowerCase(); ! Object value = rs.getObject(j); ! xml.append("<" + name + ">"); ! xml.append(value); ! xml.append("</" + name + ">\n"); ! } ! xml.append("</row>\n"); ! } ! xml.append("</" + queryName + ">\n"); ! } ! } ! } ! catch (ResourceException e) { throw new PipelineException(I18n.get("sql.103"), e); } catch (SQLException e) { --- 149,179 ---- String sql = null; try { ! conn = getConnection(); ! ! // Iterate through sqls ! if ((queries != null) && (queries.length > 0)) { ! for (int i = 0; i < queries.length; ++i) { ! String queryName = queries[i].getName(); ! xml.append("<" + queryName + ">\n"); ! sql = queries[i].getValue(); ! stmt = conn.createStatement(); ! LogService.getInstance().logDebug("Executing " + sql); ! rs = stmt.executeQuery(sql); ! ResultSetMetaData metaData = rs.getMetaData(); ! while (rs.next()) { ! xml.append("<row>\n"); ! for (int j = 1, count = metaData.getColumnCount(); j <= count; j++) { ! String name = metaData.getColumnLabel(j).toLowerCase(); ! Object value = rs.getObject(j); ! xml.append("<" + name + ">"); ! xml.append(value); ! xml.append("</" + name + ">\n"); ! } ! xml.append("</row>\n"); ! } ! xml.append("</" + queryName + ">\n"); ! } ! } ! } catch (ResourceException e) { throw new PipelineException(I18n.get("sql.103"), e); } catch (SQLException e) { *************** *** 143,170 **** } } ! xml.append("</queryresults>\n"); ! PipelineDocument newDoc = new PipelineDocument(this.getDocument(), xml.toString().getBytes()); newDoc.setMimeType("text/xml"); ! return super.processHelper(newDoc); } ! /** * Get the named resource name from the resource factory * * @return - * @throws PipelineException * @throws ResourceException */ private Connection getConnection() ! throws PipelineException, ResourceException { if (resource == null) { resource = ResourceFactory.getResource(this.getOptions(RESOURCE_NAME)); } ! if (resource == null) ! { throw new ResourceException(I18n.get("sql.103")); } --- 201,226 ---- } } ! xml.append("</queryresults>\n"); ! PipelineDocument newDoc = new PipelineDocument(this.getDocument(), xml.toString().getBytes()); newDoc.setMimeType("text/xml"); ! return super.processHelper(newDoc); } ! /** * Get the named resource name from the resource factory * * @return * @throws ResourceException */ private Connection getConnection() ! throws ResourceException { if (resource == null) { resource = ResourceFactory.getResource(this.getOptions(RESOURCE_NAME)); } ! if (resource == null) { throw new ResourceException(I18n.get("sql.103")); } |
|
From: Bruce M. <br...@mc...> - 2003-07-15 22:29:07
|
All,
Good - it appears that this is adequately taken care of - does anyone have an
issue with this solution?
regards,
Bruce
On Tuesday 15 July 2003 05:59 pm, Leech, Jonathan wrote:
> Stefan,
>
> I implemented the "splitAttributes" option in PipelineStage.java, so any
> PipelineStage that can split up documents can use it. I had the same
> requirement for XPathSplitter... splitAttributes defaults to false. The
> code I commited looks almost identical to your patch -- One difference and
> something to watch out for is to not copy the DomifyPipelineStage.DOM_KEY
> -- this is used to cache the DOM representation of a document, to avoid
> reparsing, and if you copy this attribute, you will get weird results down
> the line if you use any of the XML parsing pipelines. They will be
> effectively running against the XML document before you split it up... I
> like the name "copyAttributes" better than "splitAttributes". Should I
> change it?
> I too had problem with the config files initially, but I think I've got a
> handle on it now.
>
> -Jonathan
>
> -----Original Message-----
> From: Stefan Krieger [mailto:ste...@co...]
> Sent: Tuesday, July 15, 2003 2:41 PM
> To: bab...@li...
> Subject: [Babeldoc-devel] Splitting Document with Attributes
>
>
> Hello,
>
> I have seen that the new RouterPipelineStage has an option wether to copy
> the attributes to the new document or not.
> I think this should be done generally for all PipelineStage that can split
> up documents.
> I have the same requirement for XPathSpillter and fixed it into the base
> PiplineStage method.
>
> What do you think about introducing a new "standard" stage option, i.e.
> "copyAttributes" ?
> This could be defaulted to false, so it want break with the existing way.
>
> BTW: During our project we have had tremendous trouble with your
> configuration appending mechanism.
> I can't give you any more details, I am just happy that we have it now
> running.
> We ended up with copies of some "config.properties" in our config dir and
> removed some from the babeldoc JARs.
> We are still on version 1.0, so I am not sure if this is already fixed.
>
> Stefan
>
> protected PipelineStageResult[] processHelper(String[] results)
> throws PipelineException, JournalException {
>
> IJournal journal = JournalFactory.getJournal();
> PipelineStageResult[] psresults = new
> PipelineStageResult[results.length];
> String name = this.getNextPipelineStageName();
> //Process each of the documents
> for (int i = 0; i < results.length; ++i) {
> IJournalTicket newTicket = journal.forkTicket(ticket);
> PipelineDocument newDoc = new
> PipelineDocument(results[i].getBytes()); // PATCH: copy attributes
> PipelineDocument doc = getDocument() ;
> for ( Iterator it = doc.keys().iterator(); it.hasNext() ; ) {
> String key = (String) it.next() ;
> newDoc.put( key, doc.get( key ) ) ;
> }
> psresults[i] = new PipelineStageResult(name, newDoc, newTicket);
> }
> return psresults;
> }
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Parasoft
> Error proof Web apps, automate testing & more.
> Download & eval WebKing and get a free book.
> www.parasoft.com/bulletproofapps1
> _______________________________________________
> Babeldoc-devel mailing list
> Bab...@li...
> https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: VM Ware
> With VMware you can run multiple operating systems on a single machine.
> WITHOUT REBOOTING! Mix Linux / Windows / Novell virtual machines at the
> same time. Free trial click here: http://www.vmware.com/wl/offer/345/0
> _______________________________________________
> Babeldoc-devel mailing list
> Bab...@li...
> https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: Bruce M. <br...@mc...> - 2003-07-15 22:28:02
|
Stefan,
Can you and Jonathon Leech talk about this. I would be interested in a
general solution to the problem of handling attributes when documents are
split / routed etc.
I have been using the 1.1 codebase extensively in a production project and am
fairly sure that the configuration merging works according to design
(hahaha). But seriously, it seems to work ok for me.
I would suggest (hope) that you start using the 1.1 codebase - it is a lot
more robust in a number of areas and especially in configuration.
regards,
Bruce McDonald
On Tuesday 15 July 2003 04:41 pm, Stefan Krieger wrote:
> Hello,
>
> I have seen that the new RouterPipelineStage has an option wether to copy
> the attributes to the new document or not.
> I think this should be done generally for all PipelineStage that can split
> up documents.
> I have the same requirement for XPathSpillter and fixed it into the base
> PiplineStage method.
>
> What do you think about introducing a new "standard" stage option, i.e.
> "copyAttributes" ?
> This could be defaulted to false, so it want break with the existing way.
>
> BTW: During our project we have had tremendous trouble with your
> configuration appending mechanism.
> I can't give you any more details, I am just happy that we have it now
> running.
> We ended up with copies of some "config.properties" in our config dir and
> removed some from the babeldoc JARs.
> We are still on version 1.0, so I am not sure if this is already fixed.
>
> Stefan
>
> protected PipelineStageResult[] processHelper(String[] results)
> throws PipelineException, JournalException {
>
> IJournal journal = JournalFactory.getJournal();
> PipelineStageResult[] psresults = new
> PipelineStageResult[results.length];
> String name = this.getNextPipelineStageName();
> //Process each of the documents
> for (int i = 0; i < results.length; ++i) {
> IJournalTicket newTicket = journal.forkTicket(ticket);
> PipelineDocument newDoc = new
> PipelineDocument(results[i].getBytes()); // PATCH: copy attributes
> PipelineDocument doc = getDocument() ;
> for ( Iterator it = doc.keys().iterator(); it.hasNext() ; ) {
> String key = (String) it.next() ;
> newDoc.put( key, doc.get( key ) ) ;
> }
> psresults[i] = new PipelineStageResult(name, newDoc, newTicket);
> }
> return psresults;
> }
>
>
>
> -------------------------------------------------------
> This SF.Net email sponsored by: Parasoft
> Error proof Web apps, automate testing & more.
> Download & eval WebKing and get a free book.
> www.parasoft.com/bulletproofapps1
> _______________________________________________
> Babeldoc-devel mailing list
> Bab...@li...
> https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: Bruce M. <br...@mc...> - 2003-07-15 22:24:52
|
Bill, Good to hear it. Version 1.1 is developmental right now. I would suggest that if you need good stability at the moment then use 1.0. However, I feel that the 1.1 version is pretty stable (I am using in a medium sized banking project) and this is the future for babeldoc. I want to do a release soon (not sure when). I do not anticipate much more changing in 1.1 from now to release as a stable release (1.2). You get access to 1.1 codebase by checking it out of CVS. Please read the documentation on the sourceforge.net site about this. regards, Bruce. On Tuesday 15 July 2003 09:56 am, Bill Harrelson wrote: > Bruce, > > I am about to start a project to use Babeldoc, and will want to develop one > or two new pipeline stages (although the 1.1 call external application > stage may obviate one of these, and if the jms stage is available, the > other). > > So, my question is: is 1.1 stable enough for that to be where I should > start? Any estimates on when you think it might be released in general? > (I'm expecting to deliver this project in September.) > > Also, there seems to be a lot of good stuff in 1.1. How would I get access > to it? > > Thanks, > > Bill Harrelson > > On 5 Jul 2003 at 1:27, Bruce McDonald wrote: > > All, > > > > I have added the website to CVS - just checkout module website. > > Please make changes to the website - I will set up a cron job to > > checkout the latest code to the webserver. I know that this is a > > problem area and this is first step at making this public so that we > > can work on this. > > > > regards, > > Bruce > > > > > > ------------------------------------------------------- > > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > > Data Reports, E-commerce, Portals, and Forums are available now. > > Download today and enter to win an XBOX or Visual Studio .NET. > > http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/ > > 01 _______________________________________________ Babeldoc-devel > > mailing list Bab...@li... > > https://lists.sourceforge.net/lists/listinfo/babeldoc-devel |
|
From: Leech, J. <jl...@vi...> - 2003-07-15 22:00:42
|
Stefan,
I implemented the "splitAttributes" option in PipelineStage.java, so any
PipelineStage that can split up documents can use it. I had the same
requirement for XPathSplitter... splitAttributes defaults to false. The
code I commited looks almost identical to your patch -- One difference and
something to watch out for is to not copy the DomifyPipelineStage.DOM_KEY --
this is used to cache the DOM representation of a document, to avoid
reparsing, and if you copy this attribute, you will get weird results down
the line if you use any of the XML parsing pipelines. They will be
effectively running against the XML document before you split it up...
I like the name "copyAttributes" better than "splitAttributes". Should I
change it?
I too had problem with the config files initially, but I think I've got a
handle on it now.
-Jonathan
-----Original Message-----
From: Stefan Krieger [mailto:ste...@co...]
Sent: Tuesday, July 15, 2003 2:41 PM
To: bab...@li...
Subject: [Babeldoc-devel] Splitting Document with Attributes
Hello,
I have seen that the new RouterPipelineStage has an option wether to copy
the attributes to the new document or not.
I think this should be done generally for all PipelineStage that can split
up documents.
I have the same requirement for XPathSpillter and fixed it into the base
PiplineStage method.
What do you think about introducing a new "standard" stage option, i.e.
"copyAttributes" ?
This could be defaulted to false, so it want break with the existing way.
BTW: During our project we have had tremendous trouble with your
configuration appending mechanism.
I can't give you any more details, I am just happy that we have it now
running.
We ended up with copies of some "config.properties" in our config dir and
removed some from the babeldoc JARs.
We are still on version 1.0, so I am not sure if this is already fixed.
Stefan
protected PipelineStageResult[] processHelper(String[] results)
throws PipelineException, JournalException {
IJournal journal = JournalFactory.getJournal();
PipelineStageResult[] psresults = new
PipelineStageResult[results.length];
String name = this.getNextPipelineStageName();
//Process each of the documents
for (int i = 0; i < results.length; ++i) {
IJournalTicket newTicket = journal.forkTicket(ticket);
PipelineDocument newDoc = new PipelineDocument(results[i].getBytes());
// PATCH: copy attributes
PipelineDocument doc = getDocument() ;
for ( Iterator it = doc.keys().iterator(); it.hasNext() ; ) {
String key = (String) it.next() ;
newDoc.put( key, doc.get( key ) ) ;
}
psresults[i] = new PipelineStageResult(name, newDoc, newTicket);
}
return psresults;
}
-------------------------------------------------------
This SF.Net email sponsored by: Parasoft
Error proof Web apps, automate testing & more.
Download & eval WebKing and get a free book.
www.parasoft.com/bulletproofapps1
_______________________________________________
Babeldoc-devel mailing list
Bab...@li...
https://lists.sourceforge.net/lists/listinfo/babeldoc-devel
|
|
From: Stefan K. <ste...@co...> - 2003-07-15 20:41:20
|
Hello,
I have seen that the new RouterPipelineStage has an option wether to copy
the attributes to the new document or not.
I think this should be done generally for all PipelineStage that can split
up documents.
I have the same requirement for XPathSpillter and fixed it into the base
PiplineStage method.
What do you think about introducing a new "standard" stage option, i.e.
"copyAttributes" ?
This could be defaulted to false, so it want break with the existing way.
BTW: During our project we have had tremendous trouble with your
configuration appending mechanism.
I can't give you any more details, I am just happy that we have it now
running.
We ended up with copies of some "config.properties" in our config dir and
removed some from the babeldoc JARs.
We are still on version 1.0, so I am not sure if this is already fixed.
Stefan
protected PipelineStageResult[] processHelper(String[] results)
throws PipelineException, JournalException {
IJournal journal = JournalFactory.getJournal();
PipelineStageResult[] psresults = new
PipelineStageResult[results.length];
String name = this.getNextPipelineStageName();
//Process each of the documents
for (int i = 0; i < results.length; ++i) {
IJournalTicket newTicket = journal.forkTicket(ticket);
PipelineDocument newDoc = new PipelineDocument(results[i].getBytes());
// PATCH: copy attributes
PipelineDocument doc = getDocument() ;
for ( Iterator it = doc.keys().iterator(); it.hasNext() ; ) {
String key = (String) it.next() ;
newDoc.put( key, doc.get( key ) ) ;
}
psresults[i] = new PipelineStageResult(name, newDoc, newTicket);
}
return psresults;
}
|
|
From: <jon...@us...> - 2003-07-15 15:07:59
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline
In directory sc8-pr-cvs1:/tmp/cvs-serv8139/pipeline
Modified Files:
IPipelineStage.java PipelineStage.java
PipelineStageFactory.java
Log Message:
Threading via the 'threaded' and 'maxThreads' attributes. 'splitAttributes'
copies document attributes to split pipeline stages.
Index: IPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/IPipelineStage.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** IPipelineStage.java 27 Jun 2003 02:19:58 -0000 1.10
--- IPipelineStage.java 15 Jul 2003 15:07:53 -0000 1.11
***************
*** 137,140 ****
--- 137,150 ----
/**
+ * Return true if nextStages are threaded
+ **/
+ public boolean getThreaded();
+
+ /**
+ * Return the maxThreads for the nextStages
+ **/
+ public int getMaxThreads();
+
+ /**
* Initialization of stage. It is performed when new document is to be
* processed
Index: PipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/PipelineStage.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** PipelineStage.java 27 Jun 2003 02:19:58 -0000 1.14
--- PipelineStage.java 15 Jul 2003 15:07:53 -0000 1.15
***************
*** 72,75 ****
--- 72,76 ----
import com.babeldoc.core.service.ServiceException;
import com.babeldoc.core.service.ServiceFactory;
+ import com.babeldoc.core.pipeline.stage.DomifyPipelineStage;
import org.apache.commons.lang.builder.ToStringBuilder;
***************
*** 77,80 ****
--- 78,82 ----
import java.util.ArrayList;
import java.util.Iterator;
+ import java.util.Set;
***************
*** 113,116 ****
--- 115,127 ----
public static final String ERROR_HANDLER = "errorHandler";
+ /** constant: split documents inherit attributes */
+ public static final String SPLIT_ATTRIBUTES = "splitAttributes";
+
+ /** constant: nextStages are threaded */
+ public static final String THREADED = "threaded";
+
+ /** constant: maximum number of threads for nextStages */
+ public static final String MAX_THREADS = "maxThreads";
+
/** Store the configuration information */
private IConfigInfo info;
***************
*** 213,216 ****
--- 224,246 ----
/**
+ * Return true if nextStages are threaded
+ **/
+ public boolean getThreaded() {
+ return "true".equalsIgnoreCase(this.getOptions(THREADED));
+ }
+
+ /**
+ * Return the maxThreads for the nextStages
+ **/
+ public int getMaxThreads() {
+ if (this.hasOption(MAX_THREADS)) {
+ return Integer.parseInt(this.getOptions(MAX_THREADS));
+ }
+ else {
+ return 0;
+ }
+ }
+
+ /**
* Get the journal
*
***************
*** 266,270 ****
ConfigOption config = ((PipelineStageInfo) getInfo()).getOptionInPath(keys);
! if (config != null) {
ArrayList array = new ArrayList();
--- 296,300 ----
ConfigOption config = ((PipelineStageInfo) getInfo()).getOptionInPath(keys);
! if ((config != null) && (config.getSuboptionNames() != null)) {
ArrayList array = new ArrayList();
***************
*** 273,277 ****
String oname = (String) iterator.next();
ConfigOption subopt = config.getSuboption(oname);
- ;
String ovalue = (String) subopt.getValue();
--- 303,306 ----
***************
*** 662,665 ****
--- 691,706 ----
PipelineDocument newDoc = new PipelineDocument(results[i].getBytes());
newDoc.setMimeType(mimeType);
+ if ("true".equalsIgnoreCase(getOptions(SPLIT_ATTRIBUTES))) {
+ // copy the attributes from the old document to the new document, minus NAME, MIME_TYPE, and DOM_KEY
+ PipelineDocument oldDoc = getDocument();
+ Set oldKeys = oldDoc.keys();
+ for (Iterator j = oldKeys.iterator(); j.hasNext(); ) {
+ String key = (String)j.next();
+ if (!PipelineDocument.NAME.equals(key) && !PipelineDocument.MIME_TYPE.equals(key) && !DomifyPipelineStage.DOM_KEY.equals(key)) {
+ Object value = oldDoc.get(key);
+ newDoc.put(key, value);
+ }
+ }
+ }
psresults[i] = new PipelineStageResult(name, newDoc, newTicket);
}
***************
*** 689,692 ****
--- 730,745 ----
IJournalTicket newTicket = journal.forkTicket(ticket);
PipelineDocument newDoc = new PipelineDocument(results[i].getBytes());
+ if ("true".equalsIgnoreCase(getOptions(SPLIT_ATTRIBUTES))) {
+ // copy the attributes from the old document to the new document, minus NAME, MIME_TYPE, and DOM_KEY
+ PipelineDocument oldDoc = getDocument();
+ Set oldKeys = oldDoc.keys();
+ for (Iterator j = oldKeys.iterator(); j.hasNext(); ) {
+ String key = (String)j.next();
+ if (!PipelineDocument.NAME.equals(key) && !PipelineDocument.MIME_TYPE.equals(key) && !DomifyPipelineStage.DOM_KEY.equals(key)) {
+ Object value = oldDoc.get(key);
+ newDoc.put(key, value);
+ }
+ }
+ }
psresults[i] = new PipelineStageResult(name, newDoc, newTicket);
}
Index: PipelineStageFactory.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/PipelineStageFactory.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** PipelineStageFactory.java 27 Jun 2003 02:19:58 -0000 1.12
--- PipelineStageFactory.java 15 Jul 2003 15:07:53 -0000 1.13
***************
*** 76,79 ****
--- 76,81 ----
import java.util.HashMap;
import java.util.Map;
+ import java.util.Collections;
+ import java.util.Vector;
***************
*** 97,101 ****
/** Hold the constructed stages */
! private Map stages;
/**
--- 99,109 ----
/** Hold the constructed stages */
! // this is put in a ThreadLocal, since with Threads the same stage can be called by several Threads at once
! private ThreadLocal localStages = new ThreadLocal() {
! protected synchronized Object initialValue() {
! getLog().logDebug(I18n.get("019005", "new"));
! return new HashMap();
! }
! };
/**
***************
*** 187,194 ****
public IPipelineStage getPipelineStage(String stageName)
throws PipelineException {
! if (stages == null) {
! getLog().logDebug(I18n.get("019005", "new"));
! stages = new HashMap();
! }
if (!stages.containsKey(stageName)) {
--- 195,199 ----
public IPipelineStage getPipelineStage(String stageName)
throws PipelineException {
! Map stages = (Map)localStages.get();
if (!stages.containsKey(stageName)) {
***************
*** 307,311 ****
pstage.setTicket(ticket);
trackDocument(pstage);
! processPipelineStageResults(pstage.processStage(), results);
} else {
getLog().logError(I18n.get("019008", name), null);
--- 312,325 ----
pstage.setTicket(ticket);
trackDocument(pstage);
! if (pstage.getThreaded()) {
! int maxThreads = pstage.getMaxThreads();
! if (maxThreads <= 0) {
! maxThreads = 2; // default to 2 if <= 0
! }
! processPipelineStageResults(pstage.processStage(), results, maxThreads);
! }
! else {
! processPipelineStageResults(pstage.processStage(), results);
! }
} else {
getLog().logError(I18n.get("019008", name), null);
***************
*** 359,362 ****
--- 373,436 ----
}
+ private void processPipelineStageResults(final PipelineStageResult[] psResults,
+ Collection results, final int maxThreads) throws PipelineException {
+ // ensure synchronized access to results Collection if threads are spawned
+ final Collection syncResults = Collections.synchronizedCollection(results);
+
+ // Only process if we get a valid result
+ if ((psResults != null) && (psResults.length > 0)) {
+ final int numResults = psResults.length;
+
+ // Kick of maxThreads Threads, each of which processes some of the results.
+ // For example (maxThreads = 4, numResults = 11
+ // Thread Processes These Results
+ // 0 0, 4, 8
+ // 1 1, 5, 9
+ // 2 2, 6, 10
+ // 3 3, 7
+ Vector threads = new Vector();
+ final Vector exceptions = new Vector();
+ for (int i = 0; i < maxThreads; i++) {
+ final int index = i;
+ Runnable r = new Runnable() {
+ public void run() {
+ for (int j = 0; j < numResults; j++) {
+ if ((j % maxThreads) == index) {
+ String name = psResults[j].getNamePipelineStage();
+ PipelineDocument document = psResults[j].getDocument();
+ IJournalTicket ticket = psResults[j].getTicket();
+ try {
+ process(name, document, ticket, syncResults);
+ }
+ catch (PipelineException p) {
+ exceptions.add(p);
+ }
+ }
+ }
+ }
+ };
+ Thread t = new Thread(r);
+ threads.add(t);
+ t.start();
+ }
+
+ // wait for any threads to finish before returning
+ for (int i = 0; i < threads.size(); i++) {
+ try {
+ Thread t = (Thread)threads.get(i);
+ t.join();
+ }
+ catch (InterruptedException ie) {
+ }
+ }
+
+ // see if any of the threads threw any exceptions, and if so, re-throw the first one
+ // TODO: throw an exception encapsulating all the exceptions that were thrown?
+ if (exceptions.size() > 0) {
+ throw (PipelineException)exceptions.get(0);
+ }
+ }
+ }
+
/**
* Track the document on the pipeline stage
|
|
From: <jon...@us...> - 2003-07-15 15:07:58
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv8139/pipeline/stage
Modified Files:
RouterPipelineStage.java
Log Message:
Threading via the 'threaded' and 'maxThreads' attributes. 'splitAttributes'
copies document attributes to split pipeline stages.
Index: RouterPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/RouterPipelineStage.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** RouterPipelineStage.java 27 Jun 2003 02:19:59 -0000 1.9
--- RouterPipelineStage.java 15 Jul 2003 15:07:53 -0000 1.10
***************
*** 74,79 ****
import java.util.ArrayList;
import java.util.Collection;
! import java.util.Vector;
!
/**
--- 74,80 ----
import java.util.ArrayList;
import java.util.Collection;
! import java.util.TreeMap;
! import java.util.Iterator;
! import java.util.HashMap;
/**
***************
*** 99,102 ****
--- 100,104 ----
public static final String NEXTSTAGE = "nextStage";
private static final String NEXT_STAGE_NAME = "nextStageName";
+ private static final String ORDER = "order";
/**
***************
*** 145,149 ****
throws com.babeldoc.core.pipeline.PipelineException {
com.babeldoc.core.NameValuePair[] stages = this.getOptionList(new String[] { NEXTSTAGE });
! Vector vec = new Vector();
// Now templatize and enrich the document
--- 147,169 ----
throws com.babeldoc.core.pipeline.PipelineException {
com.babeldoc.core.NameValuePair[] stages = this.getOptionList(new String[] { NEXTSTAGE });
! com.babeldoc.core.NameValuePair[] orders = this.getOptionList(new String[]{ORDER});
!
! HashMap orderByStageName = new HashMap();
! if (orders != null) {
! for (int i = 0; i < orders.length; i++) {
! String stage = orders[i].getName();
! String orderStr = orders[i].getValue();
! Integer order = null;
! try {
! order = new Integer(orderStr);
! }
! catch (NumberFormatException nfe) {
! order = new Integer(stage.hashCode());
! }
! orderByStageName.put(stage, order);
! }
! }
!
! TreeMap tm = new TreeMap();
// Now templatize and enrich the document
***************
*** 154,159 ****
if (Boolean.valueOf(script).booleanValue()) {
! vec.addElement(new com.babeldoc.core.pipeline.PipelineStageResult(
! stage, getDocument(), getTicket()));
}
}
--- 174,183 ----
if (Boolean.valueOf(script).booleanValue()) {
! Integer order = (Integer)orderByStageName.get(stage);
! if (order == null) {
! order = new Integer(stage.hashCode());
! }
! com.babeldoc.core.pipeline.PipelineStageResult psr = new com.babeldoc.core.pipeline.PipelineStageResult(stage, getDocument(), getTicket());
! tm.put(order, psr);
}
}
***************
*** 161,168 ****
// If one or more routes where selected, then build the array
! if (vec.size() > 0) {
! com.babeldoc.core.pipeline.PipelineStageResult[] results = new com.babeldoc.core.pipeline.PipelineStageResult[vec.size()];
! vec.copyInto(results);
!
return results;
} else {
--- 185,196 ----
// If one or more routes where selected, then build the array
! if (tm.size() > 0) {
! int index = 0;
! com.babeldoc.core.pipeline.PipelineStageResult[] results = new com.babeldoc.core.pipeline.PipelineStageResult[tm.size()];
! for (Iterator i = tm.keySet().iterator(); i.hasNext(); ) {
! Object key = i.next();
! results[index++] = (com.babeldoc.core.pipeline.PipelineStageResult)tm.get(key);
! }
!
return results;
} else {
|
|
From: <jon...@us...> - 2003-07-14 22:43:40
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/config/sql In directory sc8-pr-cvs1:/tmp/cvs-serv19573/config/sql Modified Files: query.properties Log Message: Added SqlQueryPipelineStage, and fixed a couple of bugs in the GenericSQL and Oracle journals. Index: query.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/config/sql/query.properties,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** query.properties 24 Feb 2003 22:47:22 -0000 1.1.1.1 --- query.properties 14 Jul 2003 22:43:29 -0000 1.2 *************** *** 7,10 **** --- 7,11 ---- journalAddBlankDataRow-mysql=insert into journal values ( ? , ? , ? ) journalSelectBlob=select jrn_data from journal where jrn_log_id=? and jrn_log_step=? + journalSelectBlobForUpdate-oracle=select jrn_data from journal where jrn_log_id=? and jrn_log_step=? for update journalUpdateDeltaData=insert into journal_data values ( ? , ? , ? , ? ) queryOtherTicketValues=select distinct log_id from log where log_other_data=? and log_operation=? |
|
From: <jon...@us...> - 2003-07-14 22:43:35
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv19573/src/com/babeldoc/sql/pipeline/stage
Added Files:
SqlQueryPipelineStage.java
Log Message:
Added SqlQueryPipelineStage, and fixed a couple of bugs in the GenericSQL and Oracle journals.
--- NEW FILE: SqlQueryPipelineStage.java ---
package com.babeldoc.sql.pipeline.stage;
import com.babeldoc.core.I18n;
import com.babeldoc.core.LogService;
import com.babeldoc.core.NameValuePair;
import com.babeldoc.core.option.ComplexConfigOptionType;
import com.babeldoc.core.option.ConfigOption;
import com.babeldoc.core.option.IConfigOptionType;
import com.babeldoc.core.pipeline.PipelineException;
import com.babeldoc.core.pipeline.PipelineStage;
import com.babeldoc.core.pipeline.PipelineStageInfo;
import com.babeldoc.core.pipeline.PipelineStageResult;
import com.babeldoc.core.pipeline.PipelineDocument;
import com.babeldoc.core.resource.IResource;
import com.babeldoc.core.resource.ResourceException;
import com.babeldoc.core.resource.ResourceFactory;
import java.sql.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
/**
* Make an XML document out of a SQL query
**/
public class SqlQueryPipelineStage
extends PipelineStage {
/**
* constants
*/
public final static String SQL = "sql";
public final static String RESOURCE_NAME = "resourceName";
//Connection pool
private IResource resource = null;
/**
* Construct with this stages info
*/
public SqlQueryPipelineStage() {
super(new PipelineStageInfo() {
public String getName() {
return "SqlQuery";
}
public String getDescription() {
return I18n.get("sql.900");
}
public Collection getTypeSpecificOptions() {
ArrayList options = new ArrayList();
options.add(new ConfigOption(RESOURCE_NAME, IConfigOptionType.STRING,
null, true, I18n.get("sql.901")));
IConfigOptionType queries = new ComplexConfigOptionType( new ConfigOption[] {
new ConfigOption(SQL, IConfigOptionType.MULTI, null, false, I18n.get("sql.902"))
});
options.add(new ConfigOption(SQL, queries,
null, false, I18n.get("sql.106")));
return options;
}
});
}
/**
* Heart of pipeline stage processing
*
* @return set of results from the processing
*/
public PipelineStageResult[] process() throws PipelineException {
// Check that the resource is set
if (! hasOption(RESOURCE_NAME))
{
throw new PipelineException(I18n.get("sql.201"));
}
NameValuePair[] queries = this.getOptionList(new String[]{SQL});
StringBuffer xml = new StringBuffer();
xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
xml.append("<queryresults>\n");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String sql = null;
try {
conn = getConnection();
// Iterate through sqls
if ((queries != null) && (queries.length > 0)) {
for (int i = 0; i < queries.length; ++i) {
String queryName = queries[i].getName();
xml.append("<" + queryName + ">\n");
sql = queries[i].getValue();
stmt = conn.createStatement();
LogService.getInstance().logDebug("Executing " + sql);
rs = stmt.executeQuery(sql);
ResultSetMetaData metaData = rs.getMetaData();
while (rs.next()) {
xml.append("<row>\n");
for (int j = 1, count = metaData.getColumnCount(); j <= count; j++) {
String name = metaData.getColumnLabel(j).toLowerCase();
Object value = rs.getObject(j);
xml.append("<" + name + ">");
xml.append(value);
xml.append("</" + name + ">\n");
}
xml.append("</row>\n");
}
xml.append("</" + queryName + ">\n");
}
}
}
catch (ResourceException e) {
throw new PipelineException(I18n.get("sql.103"), e);
} catch (SQLException e) {
throw new PipelineException(I18n.get("sql.104", sql), e);
} finally {
try {
if (rs != null) {
rs.close();
}
} catch (Exception ignoreThis) {
}
try {
if (stmt != null) {
stmt.close();
}
} catch (Exception ignoreThis) {
}
try {
if (conn != null) {
resource.checkIn(conn);
}
} catch (Exception ignoreThis) {
}
}
xml.append("</queryresults>\n");
PipelineDocument newDoc = new PipelineDocument(this.getDocument(), xml.toString().getBytes());
newDoc.setMimeType("text/xml");
return super.processHelper(newDoc);
}
/**
* Get the named resource name from the resource factory
*
* @return
* @throws PipelineException
* @throws ResourceException
*/
private Connection getConnection()
throws PipelineException, ResourceException {
if (resource == null) {
resource = ResourceFactory.getResource(this.getOptions(RESOURCE_NAME));
}
if (resource == null)
{
throw new ResourceException(I18n.get("sql.103"));
}
return ((Connection) resource.checkOut());
}
}
|
|
From: <jon...@us...> - 2003-07-14 22:43:35
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/journal
In directory sc8-pr-cvs1:/tmp/cvs-serv19573/src/com/babeldoc/sql/journal
Modified Files:
GenericSqlJournal.java
Log Message:
Added SqlQueryPipelineStage, and fixed a couple of bugs in the GenericSQL and Oracle journals.
Index: GenericSqlJournal.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/journal/GenericSqlJournal.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** GenericSqlJournal.java 27 Jun 2003 02:05:58 -0000 1.7
--- GenericSqlJournal.java 14 Jul 2003 22:43:29 -0000 1.8
***************
*** 380,384 ****
// Log the operation
! log(ticket, JournalOperation.forkTicket, parentTicket.toString(), null,
null);
--- 380,384 ----
// Log the operation
! log(ticket, JournalOperation.forkTicket, parentTicket.getId(), null,
null);
|
|
From: <jon...@us...> - 2003-07-14 22:43:33
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/config/service In directory sc8-pr-cvs1:/tmp/cvs-serv19573/config/service Modified Files: query.properties Log Message: Added SqlQueryPipelineStage, and fixed a couple of bugs in the GenericSQL and Oracle journals. Index: query.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/config/service/query.properties,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** query.properties 24 Feb 2003 22:47:21 -0000 1.1.1.1 --- query.properties 14 Jul 2003 22:43:29 -0000 1.2 *************** *** 1,4 **** --- 1,5 ---- PipelineStage.SqlEnrich=com.babeldoc.sql.pipeline.stage.SqlEnrichPipelineStage PipelineStage.SqlWriter=com.babeldoc.sql.pipeline.stage.SqlWriterPipelineStage + PipelineStage.SqlQuery=com.babeldoc.sql.pipeline.stage.SqlQueryPipelineStage Journal.mysql=com.babeldoc.sql.journal.MySqlJournal |
|
From: <jon...@us...> - 2003-07-14 20:49:51
|
Update of /cvsroot/babeldoc/babeldoc/modules/web/src/com/babeldoc/web/pipeline/stage In directory sc8-pr-cvs1:/tmp/cvs-serv30021/src/com/babeldoc/web/pipeline/stage Added Files: HttpClientPipelineStage.java Log Message: Initial version of HttpClientPipelineStage supporting http get, post. --- NEW FILE: HttpClientPipelineStage.java --- package com.babeldoc.web.pipeline.stage; // TODO: http authentication // TODO: handle cookies // TODO: handle all http methods import java.util.ArrayList; import java.util.Collection; import java.io.*; import java.net.*; import org.apache.commons.httpclient.*; import org.apache.commons.httpclient.methods.*; import com.babeldoc.core.I18n; import com.babeldoc.core.option.ConfigOption; import com.babeldoc.core.option.IConfigInfo; import com.babeldoc.core.option.IConfigOptionType; import com.babeldoc.core.option.ComplexConfigOptionType; import com.babeldoc.core.pipeline.PipelineDocument; import com.babeldoc.core.pipeline.PipelineException; import com.babeldoc.core.pipeline.PipelineStage; import com.babeldoc.core.pipeline.PipelineStageInfo; import com.babeldoc.core.pipeline.PipelineStageResult; import com.babeldoc.core.NameValuePair; /** * Pipeline stage for http/https client * * @author Jonathan Leech * @version 1.0 */ public class HttpClientPipelineStage extends PipelineStage { /* http method: get,post,etc. */ public final static String HTTP_METHOD = "method"; /* the URL */ public final static String HTTP_URL = "URL"; /* the query string is option list of name value pairs */ public final static String HTTP_QUERY_STRING = "queryString"; /* whether to automatically follow redirects */ public final static String HTTP_FOLLOW_REDIRECTS = "followRedirects"; /* whether to use http 1.1 protocol */ public final static String HTTP_1_1 = "http1.1"; /* whether to use strict mode */ public final static String HTTP_STRICT_MODE = "strictMode"; /* the headers as option list of name value pairs */ public final static String HTTP_HEADERS = "headers"; /* the post parameters as name value pairs */ public final static String HTTP_POST_PARAMETERS = "parameters"; /** * Return this stages info */ public HttpClientPipelineStage() { super(new PipelineStageInfo() { public String getName() { return "HttpClient"; } public String getDescription() { return I18n.get("web.200"); } public Collection getTypeSpecificOptions() { ArrayList options = new ArrayList(); // add specific options ComplexConfigOptionType ccot = new ComplexConfigOptionType((ConfigOption [])null); // no constant for this in IConfigOptionType options.add(new ConfigOption(HTTP_METHOD, IConfigOptionType.STRING, null, false, I18n.get("web.201"))); options.add(new ConfigOption(HTTP_URL, IConfigOptionType.URL, null, false, I18n.get("web.202"))); options.add(new ConfigOption(HTTP_QUERY_STRING, ccot, null, false, I18n.get("web.203"))); options.add(new ConfigOption(HTTP_FOLLOW_REDIRECTS, IConfigOptionType.BOOLEAN, null, false, I18n.get("web.204"))); options.add(new ConfigOption(HTTP_1_1, IConfigOptionType.BOOLEAN, null, false, I18n.get("web.205"))); options.add(new ConfigOption(HTTP_STRICT_MODE, IConfigOptionType.BOOLEAN, null, false, I18n.get("web.206"))); options.add(new ConfigOption(HTTP_HEADERS, ccot, null, false, I18n.get("web.207"))); options.add(new ConfigOption(HTTP_POST_PARAMETERS, ccot, null, false, I18n.get("web.208"))); return options; } }); } /** * Process the pipeline document * * @return * * @throws PipelineException */ public PipelineStageResult[] process() throws PipelineException { try { // get the document PipelineDocument document = this.getDocument(); // get all the options String method = getOptions(HTTP_METHOD); String url = getOptions(HTTP_URL); NameValuePair[] queryString = getOptionList(new String[]{HTTP_QUERY_STRING}); boolean followRedirects = "true".equalsIgnoreCase(getOptions(HTTP_FOLLOW_REDIRECTS)); boolean oneDotOne = "true".equalsIgnoreCase(getOptions(HTTP_1_1)); boolean strictMode = "true".equalsIgnoreCase(getOptions(HTTP_STRICT_MODE)); NameValuePair[] headers = getOptionList(new String[]{HTTP_HEADERS}); NameValuePair[] postParameters = getOptionList(new String[]{HTTP_POST_PARAMETERS}); // Create an instance of HttpClient. HttpClient client = new HttpClient(); // Choose the appropriate Http method HttpMethodBase httpMethod; if ("post".equalsIgnoreCase(method)) { httpMethod = new PostMethod(url); } else if ("get".equalsIgnoreCase(method)) { httpMethod = new GetMethod(url); } else if ("".equals(method) || (method == null)) { // default to GET if nothing is specified httpMethod = new GetMethod(url); } else { throw new PipelineException("Invalid method: " + method); } // Build the query string if applicable if ((queryString != null) && (queryString.length > 0)) { // set the query string from the parameters httpMethod.setQueryString(babeldocToHttpClient(queryString)); } // set the rest of the options httpMethod.setFollowRedirects(followRedirects); httpMethod.setHttp11(oneDotOne); // this might be changing the default for HttpClient-what is the default? httpMethod.setStrictMode(strictMode); // set the request headers if applicable if (headers != null) { for (int i = 0; i < headers.length; i++) { httpMethod.setRequestHeader(headers[i].getName(), headers[i].getValue()); } } if ("post".equalsIgnoreCase(method)) { // if post parameters are passed, use those as the body, else use the document if ((postParameters != null) && (postParameters.length > 0)) { ((PostMethod)httpMethod).setRequestBody(babeldocToHttpClient(postParameters)); } else { ByteArrayInputStream bais = new ByteArrayInputStream(document.getBytes()); ((PostMethod)httpMethod).setRequestBody(bais); } } // todo: do something with the status code - write it as an attribute, throw an exception // if its something other than OK, etc. int statusCode = client.executeMethod(httpMethod); // Read the response body. byte[] responseBody = httpMethod.getResponseBody(); // Release the connection. httpMethod.releaseConnection(); String[] results = new String[] {new String(responseBody)}; // todo: should this be the content type of the response? return super.processHelper("text/xml", results); } catch (Exception e) { throw new com.babeldoc.core.pipeline.PipelineException("HTTPWriter", e); } } /** * convert babeldoc NameValuePair[] to HttpClient NameValuePair **/ public static org.apache.commons.httpclient.NameValuePair[] babeldocToHttpClient( NameValuePair[] pairs ) { if (pairs == null) { return null; } org.apache.commons.httpclient.NameValuePair[] pairs2 = new org.apache.commons.httpclient.NameValuePair[pairs.length]; for (int i = 0; i < pairs.length; i++) { pairs2[i] = babeldocToHttpClient(pairs[i]); } return pairs2; } /** * convert babeldoc NameValuePair to HttpClient NameValuePair **/ public static org.apache.commons.httpclient.NameValuePair babeldocToHttpClient( NameValuePair pair ) { if (pair == null) { return null; } return new org.apache.commons.httpclient.NameValuePair(pair.getName(), pair.getValue()); } } |
|
From: <jon...@us...> - 2003-07-14 20:49:50
|
Update of /cvsroot/babeldoc/babeldoc/modules/web/config/service In directory sc8-pr-cvs1:/tmp/cvs-serv30021/config/service Modified Files: query.properties Log Message: Initial version of HttpClientPipelineStage supporting http get, post. Index: query.properties =================================================================== RCS file: /cvsroot/babeldoc/babeldoc/modules/web/config/service/query.properties,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** query.properties 27 May 2003 03:04:56 -0000 1.1 --- query.properties 14 Jul 2003 20:49:47 -0000 1.2 *************** *** 1,2 **** --- 1,4 ---- + PipelineStage.HttpClient=com.babeldoc.web.pipeline.stage.HttpClientPipelineStage + UserResourceFactory.simple=com.babeldoc.core.user.simple.SimpleUserResourceFactory UserFactory.simple=com.babeldoc.core.user.simple.SimpleUserFactory |
|
From: <jon...@us...> - 2003-07-14 20:49:50
|
Update of /cvsroot/babeldoc/babeldoc/modules/web/config/i18n
In directory sc8-pr-cvs1:/tmp/cvs-serv30021/config/i18n
Modified Files:
messages.properties
Log Message:
Initial version of HttpClientPipelineStage supporting http get, post.
Index: messages.properties
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/web/config/i18n/messages.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** messages.properties 28 Feb 2003 20:05:07 -0000 1.1
--- messages.properties 14 Jul 2003 20:49:47 -0000 1.2
***************
*** 14,15 ****
--- 14,26 ----
web.105=Babeldoc Journal Ticket: {0}
web.106=Pipeline Name: {0}
+
+ # com.babeldoc.pipeline.stage.HttpClientPipelineStage
+ web.200=Act as http client and get the results as new document
+ web.201=HTTP method
+ web.202=URL
+ web.203=Query parameters
+ web.204=Follow redirects
+ web.205=HTTP 1.1
+ web.206=Strict mode
+ web.207=Headers
+ web.208=Post parameters
|
|
From: <jon...@us...> - 2003-07-14 17:27:19
|
Update of /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage
In directory sc8-pr-cvs1:/tmp/cvs-serv19716
Modified Files:
XpathExtractPipelineStage.java
Log Message:
Allow all types of XPath expressions, e.g. count() etc.
Index: XpathExtractPipelineStage.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/core/src/com/babeldoc/core/pipeline/stage/XpathExtractPipelineStage.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** XpathExtractPipelineStage.java 27 Jun 2003 02:19:59 -0000 1.8
--- XpathExtractPipelineStage.java 14 Jul 2003 17:27:16 -0000 1.9
***************
*** 75,78 ****
--- 75,79 ----
import org.apache.xpath.XPathAPI;
+ import org.apache.xpath.objects.XObject;
import org.w3c.dom.Document;
***************
*** 153,181 ****
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
! NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);
StringBuffer buffer = new StringBuffer();
- Node n;
int ctr = 0;
! while ((n = nl.nextNode()) != null) {
! if (isTextNode(n)) {
! // DOM may have more than one node corresponding to a
! // single XPath text node. Coalesce all contiguous text nodes
! // at this level
! buffer.append(n.getNodeValue());
!
! for (Node nn = n.getNextSibling(); isTextNode(nn);
! nn = nn.getNextSibling()) {
! buffer.append(nn.getNodeValue());
! }
! } else {
! ByteArrayOutputStream baos = new ByteArrayOutputStream();
! serializer.transform(new DOMSource(n), new StreamResult(baos));
! buffer.append(baos.toString());
! }
!
! ctr++;
}
!
if (ctr == 0) {
throw new PipelineException("Unable to find XPath Tag = " + xpath +
--- 154,189 ----
serializer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
! XObject xobj = XPathAPI.eval(doc, xpath);
!
StringBuffer buffer = new StringBuffer();
int ctr = 0;
! if (xobj.getType() == XObject.CLASS_NODESET) {
! NodeIterator nl = xobj.nodeset();
! Node n;
! while ((n = nl.nextNode()) != null) {
! if (isTextNode(n)) {
! // DOM may have more than one node corresponding to a
! // single XPath text node. Coalesce all contiguous text nodes
! // at this level
! buffer.append(n.getNodeValue());
!
! for (Node nn = n.getNextSibling(); isTextNode(nn);
! nn = nn.getNextSibling()) {
! buffer.append(nn.getNodeValue());
! }
! } else {
! ByteArrayOutputStream baos = new ByteArrayOutputStream();
! serializer.transform(new DOMSource(n), new StreamResult(baos));
! buffer.append(baos.toString());
! }
! ctr++;
! }
}
! else {
! ctr = 1;
! buffer.append(xobj.toString());
! }
!
if (ctr == 0) {
throw new PipelineException("Unable to find XPath Tag = " + xpath +
|
|
From: <jon...@us...> - 2003-07-14 17:02:41
|
Update of /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/resource
In directory sc8-pr-cvs1:/tmp/cvs-serv15057/src/com/babeldoc/sql/resource
Modified Files:
PooledJdbc.java
Log Message:
removed synchronization from checkOut() and checkIn() to eliminate deadlock when pool is exhausted.
Index: PooledJdbc.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/sql/src/com/babeldoc/sql/resource/PooledJdbc.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PooledJdbc.java 27 Jun 2003 02:05:59 -0000 1.3
--- PooledJdbc.java 14 Jul 2003 17:02:36 -0000 1.4
***************
*** 109,113 ****
* @throws ResourceException
*/
! public synchronized void checkIn(Object connection) throws ResourceException {
try {
((Connection) connection).close();
--- 109,113 ----
* @throws ResourceException
*/
! public void checkIn(Object connection) throws ResourceException {
try {
((Connection) connection).close();
***************
*** 124,132 ****
* @throws ResourceException
*/
! public synchronized Object checkOut() throws ResourceException {
try {
! // if we have no dbUrl, setup jdbc NOW
! if (dbUrl == null) {
! setupJdbc();
}
--- 124,134 ----
* @throws ResourceException
*/
! public Object checkOut() throws ResourceException {
try {
! synchronized(this) {
! // if we have no dbUrl, setup jdbc NOW
! if (dbUrl == null) {
! setupJdbc();
! }
}
|
|
From: Bruce M. <br...@mc...> - 2003-07-11 04:32:19
|
Sounds fair - It sounds like you have made a good catch. Commit the code. On Thursday 10 July 2003 06:42 pm, Leech, Jonathan wrote: > I think we need to remove synchronization from the checkIn() and checkOut() > methods of PooledJdbc.java, and here's the reason why: It causes deadlock > every time the connection pool is exhausted. > > Example: > - All database connections in the pool are being used by various threads. > - A thread calls checkOut(), which locks the PooledJdbc object, and the > connection pool is waiting for a checkin. > - As the various threads finish using their database connections, they call > checkIn(), but are locked out. > > The only problem I see with it doing it is that there's a chance that > multiple threads could ask for the first connection, which calls > setupJdbc(), and that might be not well behaved. I think moving the > setupJdbc to the default constructor would handle this. > > Thoughts? > > -Jonathan |
|
From: Leech, J. <jl...@vi...> - 2003-07-10 22:43:10
|
I think we need to remove synchronization from the checkIn() and checkOut() methods of PooledJdbc.java, and here's the reason why: It causes deadlock every time the connection pool is exhausted. Example: - All database connections in the pool are being used by various threads. - A thread calls checkOut(), which locks the PooledJdbc object, and the connection pool is waiting for a checkin. - As the various threads finish using their database connections, they call checkIn(), but are locked out. The only problem I see with it doing it is that there's a chance that multiple threads could ask for the first connection, which calls setupJdbc(), and that might be not well behaved. I think moving the setupJdbc to the default constructor would handle this. Thoughts? -Jonathan |