Skip to content

Commit 5a80cfe

Browse files
committed
update documentation
1 parent 3633d42 commit 5a80cfe

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

_posts/2015-03-17-reverse-routing.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,7 @@ parameters.put("action", "new");
4444
String url = routeContext.uriFor("/contacts/{id}", parameters);
4545
```
4646

47+
By default (via `DefaultRouter`) the `uriFor` method automatically encode the parameters values.
48+
4749
In conclusion if you want to create links to routes or controllers you must use `Router.uriFor` methods.
4850

_posts/2015-03-17-spring.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ order: 10
77
---
88

99
Pippo can be used together with the [Spring framework](http://projects.spring.io/spring-framework), using Spring as a dependency injection container.
10-
When Pippo creates new instances of your various `Controller` subclasses, the [pippo-spring]({{ site.codeurl }}/pippo-spring) integration would then take care that the Spring-managed service beans (e.g. Services) get injected into the desired instance fields (marked by the `@Inject` annotations in your code).
10+
When Pippo creates new instances of your various `Controller` subclasses it delegates the instance creation to a `ControllerFactory`.
11+
The module [pippo-spring]({{ site.codeurl }}/pippo-spring) contains [SpringControllerFactory]({{ site.codeurl }}/pippo-spring/src/main/java/ro/pippo/spring/SpringControllerFactory.java) that it's
12+
a `ControllerFactory` implementation that delegates to the Spring container to instantiate a given `Controller` class. This allows for the instance to be configured via dependency injection (all Spring annotations are valid, AOP, ...).
13+
1114
An example of such a Controller subclass could look as follows:
1215

1316
```java
@@ -26,7 +29,7 @@ public class ContactsController extends Controller {
2629

2730
Pippo automatically creates the _ContactsController_ instance and pippo-spring injects the ContactService service bean, so basically you don’t have to worry about any of that stuff.
2831

29-
To activate pippo-spring integration in your Application you must add `SpringControllerInjector`:
32+
To activate pippo-spring integration in your Application you must add `SpringControllerFactory`:
3033

3134
```java
3235
public class MyApplication extends Application {
@@ -36,8 +39,8 @@ public class MyApplication extends Application {
3639
// create spring application context
3740
ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfiguration.class);
3841

39-
// registering SpringControllerInjector
40-
getControllerInstantiationListeners().add(new SpringControllerInjector(applicationContext));
42+
// registering SpringControllerFactory
43+
setControllerFactory(new SpringControllerFactory(applicationContext));
4144

4245
// add controller
4346
GET("/", ContactsController.class, "index");
@@ -60,6 +63,9 @@ public class SpringConfiguration {
6063
}
6164
```
6265

66+
`SpringControllerFactory` class has two constructors: with and without `autoRegistering`. By default `autoRegistering` is true. If `autoRegistering `flag is set on true then if `Spring` doesn't contain a bean for a controller class, `SpringControllerFactory` will create and register a `BeanDefinition`.
67+
If you want to modify the default bean definition of the `Controller` you must override `createBeanDefinition` method.
68+
6369
Also don't forget to add pippo-spring as dependency in your project:
6470

6571
```xml

0 commit comments

Comments
 (0)