Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Sketch of how to use Guice to inject Restlet Components and Applications
- // to avoid explicitly having to pass FinderFactory around.
- public class MyMain {
- public static void main(String... args) {
- // RestletGuice.createInjector ensures that FinderFactory is
- // bound properly.
- Injector inj = RestletGuice.createInjector(...my modules...);
- inj.getInstance(MyComponent.class).start();
- }
- }
- public class MyComponent extends Component {
- @Inject MyComponent(Application1 app1, Application2 app2) {
- ...
- host.attach("/app1", app1);
- host.attach("/app2", app2);
- ...
- }
- }
- public class Application1 extends Application {
- private final FinderFactory ff;
- @Inject Application1(FinderFactory ff) {
- this.ff = ff
- }
- @Override public Restlet createInboundRoot() {
- ...
- router.attach("/res", ff.finder(MyResource.class));
- ...
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement