Skip to content
This repository has been archived by the owner on Jun 12, 2020. It is now read-only.

analogweb/guice-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Analog Web Framework

Guice application working with AnalogWeb's Router.

public class SayHello {

   public String sayHello() {
      return "Hello!";
   }

}
import java.net.URI;
import javax.inject.Inject;

import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;

import org.analogweb.ApplicationContext;
import org.analogweb.ApplicationProperties;
import org.analogweb.annotation.Route;
import org.analogweb.core.DefaultApplicationProperties;
import org.analogweb.core.Servers;
import org.analogweb.guice.GuiceApplicationContext;

@Route("/")
public class Hello {

      public static void main(String... args) {

         Injector injector = Guice.createInjector(new AbstractModule() {
             @Override
             protected void configure() {
               bind(Hello.class);
               bind(SayHello.class);
             }
         });
         ApplicationContext context = GuiceApplicationContext.context(injector);
         ApplicationProperties props = DefaultApplicationProperties
                                     .properties(Hello.class.getPackage().getName());
         Servers.create(URI.create("http://localhost:8080"),props,context).run();
      }

      @Inject
      private SayHello service;

      @Route
      public String hello() {
         return service.sayHello();
      }
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages