Skip to content

Commit c3635c4

Browse files
committed
Refactored rewrite-impl-servlet into rewrite-config-servlet and rewrite-impl-servlet
1 parent 6355f08 commit c3635c4

150 files changed

Lines changed: 1779 additions & 586 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎annotations-api/pom.xml‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@
1010

1111
<artifactId>rewrite-annotations-api</artifactId>
1212

13-
<properties>
14-
</properties>
15-
1613
<dependencies>
17-
1814
<dependency>
1915
<groupId>org.ocpsoft.rewrite</groupId>
2016
<artifactId>rewrite-api</artifactId>
2117
</dependency>
22-
<dependency>
23-
<groupId>org.ocpsoft.rewrite</groupId>
24-
<artifactId>rewrite-test-harness</artifactId>
25-
<scope>test</scope>
26-
</dependency>
27-
2818
</dependencies>
2919

3020
<build>

‎annotations-impl/pom.xml‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<artifactId>rewrite-annotations-impl</artifactId>
1212

1313
<dependencies>
14-
1514
<dependency>
1615
<groupId>org.ocpsoft.rewrite</groupId>
1716
<artifactId>rewrite-api</artifactId>
@@ -24,22 +23,22 @@
2423
<groupId>org.ocpsoft.rewrite</groupId>
2524
<artifactId>rewrite-annotations-api</artifactId>
2625
</dependency>
26+
<dependency>
27+
<groupId>org.jboss.spec.javax.servlet</groupId>
28+
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
29+
<scope>provided</scope>
30+
</dependency>
31+
2732
<dependency>
2833
<groupId>org.ocpsoft.rewrite</groupId>
2934
<artifactId>rewrite-test-harness</artifactId>
3035
<scope>test</scope>
3136
</dependency>
3237
<dependency>
3338
<groupId>org.ocpsoft.rewrite</groupId>
34-
<artifactId>rewrite-impl-servlet</artifactId>
39+
<artifactId>rewrite-config-servlet</artifactId>
3540
<scope>test</scope>
3641
</dependency>
37-
38-
<dependency>
39-
<groupId>org.jboss.spec.javax.servlet</groupId>
40-
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
41-
<scope>provided</scope>
42-
</dependency>
4342
</dependencies>
4443

4544
<build>

‎api-el/pom.xml‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,24 @@
88
OR CONDITIONS OF ANY KIND, either express or implied. See the License for
99
the specific language governing permissions and limitations under the License. -->
1010

11-
<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/xsd/maven-4.0.0.xsd">
11+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
12+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1213
<modelVersion>4.0.0</modelVersion>
13-
14+
1415
<parent>
1516
<groupId>org.ocpsoft.rewrite</groupId>
1617
<artifactId>rewrite-parent</artifactId>
1718
<version>2.0.0-SNAPSHOT</version>
1819
<relativePath>../</relativePath>
1920
</parent>
20-
21+
2122
<dependencies>
2223
<dependency>
2324
<groupId>org.ocpsoft.rewrite</groupId>
2425
<artifactId>rewrite-api</artifactId>
2526
</dependency>
26-
<dependency>
27-
<groupId>org.ocpsoft.rewrite</groupId>
28-
<artifactId>rewrite-test-harness</artifactId>
29-
<scope>test</scope>
30-
</dependency>
3127
</dependencies>
32-
28+
3329
<artifactId>rewrite-api-el</artifactId>
3430

3531
</project>

‎api-servlet/pom.xml‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
<artifactId>jboss-servlet-api_3.0_spec</artifactId>
2121
<scope>provided</scope>
2222
</dependency>
23-
<dependency>
24-
<groupId>org.ocpsoft.rewrite</groupId>
25-
<artifactId>rewrite-test-harness</artifactId>
26-
<scope>test</scope>
27-
</dependency>
2823
</dependencies>
2924

