Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Now we have supports for Valued Parameters #290

Merged
merged 20 commits into from
Jan 1, 2014

Conversation

garcia-jj
Copy link
Member

Initial support for valued parameters. Now we can simple inject MethodInfo to get all info about parameters like names, types, values ao so on.

We don't need to to inject Paranamer neither to foreach a pair of arrays with names and values.

There are some task to do after this pull request, like change deserializers to void, and change values of parameters in deserializer. But I think that is better to send small pull requests, to delivery faster.

This pull request closes #104

import br.com.caelum.vraptor.http.ParanamerNameProvider;
import br.com.caelum.vraptor.http.ValuedParameter;

public class ValuedParameterProducer {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This class is useful to create ValuedParameters for a method. But I don't know the best location for this class.

@@ -97,7 +98,8 @@ public void deserializes(@Observes ReadyToExecuteMethod event, HttpServletReques
// return a defensive copy
for (int i = 0; i < deserialized.length; i++) {
if (deserialized[i] != null) {
parameters[i] = deserialized[i];
// FIXME ot - change deserialize return to void, and change valued parameters into deserializer
parameters[i].setValue(deserialized[i]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put this invocation in method info.

methodInfo.setParameter(i, deserialized[i]);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why, since ValuedParameter already have the method setValue? If I already have an instance of ValuedParameter, I can simple call setValued instead methodInfo.setParameter.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this way there is no need for the line 92 and DeserializerObserver knowing about ValueParameter. Less coupling ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done by 4ed8771.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more changes or suggestions before merge?

@lucascs
Copy link
Member

lucascs commented Dec 29, 2013

Overall I didn't see much gain in this refactoring yet =(
Specially because we're almost always using .getParameterValues().

Maybe moving some of the parameter behavior to MethodInfo would be sufficient.

@garcia-jj
Copy link
Member Author

.getParameterValues() is used only in 2 places that needs onde the values. First example is MethodValidator, that we need to pass only the values for bean validation. Tests are using .getParameterValues() because I thing that is only test class :)

getValuedParameters is used in more places like ReplicatorOutjector that saves a lot of lines and now are more beautiful. As I told when open this pull request, I will improve soon, but I prefer to send many small pull request to delivery quickly and faster.

After changes, can I merge?

@lucascs
Copy link
Member

lucascs commented Dec 30, 2013

Ok, let's see where it is going ;)

public ValuedParameter[] getValuedParameters() {
if (valuedParameters == null) {
valuedParameters = new ValuedParameter[0];
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty array is better than null? AIOOBoundsEx is better than NullPEx? Is this if necessary?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done by d2d1f90

@Turini
Copy link
Member

Turini commented Dec 30, 2013

As I told when open this pull request, I will improve soon, but I prefer to send
many small pull request to delivery quickly and faster. After changes, can I merge?

I think it is better to define where this changes are going, before merge this PR :)
Soon we will release the RC version, we should no longer remain breaking compatibility.
What about open a thread on vraptor4 list? Just to everything be discussed and planned

public ControllerMethod getControllerMethod() {
return controllerMethod;
}

public void setControllerMethod(ControllerMethod controllerMethod) {
createValuedParameter(controllerMethod);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this method should be called on getValuedParameters because even if i'll never use,
it always create valued parameters when VRaptor sets ControllerMethod (and to create this, we
use parameterNameProvider, etc... it is kind of expensive). Maybe a simple lazy strategy:

if (valuedParameters != null) createValuedParameter(controllerMethod);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Done by 11fccca

@garcia-jj
Copy link
Member Author

@Turini, this pull request is done. There are only one change (see #293) that breaks compatibility, that will be solved in another pull request.

@Turini
Copy link
Member

Turini commented Dec 31, 2013

@Turini, this pull request is done. There are only one change (#293)
that breaks compatibility, that will be solved in another pull request.

Ok then... 🔥 🚒 :)

garcia-jj added a commit that referenced this pull request Jan 1, 2014
Now we have supports for Valued Parameters
@garcia-jj garcia-jj merged commit c5ee72b into master Jan 1, 2014
@garcia-jj garcia-jj deleted the ot-new-valued-parameter-again branch January 1, 2014 00:56
@Turini Turini added this to the 4.0.0-beta-4 milestone Mar 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

remove MethodInfo and create ActionParameters, ActionResult (or something like this)
3 participants