Skip to content

Commit d603309

Browse files
committed
Removed unused Parameter argument in Binding APIs
1 parent 6e47818 commit d603309

15 files changed

Lines changed: 51 additions & 72 deletions

File tree

‎api-el/src/main/java/org/ocpsoft/rewrite/el/El.java‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.ocpsoft.rewrite.el.spi.ExpressionLanguageProvider;
3131
import org.ocpsoft.rewrite.event.Rewrite;
3232
import org.ocpsoft.rewrite.exception.RewriteException;
33-
import org.ocpsoft.rewrite.param.Parameter;
3433

3534
/**
3635
* Responsible for binding to EL expressions.
@@ -156,7 +155,7 @@ public ElMethod(final Expression getExpression, final Expression setExpression)
156155
}
157156

158157
@Override
159-
public Object retrieve(final Rewrite event, final EvaluationContext context, Parameter<?> parameter)
158+
public Object retrieve(final Rewrite event, final EvaluationContext context)
160159
{
161160

162161
if (!supportsRetrieval())
@@ -188,8 +187,7 @@ public Object retrieve(final Rewrite event, final EvaluationContext context, Par
188187
}
189188

190189
@Override
191-
public Object submit(final Rewrite event, final EvaluationContext context, Parameter<?> parameter,
192-
final Object value)
190+
public Object submit(final Rewrite event, final EvaluationContext context, final Object value)
193191
{
194192
if (!supportsSubmission())
195193
throw new RewriteException("Method binding expression supports retrieval only [" + getExpression
@@ -249,7 +247,7 @@ public ElProperty(final Expression expression)
249247
}
250248

251249
@Override
252-
public Object retrieve(final Rewrite event, final EvaluationContext context, Parameter<?> parameter)
250+
public Object retrieve(final Rewrite event, final EvaluationContext context)
253251
{
254252
Object value = null;
255253
for (ExpressionLanguageProvider provider : getProviders()) {
@@ -292,8 +290,7 @@ public boolean supportsSubmission()
292290
}
293291

294292
@Override
295-
public Object submit(final Rewrite event, final EvaluationContext context, Parameter<?> parameter,
296-
final Object value)
293+
public Object submit(final Rewrite event, final EvaluationContext context, final Object value)
297294
{
298295
for (ExpressionLanguageProvider provider : getProviders()) {
299296
try
@@ -338,7 +335,7 @@ public ElProperties(final Expression submit, final Expression retrieve)
338335
}
339336

340337
@Override
341-
public Object retrieve(final Rewrite event, final EvaluationContext context, Parameter<?> parameter)
338+
public Object retrieve(final Rewrite event, final EvaluationContext context)
342339
{
343340
Object value = null;
344341
for (ExpressionLanguageProvider provider : getProviders()) {
@@ -381,8 +378,7 @@ public boolean supportsSubmission()
381378
}
382379

383380
@Override
384-
public Object submit(final Rewrite event, final EvaluationContext context, Parameter<?> parameter,
385-
final Object value)
381+
public Object submit(final Rewrite event, final EvaluationContext context, final Object value)
386382
{
387383
for (ExpressionLanguageProvider provider : getProviders()) {
388384
try

‎api-tests/src/test/java/org/ocpsoft/rewrite/bind/BindingsTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testEnqueueSubmissionsExecutesEvaluationEagerly() throws Exception
4747
DefaultParameter parameter = new DefaultParameter("lincoln");
4848
Assert.assertTrue(ParameterUtils.enqueueSubmission(rewrite, context,
4949
parameter.bindsTo(Evaluation.property("lincoln")), "baxter"));
50-
Assert.assertEquals("baxter", Evaluation.property("lincoln").retrieve(rewrite, context, parameter));
50+
Assert.assertEquals("baxter", Evaluation.property("lincoln").retrieve(rewrite, context));
5151
}
5252

5353
@Test

‎api-tests/src/test/java/org/ocpsoft/rewrite/bind/EvaluationBindingTest.java‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.mockito.Mockito;
2525
import org.ocpsoft.rewrite.event.Rewrite;
2626
import org.ocpsoft.rewrite.mock.MockEvaluationContext;
27-
import org.ocpsoft.rewrite.param.DefaultParameter;
2827
import org.ocpsoft.rewrite.servlet.impl.HttpInboundRewriteImpl;
2928
import org.ocpsoft.rewrite.servlet.impl.HttpOutboundRewriteImpl;
3029
import org.ocpsoft.urlbuilder.AddressBuilder;
@@ -54,28 +53,28 @@ public void before()
5453
public void testCannotAccessNonexistentEvaluationContextPropertyInbound() throws Exception
5554
{
5655
MockEvaluationContext context = new MockEvaluationContext();
57-
Evaluation.property("property").retrieve(inbound, context, new DefaultParameter("property"));
56+
Evaluation.property("property").retrieve(inbound, context);
5857
}
5958

6059
@Test(expected = IllegalArgumentException.class)
6160
public void testCannotAccessNonexistentEvaluationContextPropertyOutbound() throws Exception
6261
{
6362
MockEvaluationContext context = new MockEvaluationContext();
64-
Evaluation.property("property").retrieve(outbound, context, new DefaultParameter("property"));
63+
Evaluation.property("property").retrieve(outbound, context);
6564
}
6665

6766
@Test
6867
public void testCanAccessEvaluationContextPropertyInbound() throws Exception
6968
{
7069
MockEvaluationContext context = new MockEvaluationContext();
7170
try {
72-
Evaluation.property("property").retrieve(inbound, context, new DefaultParameter("property"));
71+
Evaluation.property("property").retrieve(inbound, context);
7372
Assert.fail();
7473
}
7574
catch (IllegalArgumentException e) {}
7675

77-
Evaluation.property("property").submit(inbound, context, new DefaultParameter("property"), "Foo");
78-
Object value = Evaluation.property("property").retrieve(inbound, context, new DefaultParameter("property"));
76+
Evaluation.property("property").submit(inbound, context, "Foo");
77+
Object value = Evaluation.property("property").retrieve(inbound, context);
7978

8079
Assert.assertEquals("Foo", value);
8180
}
@@ -85,13 +84,13 @@ public void testCanAccessEvaluationContextPropertyOutbound() throws Exception
8584
{
8685
MockEvaluationContext context = new MockEvaluationContext();
8786
try {
88-
Evaluation.property("property").retrieve(outbound, context, new DefaultParameter("property"));
87+
Evaluation.property("property").retrieve(outbound, context);
8988
Assert.fail();
9089
}
9190
catch (IllegalArgumentException e) {}
9291

93-
Evaluation.property("property").submit(outbound, context, new DefaultParameter("property"), "Foo");
94-
Object value = Evaluation.property("property").retrieve(outbound, context, new DefaultParameter("property"));
92+
Evaluation.property("property").submit(outbound, context, "Foo");
93+
Object value = Evaluation.property("property").retrieve(outbound, context);
9594

9695
Assert.assertEquals("Foo", value);
9796
}

‎api/src/main/java/org/ocpsoft/rewrite/bind/Evaluation.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static Evaluation property(final String property)
4040
}
4141

4242
@Override
43-
public Object submit(final Rewrite event, final EvaluationContext context, Parameter<?> parameter, final Object value)
43+
public Object submit(final Rewrite event, final EvaluationContext context, final Object value)
4444
{
4545
String unconvertedName = getParameterUnconvertedName(property);
4646
if (!context.containsKey(property))
@@ -66,8 +66,7 @@ public Object submit(final Rewrite event, final EvaluationContext context, Param
6666
return null;
6767
}
6868

69-
public Object submitConverted(final Rewrite event, final EvaluationContext context, Parameter<?> parameter,
70-
final Object value)
69+
public Object submitConverted(final Rewrite event, final EvaluationContext context, final Object value)
7170
{
7271
String convertedName = getParameterConvertedName(property);
7372
if (!context.containsKey(property))
@@ -114,7 +113,7 @@ private String getParameterConvertedName(final String parameter)
114113
}
115114

116115
@Override
117-
public Object retrieve(final Rewrite event, final EvaluationContext context, Parameter<?> parameter)
116+
public Object retrieve(final Rewrite event, final EvaluationContext context)
118117
{
119118
return retrieveFromProperty(context, getParameterUnconvertedName(property));
120119
}

‎api/src/main/java/org/ocpsoft/rewrite/bind/Retrieval.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.ocpsoft.rewrite.context.EvaluationContext;
1919
import org.ocpsoft.rewrite.event.Rewrite;
20-
import org.ocpsoft.rewrite.param.Parameter;
2120

2221
/**
2322
* Defines the methods necessary to perform {@link Binding} value retrieval.
@@ -29,5 +28,5 @@ public interface Retrieval
2928
/**
3029
* Retrieve the value from its storage location.
3130
*/
32-
Object retrieve(Rewrite event, EvaluationContext context, Parameter<?> parameter);
31+
Object retrieve(Rewrite event, EvaluationContext context);
3332
}

