Permalink
Browse files

remove guice

  • Loading branch information...
1 parent d66a8a3 commit bc61727477cba74982f9a705c100d7fc99dc7256 @pk11 pk11 committed Jan 10, 2013
@@ -1,36 +0,0 @@
-import sbt._
-import Keys._
-
-object MinimalBuild extends Build {
-
- lazy val buildVersion = "2.0.3"
- lazy val playVersion = "2.0.2"
-
-
-
- lazy val typesafeSnapshot = "Typesafe Snapshots Repository" at "http://repo.typesafe.com/typesafe/snapshots/"
- lazy val typesafe = "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
- lazy val repo = if (buildVersion.endsWith("SNAPSHOT")) typesafeSnapshot else typesafe
-
- lazy val playPlugin = ("com.typesafe" % "play-plugins-inject" % buildVersion notTransitive())
- .exclude("org.ow2.spec.ee", "ow2-atinject-1.0-spec")
- .exclude("com.cedarsoft", "guice-annotation")
-
- lazy val play = "play" %% "play" % playVersion
-
- lazy val root = Project(id = "play-plugins-guice", base = file("."), settings = Project.defaultSettings).settings(
- version := buildVersion,
- publishTo <<= (version) { version: String =>
- val nexus = "http://repo.typesafe.com/typesafe/"
- if (version.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "ivy-snapshots/")
- else Some("releases" at nexus + "ivy-releases/")
- },
- organization := "com.typesafe",
- resolvers += repo,
- javacOptions += "-Xlint:unchecked",
- libraryDependencies += play,
- crossPaths := false,
- libraryDependencies += playPlugin,
- libraryDependencies += "com.google.inject" % "guice" % "3.0"
- )
-}
@@ -1 +0,0 @@
-sbt.version=0.11.3
@@ -1,14 +0,0 @@
-import play.*;
-import play.libs.*;
-
-import java.util.*;
-
-import service.Service;
-import com.typesafe.plugin.inject.InjectPlugin;
-
-public class Global extends GlobalSettings {
-
- public void onStart(Application app) {
- Logger.warn("getting an instance from guice:"+ app.plugin(InjectPlugin.class).getInstance(Service.class));
- }
-}
@@ -1,19 +0,0 @@
-package controllers;
-
-import play.*;
-import play.mvc.*;
-
-import views.html.*;
-
-import javax.inject.*;
-import service.*;
-
-public class Application extends Controller {
-
- @Inject static Service s;
-
- public static Result index() {
- return ok(index.render(s.demonstrate()));
- }
-
-}
@@ -1,11 +0,0 @@
-package module;
-
-import com.google.inject.*;
-import service.*;
-
-public class Dependencies implements Module {
-
- public void configure(Binder binder) {
- binder.bind(Service.class).to(SomethingService.class);
- }
-}
@@ -1,6 +0,0 @@
-package service;
-
-public interface Service {
-
- public String demonstrate();
-}
@@ -1,9 +0,0 @@
-package service;
-
-public class SomethingService implements Service{
-
- public String demonstrate() {
- return "yay";
- }
-
-}
@@ -1,7 +0,0 @@
-@(message: String)
-
-@main("Welcome to Play 2.0") {
-
- @play20.welcome(message, style = "Java")
-
-}
@@ -1,15 +0,0 @@
-@(title: String)(content: Html)
-
-<!DOCTYPE html>
-
-<html>
- <head>
- <title>@title</title>
- <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")">
- <link rel="shortcut icon" type="image/png" href="@routes.Assets.at("images/favicon.png")">
- <script src="@routes.Assets.at("javascripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
- </head>
- <body>
- @content
- </body>
-</html>
@@ -1,57 +0,0 @@
-# This is the main configuration file for the application.
-# ~~~~~
-
-# Secret key
-# ~~~~~
-# The secret key is used to secure cryptographics functions.
-# If you deploy your application to several instances be sure to use the same key!
-application.secret="cBlQ[B0FM]DiFD<KIq6I`1TM81lna:gCo2XFAwdXo2lUIH;c:eL=_=N]o@UoblHu"
-
-# The application languages
-# ~~~~~
-application.langs="en"
-
-# Global object class
-# ~~~~~
-# Define the Global object class for this application.
-# Default to Global in the root package.
-# global=Global
-
-# Database configuration
-# ~~~~~
-# You can declare as many datasources as you want.
-# By convention, the default datasource is named `default`
-#
-# db.default.driver=org.h2.Driver
-# db.default.url="jdbc:h2:mem:play"
-# db.default.user=sa
-# db.default.password=
-#
-# You can expose this datasource via JNDI if needed (Useful for JPA)
-# db.default.jndiName=DefaultDS
-
-# Evolutions
-# ~~~~~
-# You can disable evolutions if needed
-# evolutionplugin=disabled
-
-# Ebean configuration
-# ~~~~~
-# You can declare as many Ebean servers as you want.
-# By convention, the default server is named `default`
-#
-# ebean.default="models.*"
-
-# Logger
-# ~~~~~
-# You can also configure logback (http://logback.qos.ch/), by providing a logger.xml file in the conf directory .
-
-# Root logger:
-logger.root=ERROR
-
-# Logger used by the framework:
-logger.play=INFO
-
-# Logger provided to your application:
-logger.application=DEBUG
-
@@ -1 +0,0 @@
-1500:com.typesafe.plugin.inject.GuicePlugin
@@ -1,9 +0,0 @@
-# Routes
-# This file defines all application routes (Higher priority routes first)
-# ~~~~
-
-# Home page
-GET / controllers.Application.index()
-
-# Map static resources from the /public folder to the /assets URL path
-GET /assets/*file controllers.Assets.at(path="/public", file)
@@ -1,19 +0,0 @@
-import sbt._
-import Keys._
-import PlayProject._
-
-object ApplicationBuild extends Build {
-
- val appName = "j"
- val appVersion = "1.0-SNAPSHOT"
-
- val appDependencies = Seq(
- "com.typesafe" % "play-plugins-guice" % "2.0.1"
-
- )
-
- val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
- // Add your own project settings here
- )
-
-}
@@ -1 +0,0 @@
-sbt.version=0.11.3
@@ -1,8 +0,0 @@
-// Comment to get more information during initialization
-logLevel := Level.Warn
-
-// The Typesafe repository
-resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
-
-// Use the Play sbt plugin for Play projects
-addSbtPlugin("play" % "sbt-plugin" % "2.0-RC3")
Deleted file not rendered
Oops, something went wrong.
@@ -1,77 +0,0 @@
-package com.typesafe.plugin.inject;
-import play.*;
-
-import com.google.inject.*;
-import java.lang.reflect.Field;
-import java.util.List;
-import java.util.ArrayList;
-
-public class GuicePlugin extends InjectPlugin {
-
- private Injector injector = null;
-
- public GuicePlugin(Application app) {
- super(app);
- }
-
- @Override
- public boolean enabled() {
- return !(app.configuration().getString("guiceplugin") != null && app.configuration().getString("guiceplugin").equals("disabled") );
- }
-
- public <T> T getInstance(Class<T> type) {
- if (injector == null) Logger.warn ("injector is null - perhaps plugin is not configured before GlobalPlugin or onStart was not called yet");
-
- return injector.getInstance(type);
- }
-
- @Override
- public void onStart() {
-
- Class<Object>[] injectables = scanInjectableClasses();
- //create injector with static support
- injector = Guice.createInjector(convertToModules(availableModules(), injectables));
-
- //inject
- for (Class<Object> clazz : injectables ) {
- try {
- Logger.debug("injection for "+ clazz.getName());
- injector.injectMembers(createOrGetInstane(clazz));
- } catch (java.lang.IllegalArgumentException ex) {
- Logger.debug("skipping injection for "+ clazz.getName());
- }
- }
- }
-
- /**
- * converts modules into Guice modules, also adding Static Injection support
- */
- private List<Module> convertToModules(List<Object> modules, Class<Object>[] injectables) {
- List<Module> guiceModules = new ArrayList<Module>();
-
- guiceModules.add(new RequestStaticInjection(injectables));
-
- for (Object m : modules ) {
- guiceModules.add((Module)m);
- }
-
- return guiceModules;
- }
-
- /**
- * creates instance for default constructor
- */
- private Object createOrGetInstane(Class<Object> clazz) throws java.lang.IllegalArgumentException {
- try {
- try {
- return clazz.newInstance();
- } catch (IllegalAccessException ex) {
- Field field = clazz.getField("MODULE$");
- return field.get(null);
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new java.lang.IllegalArgumentException();
- }
- }
-}
@@ -1,22 +0,0 @@
-package com.typesafe.plugin.inject;
-
-import com.google.inject.*;
-import java.util.*;
-
-/**
- * requests static injection for injectable classes
- */
-public class RequestStaticInjection implements Module {
-
- private Class<Object>[] injectables = null;
-
- public RequestStaticInjection (Class<Object>[] injectables) {
- this.injectables = injectables;
- }
-
- public void configure(Binder binder) {
- for (Class<Object> o : injectables) {
- binder.requestStaticInjection(o);
- }
- }
-}

0 comments on commit bc61727

Please sign in to comment.