Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[maven-release-plugin] copy for tag cocoon-servlet-service-impl-1.2.0

  • Loading branch information...
commit 7556622d5be5cb27558b7d5ced1e87e021393d5b 1 parent 3e105ba
@reinhard reinhard authored
Showing with 6,327 additions and 0 deletions.
  1. +201 −0 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/LICENSE.txt
  2. +5 −0 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/NOTICE.txt
  3. +198 −0 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/pom.xml
  4. +105 −0 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/src/changes/changes.xml
  5. +73 −0 ...let-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/CallFrame.java
  6. +61 −0 ...let-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/CallScope.java
  7. +88 −0 ...let-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/CallStack.java
  8. +95 −0 ...ocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/CallFrameHelper.java
  9. +43 −0 ...service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/HttpServletRequestFactoryBean.java
  10. +44 −0 ...ervice-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/HttpServletResponseFactoryBean.java
  11. +47 −0 ...let-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/ServletContextFactoryBean.java
  12. +112 −0 ...rvice-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletscope/ServletScope.java
  13. +95 −0 ...on-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java
  14. +57 −0 ...ce-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/Absolutizable.java
  15. +209 −0 ...on-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java
  16. +114 −0 ...-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/CallStackHelper.java
  17. +143 −0 ...mpl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/DispatcherServlet.java
  18. +93 −0 ...n-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/DynamicProxyRequestHandler.java
  19. +311 −0 ...-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/HttpServletResponseBufferingWrapper.java
  20. +37 −0 ...ervice-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/Mountable.java
  21. +24 −0 ...-1.2.0/src/main/java/org/apache/cocoon/servletservice/NoCallingServletServiceRequestAvailableException.java
  22. +106 −0 ...on-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/RelativeServletConnection.java
  23. +125 −0 ...mpl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/ServletConnection.java
  24. +508 −0 ...cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/ServletServiceContext.java
  25. +46 −0 ...service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/spring/BaseServletContextFactoryBean.java
  26. +127 −0 ...coon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/spring/ServletDecorator.java
  27. +278 −0 ...on-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/spring/ServletFactoryBean.java
  28. +38 −0 ...rvlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/spring/ServletNamespaceHandler.java
  29. +247 −0 ...oon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/url/ServletURLConnection.java
  30. +37 −0 ...-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/url/ServletURLStreamHandler.java
  31. +38 −0 ...t-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/url/ServletURLStreamHandlerFactory.java
  32. +37 −0 ...-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/util/NullServletInputStream.java
  33. +231 −0 ...ocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/util/RequestParameters.java
  34. +69 −0 ...let-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/util/ServletConfigurationWrapper.java
  35. +141 −0 ...n-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/util/ServletContextWrapper.java
  36. +835 −0 ...n-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/util/ServletServiceRequest.java
  37. +279 −0 ...-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/util/ServletServiceResponse.java
  38. +62 −0 ...e-impl/cocoon-servlet-service-impl-1.2.0/src/main/resources/META-INF/cocoon/spring/cocoon-ssf-callstack.xml
  39. +31 −0 ...ice-impl/cocoon-servlet-service-impl-1.2.0/src/main/resources/META-INF/cocoon/spring/cocoon-ssf-context.xml
  40. +27 −0 ...ce-impl/cocoon-servlet-service-impl-1.2.0/src/main/resources/META-INF/cocoon/spring/cocoon-ssf-protocol.xml
  41. +28 −0 ...impl/cocoon-servlet-service-impl-1.2.0/src/main/resources/META-INF/cocoon/spring/cocoon-ssf-servlet-map.xml
  42. +37 −0 ...ocoon-servlet-service-impl-1.2.0/src/main/resources/META-INF/cocoon/spring/cocoon-ssf-urlhandler-advice.xml
  43. +16 −0 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/resources/META-INF/spring.handlers
  44. +16 −0 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/resources/META-INF/spring.schemas
  45. +116 −0 ...ervlet-service-impl-1.2.0/src/main/resources/org/apache/cocoon/servletservice/schema/cocoon-servlet-1.0.xsd
  46. +210 −0 ...-impl-1.2.0/src/test/java/org/apache/cocoon/servletservice/HttpServletResponseBufferingWrapperTestCase.java
  47. +358 −0 ...ervlet-service-impl-1.2.0/src/test/java/org/apache/cocoon/servletservice/ServletServiceContextTestCase.java
  48. +84 −0 ...rvlet-service-impl-1.2.0/src/test/java/org/apache/cocoon/servletservice/util/RequestParametersTestCase.java
  49. +45 −0 ...-service-impl-1.2.0/src/test/java/org/apache/cocoon/servletservice/util/ServletServiceResponseTestCase.java
