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

Remove pippo-spring module from next major version of Pippo #565

Open
decebals opened this issue Sep 21, 2020 · 3 comments
Open

Remove pippo-spring module from next major version of Pippo #565

decebals opened this issue Sep 21, 2020 · 3 comments

Comments

@decebals
Copy link
Member

decebals commented Sep 21, 2020

The idea is that I used with success another, more natural approach.
First of all I injected the needed services directly in Controller class:

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import ro.pippo.controller.Controller;
import ro.pippo.controller.Path;

@Path("/clients")
@Component
public class ClientController extends Controller {

    @Autowired
    private SubscriptionService subscriptionService;

    @Autowired
    private ClientService clientService;

    // GET, POST methods

}

Add all controllers in Application after they were collected by Spring:

import org.springframework.stereotype.Component;
import ro.pippo.controller.ControllerApplication;

@Component
public class MyApplication extends ControllerApplication {

    @Autowired
    private List<? extends Controller> controllers;

    @Override
    protected void onInit() {
        addControllers(controllers.toArray(new Controller[controllers.size()]));
    }

}

The content of this issue is related somehow with #538.

@decebals
Copy link
Member Author

Also related to Spring support in Pippo, see below how you can use the Pippo hot reload mechanism when Spring is used for DI:

public class Launcher {

    public static void main(String[] args) {
        Pippo pippo = new Pippo() {

            @Override
            protected Application createReloadableApplication() {
                return new AnnotationConfigApplicationContext(SpringConfiguration.class).getBean(Application.class);
            }

        };
        pippo.start();
    }

}

@mhagnumdw
Copy link
Member

It would be nice to note in some way what we have to create / update in the documentation. Pippo has a lot of cool stuff!

@decebals
Copy link
Member Author

decebals commented Sep 27, 2020

I will update the documentation. Yes, Pippo has a lot of cool stuff that are not documented and it is easy to add some new ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants