Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Commit

Permalink
introducing inject plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ph2734 committed Mar 3, 2012
0 parents commit dc484af
Show file tree
Hide file tree
Showing 23 changed files with 864 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
@@ -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
12 changes: 12 additions & 0 deletions README.md
@@ -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.
29 changes: 29 additions & 0 deletions inject/project/Build.scala
@@ -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"
)
}
1 change: 1 addition & 0 deletions inject/project/build.properties
@@ -0,0 +1 @@
sbt.version=0.11.2
24 changes: 24 additions & 0 deletions inject/sample/app/controllers/Application.java
@@ -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()));
}

}
28 changes: 28 additions & 0 deletions inject/sample/app/module/Dependencies.java
@@ -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();}
};
}


}
12 changes: 12 additions & 0 deletions inject/sample/app/service/MyService.java
@@ -0,0 +1,12 @@
package service;

public abstract class MyService {

protected Something s;

public MyService(Something s) {
this.s = s;
}

abstract public String demonstrate();
}
7 changes: 7 additions & 0 deletions inject/sample/app/service/Something.java
@@ -0,0 +1,7 @@
package service;

public interface Something {

public String noWhat();

}
7 changes: 7 additions & 0 deletions inject/sample/app/views/index.scala.html
@@ -0,0 +1,7 @@
@(message: String)

@main("Welcome to Play 2.0") {

@play20.welcome(message, style = "Java")

}
15 changes: 15 additions & 0 deletions inject/sample/app/views/main.scala.html
@@ -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>
57 changes: 57 additions & 0 deletions inject/sample/conf/application.conf
@@ -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

1 change: 1 addition & 0 deletions inject/sample/conf/play.plugins
@@ -0,0 +1 @@
99999:com.typesafe.plugin.inject.InjectViaMiniGuicePlugin
9 changes: 9 additions & 0 deletions inject/sample/conf/routes
@@ -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)
19 changes: 19 additions & 0 deletions inject/sample/project/Build.scala
@@ -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
)

}
1 change: 1 addition & 0 deletions inject/sample/project/build.properties
@@ -0,0 +1 @@
sbt.version=0.11.2
8 changes: 8 additions & 0 deletions inject/sample/project/plugins.sbt
@@ -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")
Binary file added inject/sample/public/images/favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions inject/sample/public/javascripts/jquery-1.7.1.min.js

Large diffs are not rendered by default.

Empty file.

0 comments on commit dc484af

Please sign in to comment.