21Changelog
3.5.0
- Bean Validation: Hibernate Validator 3 support are removed. If you are using it, please, update to Hibernate Validator 4.
- Initial support to method validation (Bean Validation 1.1).
public void theMethod(@NotNull String param) {..} // validates if param != null
- Build migration from ant to maven.
- New localized and joda-time converters (by jlemes).
- Removed deprecated and unused objects.
- Remove CGLIB in favor to Javassist Proxifier.
- Google Guice is now the default ioc container.
- Support to java.util.Set for IOGI.
- All dependencies are updated.
- Supports to HTTP method OPTIONS (by douglasrodrigo) and PATCH (by nykolaslima).
- Migration from Jmock to Mockito. More test coverage.
- Added supports for GSON (by renanreismartins).
- Changed how Exception Handler reports exceptions (by vulpios).
- Hibernate and JPA subprojects now have your own repository: http://github.com/caelum/vraptor-hibernate and http://github.com/caelum/vraptor-jpa.
- New plugin with Hibernate 4 support: http://github.com/garcia-jj/vraptor-plugin-hibernate4.
- Subproject now have your own repository: vraptor-vraptor2, vraptor-scala and vraptor-flex.
- Improvement: @Load annotation now discovery primary key byself.
- Bean validation with property and group validation (by nykolaslima).
- Bugfix: static files without querystring and jsessionid (by nykolaslima).
- Bugfix: when call servletContext.getClassLoader (by nykolaslima)
- Bugfix: skip bridge and overloaded methods (by nykolaslima).
- Improvement: upload validation (by marceloemanoel).
- Improvement: documentation (by bbviana, awvalenti and igordeoliveirasa).
3.3.1
- bugfix - fixed scannotation as mandatory on maven
- bugfix - fixed ConcurrentModificationException on interceptors ordering
- updating spring from 3.0.0 to 3.0.5
- bugfix - fixed @PostConstruct on @ApplicationScoped components when using Spring as DI container.
- better docs
- bugfix - redirect to @Path's with regexes
- bugfix - Hibernate and JPA Transaction interceptors now rollback when there are validation errors.
3.3.0
Jar changes
- change google-collect 1.0rc to guava-r07.
- scannotations 1.0.2 is now mandatory.
- better Spring integration: now Spring components can access VRaptor components and vice-versa
- guice: @PostConstruct and @PreDestroy working properly
- guice: all request and session scoped components are exported to the view in the same way as spring provider (class name as key)
- interceptor ordering strategy changed: one can order the interceptors using @Intercepts annotation, specifying which interceptors must run before or after the annotated interceptor
So VRaptor will execute the interceptors in an ordering that respects before and after restrictions of all interceptors. Therefore the InterceptorSequence interface is deprecated.
@Intercepts(before=AnInterceptor.class, after=AnotherInterceptor.class)
- HTTP verb annotations now also can set paths:
@Get("/items/{id}"), @Post("/items"), etc
- bugfix: @Transactional from Spring can be used in any class (within spring aop limitations)
- bugfix: upload of files with same name
- bugfix: web-fragments.xml on jboss 6
- bugfix: better support for arrays as parameters
- new Download implementation: ByteArrayDownload and JFreeChartDownload
- new jsonp view:
which returns
result.use(jsonp()).withCallback("theCallback").from(object).serialize();
theCallback({"object": {...} })
- commons-io dependency removed
- PageResult methods renamed for consistency with other results.
- better upload logs
- refactor on converters: using Localization to get Locale and bundle
- Hibernate class removed. Use validator.validate(object) instead.
- JSON response with optional indentation.
3.2.0
- several performance tweaks: about 60% less request time.
- internal compatibility break: InterceptorStack interface reorganized.
- better implementation of VRaptor internal interceptors accepts method.
- beta support to Google Guice, that can be used instead of Spring.
- Pico provider is not deprecated anymore.
- One can change the DI container without configuring it on web.xml. If VRaptor finds the Spring jars on classpath, Spring will be used; if PicoContainer jars are found it will be used; the same for Guice jars. One can find the container jars on lib/containers folder on vraptor zip.
- internal compatibility break: interfaces Converters, Router and constructor of PathAnnotationRoutesParser class were changed. RouteBuilder converted is now an interface => DefaultRouteBuilder is the implementation. Those who extend PathAnnotationRoutesParser must change the call to delegate constructor. Those who instantiate RouteBuilder directly must instantiate DefaultRouteBuilder.
- new annotation @Lazy. Use it on interceptors which accepts method doesn't depend on the interceptor internal state:
In this case, MyLazyInterceptor will only be instantiated when accepts returns true. A non-functional instance of MyLazyInterceptor will be used to call the accepts method, so it should not depend on the interceptor's internal state. Do not use @Lazy if your accepts is trivial (always returns true).
@Intercepts @Lazy public class MyLazyInterceptor implements Interceptor { public MyLazyInterceptor(Dependency dependency) { this.dependency = dependency; } public boolean accepts(ResourceMethod method) { // depends only on method return method.containsAnnotation(Abc.class); } public void intercepts(...) { //... } }
- slight backwards compatibility break: the default priority of @Path has changed to Integer.MAX_INTEGER/2. It was Integer.MAX_INTEGER - 1. Despite of this compatibility break, we believe that it won't affect working applications.
- @Path priority can be defined with constants:
@Path(value="/url", priority=Path.HIGHEST) @Path(value="/url", priority=Path.HIGH) @Path(value="/url", priority=Path.DEFAULT) @Path(value="/url", priority=Path.LOW) @Path(value="/url", priority=Path.LOWEST)
- Servlet 3.0 upload support (by garcia-jj)
- new Exception handlers (by garcia-jj)
result.on(SomeException.class).forwardTo(Controller.class).method(); //if a SomeException occurs, the request will be redirected
- new interface TwoWayConverter for bidirecional convertions.
- native support for OPTIONS requests
- fix: 405 instead of 500 on requests with unknown HTTP method.
- more Joda Time converters (by Rodolfo Liviero)
- improvings on Scala Blank Project (by Pedro Matiello)
- bugfix: null Accept Header fallback to html
3.1.3
- Scala Blank Project
- Better strategy on Flash scope
- starting support for javax.inject API. Naming logic parameters is now possible:
- bugfixes on new Validator
- bugfix: char as URI parameter
- bugfix: now VRaptor works with browsers that do not correctly send Accepts header.
So the request parameter must be called 'a_name'.
public void logic(@Named("a_name") String anotherName) {...}
- better support for GAE
- new method on http result:
content can be either a String, an InputStream or a Reader.
result.use(http()).body(content);
- more available methods for result.use(status())
- new method: result.use(representation()).from(object, alias)
- support for multiple selects:
public void logic(List<String> abc) {...}
<select name="abc[]" multiple="multiple">...</select>
- auto 406 status when using result.use(representation())
- One can register now all optional vraptor components on packages configuration on web.xml:
<context-param> <param-name>br.com.caelum.vraptor.packages</param-name> <param-value> br.com.caelum.vraptor.util.hibernate, // Session and SessionFactory br.com.caelum.vraptor.util.jpa, // EntityManager and EntityManagerFactory br.com.caelum.vraptor.converter.l10n, //Localized numeric Converters br.com.caelum.vraptor.http.iogi // Immutable parameters support </param-value> </context-param>
- rendering a null representation means returning a 404
- new class: JsonDeserializer
- MultipartInterceptor is now optional.
- bugfix: arrays of length == 1 are now supported as logic parameters
- Pico provider is deprecated
- Validations using the request bundle (and locale)
- ValidationMessage implements Serializable
- new method: result.use(status()).badRequest(errorList); serializes the given error list with:
result.use(representation()).from(errorList, "errors");
- shortcuts on Validator:
where controller can be either a controller class or this, as in Result shortcuts. And the shortcut:
validator.onErrorForwardTo(controller).logic(); validator.onErrorRedirectTo(controller).logic(); validator.onErrorUsePageOf(controller).logic();
which returns the Bad Request (400) status codes and serializes the validation error list according to Accept request header (result.use(representation()))validator.onErrorSendBadRequest();
3.1.2
- Blank project now also runs on netbeans 6.8
- Supports encoding for file uploads in Google App Engine
- bugfix: no more NullPointerExceptions on validator.onErrorUse(json())...
- Serializers now have the recursive method:
It means that all object tree from myObject will be serialized.
result.use(xml()).from(myObject).recursive().serialize();
- Message parameters on Validations now can be i18n'ed:
// age = Age // greater_than = {0} should be greater than {1} validator.checking(new Validations() { { that(age > 18, "age", "greater_than", i18n("age"), 10); //results on "Age should be greater than 18" }});
- Hibernate proxies are now nicely serialized (almost) like regular classes (thanks to Tomaz Lavieri)
- It is now possible to serialize to json without the root element (thanks to Tomaz Lavieri):
result.use(json()).from(car).serialize(); //=> {'car': {'color': 'blue'} } result.use(json()).withoutRoot().from(car).serialize(); //=> {'color': 'blue'}
- Google collections updated to version 1.0
- fixed bug with curly braces on regexes inside @Path's
- XStream annotations are now automatically read when you use VRaptor's default serialization
- when you upload a file bigger than the file size limit you get a validation error instead of a generic exception
- more shortcuts on Result interface:
redirectTo("a/uri") => use(page()).redirect("a/uri") notFound() => use(status()).notFound() nothing() => use(nothing()); permanentlyRedirectTo(Controller.class) => use(status()).movedPermanentlyTo(Controller.class); permanentlyRedirectTo("a/uri") => use(status()).movedPermanentlyTo("a/uri"); permanentlyRedirectTo(this) => use(status()).movedPermanentlyTo(this.getClass());
- added a new method to Validator interface (thanks to Otávio Garcia)
This method will validate the given object using Hibernate Validator 3, Java Validation API (JSR303), or any implementation of BeanValidation annotated with @Component
validator.validate(object);
- new BigDecimal, Double and Float converters, that consider the current Locale to convert the values (thanks to Otávio Garcia).
In order to use them you must add to your web.xml:
<context-param> <param-name>br.com.caelum.vraptor.packages</param-name> <param-value>!!previous value!!,br.com.caelum.vraptor.converter.l10n</param-value> </context-param>
3.1.1
- VRaptor 3 was published on Maven central repository!
<dependency> <groupId>br.com.caelum</groupId> <artifactId>vraptor</artifactId> <version>3.1.1</version> </dependency>
- new implementation for Outjector. Now when there are validation errors actual objects are replicated to the next request, not string parameters as before, preventing class cast exceptions on taglibs.
- bugfixes on VRaptor 2 compatibility
3.1.0
- it is now possible to serialize collections via result.use(xml()) or result.use(json()).
- new scope: @PrototypeScoped, that creates a new instance of annotated class whenever it is requested.
- new view: result.use(Results.representation()).from(object).serialize(); This view tries to discover the request format (through _format or Accept header) and then serialize the given object in this format. For now only xml and json are supported, but you can add a serializer for any format you like. If there is no format given, or it is unsupported the default jsp page will be shown.
- bugfix: Flash scope parameters are now set with arrays, so it will work on GAE
- bugfix: validation.onErrorUse(...) now works with all default Results
- bugfix: when returning a null Download/File/InputStream will not throw NullPointerException if any redirect has occurred (result.use(...)).
- bugfix: result.use(page()).redirect("...") now includes the contextPath if given url starts with /
- bugfix: one can create generic Controllers now:
public class ClientsController extends GenericController<Client> { } public class GenericController<T> { public T show(Long id) {...} // exported variable will be called t public void add(T obj) {...} // request parameters will be like obj.field }
- you can annotate your controller class with @Path, and all methods URIs will have the path specified as prefix.:
@Resource @Path("/prefix") public class MyController { //URI: /prefix/aMethod public void aMethod() {...} //URI: /prefix/relative @Path("relative") public void relativePath() {...} //URI: /prefix/absolute @Path("/absolute") public void absolutePath() {...} }
- @Path now supports regexes: @Path("/abc/{abc:a+b+c+}") will match URIs like:
whenever the parameter matches the a+b+c+ regex.
/abc/abc /abc/aaaaabbcccc /abc/abbc
- New methods on Result interface as shortcuts for most common operations:
- result.forwardTo("/some/uri") ==> result.use(page()).forward("/some/uri");
- result.forwardTo(ClientController.class).list() ==> result.use(logic()).forwardTo(ClientController.class).list();
- result.redirectTo(ClientController.class).list() ==> result.use(logic()).redirectTo(ClientController.class).list();
- result.of(ClientController.class).list() ==> result.use(page()).of(ClientController.class).list();
- result.forwardTo(this).list() ==> result.use(logic()).forwardTo(this.getClass()).list();
- result.redirectTo(this).list() ==> result.use(logic()).redirectTo(this.getClass()).list();
- result.of(this).list() ==> result.use(page()).of(this.getClass()).list();
- VRaptor will scan for all resources and components inside WEB-INF/classes automatically
- support for servlets 3.0, so it is not necessary configure the filter anymore (webfragment feature)
- using latest spring version (3.0.0) and also hibernate (for examples and so on). google collections updated to final version
- blank project now working for wtp 3.5 and using vraptor 3.1 new features
- blank project much easier to import under wtp now. logging and other configs adjusted
- bugfix: mimetypes now work for webkit browsers, priorizing html when no order specified
- bugfix: in case of validation erros, the request parameters are outjected as Strings, not Maps as before. It prevents ClassCastExceptions when using taglibs, like fmt:formatNumber.
3.0.2
- servlet 2.4 containers are now supported
- bugfix: Results.referer() now implements View
- bugfix: content-type is now set when using File/InputStreamDownload
- removed java 6 api calls
- new providers, spring based: HibernateCustomProvider and JPACustomProvider. These providers register optional Hibernate or JPA components.
- bugfix: converters are not throwing exceptions when there is no ResourceBundle configured.
- bugfix: method return values are now included on result when forwarding.
- bugfix: request parameters are now kept when there is a validation error.
- bugfix: throwing exception when paranamer can't find parameters metadata, so you can recover for this problem.
- initial support to xml and json serialization:
result.use(Results.json()).from(myObject).include(...).exclude(...).serialize(); result.use(Results.xml()).from(myObject).include(...).exclude(...).serialize();
3.0.1
- paranamer upgraded to version 1.5 (Update your jar!)
- jars split in optional and mandatory on vraptor-core
- dependencies are now explained on vraptor-core/libs/mandatory/dependencies.txt and vraptor-core/libs/optional/dependencies.txt
- you can set now your application character encoding on web.xml through the context-param br.com.caelum.vraptor.encoding
- new view: Referer view: result.use(Results.referer()).redirect();
- Flash scope:
objects included on Result will survive until next request when a redirect happens.
result.include("aKey", anObject); result.use(logic()).redirectTo(AController.class).aMethod();
- @Path annotation supports multiple values (String -> String[])
- Result.include returns this to enable a fluent interface (result.include(...).include(...))
- Better exception message when there is no such http method as requested
- FileDownload registers content-length
- Solving issue 117: exposing null when null returned (was exposing "ok")
- Solving issue 109: if you have a file /path/index.jsp, you can access it now through /path/, unless you have a controller that handles this URI.
- When there is a route that can handle the request URI, but doesn't allow the requested HTTP method, VRaptor will send a 405 -> Method Not Allowed HTTP status code, instead of 404.
- A big refactoring on Routes internal API.
3.0.0
- ValidationError renamed to ValidationException
- result.use(Results.http()) for setting headers and status codes of HTTP protocol
- bug fixes
- documentation
- new site
3.0.0-rc-1
- example application: mydvds
- new way to add options components into VRaptor:
public class CustomProvider extends SpringProvider { @Override protected void registerCustomComponents(ComponentRegistry registry) { registry.registry(OptionComponent.class, OptionComponent.class); } }
- Utils: HibernateTransactionInterceptor and JPATransactionInterceptor
- Full application example inside the docs
- English docs
3.0.0-beta-5
- New way to do validations:
public void visualiza(Client client) { validator.checking(new Validations() { { that(client.getId() != null, "id", "id.should.be.filled"); }}); validator.onErrorUse(page()).of(ClientsController.class).list(); //continua o metodo }
- UploadedFile.getFile() now returns InputStream.
- EntityManagerCreator and EntityManagerFactoryCreator
- bugfixes
3.0.0-beta-4
- New result: result.use(page()).of(MyController.class).myLogic() renders the default view (/WEB-INF/jsp/meu/myLogica.jsp) without execting the logic.
- Mock classes for testing: MockResult e MockValidator, to make easier to unit test your logics. They ignores the fluent interface calls and keep the parameters included under the result and the validation errors.
- The URIs passed to result.use(page()).forward(uri) and result.use(page()).redirect(uri) can't be logic URIs. Use forwards or redirects from result.use(logic()) instead.
- Parameters passed to URI's now accepts pattern-matching:
- Automatic: if we have the URI /clients/{client.id} and client.id is a Long, the {client.id} parameter will only match numbers, so, the URI /clients/42 matches, but the /clients/random doesn't matches. This works for all numeric types, booleans and enums. VRaptor will restrict the possible values.
- Manual: in your CustomRoutes you can do:
which means you can restrict values for the parameters you want by regexes at the matching method.
routeFor("/clients/{client.id}").withParameter("client.id") .matching("\\d{1,4}") .is(ClienteController.class).mostra(null);
- Converters for joda-times's LocalDate and LocalTime comes by default.
- When Spring is the IoC provider, VRaptor tries to find your application's spring to use as a father container. This search is made by one of the following two ways:
- WebApplicationContextUtils.getWebApplicationContext(servletContext), when you have Spring's listeners configured.
- applicationContext.xml inside the classpath
- Utils:
- SessionCreator and SessionFactoryCreator to create Hibernate's Session and SessionFactory to your registered components.
- EncodingInterceptor, to change you default encoding.
- several bugfixes and docs improvements.
3.0.0-beta-3
- Spring becomes the default IoC provider
- the applicationContext.xml under the classpath is used as Spring initial configuration, if it exists.
- improved docs at http://vraptor.caelum.com.br/documentacao
- small bugfixes and optimizations