3025
</project>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.ocpsoft.rewrite.servlet;
2+
3+
import java.util.Map;
4+
5+
import javax.servlet.ServletRequest;
6+
import javax.servlet.http.HttpServletRequest;
7+
import javax.servlet.http.HttpServletRequestWrapper;
8+
9+
public abstract class RewriteWrappedRequest extends HttpServletRequestWrapper
10+
{
11+
public static RewriteWrappedRequest getCurrentInstance(ServletRequest request)
12+
{
13+
RewriteWrappedRequest wrapper = (RewriteWrappedRequest) request.getAttribute(RewriteWrappedRequest.class
14+
.getName());
15+
return wrapper;
16+
}
17+
18+
protected static void setCurrentInstance(final RewriteWrappedRequest instance)
19+
{
20+
instance.setAttribute(RewriteWrappedRequest.class.getName(), instance);
21+
}
22+
23+
public RewriteWrappedRequest(HttpServletRequest request)
24+
{
25+
super(request);
26+
}
27+
28+
abstract public Map<String, String[]> getModifiableParameters();
29+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2012 <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.ocpsoft.rewrite.servlet;
17+
18+
import javax.servlet.ServletRequest;
19+
import javax.servlet.ServletResponse;
20+
import javax.servlet.http.HttpServletRequest;
21+
import javax.servlet.http.HttpServletResponse;
22+
import javax.servlet.http.HttpServletResponseWrapper;
23+
24+
import org.ocpsoft.rewrite.servlet.config.response.ResponseContentInterceptor;
25+
import org.ocpsoft.rewrite.servlet.config.response.ResponseStreamWrapper;
26+
27+
public abstract class RewriteWrappedResponse extends HttpServletResponseWrapper
28+
{
29+
protected final static String INSTANCE_KEY = RewriteWrappedResponse.class.getName() + "_instance";
30+
31+
/**
32+
* Get the current {@link RewriteWrappedResponse} isntance for the current {@link ServletRequest}
33+
*/
34+
public static RewriteWrappedResponse getCurrentInstance(ServletRequest request)
35+
{
36+
return (RewriteWrappedResponse) request.getAttribute(INSTANCE_KEY);
37+
}
38+
39+
private HttpServletRequest request;
40+
41+
protected void setCurrentInstance(RewriteWrappedResponse instance)
42+
{
43+
request.setAttribute(RewriteWrappedResponse.INSTANCE_KEY, instance);
44+
}
45+
46+
public RewriteWrappedResponse(HttpServletRequest request, HttpServletResponse response)
47+
{
48+
super(response);
49+
this.request = request;
50+
}
51+
52+
public HttpServletRequest getRequest()
53+
{
54+
return request;
55+
}
56+
57+
@Override
58+
public ServletResponse getResponse()
59+
{
60+
return super.getResponse();
61+
}
62+
63+
@Override
64+
public void setResponse(ServletResponse response)
65+
{
66+
super.setResponse(response);
67+
}
68+
69+
abstract public boolean isResponseContentIntercepted();
70+
71+
abstract public boolean isResponseStreamWrapped();
72+
73+
abstract public void addContentInterceptor(ResponseContentInterceptor stage);
74+
75+
abstract public void addStreamWrapper(ResponseStreamWrapper wrapper);
76+
77+
abstract public void flushBufferedContent();
78+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright 2010 Lincoln Baxter, III
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.ocpsoft.rewrite.servlet.util;
17+
18+
import java.util.List;
19+
20+
public class Metadata
21+
{
22+
private String encoding = "UTF-8";
23+
private boolean trailingSlash = false;
24+
private boolean leadingSlash = false;
25+
26+
/**
27+
* Return a copy of this Metadata
28+
*/
29+
public Metadata copy()
30+
{
31+
Metadata result = new Metadata();
32+
result.setEncoding(encoding);
33+
result.setTrailingSlash(trailingSlash);
34+
result.setLeadingSlash(leadingSlash);
35+
return result;
36+
}
37+
38+
public String buildURLFromSegments(final List<String> segments)
39+
{
40+
StringBuilder result = new StringBuilder();
41+
42+
if (hasLeadingSlash())
43+
{
44+
result.append("/");
45+
}
46+
47+
/*
48+
* Normal loop for performance reasons
49+
*/
50+
for (int i = 0; i < segments.size(); i++) {
51+
String segment = segments.get(i);
52+
result.append(segment);
53+
if (i < (segments.size() - 1))
54+
{
55+
result.append("/");
56+
}
57+
}
58+
59+
if (hasTrailingSlash() && (!segments.isEmpty() || (result.indexOf("/") < 0)))
60+
{
61+
result.append("/");
62+
}
63+
return result.toString();
64+
}
65+
66+
/*
67+
* Getters & Setters
68+
*/
69+
70+
public String getEncoding()
71+
{
72+
return encoding;
73+
}
74+
75+
public void setEncoding(final String encoding)
76+
{
77+
this.encoding = encoding;
78+
}
79+
80+
public boolean hasTrailingSlash()
81+
{
82+
return trailingSlash;
83+
}
84+
85+
public void setTrailingSlash(final boolean trailingSlash)
86+
{
87+
this.trailingSlash = trailingSlash;
88+
}
89+
90+
public boolean hasLeadingSlash()
91+
{
92+
return leadingSlash;
93+
}
94+
95+
public void setLeadingSlash(final boolean leadingSlash)
96+
{
97+
this.leadingSlash = leadingSlash;
98+
}
99+
}

0 commit comments

Comments
 (0)