haul 2003/01/17 03:33:19
Added: src/blocks/web3/samples samples.xml sitemap.xmap
src/blocks/web3/samples/stylesheets pics2view.xsl pretty.xsl
proper.xsl rfc2html.xsl
src/blocks/web3/samples/resources info.xml
src/blocks/web3/samples/dtd rfc-in.dtd rfc-out.dtd
src/blocks/web3/mocks/com/sap/mw/jco IFunctionTemplate.java
IRepository.java JCO.java
src/blocks/web3/java/org/apache/cocoon/transformation
Web3RfcTransformer.java
src/blocks/web3/java/org/apache/cocoon/components/web3
Web3.java Web3Client.java Web3DataSource.java
Web3Streamer.java
src/blocks/web3/java/org/apache/cocoon/components/web3/impl
DefaultWeb3StreamerImpl.java Web3ClientImpl.java
Web3DataSourceImpl.java
Web3DataSourceSelectorImpl.java Web3Properties.java
src/blocks/web3/conf web3.xconf web3.xroles web3.xsamples
Log:
Added web3 (SAP connectivity) block
Revision Changes Path
1.1 xml-cocoon2/src/blocks/web3/samples/samples.xml
Index: samples.xml
===================================================================
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- CVS: $Id: samples.xml,v 1.1 2003/01/17 11:33:18 haul Exp $ -->
<samples xmlns:xlink="http://www.w3.org/1999/xlink" name="web3 block">
<group name="web3">
<sample name="Documentation"
href="/cocoon/documentation/developing/web3.html">
Documentation for this component.
</sample>
<sample name="Connect to SAP R/3" href="info.html">
Demo connection to <b>your</b> SAP system.
</sample>
<sample name="Connect to SAP R/3 (XML)" href="info.xml">
Same as above but produces XML.
</sample>
</group>
</samples>
1.1 xml-cocoon2/src/blocks/web3/samples/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<!-- =========================== Components
================================ -->
<map:components>
<map:generators default="file"/>
<map:transformers default="xslt">
<!-- include the transformer like this:
-->
<map:transformer name="rfc"
src="org.apache.cocoon.transformation.Web3RfcTransformer"
logger="web3.transformation">
<system>indy</system>
</map:transformer>
</map:transformers>
<map:readers default="resource"/>
<map:serializers default="html"/>
<map:selectors default="browser"/>
<map:matchers default="wildcard"/>
</map:components>
<!-- =========================== Views ===================================
-->
<map:views>
<map:view name="content" from-label="content">
<map:serialize type="xml"/>
</map:view>
<map:view name="pretty-content" from-label="data">
<map:transform
src="context://samples/common/style/xsl/html/simple-xml2html.xsl"/>
<map:serialize type="html"/>
</map:view>
<map:view name="links" from-position="last">
<map:serialize type="links"/>
</map:view>
<map:view from-label="generic" name="generic">
<map:serialize type="xml"/>
</map:view>
<map:view from-label="source" name="source">
<map:serialize type="xml"/>
</map:view>
</map:views>
<!-- =========================== Pipelines
================================= -->
<map:pipelines>
<map:pipeline>
<map:match pattern="">
<map:redirect-to uri="samples"/>
</map:match>
<map:match pattern="samples">
<map:generate src="samples.xml"/>
<map:transform type="xalan"
src="context://samples/common/style/xsl/html/simple-samples2html.xsl"/>
<map:serialize/>
</map:match>
<map:match pattern="">
<map:redirect-to uri="info.html"/>
</map:match>
<map:match pattern="*.html">
<map:generate src="resources/{1}.xml"/>
<map:transform type="rfc"/>
<map:transform src="stylesheets/rfc2html.xsl"/>
<map:serialize/>
</map:match>
<map:match pattern="*.xml">
<map:generate src="resources/{1}.xml"
label="source"/>
<map:transform type="rfc" label="generic"/>
<map:transform src="stylesheets/proper.xsl"/>
<map:transform src="stylesheets/pretty.xsl"/>
<map:serialize type="xml"/>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1
xml-cocoon2/src/blocks/web3/samples/stylesheets/pics2view.xsl
Index: pics2view.xsl
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Author: Michael Gerzabek, [EMAIL PROTECTED], EFP Consulting �sterreich
@version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:18 $
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rfc="http://efp.cc/Web3-Rfc/1.0">
<xsl:template match="@src">
<xsl:attribute name="src">../../documents/<xsl:value-of
select="."/></xsl:attribute>
</xsl:template>
<xsl:template match="@*|*|text()|processing-instruction()"
priority="-1">
<xsl:copy>
<xsl:apply-templates
select="@*|*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/blocks/web3/samples/stylesheets/pretty.xsl
Index: pretty.xsl
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<!-- remove element prefix (if any) -->
<xsl:element name="{local-name()}">
<!-- process attributes -->
<xsl:for-each select="@*">
<!-- remove attribute prefix (if any) -->
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:for-each>
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/blocks/web3/samples/stylesheets/proper.xsl
Index: proper.xsl
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
Author: Michael Gerzabek, [EMAIL PROTECTED], EFP Consulting �sterreich
@version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:18 $
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rfc="http://efp.cc/Web3-Rfc/1.0">
<xsl:template match="rfc:export">
<export>
<xsl:apply-templates/>
</export>
</xsl:template>
<xsl:template match="rfc:tables">
<tables>
<xsl:apply-templates/>
</tables>
</xsl:template>
<xsl:template match="rfc:row">
<row>
<xsl:attribute name="id"><xsl:number/></xsl:attribute>
<xsl:apply-templates/>
</row>
</xsl:template>
<xsl:template match="rfc:*">
<xsl:element name="[EMAIL PROTECTED]:name}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>
<xsl:template match="@*|*|text()|processing-instruction()"
priority="-1">
<xsl:copy>
<xsl:apply-templates
select="@*|*|text()|processing-instruction()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
1.1
xml-cocoon2/src/blocks/web3/samples/stylesheets/rfc2html.xsl
Index: rfc2html.xsl
===================================================================
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:rfc="http://efp.cc/Web3-Rfc/1.0">
<xsl:template match="/">
<html>
<head>
<title>Web3</title>
</head>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="rfc:tables">
<xsl:if test="count(rfc:table) > 0">
<h1>tables:</h1>
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<xsl:template match="rfc:table">
<h2>table name: <xsl:value-of select="@*[name(.)='name']"/>
</h2>
<h3>
<xsl:value-of select="count(rfc:row)"/> Zeilen
</h3>
<xsl:if test="count(rfc:row) > 0">
<table border="1">
<tr>
<xsl:for-each
select="rfc:row[1]/rfc:field">
<th>
<xsl:value-of
select="@*[name(.)='name']"/>
</th>
</xsl:for-each>
</tr>
<xsl:for-each select="rfc:row">
<tr>
<xsl:for-each
select="rfc:field">
<td>
<xsl:value-of
select="."/>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</table>
</xsl:if>
</xsl:template>
<xsl:template match="rfc:export">
<xsl:if test="count(rfc:field) > 0">
<h1>fields:</h1>
<table border="1">
<tr>
<th>field name</th>
<th>value</th>
</tr>
<xsl:apply-templates select="rfc:field"/>
</table>
</xsl:if>
<xsl:if test="count(rfc:structure) > 0">
<h1>structures:</h1>
<xsl:for-each select="rfc:structure">
<h2>structure name: <xsl:value-of
select="@*[name(.)='name']"/>
</h2>
<table border="1">
<tr>
<th>field name</th>
<th>value</th>
</tr>
<xsl:apply-templates
select="rfc:field"/>
</table>
</xsl:for-each>
</xsl:if>
</xsl:template>
<xsl:template match="rfc:field">
<tr>
<td>
<xsl:value-of select="@*[name(.)='name']"/>
</td>
<td>
<xsl:value-of select="."/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
1.1 xml-cocoon2/src/blocks/web3/samples/resources/info.xml
Index: info.xml
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<page xmlns:rfc="http://efp.cc/Web3-Rfc/2.0">
<rfc:include name="RFC_SYSTEM_INFO"/>
</page>
1.1 xml-cocoon2/src/blocks/web3/samples/dtd/rfc-in.dtd
Index: rfc-in.dtd
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!ELEMENT include (import, tables*)>
<!ATTLIST include
name CDATA #REQUIRED
producer CDATA #IMPLIED
>
<!ELEMENT import (structure*, field*)>
<!ELEMENT structure (field+)>
<!ATTLIST structure
name CDATA #REQUIRED
>
<!ELEMENT field (#PCDATA)>
<!ATTLIST field
name CDATA #REQUIRED
>
<!ELEMENT tables (table)*>
<!ELEMENT table (structure+)>
<!ATTLIST table
name CDATA #REQUIRED
>
1.1 xml-cocoon2/src/blocks/web3/samples/dtd/rfc-out.dtd
Index: rfc-out.dtd
===================================================================
<?xml version="1.0" encoding="ISO-8859-1"?>
<!ELEMENT include (export+, tables*)>
<!ATTLIST include
name CDATA #REQUIRED
>
<!ELEMENT import (structure*, field*)>
<!ELEMENT export (structure*, field*)>
<!ELEMENT structure (field+)>
<!ATTLIST structure
name CDATA #REQUIRED
>
<!ELEMENT field (#PCDATA)>
<!ATTLIST field
name CDATA #REQUIRED
>
<!ELEMENT tables (table)*>
<!ELEMENT table (structure+)>
<!ATTLIST table
name CDATA #REQUIRED
>
1.1
xml-cocoon2/src/blocks/web3/mocks/com/sap/mw/jco/IFunctionTemplate.java
Index: IFunctionTemplate.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package com.sap.mw.jco;
/**
* **********************************************************************
* * W A R N I N G *
* **********************************************************************
*
* This is a mock object of the class, not the actual class.
* It's used to compile the code in absence of the actual class.
*
* This clsss is created by hand, not automatically.
*
* **********************************************************************
*
* @version CVS $Id: IFunctionTemplate.java,v 1.1 2003/01/17 11:33:18 haul
Exp $
*/
public interface IFunctionTemplate {
public JCO.Function getFunction();
}
1.1
xml-cocoon2/src/blocks/web3/mocks/com/sap/mw/jco/IRepository.java
Index: IRepository.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package com.sap.mw.jco;
/**
* **********************************************************************
* * W A R N I N G *
* **********************************************************************
*
* This is a mock object of the class, not the actual class.
* It's used to compile the code in absence of the actual class.
*
* This clsss is created by hand, not automatically.
*
* **********************************************************************
*
* @version CVS $Id: IRepository.java,v 1.1 2003/01/17 11:33:18 haul Exp $
*/
public interface IRepository {
}
1.1 xml-cocoon2/src/blocks/web3/mocks/com/sap/mw/jco/JCO.java
Index: JCO.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package com.sap.mw.jco;
import java.util.Properties;
import java.net.URL;
/**
* **********************************************************************
* * W A R N I N G *
* **********************************************************************
*
* This is a mock object of the class, not the actual class.
* It's used to compile the code in absence of the actual class.
*
* This clsss is created by hand, not automatically.
*
* **********************************************************************
*
* @version CVS $Id: JCO.java,v 1.1 2003/01/17 11:33:18 haul Exp $
*/
public class JCO {
public static void addClientPool(String SID, int poolsize, Properties
properties) {
}
public static void setTraceLevel(int level) {
}
public static JCO.Client getClient(String key) {
return null;
}
public static void releaseClient(JCO.Client client) {
}
public static void removeClientPool(String key) {
}
public static JCO.PoolManager getClientPoolManager() {
return null;
}
public static class PoolManager {
public static JCO.Pool getPool(String name) {
return null;
}
}
public static class Pool {
public final void setTrace(boolean trace) {
}
}
public static class Function {
public JCO.ParameterList getImportParameterList() {
return null;
}
public JCO.ParameterList getExportParameterList() {
return null;
}
public JCO.ParameterList getTableParameterList() {
return null;
}
public String getName() {
return null;
}
}
public static class ParameterList extends Record {
}
public static class Attributes {
}
public static class Throughput {
}
public static class Repository implements IRepository {
public Repository (String s, JCO.Client client) {
}
public IFunctionTemplate getFunctionTemplate(String name) {
return null;
}
}
public static class Record {
public String getName(int index) {
return null;
}
public final JCO.Field getField(int index) {
return null;
}
public final JCO.Field getField(String name) {
return null;
}
public String getString(int index) {
return null;
}
public JCO.Structure getStructure(int index) {
return null;
}
public JCO.Structure getStructure(String name) {
return null;
}
public JCO.Table getTable(int index) {
return null;
}
public JCO.Table getTable(String name) {
return null;
}
public int getFieldCount() {
return -1;
}
}
public static class Field {
public boolean isStructure() {
return false;
}
public void setValue(String value) throws JCO.ConversionException {
}
}
public static class Table extends Record {
public void appendRow() {
}
public final int getNumRows() {
return -1;
}
public void setRow(int pos) {
}
}
public static class Structure extends Record {
}
public static class AbapException extends Throwable {
public final String getKey() {
return null;
}
}
public static class ConversionException extends Throwable {
}
public static class Client {
public void abort(String message) {
}
public void connect() {
}
public Object clone() {
return null;
}
public void disconnect() {
}
public void execute(JCO.Function function) {
}
public void execute(String name,
JCO.ParameterList input,
JCO.ParameterList output) {
}
public void execute(String name,
JCO.ParameterList input,
JCO.ParameterList output,
JCO.ParameterList tables) {
}
public void execute(JCO.Function function,
java.lang.String tid) {
}
public void execute(JCO.Function function,
String tid,
String queue) {
}
public void execute(JCO.Function function,
String tid,
String queue,
int pos) {
}
public void execute(String name,
JCO.ParameterList input,
JCO.ParameterList tables,
String tid) {
}
public void execute(String name,
JCO.ParameterList input,
JCO.ParameterList tables,
String tid,
String queue) {
}
public void execute(String name,
JCO.ParameterList input,
JCO.ParameterList tables,
String tid,
String queue,
int pos) {
}
public String createTID() {
return null;
}
public void confirmTID(String tid) {
}
public final void ping() {
}
public boolean getAbapDebug() {
return false;
}
public String getASHost() {
return null;
}
public JCO.Attributes getAttributes() {
return null;
}
public String getClient() {
return null;
}
public String getGroup() {
return null;
}
public String getGWHost() {
return null;
}
public String getGWServ() {
return null;
}
public String getLanguage() {
return null;
}
public String getMSHost() {
return null;
}
public String[][] getPropertyInfo() {
return null;
}
public int getSapGui() {
return -1;
}
public byte getState() {
return 0;
}
public String getSystemID() {
return null;
}
public String getSystemNumber() {
return null;
}
public String getTPName() {
return null;
}
public boolean getTrace() {
return false;
}
public URL getURL() {
return null;
}
public String getUser() {
return null;
}
public boolean isAlive() {
return false;
}
public void setAbapDebug(boolean debug) {
}
public void setProperty(String key, String value) {
}
public void setSapGui(int use_sapgui) {
}
public void setTrace(boolean trace) {
}
public final Properties getProperties() {
return null;
}
public final String getProperty(String key) {
return null;
}
public boolean isValid() {
return false;
}
public void setThroughput(JCO.Throughput throughput) {
}
}
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/transformation/Web3RfcTransformer.java
Index: Web3RfcTransformer.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.transformation;
import com.sap.mw.jco.IFunctionTemplate;
import com.sap.mw.jco.JCO;
import org.apache.cocoon.components.web3.Web3Client;
import org.apache.cocoon.components.web3.Web3DataSource;
import org.apache.cocoon.components.web3.Web3Streamer;
import org.apache.cocoon.components.web3.Web3;
import java.util.Map;
import java.util.HashMap;
import org.apache.cocoon.environment.SourceResolver;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.avalon.excalibur.pool.Poolable;
import org.apache.avalon.excalibur.pool.Recyclable;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
* TBD
* @author <a href="mailto:[EMAIL PROTECTED]>Michael Gerzabek</a>
* @version 1.0, 21. Oct. 2002
*/
public class Web3RfcTransformer extends AbstractTransformer
implements Composable, Disposable, Configurable, Poolable, Recyclable {
/** The component manager instance */
protected ComponentManager manager = null;
protected Web3DataSource web3source = null;
protected Web3Client connection = null;
protected JCO.Repository repository = null;
protected IFunctionTemplate functionT = null;
protected JCO.Function function = null;
protected JCO.ParameterList importParameterList = null;
protected JCO.ParameterList tablesParameterList = null;
protected JCO.Record theRecord = null;
protected JCO.Field fillMe = null;
protected AttributesImpl attributes = new AttributesImpl();
protected int startcount = 0;
protected boolean error = false;
protected String backend = null;
protected String default_backend = null;
protected String streamer = null;
protected HashMap tags = new HashMap();
public void setup(SourceResolver resolver, Map objectModel,
String source, Parameters parameters)
throws SAXException {
try {
backend = parameters.getParameter("system");
}
catch (Exception x) {
if ( null == backend ) {
getLogger().warn("No backend configured! Try to use
configuration");
backend = default_backend;
}
}
}
public void compose(ComponentManager manager) {
this.manager = manager;
initTags();
}
public void configure(final Configuration configuration)
throws ConfigurationException {
this.default_backend =
configuration.getChild("system").getValue(null);
}
public void recycle() {
this.connection = null;
this.repository = null;
this.functionT = null;
this.function = null;
this.importParameterList = null;
this.tablesParameterList = null;
this.theRecord = null;
this.backend = null;
this.streamer = null;
this.error = false;
this.startcount = 0;
}
/** Free all ressources */
public void dispose() {
this.recycle();
this.manager = null;
this.attributes = null;
this.web3source = null;
this.tags = null;
}
/**
* Receive notification of the beginning of a document.
*/
public void startDocument()
throws SAXException {
if ( null != super.contentHandler ) {
super.contentHandler.startDocument();
}
}
/**
* Receive notification of the end of a document.
*/
public void endDocument()
throws SAXException {
if ( null != super.contentHandler) {
super.contentHandler.endDocument();
}
}
/**
* Receive notification of the beginning of an element.
*/
public void startElement(String uri, String loc, String raw, Attributes a)
throws SAXException {
if ( Web3.URI.equals( uri ) && !this.error ) {
switch ( Integer.parseInt( (String) this.tags.get( loc ))) {
case INCLUDE_ELEM:
ComponentSelector r3sc = null;
try {
r3sc = (ComponentSelector)
this.manager.lookup ( Web3DataSource.ROLE +
"Selector");
this.web3source = (Web3DataSource) r3sc.select(
this.backend );
this.connection = this.web3source.getWeb3Client();
this.repository = (JCO.Repository)
this.connection.getRepository();
this.functionT = this.repository.getFunctionTemplate(
a.getValue( Web3.INCLUDE_NAME_ATTR ) );
this.streamer = (null == a.getValue(
Web3.INCLUDE_CLASS_ATTR )) ?
"default" : a.getValue( Web3.INCLUDE_CLASS_ATTR );
this.function = this.functionT.getFunction();
}
catch (Exception ex) {
String error = "Problems getting client for backend:
'"
+ this.backend + "'";
getLogger().error (error, ex);
super.contentHandler.startElement(uri,
Web3.PROCESSING_X_ELEM,
Web3.PROCESSING_X_ELEM, a);
super.contentHandler.characters(error.toCharArray(),
0,
error.length());
super.contentHandler.endElement(uri,
Web3.PROCESSING_X_ELEM,
Web3.PROCESSING_X_ELEM);
this.error = true;
}
finally {
this.manager.release ( r3sc );
}
break;
case IMPORT_ELEM:
this.importParameterList =
this.function.getImportParameterList();
this.theRecord = this.importParameterList;
break;
case FIELD_ELEM:
this.fillMe = this.theRecord.getField(
a.getValue( Web3.FIELD_NAME_ATTR ));
break;
case STRUCTURE_ELEM:
this.theRecord = this.importParameterList.getStructure(
a.getValue( Web3.STRUCTURE_NAME_ATTR ));
break;
case TABLES_ELEM:
this.tablesParameterList =
this.function.getTableParameterList();
break;
case TABLE_ELEM:
this.theRecord = this.tablesParameterList.getTable(
a.getValue( Web3.TABLE_NAME_ATTR ));
break;
case ROW_ELEM:
if (null != this.theRecord) {
try {
JCO.Table tmpTable = (JCO.Table) this.theRecord;
tmpTable.appendRow();
}
catch (ClassCastException x) {
getLogger().error("Not a table! " +
x.getMessage(), x);
}
}
break;
default:
getLogger().error("Invalid element " + loc);
}
}
else if (super.contentHandler != null) {
super.contentHandler.startElement(uri, loc, raw, a);
}
}
/**
* Receive notification of the end of an element.
*/
public void characters(char c[], int start, int len)
throws SAXException {
String theValue = new String(c, start, len).trim();
if ( ( null != this.fillMe ) && ( !"".equals(theValue) )) {
try {
this.fillMe.setValue( theValue );
this.fillMe = null;
if( getLogger().isDebugEnabled() ) {
getLogger().debug("set value = " + theValue);
}
}
catch (JCO.ConversionException x) {
getLogger().error( x.getMessage(), x);
}
}
else {
if (super.contentHandler != null) {
super.contentHandler.characters(c, start, len);
}
}
}
/**
* Receive notification of the end of an element.
*/
public void endElement(String uri, String loc, String raw)
throws SAXException
{
if ( Web3.URI.equals(uri) && !this.error ) {
switch ( Integer.parseInt( (String) this.tags.get( loc ))) {
case INCLUDE_ELEM:
Web3Streamer w3s = null;
ComponentSelector streamerSelector = null;
try {
this.connection.execute( this.function );
streamerSelector =
(ComponentSelector)
this.manager.lookup( Web3Streamer.ROLE +
"Selector" );
w3s = (Web3Streamer) streamerSelector.select(
this.streamer );
w3s.stream( this.function, super.contentHandler );
}
catch (Exception x) {
this.attributes.clear();
super.contentHandler.startElement(uri,
Web3.ABAP_EXCEPTION_ELEM,
Web3.ABAP_EXCEPTION_ELEM, this.attributes);
super.contentHandler.characters(x.getMessage
().toCharArray(),
0, x.getMessage ().length());
super.contentHandler.endElement(uri,
Web3.ABAP_EXCEPTION_ELEM,
Web3.ABAP_EXCEPTION_ELEM);
getLogger().error(x.getMessage(), x);
}
finally {
this.web3source.releaseWeb3Client( this.connection );
if ( null != streamerSelector ) {
streamerSelector.release( w3s );
}
manager.release( streamerSelector );
}
this.connection = null;
this.repository = null;
this.functionT = null;
this.function = null;
this.importParameterList = null;
this.tablesParameterList = null;
this.theRecord = null;
break;
case STRUCTURE_ELEM:
this.theRecord = this.importParameterList;
break;
}
}
else if (super.contentHandler != null) {
super.contentHandler.endElement(uri,loc,raw);
}
}
protected final static int INCLUDE_ELEM = 1;
protected final static int IMPORT_ELEM = 2;
protected final static int EXPORT_ELEM = 3;
protected final static int TABLES_ELEM = 4;
protected final static int FIELD_ELEM = 5;
protected final static int ROW_ELEM = 6;
protected final static int STRUCTURE_ELEM = 7;
protected final static int TABLE_ELEM = 8;
protected void initTags() {
this.tags.put( Web3.INCLUDE_ELEM, "1" );
this.tags.put( Web3.IMPORT_ELEM, "2" );
this.tags.put( Web3.EXPORT_ELEM, "3" );
this.tags.put( Web3.TABLES_ELEM, "4" );
this.tags.put( Web3.FIELD_ELEM, "5" );
this.tags.put( Web3.ROW_ELEM, "6" );
this.tags.put( Web3.STRUCTURE_ELEM, "7" );
this.tags.put( Web3.TABLE_ELEM, "8" );
}
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/Web3.java
Index: Web3.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3;
/**
* Constants in Web3.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:19 $
*/
public interface Web3 {
String URI = "http://efp.cc/Web3-Rfc/2.0";
String INCLUDE_ELEM = "include";
String INCLUDE_NAME_ATTR = "name";
String INCLUDE_CLASS_ATTR = "streamer";
String IMPORT_ELEM = "import";
String EXPORT_ELEM = "export";
String TABLES_ELEM = "tables";
String FIELD_ELEM = "field";
String FIELD_NAME_ATTR = "name";
String ROW_ELEM = "row";
String ROW_ID_ATTR = "id";
String STRUCTURE_ELEM = "structure";
String STRUCTURE_NAME_ATTR = "name";
String TABLE_ELEM = "table";
String TABLE_NAME_ATTR = "name";
String ABAP_EXCEPTION_ELEM = "abap-exception";
String PROCESSING_X_ELEM = "processing-exception";
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/Web3Client.java
Index: Web3Client.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3;
import org.apache.avalon.framework.component.Component;
import com.sap.mw.jco.IRepository;
import com.sap.mw.jco.JCO.Client;
import com.sap.mw.jco.JCO.Function;
/**
* The standard interface for R3Clients in Web3.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:19 $
*/
public interface Web3Client extends Component {
String ROLE = "org.apache.cocoon.components.web3.Web3Client";
/**
* Releases the Connection to the backend
*/
void releaseClient ();
/**
* Initialize the client
*/
void initClient (Client client);
/**
* Get a Client Repository
*/
IRepository getRepository ();
/**
* Execute an Abab function
*/
void execute(Function function);
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/Web3DataSource.java
Index: Web3DataSource.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.activity.Initializable;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.component.Composable;
import java.lang.Exception;
/**
* The standard interface for R3DataSources in Web3.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:19 $
*/
public interface Web3DataSource extends Component, Configurable,
Initializable, Disposable, Composable {
String ROLE = "org.apache.cocoon.components.web3.Web3DataSource";
/**
* Gets the Connection to the backend
*/
Web3Client getWeb3Client() throws Exception;
void releaseWeb3Client( Web3Client client );
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/Web3Streamer.java
Index: Web3Streamer.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3;
import com.sap.mw.jco.JCO;
import org.xml.sax.SAXException;
import org.xml.sax.ContentHandler;
import org.apache.avalon.framework.component.Component;
/**
* The standard interface for Web3Producer.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:19 $
*/
public interface Web3Streamer extends Component {
String ROLE = "org.apache.cocoon.components.web3.Web3Streamer";
void stream(JCO.Function function,
ContentHandler contentHandler) throws SAXException;
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/impl/DefaultWeb3StreamerImpl.java
Index: DefaultWeb3StreamerImpl.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3.impl;
import com.sap.mw.jco.JCO;
import org.apache.cocoon.components.web3.Web3Streamer;
import org.apache.cocoon.components.web3.Web3;
import org.apache.avalon.excalibur.pool.Poolable;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
import org.xml.sax.ContentHandler;
/**
* TBD
* @author <a href="mailto:[EMAIL PROTECTED]>Michael Gerzabek</a>
* @version 1.0, 21. Oct. 2002
*/
public class DefaultWeb3StreamerImpl implements Web3Streamer, Poolable {
public void stream(JCO.Function function,
ContentHandler contentHandler) throws SAXException {
AttributesImpl attributes = new AttributesImpl();
attributes.clear();
attributes.addAttribute( Web3.URI, Web3.INCLUDE_NAME_ATTR,
Web3.INCLUDE_NAME_ATTR, "CDATA", function.getName().toUpperCase()
);
attributes.clear();
contentHandler.startElement( Web3.URI, Web3.INCLUDE_ELEM,
Web3.INCLUDE_ELEM, attributes );
contentHandler.startElement( Web3.URI, Web3.IMPORT_ELEM,
Web3.IMPORT_ELEM, attributes );
streamParameterList( function.getImportParameterList(),
contentHandler );
contentHandler.endElement( Web3.URI, Web3.IMPORT_ELEM,
Web3.IMPORT_ELEM );
attributes.clear();
contentHandler.startElement( Web3.URI, Web3.EXPORT_ELEM,
Web3.EXPORT_ELEM, attributes );
streamParameterList( function.getExportParameterList(),
contentHandler );
contentHandler.endElement( Web3.URI, Web3.EXPORT_ELEM,
Web3.EXPORT_ELEM );
JCO.ParameterList tablesParameterList =
function.getTableParameterList();
attributes.clear();
contentHandler.startElement( Web3.URI, Web3.TABLES_ELEM,
Web3.TABLES_ELEM, attributes );
if (null != tablesParameterList) {
for (int i = 0; i < tablesParameterList.getFieldCount(); i++) {
attributes.clear();
attributes.addAttribute( Web3.URI, Web3.TABLE_NAME_ATTR,
Web3.TABLE_NAME_ATTR, "CDATA",
tablesParameterList.getName(i).toUpperCase() );
contentHandler.startElement( Web3.URI, Web3.TABLE_ELEM,
Web3.TABLE_ELEM, attributes );
JCO.Table sapTable = tablesParameterList.getTable(i);
if (null != sapTable) {
for (int j = 0; j < sapTable.getNumRows(); j++) {
sapTable.setRow(j);
attributes.clear();
attributes.addAttribute(Web3.URI, Web3.ROW_ID_ATTR,
Web3.ROW_ID_ATTR, "CDATA", "" + (j + 1));
contentHandler.startElement(Web3.URI, Web3.ROW_ELEM,
Web3.ROW_ELEM, attributes);
for (int k = 0; k < sapTable.getFieldCount(); k++) {
attributes.clear();
attributes.addAttribute(Web3.URI,
Web3.FIELD_NAME_ATTR, Web3.FIELD_NAME_ATTR,
"CDATA", sapTable.getName(k).toUpperCase());
contentHandler.startElement(Web3.URI,
Web3.FIELD_ELEM, Web3.FIELD_ELEM, attributes);
String theValue = sapTable.getString(k);
contentHandler.characters(theValue.toCharArray(),
0,
theValue.length());
contentHandler.endElement(Web3.URI,
Web3.FIELD_ELEM,
Web3.FIELD_ELEM);
}
contentHandler.endElement(Web3.URI, Web3.ROW_ELEM,
Web3.ROW_ELEM);
}
contentHandler.endElement(Web3.URI, Web3.TABLE_ELEM,
Web3.TABLE_ELEM);
}
}
}
contentHandler.endElement(Web3.URI, Web3.TABLES_ELEM,
Web3.TABLES_ELEM);
contentHandler.endElement( Web3.URI, Web3.INCLUDE_ELEM,
Web3.INCLUDE_ELEM );
}
protected void streamParameterList(JCO.ParameterList pList,
ContentHandler contentHandler) throws SAXException {
AttributesImpl attributes = new AttributesImpl();
attributes.clear();
if (pList != null) {
for (int i = 0; i < pList.getFieldCount(); i++) {
JCO.Field theField = pList.getField(i);
if (theField.isStructure()) {
JCO.Structure sapStructure =
pList.getStructure(pList.getName(i));
attributes.clear();
attributes.addAttribute(Web3.URI,
Web3.STRUCTURE_NAME_ATTR,
Web3.STRUCTURE_NAME_ATTR, "CDATA",
pList.getName(i).toUpperCase());
contentHandler.startElement(Web3.URI,
Web3.STRUCTURE_ELEM,
Web3.STRUCTURE_ELEM, attributes);
for (int j = 0; j < sapStructure.getFieldCount(); j++) {
attributes.clear();
attributes.addAttribute(Web3.URI,
Web3.FIELD_NAME_ATTR,
Web3.FIELD_NAME_ATTR, "CDATA",
sapStructure.getName(j).toUpperCase());
contentHandler.startElement(Web3.URI,
Web3.FIELD_ELEM,
Web3.FIELD_ELEM, attributes);
String theValue = sapStructure.getString(j);
contentHandler.characters(theValue.toCharArray(), 0,
theValue.length());
contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM,
Web3.FIELD_ELEM);
}
contentHandler.endElement(Web3.URI, Web3.STRUCTURE_ELEM,
Web3.STRUCTURE_ELEM);
}
else {
attributes.clear();
attributes.addAttribute(Web3.URI, Web3.FIELD_NAME_ATTR,
Web3.FIELD_NAME_ATTR, "CDATA",
pList.getName(i).toUpperCase());
contentHandler.startElement(Web3.URI, Web3.FIELD_ELEM,
Web3.FIELD_ELEM, attributes);
String theValue = pList.getString(i);
contentHandler.characters(theValue.toCharArray(), 0,
theValue.length());
contentHandler.endElement(Web3.URI, Web3.FIELD_ELEM,
Web3.FIELD_ELEM);
}
}
}
}
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/impl/Web3ClientImpl.java
Index: Web3ClientImpl.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3.impl;
import org.apache.cocoon.components.web3.Web3Client;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.excalibur.pool.Recyclable;
import org.apache.avalon.excalibur.pool.Poolable;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.IRepository;
import java.net.URL;
import java.util.Properties;
import java.util.Date;
/**
* The standard interface for R3Clients in Web3.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:19 $
*/
public class Web3ClientImpl extends AbstractLogEnabled
implements Web3Client, Disposable, Recyclable, Poolable {
protected JCO.Client client = null;
protected String repository = null;
public void initClient(JCO.Client client) {
this.client = client;
this.repository = "" + (new Date ()).getTime();
}
public void releaseClient() {
JCO.releaseClient(this.client);
this.client = null;
}
public void dispose() {
this.client = null;
this.repository = null;
}
public IRepository getRepository() {
if (null != this.repository) {
return new JCO.Repository (this.repository, this.client);
}
return null;
}
public void abort(String message) {
this.client.abort (message);
}
public Object clone() {
return null;
}
public void confirmTID(String tid) {
this.client.confirmTID (tid);
}
public void connect() {
this.client.connect ();
}
public String createTID() {
return this.client.createTID ();
}
public void disconnect() {
this.client.disconnect ();
}
public void execute(JCO.Function function) {
this.client.execute (function);
}
public void execute(JCO.Function function, String tid) {
this.client.execute (function, tid);
}
public void execute(JCO.Function function, String tid, String queue_name)
{
this.client.execute (function, tid, queue_name);
}
public void execute(JCO.Function function, String tid,
String queue_name, int queue_pos) {
this.client.execute (function, tid, queue_name, queue_pos);
}
public void execute(String name, JCO.ParameterList input,
JCO.ParameterList output) {
this.client.execute (name, input, output);
}
public void execute(String name, JCO.ParameterList input,
JCO.ParameterList output, JCO.ParameterList tables) {
this.client.execute (name, input, output, tables);
}
public void execute(String name, JCO.ParameterList input,
JCO.ParameterList tables, String tid) {
this.client.execute (name, input, tables, tid);
}
public void execute(java.lang.String name, JCO.ParameterList input,
JCO.ParameterList tables, String tid,
String queue_name) {
this.client.execute (name, input, tables, tid, queue_name);
}
public void execute(java.lang.String name, JCO.ParameterList input,
JCO.ParameterList tables, String tid,
String queue_name, int queue_pos) {
this.client.execute (name, input, tables, tid, queue_name, queue_pos);
}
public boolean getAbapDebug() {
return this.client.getAbapDebug ();
}
public String getASHost() {
return this.client.getASHost ();
}
public JCO.Attributes getAttributes() {
return this.client.getAttributes ();
}
public String getClient() {
return this.client.getClient ();
}
public String getGroup() {
return this.client.getGroup ();
}
public String getGWHost() {
return this.client.getGWHost ();
}
public String getGWServ() {
return this.client.getGWServ ();
}
public String getLanguage() {
return this.client.getLanguage ();
}
public String getMSHost() {
return this.client.getMSHost ();
}
public String[][] getPropertyInfo() {
return this.client.getPropertyInfo ();
}
public int getSapGui() {
return this.client.getSapGui ();
}
public byte getState() {
return this.client.getState ();
}
public String getSystemID() {
return this.client.getSystemID ();
}
public String getSystemNumber() {
return this.client.getSystemNumber ();
}
public String getTPName() {
return this.client.getTPName ();
}
public boolean getTrace() {
return this.client.getTrace ();
}
public URL getURL() {
return this.client.getURL ();
}
public String getUser() {
return this.client.getUser ();
}
public boolean isAlive() {
return this.client.isAlive ();
}
public void ping() {
this.client.ping ();
}
public void setAbapDebug(boolean debug) {
this.client.setAbapDebug (debug);
}
public void setProperty(String key, String value) {
this.client.setProperty (key, value);
}
public void setSapGui(int use_sapgui) {
this.client.setSapGui (use_sapgui);
}
public void setTrace(boolean trace) {
this.client.setTrace (trace);
}
public final Properties getProperties() {
return this.client.getProperties ();
}
public final String getProperty(String key) {
return this.client.getProperty (key);
}
public boolean isValid() {
return this.client.isValid ();
}
public void setThroughput(JCO.Throughput throughput) {
this.client.setThroughput (throughput);
}
public void recycle() {
this.client = null;
this.repository = null;
}
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/impl/Web3DataSourceImpl.java
Index: Web3DataSourceImpl.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3.impl;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.excalibur.concurrent.Mutex;
import com.sap.mw.jco.JCO;
import com.sap.mw.jco.JCO.PoolManager;
import org.apache.cocoon.components.web3.Web3Client;
import org.apache.cocoon.components.web3.Web3DataSource;
/**
* The Default implementation for R3DataSources in Web3. This uses the
* normal <code>com.sap.mw.jco.JCO</code> classes.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:19 $
*/
public class Web3DataSourceImpl extends AbstractLogEnabled
implements Web3DataSource, ThreadSafe {
protected Web3Properties properties = null;
protected int poolsize = 0;
protected int current_clients = 0;
protected String mySID = null;
protected boolean trace = false;
protected int level = 0;
private static Mutex lock = new Mutex();
protected ComponentManager manager;
public void compose(ComponentManager componentManager) throws
ComponentException {
this.manager = componentManager;
}
/** Configure backend component */
public void configure(final Configuration configuration)
throws ConfigurationException {
if (null != configuration) {
this.properties = new Web3Properties ();
Configuration child = configuration.getChild("pool");
this.trace = child.getAttributeAsBoolean("trace", false);
this.level = child.getAttributeAsInteger("level", 0);
this.mySID = configuration.getAttribute("name");
this.poolsize = child.getAttributeAsInteger("size");
this.properties.put("jco.client.client",
child.getChild("client").getValue());
this.properties.put("jco.client.user",
child.getChild("user").getValue());
this.properties.put("jco.client.passwd",
child.getChild("password").getValue());
this.properties.put("jco.client.ashost",
child.getChild("route").getValue());
this.properties.put("jco.client.sysnr",
child.getChild("system").getValue());
this.properties.put("sap.gateway",
child.getChild("gateway").getValue(""));
this.properties.put("sap.programid",
child.getChild("program-id").getValue(""));
if ( getLogger().isDebugEnabled() ) {
getLogger ().debug ("Configure R3DataSource [mySID="
+ this.mySID );
}
} else {
getLogger ().error ("Couldn't configure Web3DataSource." +
" No configuration provided!");
}
}
/** initialize the component */
public void initialize() throws Exception {
try {
Web3DataSourceImpl.lock.acquire();
JCO.addClientPool( this.mySID, this.poolsize, this.properties );
PoolManager.getPool( this.mySID ).setTrace( this.trace );
JCO.setTraceLevel( this.level );
} catch (Exception ex) {
getLogger ().error ("Couldn't initialize Web3DataSource "
+ this.mySID, ex);
throw new Exception ( ex.getMessage() + this.mySID );
}
finally {
Web3DataSourceImpl.lock.release();
}
}
/** Get the backend client, returns <code>null</code> if there is no more
client in the pool. */
public Web3Client getWeb3Client() throws Exception {
Web3Client theClient = null;
if ( this.current_clients + 1 < this.poolsize ) {
this.current_clients++;
try {
Web3DataSourceImpl.lock.acquire();
theClient = (Web3Client) this.manager.lookup( Web3Client.ROLE
);
theClient.initClient (JCO.getClient(this.mySID));
if ( getLogger().isDebugEnabled() ) {
getLogger ().debug ("returning client " + theClient);
}
} catch (Exception ex){
getLogger ().error ( this.mySID, ex);
throw new Exception ( ex.getMessage() );
} finally {
Web3DataSourceImpl.lock.release();
}
}
return theClient;
}
public void releaseWeb3Client(Web3Client client) {
try {
Web3DataSourceImpl.lock.acquire();
client.releaseClient();
this.current_clients--;
manager.release( client );
}
catch (Exception x) {
getLogger().error( x.getMessage(), x);
}
finally {
Web3DataSourceImpl.lock.release();
}
}
/** Dispose properly of the pool */
public void dispose() {
try {
JCO.removeClientPool(this.mySID);
} catch (Exception ex) {
getLogger ().error ("Web3DataSource: couldn't" +
" return Web3DataSource", ex);
}
this.properties = null;
this.mySID = null;
getLogger ().debug ("Web3DataSource disposed.");
}
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/impl/Web3DataSourceSelectorImpl.java
Index: Web3DataSourceSelectorImpl.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3.impl;
import org.apache.cocoon.components.web3.Web3DataSource;
import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.avalon.framework.component.Composable;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.Configurable;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.logger.LogEnabled;
import org.apache.cocoon.util.ClassUtils;
import java.util.Enumeration;
import java.util.Hashtable;
import org.apache.avalon.excalibur.concurrent.Mutex;
/**
* The Default implementation for R3DataSources in Web3. This uses the
* normal <code>com.sap.mw.jco.JCO</code> classes.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version 1.0, 21. Oct. 2002
*/
public class Web3DataSourceSelectorImpl
extends AbstractLogEnabled
implements ComponentSelector, Disposable, Composable, Configurable,
ThreadSafe {
/** The component manager instance */
protected ComponentManager manager = null;
protected Configuration configuration = null;
private static Hashtable pools = new Hashtable();
private static Mutex lock = new Mutex();
/**
* Set the current <code>ComponentManager</code> instance used by this
* <code>Composable</code>.
*/
public void compose(ComponentManager manager) throws ComponentException
{
this.manager = manager;
}
public void configure(Configuration configuration)
throws ConfigurationException {
if (null != configuration) {
this.configuration = configuration;
} else {
getLogger().error(
"Couldn't configure Web3DataSourceSelector."
+ " No configuration provided!");
}
}
public boolean hasComponent(Object obj) {
return Web3DataSourceSelectorImpl.pools.containsKey(obj);
}
public Component select(Object obj) throws ComponentException {
Web3DataSource pool = null;
try {
Web3DataSourceSelectorImpl.lock.acquire();
if (null != obj) {
if
(Web3DataSourceSelectorImpl.pools.containsKey(obj)) {
pool =
(Web3DataSource)
Web3DataSourceSelectorImpl.pools.get(
obj);
} else {
Configuration a[] =
this.configuration.getChildren("backend"),
c = null;
if (null != a)
for (int i = 0; i < a.length;
i++) {
try {
String s =
a[i].getAttribute("name");
if (null != s
&& s.equals(obj.toString())) {
// a
backend with a name can be defined only once
c =
a[i];
break;
}
} catch
(ConfigurationException x) {
// this
configuration element has no mandatory
//attribute name
}
}
// No configuration for this backend-id
found!
if (null == c) {
return null;
}
Class theClass =
Class.forName(
c.getChild("class").getValue(
"org.apache.cocoon.components.web3.impl.Web3DataSourceImpl"),
true,
ClassUtils.getClassLoader());
pool = (Web3DataSource)
theClass.newInstance();
if (pool instanceof LogEnabled) {
((LogEnabled)
pool).enableLogging(getLogger());
}
pool.compose(this.manager);
pool.configure(c);
pool.initialize();
Web3DataSourceSelectorImpl.pools.put(obj, pool);
}
}
} catch (Exception ex) {
getLogger().error(ex.getMessage(), ex);
throw new ComponentException(ex.getMessage());
} finally {
Web3DataSourceSelectorImpl.lock.release();
}
getLogger().debug("Returning Web3DataSource[" + pool + "]");
return pool;
}
public void release(Component component) {
}
/** Dispose properly of the pool */
public void dispose() {
this.manager = null;
try {
Web3DataSourceSelectorImpl.lock.acquire();
String sid = null;
Web3DataSource pool;
for (Enumeration enum =
Web3DataSourceSelectorImpl.pools.keys();
enum.hasMoreElements();
) {
sid = (String) enum.nextElement();
pool =
(Web3DataSource)
Web3DataSourceSelectorImpl.pools.get(sid);
pool.dispose();
}
Web3DataSourceSelectorImpl.pools.clear();
} catch (Exception ex) {
} finally {
Web3DataSourceSelectorImpl.lock.release();
}
Web3DataSourceSelectorImpl.lock = null;
}
}
1.1
xml-cocoon2/src/blocks/web3/java/org/apache/cocoon/components/web3/impl/Web3Properties.java
Index: Web3Properties.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, 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 Cocoon" 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
[EMAIL PROTECTED]
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 (INCLU-
DING, 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 and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.components.web3.impl;
import java.util.Properties;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.InputStream;
import java.io.IOException;
/**
* Properties helper class.
* @author <a href="mailto:[EMAIL PROTECTED]">Michael Gerzabek</a>
* @version CVS $Revision: 1.1 $ $Date: 2003/01/17 11:33:19 $
*/
public class Web3Properties extends Properties {
ArrayList orderedKeys = new ArrayList();
/** Creates new Properties */
public Web3Properties() {
super();
}
public Web3Properties(Properties defaults) {
super(defaults);
}
public synchronized Iterator getKeysIterator() {
return orderedKeys.iterator();
}
public static Web3Properties load(String name) throws Exception {
Web3Properties props = null;
InputStream is = Web3Properties.class.getResourceAsStream(name);
props = new Web3Properties();
if (null != is) {
props.load(is);
return props;
}
else {
throw new IOException("Properties could not be loaded.");
}
}
public synchronized Object put(Object key, Object value) {
Object obj = super.put(key, value);
orderedKeys.add(key);
return obj;
}
public synchronized Object remove(Object key) {
Object obj = super.remove(key);
orderedKeys.remove(key);
return obj;
}
}
1.1 xml-cocoon2/src/blocks/web3/conf/web3.xconf
Index: web3.xconf
===================================================================
<?xml version="1.0"?>
<xconf xpath="/cocoon" unless="web3">
<web3 logger="core.web3">
<!-- optional
<class>put your DSImpl here</class>
-->
<backend name="indy">
<pool size="10" trace="false" level="0">
<client>100</client>
<user>user</user>
<password>secret</password>
<language>DE</language>
<route>indy</route>
<system>00</system>
<gateway>sapgw00</gateway>
<program-id>USR-GR02</program-id>
</pool>
</backend>
</web3>
<web3-streamer logger="core.web3">
<default name="default" logger="core.web3.default-streamer"/>
</web3-streamer>
<web-client logger="core.web3-client"/>
</xconf>
1.1 xml-cocoon2/src/blocks/web3/conf/web3.xroles
Index: web3.xroles
===================================================================
<?xml version="1.0"?>
<xroles xpath="/role-list" unless="[EMAIL
PROTECTED]'org.apache.cocoon.components.web3.Web3DataSourceSelector']">
<role name="org.apache.cocoon.components.web3.Web3DataSourceSelector"
shorthand="web3"
default-class="org.apache.cocoon.components.web3.impl.Web3DataSourceSelectorImpl"/>
<role name="org.apache.cocoon.components.web3.Web3StreamerSelector"
shorthand="web3-streamer"
default-class="org.apache.avalon.excalibur.component.ExcaliburComponentSelector">
<hint shorthand="default"
class="org.apache.cocoon.components.web3.impl.DefaultWeb3StreamerImpl"/>
<!-- your streamer here -->
</role>
<role name="org.apache.cocoon.components.web3.Web3Client"
shorthand="web-client"
default-class="org.apache.cocoon.components.web3.impl.Web3ClientImpl"/>
</xroles>
1.1 xml-cocoon2/src/blocks/web3/conf/web3.xsamples
Index: web3.xsamples
===================================================================
<?xml version="1.0"?>
<xsamples xpath="/samples" unless="[EMAIL PROTECTED]'web3']">
<group name="web3">
<note>
For the examples of this block to work, an SAP R/3 system and some
SAP java classes need to be available and configured according to the
docs that
can be found in the developer section of the Apache Cocoon
documentation.
</note>
<sample name="Samples" href="web3/samples">
Continue to web3 block samples.
</sample>
</group>
</xsamples>
----------------------------------------------------------------------
In case of troubles, e-mail: [EMAIL PROTECTED]
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]