‎api/src/main/java/org/ocpsoft/rewrite/bind/Submission.java‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
import org.ocpsoft.rewrite.context.EvaluationContext;
1919
import org.ocpsoft.rewrite.event.Rewrite;
20-
import org.ocpsoft.rewrite.param.Parameter;
2120

2221
/**
2322
* Defines the methods necessary to perform, converted, validated {@link Binding} value submission.
@@ -31,5 +30,5 @@ public interface Submission
3130
* Store a value into the designated storage location. Return any value that is produces as a result of this
3231
* operation.
3332
*/
34-
Object submit(Rewrite event, EvaluationContext context, Parameter<?> parameter, Object value);
33+
Object submit(Rewrite event, EvaluationContext context, Object value);
3534
}

‎api/src/main/java/org/ocpsoft/rewrite/config/Invoke.java‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
import org.ocpsoft.rewrite.bind.Submission;
2323
import org.ocpsoft.rewrite.context.EvaluationContext;
2424
import org.ocpsoft.rewrite.event.Rewrite;
25-
import org.ocpsoft.rewrite.param.DefaultParameter;
26-
import org.ocpsoft.rewrite.param.Parameter;
2725
import org.ocpsoft.rewrite.spi.InvocationResultHandler;
2826

2927
/**
30-
* Builds {@link Operation} instances used to directly invoke {@link Binding} submission or
31-
* retrieval on {@link Rewrite} events.
28+
* Builds {@link Operation} instances used to directly invoke {@link Binding} submission or retrieval on {@link Rewrite}
29+
* events.
3230
*
3331
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
3432
*/
@@ -37,7 +35,6 @@ public class Invoke extends DefaultOperationBuilder
3735
private static final Logger log = Logger.getLogger(Invoke.class);
3836
private final Submission submission;
3937
private final Retrieval retrieval;
40-
private final Parameter<?> parameter = new DefaultParameter("");
4138