View
201 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/LICENSE.txt
@@ -0,0 +1,201 @@
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
View
5 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/NOTICE.txt
@@ -0,0 +1,5 @@
+Apache Cocoon
+Copyright 1999-2008 The Apache Software Foundation.
+
+This product includes software developed at
+The Apache Software Foundation (http://www.apache.org/).
View
198 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/pom.xml
@@ -0,0 +1,198 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<!-- Id: pom.xml 638085 2008-03-17 22:01:25Z reinhard $ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <artifactId>cocoon</artifactId>
+ <groupId>org.apache.cocoon</groupId>
+ <version>8</version>
+ <relativePath>../../../parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>cocoon-servlet-service-impl</artifactId>
+ <packaging>jar</packaging>
+ <version>1.2.0</version>
+ <name>Cocoon Servlet Service Implementation</name>
+ <description>
+ The servlet service framework makes it easy to use servlets as Spring components.
+ It also contains functionality so that a servlet service can call other servlet
+ services that it is connected to in the Spring configuration.
+ </description>
+ <url>http://cocoon.apache.org/${docs.m.servlet-service-impl.relPath}</url>
+
+ <properties>
+ <docs.name>${project.name}</docs.name>
+ <docs.version>${docs.m.servlet-service-impl.version}</docs.version>
+ <docs.urlRelativizer>../../../../../</docs.urlRelativizer>
+ </properties>
+
+ <distributionManagement>
+ <site>
+ <id>website</id>
+ <url>${docs.deploymentBaseUrl}/${docs.m.servlet-service-impl.relPath}</url>
+ </site>
+ </distributionManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.cocoon</groupId>
+ <artifactId>cocoon-spring-configurator</artifactId>
+ <version>2.1.0</version>
+ <scope>compile</scope>
+ </dependency>
+ <!-- Spring Framework -->
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-beans</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-context</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-aop</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjweaver</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cocoon</groupId>
+ <artifactId>cocoon-jnet</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <!-- commons -->
+ <dependency>
+ <groupId>commons-collections</groupId>
+ <artifactId>commons-collections</artifactId>
+ </dependency>
+ <!-- test -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>easymock</groupId>
+ <artifactId>easymock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-release-plugin</artifactId>
+ <configuration>
+ <tagBase>https://svn.apache.org/repos/asf/cocoon/tags/cocoon-servlet-service/${project.artifactId}</tagBase>
+ </configuration>
+ </plugin>
+ </plugins>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ <resource>
+ <directory>.</directory>
+ <targetPath>META-INF</targetPath>
+ <includes>
+ <include>LICENSE.txt</include>
+ <include>NOTICE.txt</include>
+ </includes>
+ </resource>
+ </resources>
+ </build>
+
+ <scm>
+ <connection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-servlet-service/cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-servlet-service/cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0</developerConnection>
+ <url>https://svn.apache.org/repos/asf/cocoon/tags/cocoon-servlet-service/cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0</url>
+ </scm>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>project-team</report>
+ <report>dependencies</report>
+ <report>license</report>
+ <report>summary</report>
+ <report>index</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-changes-plugin</artifactId>
+ <reportSets>
+ <reportSet>
+ <reports>
+ <report>changes-report</report>
+ </reports>
+ </reportSet>
+ </reportSets>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <profiles>
+ <profile>
+ <id>daisy</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.daisycms</groupId>
+ <artifactId>daisy-maven-plugin</artifactId>
+ <configuration>
+ <navDocId>1413</navDocId>
+ <collection>cdocs-servlet-service-impl</collection>
+ <skipFirstNavigationDocumentLevel>false</skipFirstNavigationDocumentLevel>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
View
105 cocoon-servlet-service-impl/cocoon-servlet-service-impl-1.2.0/src/changes/changes.xml
@@ -0,0 +1,105 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<!--
+ - See http://maven.apache.org/plugins/maven-changes-plugin/usage.html
+ -
+ - $Id$
+-->
+<document>
+ <body>
+ <release version="1.2.0-SNAPSHOT" date="2008-??-??" description="unreleased">
+ <action dev="reinhard" type="add">
+ ServletUrlConnection correctly implements #getHeaderFields() instead of relying on the NOP implementation of HttpURLConnection.
+ </action>
+ <action dev="gkossakowski" type="fix">
+ Fixed NPE thrown by HttpServletResponseBufferingWrapper and ServletServiceResponse after resetBuffer() method was called.
+ </action>
+ <action dev="gkossakowski" type="update">
+ Java 5 as minimum requirement.
+ </action>
+ <action dev="gkossakowski" type="fix" issue="COCOON-2237">
+ Fixed HttpServletResponseBufferingWrapper implementation so it does not throw IllegalStateException
+ when resestBufferedResponse is being called.
+ </action>
+ <action dev="gkossakowski" type="fix" issue="COCOON-2236">
+ ServletFactoryBean will install JNet handlers before calling init() method
+ of Servlet that is being created. This should make SSF compatible with Cocoon Core 2.2.0 again.
+ </action>
+ </release>
+ <release version="1.1.0" date="2008-08-09" description="released">
+ <action dev="reinhard" type="fix">
+ The dependency on the Cocoon SourceResolver, that introduced a circular dependency with Cocoon 2.2, was
+ removed. The Cocoon SourceResolver was used to resolve URLs in the context-path attribute of a servlet
+ bean definition. After the change the Servlet-Service framework only relies on the default URL handling
+ of the JVM. In order to dynamically support different URLStreamHandlers, it is recommended to use
+ Cocoon JNet.
+ </action>
+ <action dev="reinhard" type="fix">
+ Fix the lastModified() method of the ServletConnection: make sure that there is an existing connection
+ before reading the Last-Modified header
+ </action>
+ <action dev="reinhard" type="add">
+ Add a ServletURLConnection, ServletURLStreamHandler and a ServletURLStreamHandlerFactory to provide
+ support for service: URLs.
+ </action>
+ <action dev="gkossakowski" type="fix" issue="COCOON-2150">
+ Fixed bug in ServletServiceContext that was responsible for errors on resetting response that was already committed.
+ Now the Servlet-Service framework buffers response but only if 404 status code has been set.
+ This allows to reset the response safely.
+ </action>
+ </release>
+ <release version="1.0.0" date="2008-04-07" description="unreleased">
+ <action dev="gkossakowski" type="update">
+ Made attributes 'mount-path' and 'context-path' of servlet-context tag required.
+ </action>
+ <action dev="reinhard" type="add">
+ The "+" character is not allowed at the end of connection names anymore. Starting
+ Cocoon will fail hard with a RuntimeException if this rule is broken. See
+ org.apache.cocoon.servletservice.spring.ServletDecorator.
+ </action>
+ <action dev="reinhard" type="add" issue="COCOON-2154">
+ Add support for absolute ServetConnections.
+ </action>
+ <action dev="reinhard" type="add" issue="COCOON-1831">
+ The ServletServiceResponse inherits the request attributes, request parameters and the session
+ from the caller.
+ </action>
+ <action dev="gkossakowski" type="add" issue="COCOON-2036" due-to="Alexander Klimetschek" due-to-email="alexander.klimetschek@googlemail.com">
+ Throw an exception when circular dependencies in servlet connections are detected.
+ </action>
+ <action dev="gkossakowski" type="fix">
+ DispatcherServlet does not throw an exception if it fails to find suitable servlet for processing incomming request.
+ It returns 404 error and puts information to log about the failure, instead.
+ </action>
+ </release>
+ <release version="1.0.0-RC1" date="2007-10-29" description="released">
+ <action dev="gkossakowski" type="add" issue="COCOON-2038">
+ Implemented true Object Oriented approach for handling servlet calls.
+ This change removes the need for explicit super calls.
+ </action>
+ <action dev="gkossakowski" type="fix" issue="COCOON-1939">
+ Fixed handling of multilevel inheritance that could cause stack overflow.
+ </action>
+ <action dev="gkossakowski" type="fix" issue="COCOON-2121">
+ Fixed bug in DispatcherServlet that caused servlet (blocks) mounted at "/" to be handled improperly.
+ </action>
+ </release>
+ </body>
+</document>
View
73 ...-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/CallFrame.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.callstack;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * Attributes in the call frame and destruction callbacks that should be
+ * executed when the call frame is left.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public class CallFrame {
+ private Map attributes;
+ private Map destructionCallbacks;
+
+ public boolean hasAttribute(String name) {
+ return this.attributes != null && this.attributes.containsKey(name);
+ }
+
+ public Object getAttribute(String name) {
+ return this.attributes != null ? this.attributes.get(name) : null;
+ }
+
+ public void setAttribute(String name, Object value) {
+ if (this.attributes == null) {
+ this.attributes = new HashMap();
+ }
+
+ this.attributes.put(name, value);
+ }
+
+ public Object removeAttribute(String name) {
+ return this.attributes != null ? this.attributes.remove(name) : null;
+ }
+
+ public void registerDestructionCallback(String name, Runnable callback) {
+ if (this.destructionCallbacks == null) {
+ this.destructionCallbacks = new HashMap();
+ }
+
+ this.destructionCallbacks.put(name, callback);
+ }
+
+ void executeDestructionCallbacks() {
+ if (this.destructionCallbacks == null) {
+ return;
+ }
+
+ Iterator i = this.destructionCallbacks.values().iterator();
+ while (i.hasNext()) {
+ ((Runnable) i.next()).run();
+ }
+ }
+
+}
View
61 ...-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/CallScope.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.callstack;
+
+import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.beans.factory.config.Scope;
+
+/**
+ * Stack based scope implementation. It is based on the CallStack and
+ * an object is in scope when it is in the top frame of the stack.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public class CallScope implements Scope {
+
+ public Object get(String name, ObjectFactory objectFactory) {
+ CallFrame frame = CallStack.getCurrentFrame();
+ Object scopedObject = frame.getAttribute(name);
+ if (scopedObject == null) {
+ scopedObject = objectFactory.getObject();
+ frame.setAttribute(name, scopedObject);
+ }
+
+ return scopedObject;
+ }
+
+ public Object remove(String name) {
+ CallFrame frame = CallStack.getCurrentFrame();
+ Object scopedObject = frame.getAttribute(name);
+ if (scopedObject != null) {
+ frame.removeAttribute(name);
+ }
+
+ return scopedObject;
+ }
+
+ public String getConversationId() {
+ // There is no conversation id concept for the call stack
+ return null;
+ }
+
+ public void registerDestructionCallback(String name, Runnable callback) {
+ CallStack.getCurrentFrame().registerDestructionCallback(name, callback);
+ }
+
+}
View
88 ...-service-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/CallStack.java
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.callstack;
+
+import java.util.Stack;
+
+/**
+ * Stack used for storing objects in the current call frame.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public class CallStack {
+
+ /** The call stack */
+ private static final ThreadLocal callStack = new ThreadLocal();
+
+ /**
+ * This hook must be called each time a call frame is entered.
+ */
+ public static void enter() {
+ Stack stack = (Stack) callStack.get();
+ if (stack == null) {
+ stack = new Stack();
+ callStack.set(stack);
+ }
+
+ CallFrame info = new CallFrame();
+ stack.push(info);
+ }
+
+ /**
+ * This hook must be called each time a call frame is left.
+ *
+ * <p>It's the counterpart to the {@link #enter()}
+ * method.</p>
+ */
+ public static void leave() {
+ final Stack stack = (Stack) callStack.get();
+ CallFrame info = (CallFrame) stack.pop();
+ info.executeDestructionCallbacks();
+ }
+
+ /**
+ * Use this method for getting the current call frame
+ * @return a call frame
+ */
+ public static CallFrame getCurrentFrame() {
+ final Stack stack = (Stack) callStack.get();
+ if (stack != null && !stack.isEmpty()) {
+ return (CallFrame) stack.peek();
+ }
+
+ return null;
+ }
+
+ /**
+ * @return the size of the call stack
+ */
+ public static int size() {
+ final Stack stack = (Stack) callStack.get();
+ return stack != null ? stack.size() : 0;
+ }
+
+ /**
+ * Get the frame at the i:th position in the call stack
+ * @param i
+ * @return
+ */
+ public static CallFrame frameAt(int i) {
+ final Stack stack = (Stack) callStack.get();
+ return (CallFrame) (stack != null ? stack.elementAt(i) : null);
+ }
+}
View
95 ...on-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/CallFrameHelper.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.callstack.environment;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cocoon.callstack.CallFrame;
+import org.apache.cocoon.callstack.CallStack;
+
+/**
+ * A set of constants and methods to access the content of the call frame.
+ *
+ * <p>
+ * The call frame is used to pass information about the Request, Response and
+ * Context of the calling environment to components used while the call frame
+ * is active.</p>
+ *
+ * @version $Id$
+ */
+public abstract class CallFrameHelper {
+
+ /** Key for the environment {@link HttpServletRequest} in the call frame. */
+ public final static String REQUEST_OBJECT = "request";
+
+ /** Key for the environment {@link HttpServletResponse} in the call frame. */
+ public final static String RESPONSE_OBJECT = "response";
+
+ /** Key for the environment {@link ServletContext} in the call frame. */
+ public final static String CONTEXT_OBJECT = "context";
+
+ public static final void setEnvironment(HttpServletRequest request, HttpServletResponse response, ServletContext context) {
+ CallFrame frame = CallStack.getCurrentFrame();
+ frame.setAttribute(REQUEST_OBJECT, request);
+ frame.setAttribute(RESPONSE_OBJECT, response);
+ frame.setAttribute(CONTEXT_OBJECT, context);
+ }
+
+ public static final HttpServletRequest getRequest() {
+ CallFrame currentCallFrame = CallStack.getCurrentFrame();
+
+ if(currentCallFrame == null) {
+ return null;
+ }
+
+ return (HttpServletRequest) currentCallFrame.getAttribute(REQUEST_OBJECT);
+ }
+
+ public static final void setRequest(HttpServletRequest request) {
+ CallStack.getCurrentFrame().setAttribute(REQUEST_OBJECT, request);
+ }
+
+ public static final HttpServletResponse getResponse() {
+ CallFrame currentCallFrame = CallStack.getCurrentFrame();
+
+ if(currentCallFrame == null) {
+ return null;
+ }
+
+ return (HttpServletResponse) currentCallFrame.getAttribute(RESPONSE_OBJECT);
+ }
+
+ public static final void setResponse(HttpServletResponse response) {
+ CallStack.getCurrentFrame().setAttribute(RESPONSE_OBJECT, response);
+ }
+
+ public static final ServletContext getContext() {
+ CallFrame currentCallFrame = CallStack.getCurrentFrame();
+
+ if(currentCallFrame == null) {
+ return null;
+ }
+
+ return (ServletContext) currentCallFrame.getAttribute(CONTEXT_OBJECT);
+ }
+
+ public static final void setContext(ServletContext context) {
+ CallStack.getCurrentFrame().setAttribute(CONTEXT_OBJECT, context);
+ }
+}
View
43 ...vice-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/HttpServletRequestFactoryBean.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.callstack.environment;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * {@link FactoryBean} that exposes the {@link HttpServletRequest} in the
+ * current call frame. It will typically be used together with the call scope.
+ *
+ * @version $Id$
+ */
+public final class HttpServletRequestFactoryBean implements FactoryBean {
+
+ public Object getObject() throws Exception {
+ return CallFrameHelper.getRequest();
+ }
+
+ public Class getObjectType() {
+ return HttpServletRequest.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+}
View
44 ...ice-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/HttpServletResponseFactoryBean.java
@@ -0,0 +1,44 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.callstack.environment;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * {@link FactoryBean} that exposes the {@link HttpServletResponse} in the
+ * current call frame. It will typically be used together with the call scope.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public final class HttpServletResponseFactoryBean implements FactoryBean {
+
+ public Object getObject() throws Exception {
+ return CallFrameHelper.getResponse();
+ }
+
+ public Class getObjectType() {
+ return HttpServletResponse.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+}
View
47 ...-service-impl-1.2.0/src/main/java/org/apache/cocoon/callstack/environment/ServletContextFactoryBean.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.callstack.environment;
+
+import javax.servlet.ServletContext;
+
+import org.apache.cocoon.servletservice.ServletServiceContext;
+import org.springframework.beans.factory.FactoryBean;
+
+/**
+ * {@link FactoryBean} that exposes the {@link ServletContext} in the current call
+ * frame. It will typically be used together with the call scope.
+ *
+ * @version $Id$
+ */
+public final class ServletContextFactoryBean implements FactoryBean {
+
+
+ public Object getObject() throws Exception {
+ return CallFrameHelper.getContext();
+ }
+
+ public Class getObjectType() {
+ // A ServletServiceContext rather than a ServletContext is needed to make the
+ // Absolutizable interface available through the ScopedProxyFactoryBean
+ return ServletServiceContext.class;
+ }
+
+ public boolean isSingleton() {
+ return true;
+ }
+
+}
View
112 ...ce-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletscope/ServletScope.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletscope;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+
+import org.springframework.beans.factory.ObjectFactory;
+import org.springframework.beans.factory.config.Scope;
+
+
+/**
+ * Stack based scope implementation. It is based on the CallStack and
+ * an object is in scope when it is in the top frame of the stack.
+ *
+ * @version $Id: CallScope.java 562806 2007-08-05 02:26:41Z vgritsenko $
+ * @since 2.2
+ */
+public class ServletScope implements Scope {
+
+ static private String destructionCallbacksAttributeName = ServletScope.class.getName() + "/destructionCallbacks";
+
+ private ServletContext servletContext;
+
+ public void setServletContext(ServletContext servletContext) {
+ this.servletContext = servletContext;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.config.Scope#get(java.lang.String, org.springframework.beans.factory.ObjectFactory)
+ */
+ public Object get(String name, ObjectFactory objectFactory) {
+ Object scopedObject = servletContext.getAttribute(name);
+ if (scopedObject == null) {
+ scopedObject = objectFactory.getObject();
+ servletContext.setAttribute(name, scopedObject);
+ }
+
+ return scopedObject;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.config.Scope#remove(java.lang.String)
+ */
+ public Object remove(String name) {
+ Object scopedObject = servletContext.getAttribute(name);
+ if (scopedObject != null) {
+ servletContext.removeAttribute(name);
+ }
+
+ return scopedObject;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.config.Scope#getConversationId()
+ */
+ public String getConversationId() {
+ // There is no conversation id concept for the call stack
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.springframework.beans.factory.config.Scope#registerDestructionCallback(java.lang.String, java.lang.Runnable)
+ */
+ public void registerDestructionCallback(String name, Runnable callback) {
+ Map destructionCallbacks = getDestructionCallbacks(servletContext);
+ destructionCallbacks.put(name, callback);
+ }
+
+ /**
+ * @param servletContext
+ * @return the destruction callbacks map that is stored as a attribute of servletContext
+ */
+ private static Map getDestructionCallbacks(ServletContext servletContext) {
+ Map destructionCallbacks = (Map)servletContext.getAttribute(destructionCallbacksAttributeName);
+ if (destructionCallbacks == null) {
+ destructionCallbacks = new HashMap();
+ servletContext.setAttribute(destructionCallbacksAttributeName, destructionCallbacks);
+ }
+ return destructionCallbacks;
+ }
+
+ /**
+ * Executes destruction callbacks of beans from servlet scope. This method should be called once the Servlet that the scope
+ * is tied to is being destroyed.
+ * @param servletContext
+ */
+ public static void executeDestructionCallbacks(ServletContext servletContext) {
+ Map destructionCallbacks = getDestructionCallbacks(servletContext);
+ Iterator i = destructionCallbacks.values().iterator();
+ while (i.hasNext()) {
+ ((Runnable) i.next()).run();
+ }
+ }
+}
View
95 ...servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/AbsoluteServletConnection.java
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+
+import org.apache.cocoon.callstack.environment.CallFrameHelper;
+import org.apache.cocoon.servletservice.util.ServletServiceRequest;
+import org.apache.cocoon.servletservice.util.ServletServiceResponse;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * Create a connection to a servlet service. In order to use it, the fully qualified service name must be available.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public final class AbsoluteServletConnection extends AbstractServletConnection {
+
+ public static String ABSOLUTE_SERVLET_SOURCE_POSTFIX = "+";
+
+ private Servlet servlet;
+
+ /**
+ * Create an absolute connection to a servlet service.
+ *
+ * @param serviceName The fully qualified service name (= the name of the Spring bean).
+ * @param path The requested path of the service.
+ * @param queryString The query parameters formatted as HTTP request query string.
+ */
+ public AbsoluteServletConnection(String serviceName, String path, String queryString) {
+ if (serviceName == null) {
+ throw new IllegalArgumentException("The serviceName parameter must be passed.");
+ }
+ this.context = CallStackHelper.getBaseServletContext();
+ final ApplicationContext applicationContext = WebApplicationContextUtils
+ .getRequiredWebApplicationContext(this.context);
+ try {
+ this.servlet = (Servlet) applicationContext.getBean(serviceName);
+ } catch (ClassCastException cce) {
+ throw new IllegalArgumentException("The service '" + serviceName + "' is not of type "
+ + Servlet.class.getName() + ".");
+ }
+ if (this.servlet == null) {
+ throw new IllegalArgumentException("The service '" + serviceName + "' does not exist.");
+ }
+
+ URI reqUri = null;
+ try {
+ this.uri = new URI(serviceName + ABSOLUTE_SERVLET_SOURCE_POSTFIX, null, path, queryString, null);
+ this.uri = new URI("servlet", this.uri.toASCIIString(), null);
+ reqUri = new URI("servlet", null, path, queryString, null);
+ } catch (URISyntaxException e) {
+ IllegalArgumentException iae = new IllegalArgumentException("Can't create a URI using the passed path '"
+ + path + "' and query string '" + queryString + "' values.");
+ iae.initCause(e);
+ throw iae;
+ }
+ this.request = new ServletServiceRequest(reqUri, CallFrameHelper.getRequest());
+ this.response = new ServletServiceResponse();
+ }
+
+ /**
+ * Perform the actual connect that invokes the servlet service.
+ */
+ protected void performConnect() throws ServletException, IOException {
+ try {
+ CallStackHelper.enterServlet(this.context, this.request, this.response);
+ this.servlet.service(this.request, this.response);
+ } finally {
+ CallStackHelper.leaveServlet();
+ }
+ }
+
+}
View
57 ...impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/Absolutizable.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+/**
+ * By this interface, a {@link ServletServiceContext} provides absolute information
+ * about a mounted servlet service.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public interface Absolutizable {
+
+ /**
+ * Takes the scheme specific part of a servlet service URI (the scheme is the
+ * responsibilty of the ServletSource) and resolve it with respect to the
+ * servlets mount point.
+ *
+ * @param uri relative uri
+ * @return absolutized uri
+ * @throws URISyntaxException
+ */
+ URI absolutizeURI(URI uri) throws URISyntaxException;
+
+ /**
+ * Get the fully qualified servlet service name of a connected service.
+ *
+ * @param connectionName
+ * @return The fully qualified servlet service name of a connected service.
+ */
+ String getServiceName(String connectionName);
+
+ /**
+ * Get the fully qualifed service name.
+ *
+ * @return The fully qualified servlet service name.
+ */
+ String getServiceName();
+
+}
View
209 ...servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/AbstractServletConnection.java
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+
+import org.apache.cocoon.servletservice.util.ServletServiceRequest;
+import org.apache.cocoon.servletservice.util.ServletServiceResponse;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * @version $Id$
+ * @since 1.0.0
+ */
+public abstract class AbstractServletConnection implements ServletConnection {
+
+ /** By default we use the logger for this class. */
+ protected final Log logger = LogFactory.getLog(this.getClass());
+
+ /** Connection request */
+ protected ServletServiceRequest request;
+
+ /** Connection response */
+ protected ServletServiceResponse response;
+
+ /** The current block context */
+ protected ServletContext context;
+
+ /** If already connected */
+ protected boolean connected;
+
+ protected ByteArrayOutputStream requestBody;
+
+ protected InputStream responseBody;
+
+ protected URI uri;
+
+ public void connect() throws IOException, ServletException {
+ // if already connected, do nothing
+ if (this.connected) {
+ return;
+ }
+
+ this.request.setContext(this.context);
+
+ if (this.requestBody != null) {
+ this.request.setMethod("POST");
+ this.request.setInputStream(new ByteArrayInputStream(this.requestBody.toByteArray()));
+ }
+
+ ByteArrayOutputStream os = new ByteArrayOutputStream();
+ this.response.setOutputStream(os);
+
+ try {
+ this.performConnect();
+ this.response.flushBuffer();
+ this.responseBody = new ByteArrayInputStream(os.toByteArray());
+ } finally {
+ os.close();
+ }
+
+ this.connected = true;
+ }
+
+ /**
+ * Access the servlet and fill the response object.
+ *
+ * @throws ServletException
+ * @throws IOException
+ */
+ protected abstract void performConnect() throws ServletException, IOException;
+
+ /**
+ * Return an <code>InputStream</code> object to read from the source.
+ *
+ * @throws IOException
+ * @throws ServletException
+ */
+ public InputStream getInputStream() throws IOException, ServletException {
+ this.connect();
+ return this.responseBody;
+ }
+
+ public void setIfModifiedSince(long ifmodifiedsince) {
+ if (this.connected) {
+ throw new IllegalStateException("Already connected");
+ }
+
+ this.request.setDateHeader("If-Modified-Since", ifmodifiedsince);
+ }
+
+ public long getLastModified() {
+ return this.getDateHeader("Last-Modified", 0);
+ }
+
+ public String getContentType() {
+ return this.getHeaderField("Content-Type");
+ }
+
+ public long getDateHeader(String name, long defaultValue) {
+ try {
+ return this.response.getDateHeader(name);
+ } catch (Exception e) {
+ this.logger.warn("Exception while reading the response header '" + name + "'.");
+ }
+
+ return defaultValue;
+ }
+
+ public String getHeaderField(String name) {
+ try {
+ this.connect();
+ } catch (Exception e) {
+ this.logger.warn("Exception while reading the response header '" + name + "'.");
+ return null;
+ }
+
+ return this.response.getHeader(name);
+ }
+
+ public long getHeaderFieldDate(String name, long defaultValue) {
+ try {
+ return this.response.getDateHeader(name);
+ } catch (Exception e) {
+ this.logger.warn("Exception while reading the response header '" + name + "'.");
+ }
+
+ return defaultValue;
+ }
+
+ public Map getHeaders() {
+ try {
+ this.connect();
+ } catch (Exception e) {
+ this.logger.warn("Exception while reading the response headers.");
+ return null;
+ }
+
+ return this.response.getHeaders();
+ }
+
+ public int getResponseCode() throws IOException {
+ try {
+ this.connect();
+ } catch (ServletException e) {
+ throw new IOException("Could not get response status code");
+ }
+
+ return this.response.getStatus();
+ }
+
+ /**
+ * Returns an output stream that writes as POST to this connection.
+ *
+ * @return an output stream that writes as POST to this connection.
+ * @throws IllegalStateException - if already connected
+ */
+ public OutputStream getOutputStream() throws IllegalStateException {
+ if (this.connected) {
+ throw new IllegalStateException("You cannot write to the connection already connected.");
+ }
+
+ if (this.requestBody == null) {
+ this.requestBody = new ByteArrayOutputStream();
+ }
+ return this.requestBody;
+
+ }
+
+ public URI getURI() {
+ return this.uri;
+ }
+
+ /**
+ * A special exception indicating that there is no servlet context available.
+ */
+ protected static class NoServletContextAvailableException extends RuntimeException {
+
+ private static final long serialVersionUID = 1L;
+
+ public NoServletContextAvailableException(String message) {
+ super(message);
+ }
+ }
+}
View
114 ...pl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/CallStackHelper.java
@@ -0,0 +1,114 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cocoon.callstack.CallFrame;
+import org.apache.cocoon.callstack.CallStack;
+import org.apache.cocoon.callstack.environment.CallFrameHelper;
+
+/**
+ * Helper class used for geting hold on the current servlet service
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public class CallStackHelper {
+
+ /** Key for a value determing wether a call frame contains a super call or not */
+ public final static String SUPER_CALL = "super";
+
+ /**
+ * This hook must be called each time a servlet service is entered.
+ *
+ * <p>This method should never raise an exception, except when the
+ * parameters are not set!</p>
+ *
+ * @throws ServletException if at least one of the parameters is null
+ */
+ public static void enterServlet(ServletContext context, HttpServletRequest request, HttpServletResponse response)
+ throws ServletException {
+ enterServlet(context, request, response, false);
+ }
+
+ /**
+ * This hook must be called each time a super servlet service is entered.
+ *
+ * <p>This method should never raise an exception, except when the
+ * parameters are not set!</p>
+ *
+ * @throws ServletException if at least one of the parameters is null
+ */
+ public static void enterSuperServlet(ServletContext context, HttpServletRequest request, HttpServletResponse response)
+ throws ServletException {
+ enterServlet(context, request, response, true);
+ }
+
+ private static void enterServlet(ServletContext context, HttpServletRequest request, HttpServletResponse response, boolean superCall)
+ throws ServletException {
+ if (null == context) throw new ServletException("The context is not set.");
+ if (null == request) throw new ServletException("The request is not set.");
+ if (null == response) throw new ServletException("The response is not set.");
+
+
+ CallStack.enter();
+ CallStack.getCurrentFrame().setAttribute(SUPER_CALL, Boolean.valueOf(superCall));
+ CallFrameHelper.setContext(context);
+ CallFrameHelper.setRequest(request);
+ CallFrameHelper.setResponse(response);
+ }
+
+ /**
+ * This hook must be called each time a servlet service is left.
+ *
+ * <p>It's the counterpart to the {@link #enterServlet} method.</p>
+ */
+ public static void leaveServlet() {
+ CallStack.leave();
+ }
+
+ /**
+ * Use this method for getting the context that should be used for
+ * resolving a polymorphic servlet protocol call.
+ *
+ * @return a servlet context
+ */
+ public static ServletContext getBaseServletContext() {
+ for (int i = CallStack.size() - 1; i >= 0; i--) {
+ CallFrame frame = CallStack.frameAt(i);
+ if (frame.hasAttribute(SUPER_CALL) && !((Boolean) frame.getAttribute(SUPER_CALL)).booleanValue()) {
+ return (ServletContext) frame.getAttribute(CallFrameHelper.CONTEXT_OBJECT);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Use this method for getting the context that should be used for
+ * resolving a servlet protocol call to a super servlet service.
+ *
+ * @return a servlet context
+ */
+ public static ServletContext getCurrentServletContext() {
+ return CallFrameHelper.getContext();
+ }
+}
View
143 .../cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/DispatcherServlet.java
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.io.IOException;
+import java.lang.reflect.Proxy;
+import java.util.Arrays;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+/**
+ * A servlet that dispatch to managed sevlets from the context Spring container.
+ * It dispatch to servlets that has the property mountPath, and dispatches to the
+ * servlet with the longest prefix of the request pathInfo.
+ *
+ * This servlet will also initialize and destroy all the servlets that it finds
+ * from the context container. This means that there must only be one dispatcher
+ * servlet, otherwise the managed servlets will be initialized several times.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public class DispatcherServlet extends HttpServlet {
+
+ /** By default we use the logger for this class. */
+ private final Log logger = LogFactory.getLog(getClass());
+
+ /**
+ * The startup date of the Spring application context used to setup the {@link #blockServletCollector}.
+ * TODO: Use a better way to reload {@link #blockServletCollector} when RCL is used, see COCOON-2076
+ */
+ private long applicationContextStartDate;
+
+ /** The servlet collector bean */
+ private Map blockServletCollector;
+
+ public void init() throws ServletException {
+ this.log("Block dispatcher was initialized successfully.");
+ }
+
+ protected void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
+ final Map mountableServlets = getBlockServletMap();
+ String path = req.getPathInfo();
+ if (path == null) {
+ path = "";
+ }
+
+ // find the servlet which mount path is the longest prefix of the path info
+ int index = path.length();
+ Servlet servlet = null;
+ while (servlet == null && index != -1) {
+ path = path.substring(0, index);
+ servlet = (Servlet) mountableServlets.get(path);
+ index = path.lastIndexOf('/');
+ }
+ //case when servlet is mounted at "/" must be handled separately
+ servlet = servlet == null ? (Servlet) mountableServlets.get("/") : servlet;
+ if (servlet == null) {
+ String message = "No block for " + req.getPathInfo();
+ res.sendError(HttpServletResponse.SC_NOT_FOUND, message);
+ this.logger.info(message);
+ return;
+ }
+
+ // Create a dynamic proxy class that overwrites the getServletPath and
+ // getPathInfo methods to provide reasonable values in the called servlet
+ // the dynamic proxy implements all interfaces of the original request
+ HttpServletRequest request = (HttpServletRequest) Proxy.newProxyInstance(
+ req.getClass().getClassLoader(),
+ getInterfaces(req.getClass()),
+ new DynamicProxyRequestHandler(req, path));
+
+ if (this.logger.isDebugEnabled()) {
+ this.logger.debug("DispatcherServlet: service servlet=" + servlet +
+ " mountPath=" + path +
+ " servletPath=" + request.getServletPath() +
+ " pathInfo=" + request.getPathInfo());
+ }
+
+ servlet.service(request, res);
+ }
+
+ private void getInterfaces(Set interfaces, Class clazz) {
+ Class[] clazzInterfaces = clazz.getInterfaces();
+ for (int i = 0; i < clazzInterfaces.length; i++) {
+ //add all interfaces extended by this interface or directly
+ //implemented by this class
+ getInterfaces(interfaces, clazzInterfaces[i]);
+ }
+
+ // the superclazz is null if class is instanceof Object, is
+ // an interface, a primitive type or void
+ Class superclazz = clazz.getSuperclass();
+ if (superclazz != null) {
+ //add all interfaces of the superclass to the list
+ getInterfaces(interfaces, superclazz);
+ }
+
+ interfaces.addAll(Arrays.asList(clazzInterfaces));
+ }
+
+ private Class[] getInterfaces(final Class clazz) {
+ Set interfaces = new LinkedHashSet();
+ getInterfaces(interfaces, clazz);
+ return (Class[]) interfaces.toArray(new Class[interfaces.size()]);
+ }
+
+ public Map getBlockServletMap() {
+ ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
+ if (this.blockServletCollector == null || applicationContext.getStartupDate() != this.applicationContextStartDate) {
+ this.applicationContextStartDate = applicationContext.getStartupDate();
+ this.blockServletCollector = (Map) applicationContext.getBean("org.apache.cocoon.servletservice.spring.BlockServletMap");
+ }
+ return blockServletCollector;
+ }
+
+}
View
93 ...ervlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/DynamicProxyRequestHandler.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * A dynamic wrapper for servlet requests that overwrites the
+ * getContextPath, getServletPath and getPathInfo methods to
+ * reflect the mount path of the block servlet.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public class DynamicProxyRequestHandler implements InvocationHandler {
+ private final HttpServletRequest wrapped;
+ private final String mountPath;
+
+ private static final Method getContextPathMethod;
+ private static final Method getServletPathMethod;
+ private static final Method getPathInfoMethod;
+
+ static {
+ getContextPathMethod = getHttpServletRequestMethod("getContextPath");
+ getServletPathMethod = getHttpServletRequestMethod("getServletPath");
+ getPathInfoMethod = getHttpServletRequestMethod("getPathInfo");
+ }
+
+ /**
+ * Helper method for getting methods of the HttpServletRequest interface
+ *
+ * @param name name of the method
+ * @return the method object
+ */
+ static private Method getHttpServletRequestMethod(String name) {
+ Class[] paramTypes = new Class[]{};
+ try {
+ return HttpServletRequest.class.getMethod(name, paramTypes);
+ } catch (SecurityException e) {
+ throw new RuntimeException("could not get method: " +
+ name + " from class: " + HttpServletRequest.class);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("could not get method: " +
+ name + " from class: " + HttpServletRequest.class);
+ }
+ }
+
+ /**
+ * Creates a new request wrapper from a specified proxied request and
+ * the mount path of the block servlet
+ * @param req the request to proxy
+ * @param mountPath the mount path of the servlet
+ */
+ public DynamicProxyRequestHandler(HttpServletRequest req, String mountPath) {
+ this.wrapped = req;
+ this.mountPath = mountPath;
+ }
+
+ /**
+ * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+ */
+ public Object invoke(Object proxy, Method method, Object[] arguments)
+ throws Throwable {
+ if (method.equals(getContextPathMethod)) {
+ return wrapped.getContextPath() + wrapped.getServletPath();
+ } else if (method.equals(getServletPathMethod)) {
+ return mountPath;
+ } else if (method.equals(getPathInfoMethod)) {
+ String pathInfo = wrapped.getPathInfo().substring(mountPath.length());
+ return pathInfo.length() == 0 ? null : pathInfo;
+ } else {
+ return method.invoke(wrapped, arguments);
+ }
+ }
+
+}
View
311 ...rvice-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/HttpServletResponseBufferingWrapper.java
@@ -0,0 +1,311 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletOutputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * <p>THIS IS INTERNAL CLASS OF SERVLET SERVICE FRAMEWORK AND SHOULDN'T BE USED ELSEWHERE!</p>
+ *
+ * <p>This class works in two modes:</p>
+ * <ol>
+ * <li>If status code has been set to value different than <code>404</code> (<code>SC_NOT_FOUND</code>) then this class
+ * acts completely transparently by forwarding all method calls to wrapped response object.</li>
+ * <li>If status code has been set to <code>404</code> then this class acts like a buffer. It buffers all method calls
+ * that would commit wrapped response. Buffering of such calls is being performed in order to assure that wrapped
+ * response can be always reseted if needed. It's worth mentioning the fact that buffer for {@link OutputStream}
+ * returned by {@link #getOutputStream()} is limited to the size specified in
+ * {@link #BUFFER_LIMIT} field.</li>
+ *
+ * <p>Additionally, this class lets the access to statusCode code that has been set through the
+ * {@link #getStatusCode()} method.</p>
+ */
+class HttpServletResponseBufferingWrapper extends HttpServletResponseWrapper {
+
+ /**
+ * Limit for a buffer for output stream returned by {@link #getOutputStream()} method.
+ * This is a hard limit, if exceeded an exception is thrown.
+ */
+ static private int BUFFER_LIMIT = 1024 * 1024; //= 1MB
+ static private String ALREADY_COMMITTED_EXCEPTION = "The response has been already committed.";
+
+ private boolean bufferResponse;
+ private boolean committed;
+ private String message;
+ private int statusCode;
+ private boolean sendError;
+
+ private ForwardingOrLimitingServletOutputStream outputStream;
+ private PrintWriter printWriter;
+
+ public HttpServletResponseBufferingWrapper(HttpServletResponse response) {
+ super(response);
+ resetBufferedResponse();
+ }
+
+ public void addCookie(Cookie cookie) {
+ if (isCommitted())
+ return;
+ super.addCookie(cookie);
+ }
+
+ public void sendError(int sc) throws IOException {
+ if (isCommitted())
+ throw new IllegalStateException(ALREADY_COMMITTED_EXCEPTION);
+ if (sc != SC_NOT_FOUND)
+ super.sendError(sc);
+ else {
+ bufferResponse = true;
+ committed = true;
+ sendError = true;
+ }
+ statusCode = sc;
+ }
+
+ public void sendError(int sc, String msg) throws IOException {
+ if (isCommitted())
+ throw new IllegalStateException(ALREADY_COMMITTED_EXCEPTION);
+ if (sc != SC_NOT_FOUND)
+ super.sendError(sc, msg);
+ else {
+ bufferResponse = true;
+ committed = true;
+ message = msg;
+ sendError = true;
+ }
+ statusCode = sc;
+ }
+
+ public void sendRedirect(String location) throws IOException {
+ if (isCommitted())
+ throw new IllegalStateException(ALREADY_COMMITTED_EXCEPTION);
+ super.sendRedirect(location);
+ statusCode = HttpServletResponse.SC_TEMPORARY_REDIRECT;
+ }
+
+ public void setDateHeader(String name, long date) {
+ if (isCommitted())
+ return;
+ super.setDateHeader(name, date);
+ }
+
+ public void addDateHeader(String name, long date) {
+ if (isCommitted())
+ return;
+ super.addDateHeader(name, date);
+ }
+
+ public void setHeader(String name, String value) {
+ if (isCommitted())
+ return;
+ super.setHeader(name, value);
+ }
+
+ public void addHeader(String name, String value) {
+ if (isCommitted())
+ return;
+ super.addHeader(name, value);
+ }
+
+ public void setIntHeader(String name, int value) {
+ if (isCommitted())
+ return;
+ super.setIntHeader(name, value);
+ }
+
+ public void addIntHeader(String name, int value) {
+ if (isCommitted())
+ return;
+ super.addIntHeader(name, value);
+ }
+
+ public void setStatus(int sc) {
+ if (isCommitted())
+ return;
+ if (sc != SC_NOT_FOUND)
+ super.setStatus(sc);
+ else {
+ bufferResponse = true;
+ }
+ statusCode = sc;
+ }
+
+ public void setStatus(int sc, String sm) {
+ throw new UnsupportedOperationException(
+ "This method has been deprecated.");
+ }
+
+ public ServletOutputStream getOutputStream() throws IOException {
+ if (outputStream == null)
+ this.outputStream = new ForwardingOrLimitingServletOutputStream(BUFFER_LIMIT, super.getOutputStream());
+ return outputStream;
+ }
+
+ public PrintWriter getWriter() throws IOException {
+ if (this.outputStream != null)
+ throw new IllegalStateException(
+ "Output buffer has been already obtained. You can use either output buffer or print writer at one time.");
+ if (this.printWriter == null)
+ this.printWriter = new PrintWriter(new OutputStreamWriter(getOutputStream(), getCharacterEncoding()));
+ return printWriter;
+ }
+
+ public void flushBuffer() throws IOException {
+ if (!bufferResponse)
+ super.flushBuffer();
+ else
+ committed = true;
+ }
+
+ public boolean isCommitted() {
+ return committed || super.isCommitted();
+ }
+
+ public void resetBuffer() {
+ if (isCommitted())
+ throw new IllegalStateException(ALREADY_COMMITTED_EXCEPTION);
+ if (!bufferResponse)
+ super.resetBuffer();
+ else if (outputStream != null)
+ outputStream.reset();
+ }
+
+ public void reset() {
+ if (isCommitted())
+ throw new IllegalStateException(ALREADY_COMMITTED_EXCEPTION);
+ super.reset();
+ bufferResponse = false;
+ message = null;
+ }
+
+ public void flushBufferedResponse() throws IOException {
+ if (bufferResponse) {
+ if (sendError) {
+ try {
+ if (message != null)
+ super.sendError(SC_NOT_FOUND, message);
+ else
+ super.setStatus(SC_NOT_FOUND);
+ } catch (IOException e) {
+ // this should never occur
+ throw new IllegalStateException(
+ "FATAL ERROR! This situation should never occur because it's a job of "
+ + getClass().getName() + " class to "
+ + "prevent such situation.");
+ }
+ } else {
+ if (message != null)
+ super.setStatus(SC_NOT_FOUND, message);
+ else
+ super.setStatus(SC_NOT_FOUND);
+ }
+ }
+
+ //since all data goes through ForwardingOrLimitingServletOutputStream then flushing
+ //must be performed in *every* case now
+ if (this.printWriter != null) {
+ if (this.printWriter.checkError())
+ throw new IOException(
+ "Error occured while writing to printWriter.");
+ this.printWriter.close();
+ } else if (outputStream != null)
+ outputStream.writeTo(super.getOutputStream());
+
+ super.flushBuffer();
+ }
+
+ public void resetBufferedResponse() {
+ if (super.isCommitted())
+ throw new IllegalStateException(ALREADY_COMMITTED_EXCEPTION);
+ if (bufferResponse) {
+ message = null;
+ bufferResponse = false;
+ committed = false;
+ sendError = false;
+ }
+ }
+
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ /**
+ * Simple class acting like a {@link ServletOutputStream} but limiting (if it does not forward) number of bytes that
+ * can be written to the stream.
+ */
+ private class ForwardingOrLimitingServletOutputStream extends ServletOutputStream {
+
+ private Log log = LogFactory.getLog(getClass());
+
+ private int writeLimit;
+ private ByteArrayOutputStream outputStream;
+
+ private OutputStream forwardTo;
+
+ public ForwardingOrLimitingServletOutputStream(int writeLimit, OutputStream forwardTo) {
+ this.writeLimit = writeLimit;
+ this.forwardTo = forwardTo;
+ reset();
+ }
+
+ public void write(int b) throws IOException {
+ HttpServletResponseBufferingWrapper.this.committed = true;
+
+ if (isForwarding())
+ forwardTo.write(b);
+ else {
+ if (this.outputStream.size() < this.writeLimit)
+ this.outputStream.write(b);
+ else {
+ RuntimeException e = new RuntimeException(
+ "The buffering limit (" + writeLimit+ ") has been reached. If you encounter this exception it means that you to "
+ + "write a big response body for response that has error code set as status code. This is always a bad "
+ + "idea and in such case you should reconsider your design.");
+ log.fatal("Fatal error occured in writing to response", e);
+ throw e;
+ }
+ }
+ }
+
+ public void reset() {
+ this.outputStream = new ByteArrayOutputStream(writeLimit);
+ }
+
+ public void writeTo(OutputStream outputStream) throws IOException {
+ if (this.outputStream.size() > 0)
+ this.outputStream.writeTo(outputStream);
+ }
+
+ private boolean isForwarding() {
+ return !HttpServletResponseBufferingWrapper.this.bufferResponse;
+ }
+
+ }
+
+}
View
37 ...ice-impl/cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/Mountable.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+/**
+ * Interface for servlet services that are mounted on a specific path.
+ * The inteface is not needed for using the {@link DispatcherServlet}
+ * as it mounts all servlet beans that has a property named mountPath.
+ * The main use for the interface is to b e able to create an AOP mixin
+ * with an ordinary Java proxy.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public interface Mountable {
+
+ /**
+ * The mount path of the servlet.
+ *
+ * @return servlet mount path
+ */
+ public String getMountPath();
+}
View
24 ...2.0/src/main/java/org/apache/cocoon/servletservice/NoCallingServletServiceRequestAvailableException.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+public class NoCallingServletServiceRequestAvailableException extends RuntimeException {
+
+ public NoCallingServletServiceRequestAvailableException(String message) {
+ super(message);
+ }
+}
View
106 ...servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/RelativeServletConnection.java
@@ -0,0 +1,106 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.servletservice;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+
+import org.apache.cocoon.callstack.environment.CallFrameHelper;
+import org.apache.cocoon.servletservice.util.ServletServiceRequest;
+import org.apache.cocoon.servletservice.util.ServletServiceResponse;
+
+/**
+ * Implementation of a {@link ServletConnection} that gets its content by
+ * invoking the servlet service. It works based on the context of the current
+ * servlet context and its connections.
+ *
+ * @version $Id$
+ * @since 1.0.0
+ */
+public final class RelativeServletConnection extends AbstractServletConnection {
+
+ private String connectionName;
+
+ public RelativeServletConnection(String connectionName, String path, String queryString) {
+ // path validation
+ if (path == null) {
+ throw new IllegalArgumentException("Path musn't be null.");
+ }
+ if (!path.startsWith("/")) {
+ throw new IllegalArgumentException(
+ "The path has to start with a slash '/' because it is always absolute within this servlet context.");
+ }
+
+ this.connectionName = connectionName;
+
+ // setup URI
+ URI reqUri;
+ try {
+ this.uri = new URI((connectionName != null ? connectionName : "local"), null, path, queryString, null);
+ this.uri = new URI("servlet", this.uri.toASCIIString(), null);
+ reqUri = new URI("servlet", null, path, queryString, null);
+ } catch (URISyntaxException e) {
+ String message = "Invalid relative servlet service URI created.";
+ this.logger.error(message, e);
+ throw new RuntimeException(message, e);
+ }
+
+ // lookup the servlet context
+ if (ServletServiceContext.SUPER.equals(this.connectionName)) {
+ // Super calls are resolved relative the current context and ordinary
+ // calls relative to the last non super call in the call chain
+ this.context = CallStackHelper.getCurrentServletContext();
+ } else {
+ this.context = CallStackHelper.getBaseServletContext();
+ }
+ if (this.context == null) {
+ throw new NoServletContextAvailableException(
+ "A servlet connection can only be used with an available servlet context. [" + this.uri
+ + "]");
+ }
+
+ // prepare request and response objects
+ this.request = new ServletServiceRequest(reqUri, CallFrameHelper.getRequest());
+ this.response = new ServletServiceResponse();
+
+ if(this.logger.isDebugEnabled()) {
+ this.logger.debug("Resolving relative servlet URI " + this.uri.toASCIIString());
+ }
+ }
+
+ /**
+ * Perform the actual connect that invokes the servlet service.
+ */
+ protected void performConnect() throws ServletException, IOException {
+ final RequestDispatcher dispatcher;
+ if (this.connectionName == null) {
+ dispatcher = this.context.getRequestDispatcher(null);
+ } else {
+ dispatcher = this.context.getNamedDispatcher(this.connectionName);
+ }
+
+ if (dispatcher == null) {
+ throw new ServletException("No dispatcher for connection" + this.connectionName);
+ }
+ dispatcher.forward(this.request, this.response);
+ }
+
+}
View
125 .../cocoon-servlet-service-impl-1.2.0/src/main/java/org/apache/cocoon/servletservice/ServletConnection.java
@@ -0,0 +1,125 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0