Permalink
Browse files

introducing inject plugin

  • Loading branch information...
pk11 committed Mar 3, 2012
0 parents commit dc484af932d5bf1dece723785bff0ae0fb9eeca3
@@ -0,0 +1,15 @@
+target/
+logs/
+repository/
+dist/
+*.lock
+*.komodoproject
+.DS_Store
+project/boot/
+framework/project/boot/
+documentation/api
+workspace/
+framework/sbt/boot
+.history
+.idea
+RUNNING_PID
@@ -0,0 +1,12 @@
+# Play Plugins
+
+
+## Licence
+
+This software is licensed under the Apache 2 license, quoted below.
+
+Copyright 2012 Typesafe (http://www.typesafe.com).
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use this project except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.
+
+Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
@@ -0,0 +1,29 @@
+import sbt._
+import Keys._
+
+object MinimalBuild extends Build {
+
+ lazy val buildVersion = "2.0-RC3"
+
+ 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 play = "play" %% "play" % buildVersion
+
+
+ lazy val root = Project(id = "play-plugins-inject", 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,
+ libraryDependencies += "org.ow2.spec.ee" % "ow2-atinject-1.0-spec" % "1.0.10",
+ libraryDependencies += "com.cedarsoft" % "guice-annotations" % "2.0.1"
+ )
+}
@@ -0,0 +1 @@
+sbt.version=0.11.2
@@ -0,0 +1,24 @@
+package controllers;
+
+import play.*;
+import play.mvc.*;
+
+import views.html.*;
+
+import javax.inject.*;
+import service.*;
+
+public class Application extends Controller {
+
+ @Inject private static MyService s;
+
+ // used for testing, not used by Play
+ //public Application(MyService s){
+ // this.s = s;
+ //}
+
+ public static Result index() {
+ return ok(index.render(s.demonstrate()));
+ }
+
+}
@@ -0,0 +1,28 @@
+package module;
+
+import com.google.inject.Provides;
+import javax.inject.Singleton;
+import service.*;
+
+public class Dependencies {
+
+ @Provides
+ @Singleton
+ public Something makeSomething() {
+ return new Something() {
+ public String noWhat() {
+ return "yay";
+ }
+ };
+ }
+
+ @Provides
+ @Singleton
+ public MyService makeService(Something s) {
+ return new MyService(s) {
+ public String demonstrate() { return s.noWhat();}
+ };
+ }
+
+
+}
@@ -0,0 +1,12 @@
+package service;
+
+public abstract class MyService {
+
+ protected Something s;
+
+ public MyService(Something s) {
+ this.s = s;
+ }
+
+ abstract public String demonstrate();
+}
@@ -0,0 +1,7 @@
+package service;
+
+public interface Something {
+
+ public String noWhat();
+
+}
@@ -0,0 +1,7 @@
+@(message: String)
+
+@main("Welcome to Play 2.0") {
+
+ @play20.welcome(message, style = "Java")
+
+}
@@ -0,0 +1,15 @@
+@(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>
@@ -0,0 +1,57 @@
+# 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
+
@@ -0,0 +1 @@
+99999:com.typesafe.plugin.inject.InjectViaMiniGuicePlugin
@@ -0,0 +1,9 @@
+# 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)
@@ -0,0 +1,19 @@
+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-inject" % "2.0-RC3"
+
+ )
+
+ val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
+ // Add your own project settings here
+ )
+
+}
@@ -0,0 +1 @@
+sbt.version=0.11.2
@@ -0,0 +1,8 @@
+// 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")
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

Oops, something went wrong.
No changes.
Oops, something went wrong.

0 comments on commit dc484af

Please sign in to comment.