4239
private Invoke(final Submission submission, final Retrieval retrieval)
4340
{
@@ -52,13 +49,13 @@ public void perform(final Rewrite event, final EvaluationContext context)
5249
Object result = null;
5350
if ((submission == null) && (retrieval != null))
5451
{
55-
result = retrieval.retrieve(event, context, parameter);
52+
result = retrieval.retrieve(event, context);
5653
log.debug("Invoked binding [" + retrieval + "] returned value [" + result + "]");
5754
}
5855
else if (retrieval != null)
5956
{
6057
// TODO convert/validate here?
61-
result = submission.submit(event, context, parameter, retrieval.retrieve(event, context, parameter));
58+
result = submission.submit(event, context, retrieval.retrieve(event, context));
6259
log.debug("Invoked binding [" + submission + "] returned value [" + result + "]");
6360
}
6461
else

‎api/src/main/java/org/ocpsoft/rewrite/util/ParameterUtils.java‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public static boolean enqueueSubmission(final Rewrite event, final EvaluationCon
7575
if (ValueHolderUtil.validates(event, context, parameter.getValidator(), convertedValue))
7676
{
7777
Evaluation evaluation = (Evaluation) binding;
78-
evaluation.submit(event, context, parameter, value);
79-
evaluation.submitConverted(event, context, parameter, convertedValue);
78+
evaluation.submit(event, context, value);
79+
evaluation.submitConverted(event, context, convertedValue);
8080
}
8181
else
8282
return false;
@@ -86,7 +86,7 @@ public static boolean enqueueSubmission(final Rewrite event, final EvaluationCon
8686
Object convertedValue = ValueHolderUtil.convert(event, context, parameter.getConverter(), value);
8787
if (ValueHolderUtil.validates(event, context, parameter.getValidator(), convertedValue))
8888
{
89-
operations.add(new BindingOperation(parameter, binding, convertedValue));
89+
operations.add(new BindingOperation(binding, convertedValue));
9090
}
9191
else
9292
return false;
@@ -120,7 +120,7 @@ public static Object performRetrieval(final Rewrite event, final EvaluationConte
120120
{
121121
if (result == null && !(binding instanceof Evaluation))
122122
{
123-
result = binding.retrieve(event, context, parameter);
123+
result = binding.retrieve(event, context);
124124
}
125125
}
126126

@@ -130,7 +130,7 @@ public static Object performRetrieval(final Rewrite event, final EvaluationConte
130130
{
131131
if (((Evaluation) binding).hasValue(event, context))
132132
{
133-
result = binding.retrieve(event, context, parameter);
133+
result = binding.retrieve(event, context);
134134
}
135135
}
136136
}
@@ -145,21 +145,19 @@ public static Object performRetrieval(final Rewrite event, final EvaluationConte
145145
*/
146146
private static class BindingOperation implements Operation
147147
{
148-
private final Parameter<?> parameter;
149148
private final Binding binding;
150149
private final Object value;
151150

152-
public BindingOperation(final Parameter<?> parameter, final Binding binding, final Object value)
151+
public BindingOperation(final Binding binding, final Object value)
153152
{
154-
this.parameter = parameter;
155153
this.binding = binding;
156154
this.value = value;
157155
}
158156

159157
@Override
160158
public void perform(final Rewrite event, final EvaluationContext context)
161159
{
162-
binding.submit(event, context, parameter, value);
160+
binding.submit(event, context, value);
163161
}
164162

165163
@Override

‎config-servlet/src/main/java/org/ocpsoft/rewrite/servlet/config/bind/Request.java‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@ public RequestParameterBinding(final String parameter)
7474
}
7575

7676
@Override
77-
public Object submit(final Rewrite event, final EvaluationContext context, final Parameter<?> parameter,
78-
final Object value)
77+
public Object submit(final Rewrite event, final EvaluationContext context, final Object value)
7978
{
8079
ServletRequest request = ((ServletRewrite<?, ?>) event).getRequest();
8180
RewriteWrappedRequest wrapper = RewriteWrappedRequest.getCurrentInstance(request);
@@ -97,7 +96,7 @@ public Object submit(final Rewrite event, final EvaluationContext context, final
9796
}
9897

9998
@Override
100-
public Object retrieve(final Rewrite event, final EvaluationContext context, final Parameter<?> parameter)
99+
public Object retrieve(final Rewrite event, final EvaluationContext context)
101100
{
102101
return ((HttpServletRewrite) event).getRequest().getParameter(name);
103102
}
@@ -119,15 +118,14 @@ public RequestAttributeBinding(final String attribute)
119118
}
120119

121120
@Override
122-
public Object submit(final Rewrite event, final EvaluationContext context, final Parameter<?> parameter,
123-
final Object value)
121+
public Object submit(final Rewrite event, final EvaluationContext context, final Object value)
124122
{
125123
((HttpServletRewrite) event).getRequest().setAttribute(name, value);
126124
return null;
127125
}
128126

129127
@Override
130-
public Object retrieve(final Rewrite event, final EvaluationContext context, final Parameter<?> parameter)
128+
public Object retrieve(final Rewrite event, final EvaluationContext context)
131129
{
132130
if (event instanceof HttpServletRewrite)
133131
return ((HttpServletRewrite) event).getRequest().getParameter(name);

‎impl-servlet-tests/src/test/java/org/ocpsoft/rewrite/servlet/config/RequestConstraintTransformTestProvider.java‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
/**
3232
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a>
33-
*
33+
*
3434
*/
3535
public class RequestConstraintTransformTestProvider extends HttpConfigurationProvider
3636
{
@@ -74,9 +74,8 @@ public Configuration getConfiguration(final ServletContext context)
7474
@Override
7575
public void performHttp(final HttpServletRewrite event, final EvaluationContext context)
7676
{
77-
ParameterStore store = (ParameterStore) context.get(ParameterStore.class);
78-
String one = ((String) Evaluation.property("1").retrieve(event, context, store.get("1")));
79-
String two = ((String) Evaluation.property("2").retrieve(event, context, store.get("1")));
77+
String one = ((String) Evaluation.property("1").retrieve(event, context));
78+
String two = ((String) Evaluation.property("2").retrieve(event, context));
8079
String three = event.getResponse().encodeRedirectURL(event.getContextPath() + "/outbound/THREE");
8180

8281
Response.addHeader("one", one).perform(event, context);

0 commit comments

Comments
 (0)