Skip to content

Commit

Permalink
Licence headers and JavaDocs for all classes in modules above (but no…
Browse files Browse the repository at this point in the history
…t including) PrettyFaces 3.x Config
  • Loading branch information
lincolnthree committed Mar 23, 2013
1 parent 79343c2 commit 6f8000f
Show file tree
Hide file tree
Showing 34 changed files with 391 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2013 <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*
* 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.
*/
package org.ocpsoft.rewrite.servlet;

import java.util.Map;
Expand All @@ -6,24 +21,46 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

import org.ocpsoft.rewrite.event.Rewrite;
import org.ocpsoft.rewrite.servlet.spi.RequestParameterProvider;

/**
* An {@link HttpServletRequestWrapper} for the {@link Rewrite} framework
*
* @author <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*/
public abstract class RewriteWrappedRequest extends HttpServletRequestWrapper
{
/**
* Get the current {@link RewriteWrappedRequest}
*/
public static RewriteWrappedRequest getCurrentInstance(ServletRequest request)
{
RewriteWrappedRequest wrapper = (RewriteWrappedRequest) request.getAttribute(RewriteWrappedRequest.class
.getName());
return wrapper;
}

/**
* Set the current {@link RewriteWrappedRequest}
*/
protected static void setCurrentInstance(final RewriteWrappedRequest instance)
{
instance.setAttribute(RewriteWrappedRequest.class.getName(), instance);
}

/**
* Create a new {@link RewriteWrappedRequest}
*/
public RewriteWrappedRequest(HttpServletRequest request)
{
super(request);
}

/**
* Get the current {@link Map} of modifiable {@link HttpServletRequest} parameters.
*
* @see {@link RequestParameterProvider}
*/
abstract public Map<String, String[]> getModifiableParameters();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@
package org.ocpsoft.rewrite.servlet;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;

import org.ocpsoft.rewrite.event.Rewrite;
import org.ocpsoft.rewrite.servlet.config.response.ResponseContentInterceptor;
import org.ocpsoft.rewrite.servlet.config.response.ResponseStreamWrapper;

/**
* A {@link HttpServletResponseWrapper} for the {@link Rewrite} framework.
*
* @author <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*/
public abstract class RewriteWrappedResponse extends HttpServletResponseWrapper
{
protected final static String INSTANCE_KEY = RewriteWrappedResponse.class.getName() + "_instance";
Expand All @@ -38,41 +43,58 @@ public static RewriteWrappedResponse getCurrentInstance(ServletRequest request)

private HttpServletRequest request;

/**
* Set the current {@link RewriteWrappedResponse} instance.
*/
protected void setCurrentInstance(RewriteWrappedResponse instance)
{
request.setAttribute(RewriteWrappedResponse.INSTANCE_KEY, instance);
}

/**
* Create a new {@link RewriteWrappedResponse} instance.
*/
public RewriteWrappedResponse(HttpServletRequest request, HttpServletResponse response)
{
super(response);
this.request = request;
}

/**
* Get the {@link HttpServletRequest} to which this {@link RewriteWrappedResponse} is associated.
*/
public HttpServletRequest getRequest()
{
return request;
}

@Override
public ServletResponse getResponse()
{
return super.getResponse();
}

@Override
public void setResponse(ServletResponse response)
{
super.setResponse(response);
}

/**
* Return <code>true</code> if any {@link ResponseContentInterceptor} instances have been registered on the current
* {@link HttpServletResponse}.
*/
abstract public boolean isResponseContentIntercepted();

/**
* Return <code>true</code> if any {@link ResponseStreamWrapper} instances have been registered on the current
* {@link HttpServletResponse}.
*/
abstract public boolean isResponseStreamWrapped();

/**
* Register a new {@link ResponseContentInterceptor} for the current {@link HttpServletResponse}. This method must be
* called before the {@link HttpServletRequest} has been passed to the underlying application..
*/
abstract public void addContentInterceptor(ResponseContentInterceptor stage);

/**
* Register a new {@link ResponseStreamWrapper} for the current {@link HttpServletResponse}. This method must be
* called before the {@link HttpServletRequest} has been passed to the underlying application..
*/
abstract public void addStreamWrapper(ResponseStreamWrapper wrapper);

/**
* Flush any content that may be buffered in registered {@link ResponseContentInterceptor} instances. This operation
* has no effect if no {@link ResponseContentInterceptor} instances are registered.
*/
abstract public void flushBufferedContent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,41 @@ public class ServletRegistration

private final List<String> mappings = new ArrayList<String>();

/**
* Get the {@link Class} name of this {@link ServletRegistration}.
*/
public String getClassName()
{
return className;
}

/**
* Set the {@link Class} name of this {@link ServletRegistration}.
*/
public void setClassName(String className)
{
this.className = className;
}

/**
* Get the mappings for this {@link ServletRegistration}.
*/
public List<String> getMappings()
{
return mappings;
}

/**
* Add a mapping to this {@link ServletRegistration}.
*/
public void addMapping(String mapping)
{
this.mappings.add(mapping);
}

/**
* Add all given mappings to this {@link ServletRegistration}.
*/
public void addMappings(Collection<String> mappings)
{
this.mappings.addAll(mappings);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.ocpsoft.rewrite.servlet.config;

import org.ocpsoft.rewrite.config.Condition;
import org.ocpsoft.rewrite.config.DefaultConditionBuilder;
import org.ocpsoft.rewrite.context.EvaluationContext;
import org.ocpsoft.rewrite.event.Rewrite;
Expand All @@ -28,8 +29,10 @@
public abstract class HttpCondition extends DefaultConditionBuilder
{
/**
* Evaluate this condition against the given {@link org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite} event. If this condition does not apply to
* the given event, it must return false. If the condition applies and is satisfied, return true.
* Evaluate this {@link Condition} against the given
* {@link org.ocpsoft.rewrite.servlet.http.event.HttpServletRewrite} event. If this condition does not apply to the
* given event, it must return <code>false</code>. If the condition applies and is satisfied, return
* <code>true</code>.
*/
public abstract boolean evaluateHttp(final HttpServletRewrite event, EvaluationContext context);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
/*
* Copyright 2011 <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*
* 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.
*/
package org.ocpsoft.rewrite.servlet.config;

import javax.servlet.ServletContext;

import org.ocpsoft.rewrite.config.ConfigurationProvider;
import org.ocpsoft.rewrite.spi.ConfigurationCacheProvider;

/**
* Configuration cache provider for HTTP/Servlet environments.
* {@link ConfigurationCacheProvider} for HTTP/Servlet environments.
*
* @see org.ocpsoft.rewrite.config.ConfigurationProvider
* @see ConfigurationProvider
* @author <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
import org.ocpsoft.rewrite.config.ConfigurationProvider;

/**
* Configuration provider for HTTP/Servlet environments.
* {@link ConfigurationProvider} for HTTP/Servlet environments.
*
* @see org.ocpsoft.rewrite.config.ConfigurationProvider
* @author <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2011 <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*
* 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.
*/
package org.ocpsoft.rewrite.servlet.event;

import org.ocpsoft.rewrite.context.EvaluationContext;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2011 <a href="mailto:[email protected]">Lincoln Baxter, III</a>
*
* 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.
*/
package org.ocpsoft.rewrite.servlet.http;

import javax.servlet.Servlet;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ public final void rewrite(Rewrite event)
rewriteHttp((HttpServletRewrite) event);
}

/**
* Handle the current {@link HttpServletRewrite} event.
*/
public abstract void rewriteHttp(HttpServletRewrite event);
}
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public void testWhereAPI() throws Exception
.addRule()
.when(new True())
.perform(operation)
.otherwise(operation)
.where("p").bindsTo(El.property("whee.glee")).matches("blah")
.constrainedBy(null).convertedBy(null).transformedBy(null).validatedBy(null)
.where("s").matches("oh").bindsTo(El.property("ee.flee"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public static void initialize(ParameterStore store, Parameterized parameterized)
{
Set<String> names = parameterized.getRequiredParameterNames();
for (String name : names) {
if (!store.contains(name))
store.put(name, new DefaultParameter(name));
store.get(name, new DefaultParameter(name));
}

parameterized.setParameterStore(store);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ private Configuration build(Object context)
List<Rule> list = priorityMap.get(integer);
for (final Rule rule : list) {
result.addRule(rule);
if(rule instanceof RuleBuilder) {

if (rule instanceof RuleBuilder) {
ParameterizedCallback callback = new ParameterizedCallback() {
@Override
public void call(Parameterized parameterized)
Expand All @@ -185,9 +185,7 @@ public void call(Parameterized parameterized)
ParameterStore store = ((RuleBuilder) rule).getParameterStore();

for (String name : names) {
if (!store.contains(name)) {

This comment has been minimized.

Copy link
@didiez

didiez Jul 23, 2020

It seems that the issues #223 and #281 were caused by removing this condition in 6f8000f

store.put(name, new DefaultParameter(name).bindsTo(Evaluation.property(name)));
}
store.get(name, new DefaultParameter(name)).bindsTo(Evaluation.property(name));
}

parameterized.setParameterStore(store);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
*/
public interface ConfigurationRuleBuilderOtherwise extends ConfigurationBuilderRoot
{

/**
* Set the ID for the current {@link Rule}. This may be used in logging and for rule lookup purposes.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class ConfigurationRuleParameterBuilder extends ParameterBuilder<Configur

ConfigurationRuleParameter,
ConfigurationRuleParameterMatches,
ConfigurationRuleParameterPerform,
ConfigurationRuleParameterWhere,
ConfigurationRuleBuilderOtherwise
{
Expand Down

This file was deleted.

Loading

0 comments on commit 6f8000f

Please sign in to comment.