├── .gitignore ├── CONTRIBUTING.md ├── README.md ├── build.sbt ├── conf └── application.conf ├── images ├── play_ja_logo.ai └── play_ja_logo.png ├── manual ├── Home.md ├── ModuleDirectory.md ├── about │ ├── Philosophy.md │ ├── PlayUserGroups.md │ └── index.toc ├── detailedTopics │ ├── assets │ │ ├── Assets.md │ │ ├── AssetsCoffeeScript.md │ │ ├── AssetsJSHint.md │ │ ├── AssetsLess.md │ │ ├── RequireJS-support.md │ │ ├── images │ │ │ ├── ClosureError.png │ │ │ ├── coffeeError.png │ │ │ └── lessError.png │ │ └── index.toc │ ├── build │ │ ├── AggregatingReverseRouters.md │ │ ├── Build.md │ │ ├── Build.pdf │ │ ├── CompilationSpeed.md │ │ ├── PlayEnhancer.md │ │ ├── SBTCookbook.md │ │ ├── SBTDebugging.md │ │ ├── SBTDependencies.md │ │ ├── SBTSettings.md │ │ ├── SBTSubProjects.md │ │ ├── code │ │ │ ├── SubProjectsAssetsBuilder.scala │ │ │ ├── aggregate.sbt │ │ │ ├── build.sbt │ │ │ ├── detailedtopics.build.subprojects.assets.routes │ │ │ └── enhancer.sbt │ │ ├── images │ │ │ └── ivy-report.png │ │ ├── index.toc │ │ └── subprojectError.png │ ├── configuration │ │ ├── ApplicationSecret.md │ │ ├── Configuration.md │ │ ├── SettingsJDBC.md │ │ ├── SettingsLogger.md │ │ ├── ThreadPools.md │ │ ├── code │ │ │ ├── ThreadPools.scala │ │ │ └── ThreadPoolsJava.java │ │ ├── filters │ │ │ ├── CorsFilter.md │ │ │ ├── GzipEncoding.md │ │ │ ├── SecurityHeaders.md │ │ │ ├── code │ │ │ │ ├── CorsFilter.scala │ │ │ │ ├── GzipEncoding.scala │ │ │ │ ├── SecurityHeaders.scala │ │ │ │ ├── detailedtopics │ │ │ │ │ └── configuration │ │ │ │ │ │ ├── cors │ │ │ │ │ │ └── Filters.java │ │ │ │ │ │ ├── gzipencoding │ │ │ │ │ │ └── Filters.java │ │ │ │ │ │ └── headers │ │ │ │ │ │ └── Filters.java │ │ │ │ └── filters.sbt │ │ │ └── index.toc │ │ ├── index.toc │ │ └── ws │ │ │ ├── CertificateGeneration.md │ │ │ ├── CertificateRevocation.md │ │ │ ├── CertificateValidation.md │ │ │ ├── CipherSuites.md │ │ │ ├── DebuggingSSL.md │ │ │ ├── DefaultContext.md │ │ │ ├── ExampleSSLConfig.md │ │ │ ├── HostnameVerification.md │ │ │ ├── KeyStores.md │ │ │ ├── LooseSSL.md │ │ │ ├── Protocols.md │ │ │ ├── TestingSSL.md │ │ │ ├── WSQuickStart.md │ │ │ ├── WsSSL.md │ │ │ ├── code │ │ │ ├── HowsMySSLSpec.scala │ │ │ ├── genca.sh │ │ │ ├── genclient.sh │ │ │ ├── genpassword.sh │ │ │ ├── genserver.sh │ │ │ ├── genserverexp.sh │ │ │ └── gentruststore.sh │ │ │ └── index.toc │ ├── database │ │ ├── Developing-with-the-H2-Database.md │ │ └── index.toc │ ├── evolutions │ │ ├── Evolutions.md │ │ ├── images │ │ │ ├── evolutions.png │ │ │ └── evolutionsError.png │ │ └── index.toc │ ├── index.toc │ └── production │ │ ├── ConfiguringHttps.md │ │ ├── HTTPServer.md │ │ ├── Production.md │ │ ├── ProductionConfiguration.md │ │ ├── cloud │ │ ├── Deploying-Boxfuse.md │ │ ├── Deploying-CleverCloud.md │ │ ├── Deploying-CloudFoundry.md │ │ ├── DeployingCloud.md │ │ ├── ProductionHeroku.md │ │ └── index.toc │ │ ├── code │ │ ├── assembly.sbt │ │ ├── debian.sbt │ │ ├── java │ │ │ └── CustomSSLEngineProvider.java │ │ ├── production.sbt │ │ ├── rpm.sbt │ │ └── scala │ │ │ └── CustomSSLEngineProvider.scala │ │ ├── images │ │ ├── dist.png │ │ └── stage.png │ │ └── index.toc ├── experimental │ ├── AkkaHttpServer.md │ ├── ReactiveStreamsIntegration.md │ └── index.toc ├── gettingStarted │ ├── Anatomy.md │ ├── IDE.md │ ├── Installing.md │ ├── Modules.md │ ├── NewApplication.md │ ├── PlayConsole.md │ ├── Tutorials.md │ ├── images │ │ ├── activator.png │ │ ├── activatorNew.png │ │ ├── comet-clock.png │ │ ├── computerdatabase.png │ │ ├── console.png │ │ ├── consoleCompile.png │ │ ├── consoleEval.png │ │ ├── consoleRun.png │ │ ├── eclipse.png │ │ ├── errorPage.png │ │ ├── forms.png │ │ ├── helloworld.png │ │ ├── idea.png │ │ ├── rps-screenshot.png │ │ ├── websocket-chat.png │ │ └── zentask.png │ └── index.toc ├── hacking │ ├── BuildingFromSource.md │ ├── Documentation.md │ ├── Issues.md │ ├── Repositories.md │ ├── ThirdPartyTools.md │ ├── Translations.md │ ├── WorkingWithGit.md │ ├── images │ │ ├── cloudbees.png │ │ └── yourkit.png │ └── index.toc ├── index.toc ├── releases │ ├── Highlights21.md │ ├── Highlights22.md │ ├── Highlights23.md │ ├── Highlights24.md │ ├── Migration21.md │ ├── Migration22.md │ ├── Migration23.md │ ├── index.toc │ └── migration24 │ │ ├── Anorm.md │ │ ├── GlobalSettings.md │ │ ├── Migration24.md │ │ ├── PluginsToModules.md │ │ ├── code24 │ │ ├── MyComponent.java │ │ ├── MyComponent.scala │ │ ├── MyModule.java │ │ └── MyModule.scala │ │ └── index.toc └── working │ ├── index.toc │ ├── javaGuide │ ├── JavaHome.md │ ├── advanced │ │ ├── dependencyinjection │ │ │ ├── JavaDependencyInjection.md │ │ │ ├── code │ │ │ │ ├── injected.sbt │ │ │ │ ├── javaguide.advanced.di.routes │ │ │ │ └── javaguide │ │ │ │ │ └── advanced │ │ │ │ │ └── di │ │ │ │ │ ├── CurrentSharePrice.java │ │ │ │ │ ├── EnglishHello.java │ │ │ │ │ ├── GermanHello.java │ │ │ │ │ ├── Hello.java │ │ │ │ │ ├── JavaDependencyInjection.java │ │ │ │ │ ├── MessageQueue.java │ │ │ │ │ ├── MessageQueueConnection.java │ │ │ │ │ ├── constructor │ │ │ │ │ ├── controllers │ │ │ │ │ └── Application.java │ │ │ │ │ ├── field │ │ │ │ │ └── MyComponent.java │ │ │ │ │ ├── guice │ │ │ │ │ ├── CustomApplicationLoader.java │ │ │ │ │ ├── HelloModule.java │ │ │ │ │ ├── dynamic │ │ │ │ │ │ └── HelloModule.java │ │ │ │ │ └── eager │ │ │ │ │ │ └── HelloModule.java │ │ │ │ │ └── playlib │ │ │ │ │ └── HelloModule.java │ │ │ └── index.toc │ │ ├── embedding │ │ │ ├── JavaEmbeddingPlay.md │ │ │ ├── code │ │ │ │ └── javaguide │ │ │ │ │ └── advanced │ │ │ │ │ └── embedding │ │ │ │ │ └── JavaEmbeddingPlay.java │ │ │ └── index.toc │ │ ├── extending │ │ │ ├── JavaPlugins.md │ │ │ ├── code │ │ │ │ └── javaguide │ │ │ │ │ └── advanced │ │ │ │ │ └── extending │ │ │ │ │ ├── Actors.java │ │ │ │ │ ├── JavaPlugins.java │ │ │ │ │ ├── MyActor.java │ │ │ │ │ ├── MyComponent.java │ │ │ │ │ └── MyPlugin.java │ │ │ └── index.toc │ │ ├── http │ │ │ ├── JavaHttpFilters.md │ │ │ ├── JavaHttpRequestHandlers.md │ │ │ ├── code │ │ │ │ └── javaguide │ │ │ │ │ ├── RequestHandler.java │ │ │ │ │ └── httpfilters │ │ │ │ │ └── Filters.java │ │ │ └── index.toc │ │ ├── index.toc │ │ └── routing │ │ │ ├── JavaRoutingDsl.md │ │ │ ├── code │ │ │ └── javaguide │ │ │ │ └── advanced │ │ │ │ └── routing │ │ │ │ └── JavaRoutingDsl.java │ │ │ └── index.toc │ ├── code │ │ └── MockJavaAction.scala │ ├── index.toc │ └── main │ │ ├── akka │ │ ├── JavaAkka.md │ │ ├── code │ │ │ └── javaguide │ │ │ │ └── akka │ │ │ │ ├── ConfiguredActor.java │ │ │ │ ├── ConfiguredActorProtocol.java │ │ │ │ ├── ConfiguredChildActor.java │ │ │ │ ├── ConfiguredChildActorProtocol.java │ │ │ │ ├── HelloActor.java │ │ │ │ ├── HelloActorProtocol.java │ │ │ │ ├── JavaAkka.java │ │ │ │ ├── ParentActor.java │ │ │ │ ├── ParentActorProtocol.java │ │ │ │ ├── akka.conf │ │ │ │ ├── ask │ │ │ │ └── Application.java │ │ │ │ ├── async │ │ │ │ └── Application.java │ │ │ │ ├── factorymodules │ │ │ │ └── MyModule.java │ │ │ │ ├── inject │ │ │ │ └── Application.java │ │ │ │ └── modules │ │ │ │ └── MyModule.java │ │ └── index.toc │ │ ├── async │ │ ├── JavaAsync.md │ │ ├── JavaComet.md │ │ ├── JavaStream.md │ │ ├── JavaWebSockets.md │ │ ├── code │ │ │ ├── javaguide.async.routes │ │ │ └── javaguide │ │ │ │ └── async │ │ │ │ ├── JavaAsync.java │ │ │ │ ├── JavaComet.java │ │ │ │ ├── JavaStream.java │ │ │ │ ├── JavaWebSockets.java │ │ │ │ ├── MyWebSocketActor.java │ │ │ │ └── controllers │ │ │ │ └── Application.java │ │ └── index.toc │ │ ├── cache │ │ ├── JavaCache.md │ │ ├── code │ │ │ └── javaguide │ │ │ │ └── cache │ │ │ │ ├── JavaCache.java │ │ │ │ ├── inject │ │ │ │ └── Application.java │ │ │ │ └── qualified │ │ │ │ └── Application.java │ │ └── index.toc │ │ ├── forms │ │ ├── JavaCsrf.md │ │ ├── JavaFormHelpers.md │ │ ├── JavaForms.md │ │ ├── code │ │ │ ├── javaguide.forms.routes │ │ │ └── javaguide │ │ │ │ └── forms │ │ │ │ ├── JavaCsrf.java │ │ │ │ ├── JavaFormHelpers.scala │ │ │ │ ├── JavaForms.java │ │ │ │ ├── controllers │ │ │ │ └── Application.scala │ │ │ │ ├── csrf.scala.html │ │ │ │ ├── csrf │ │ │ │ └── Filters.java │ │ │ │ ├── form.scala.html │ │ │ │ ├── fullform.scala.html │ │ │ │ ├── helpers.scala.html │ │ │ │ ├── html │ │ │ │ ├── User.java │ │ │ │ ├── UserForm.java │ │ │ │ └── routes │ │ │ │ │ └── package.scala │ │ │ │ ├── myFieldConstructorTemplate.scala.html │ │ │ │ ├── u1 │ │ │ │ └── User.java │ │ │ │ ├── u2 │ │ │ │ └── User.java │ │ │ │ ├── u3 │ │ │ │ └── User.java │ │ │ │ ├── view.scala.html │ │ │ │ └── withFieldConstructor.scala.html │ │ └── index.toc │ │ ├── global │ │ ├── JavaGlobal.md │ │ ├── JavaInterceptors.md │ │ ├── code │ │ │ └── javaguide │ │ │ │ └── global │ │ │ │ ├── intercept │ │ │ │ └── Global.java │ │ │ │ ├── simple │ │ │ │ └── Global.java │ │ │ │ └── startstop │ │ │ │ └── Global.java │ │ └── index.toc │ │ ├── http │ │ ├── JavaActions.md │ │ ├── JavaActionsComposition.md │ │ ├── JavaBodyParsers.md │ │ ├── JavaContentNegotiation.md │ │ ├── JavaErrorHandling.md │ │ ├── JavaResponse.md │ │ ├── JavaRouting.md │ │ ├── JavaSessionFlash.md │ │ ├── code │ │ │ ├── javaguide.http.routing.defaultvalue.routes │ │ │ ├── javaguide.http.routing.fixed.routes │ │ │ ├── javaguide.http.routing.query.routes │ │ │ ├── javaguide.http.routing.reverse.routes │ │ │ ├── javaguide.http.routing.routes │ │ │ └── javaguide │ │ │ │ └── http │ │ │ │ ├── JavaActions.java │ │ │ │ ├── JavaActionsComposition.java │ │ │ │ ├── JavaBodyParsers.java │ │ │ │ ├── JavaContentNegotiation.java │ │ │ │ ├── JavaErrorHandling.scala │ │ │ │ ├── JavaResponse.java │ │ │ │ ├── JavaRouting.scala │ │ │ │ ├── JavaSessionFlash.java │ │ │ │ ├── def │ │ │ │ └── ErrorHandler.java │ │ │ │ ├── full │ │ │ │ └── Application.java │ │ │ │ ├── root │ │ │ │ └── ErrorHandler.java │ │ │ │ ├── routing │ │ │ │ ├── controllers │ │ │ │ │ ├── Api.java │ │ │ │ │ ├── Application.java │ │ │ │ │ ├── Clients.java │ │ │ │ │ └── Items.java │ │ │ │ └── reverse │ │ │ │ │ └── controllers │ │ │ │ │ └── Application.java │ │ │ │ └── views │ │ │ │ └── index.scala.html │ │ ├── images │ │ │ └── routesError.png │ │ └── index.toc │ │ ├── i18n │ │ ├── JavaI18N.md │ │ ├── code │ │ │ └── javaguide │ │ │ │ └── i18n │ │ │ │ ├── JavaI18N.java │ │ │ │ ├── helloscalatemplate.scala.html │ │ │ │ ├── hellotemplate.scala.html │ │ │ │ ├── messages │ │ │ │ ├── messages.en-US │ │ │ │ └── messages.fr │ │ └── index.toc │ │ ├── index.toc │ │ ├── json │ │ ├── JavaJsonActions.md │ │ ├── code │ │ │ └── javaguide │ │ │ │ └── json │ │ │ │ └── JavaJsonActions.java │ │ └── index.toc │ │ ├── logging │ │ ├── JavaLogging.md │ │ ├── code │ │ │ └── javaguide │ │ │ │ └── logging │ │ │ │ ├── Application.java │ │ │ │ ├── Global.java │ │ │ │ └── JavaLogging.java │ │ └── index.toc │ │ ├── sql │ │ ├── JavaDatabase.md │ │ ├── JavaJPA.md │ │ ├── code │ │ │ └── jpa.sbt │ │ ├── images │ │ │ └── dbError.png │ │ └── index.toc │ │ ├── tests │ │ ├── JavaFunctionalTest.md │ │ ├── JavaTest.md │ │ ├── JavaTestingWebServiceClients.md │ │ ├── JavaTestingWithDatabases.md │ │ ├── JavaTestingWithGuice.md │ │ ├── code │ │ │ ├── javaguide.tests.guice.routes │ │ │ ├── javaguide.tests.routes │ │ │ ├── javaguide │ │ │ │ └── tests │ │ │ │ │ ├── ApplicationTest.java │ │ │ │ │ ├── BrowserFunctionalTest.java │ │ │ │ │ ├── DatabaseTest.java │ │ │ │ │ ├── FakeApplicationTest.java │ │ │ │ │ ├── FunctionalTest.java │ │ │ │ │ ├── GitHubClient.java │ │ │ │ │ ├── GitHubClientTest.java │ │ │ │ │ ├── HamcrestTest.java │ │ │ │ │ ├── InjectionTest.java │ │ │ │ │ ├── JavaTestingWebServiceClients.java │ │ │ │ │ ├── JavaTestingWithDatabases.java │ │ │ │ │ ├── MockitoTest.java │ │ │ │ │ ├── ModelTest.java │ │ │ │ │ ├── ServerFunctionalTest.java │ │ │ │ │ ├── SimpleTest.java │ │ │ │ │ ├── controllers │ │ │ │ │ └── Application.java │ │ │ │ │ └── index.scala.html │ │ │ └── tests │ │ │ │ └── guice │ │ │ │ ├── Component.java │ │ │ │ ├── ComponentModule.java │ │ │ │ ├── DefaultComponent.java │ │ │ │ ├── JavaGuiceApplicationBuilderTest.java │ │ │ │ ├── MockComponent.java │ │ │ │ └── controllers │ │ │ │ └── Application.java │ │ └── index.toc │ │ ├── upload │ │ ├── JavaFileUpload.md │ │ ├── code │ │ │ └── JavaFileUpload.java │ │ └── index.toc │ │ ├── ws │ │ ├── JavaOAuth.md │ │ ├── JavaOpenID.md │ │ ├── JavaWS.md │ │ ├── code │ │ │ ├── javaguide.ws.routes │ │ │ └── javaguide │ │ │ │ └── ws │ │ │ │ ├── Application.java │ │ │ │ ├── JavaWS.java │ │ │ │ ├── JavaWSSpec.scala │ │ │ │ ├── controllers │ │ │ │ ├── OpenIDController.java │ │ │ │ └── Twitter.java │ │ │ │ └── login.scala.html │ │ └── index.toc │ │ └── xml │ │ ├── JavaXmlRequests.md │ │ ├── code │ │ └── javaguide │ │ │ └── xml │ │ │ └── JavaXmlRequests.java │ │ └── index.toc │ └── scalaGuide │ ├── ScalaHome.md │ ├── advanced │ ├── dependencyinjection │ │ ├── ScalaCompileTimeDependencyInjection.md │ │ ├── ScalaDependencyInjection.md │ │ ├── code │ │ │ ├── CompileTimeDependencyInjection.scala │ │ │ ├── RuntimeDependencyInjection.scala │ │ │ ├── injected.sbt │ │ │ ├── scalaguide.advanced.dependencyinjection.bar.routes │ │ │ ├── scalaguide.advanced.dependencyinjection.injected.routes │ │ │ └── scalaguide.advanced.dependencyinjection.routes │ │ └── index.toc │ ├── embedding │ │ ├── ScalaEmbeddingPlay.md │ │ ├── code │ │ │ └── ScalaEmbeddingPlay.scala │ │ └── index.toc │ ├── extending │ │ ├── ScalaPlugins.md │ │ ├── code │ │ │ └── ScalaPlugins.scala │ │ └── index.toc │ ├── http │ │ ├── HttpApi.md │ │ ├── ScalaHttpFilters.md │ │ ├── ScalaHttpRequestHandlers.md │ │ ├── code │ │ │ ├── EssentialFilter.scala │ │ │ ├── FiltersRouting.scala │ │ │ ├── ScalaHttpFilters.scala │ │ │ └── ScalaHttpRequestHandlers.scala │ │ └── index.toc │ ├── index.toc │ ├── iteratees │ │ ├── Enumeratees.md │ │ ├── Enumerators.md │ │ ├── Iteratees.md │ │ └── index.toc │ └── routing │ │ ├── ScalaJavascriptRouting.md │ │ ├── ScalaSirdRouter.md │ │ ├── code │ │ └── ScalaSirdRouter.scala │ │ └── index.toc │ ├── index.toc │ └── main │ ├── akka │ ├── ScalaAkka.md │ ├── code │ │ └── ScalaAkka.scala │ └── index.toc │ ├── async │ ├── ScalaAsync.md │ ├── ScalaComet.md │ ├── ScalaStream.md │ ├── ScalaWebSockets.md │ ├── code │ │ ├── ScalaAsync.scala │ │ ├── ScalaComet.scala │ │ └── ScalaWebSockets.scala │ └── index.toc │ ├── cache │ ├── ScalaCache.md │ ├── code │ │ └── ScalaCache.scala │ └── index.toc │ ├── forms │ ├── ScalaCsrf.md │ ├── ScalaCustomFieldConstructors.md │ ├── ScalaCustomValidations.md │ ├── ScalaForms.md │ ├── code │ │ ├── CustomValidations.scala │ │ ├── ScalaCsrf.scala │ │ ├── ScalaFieldConstructor.scala │ │ ├── ScalaForms.scala │ │ ├── scalaguide.forms.scalaforms.routes │ │ └── scalaguide │ │ │ └── forms │ │ │ ├── csrf.scala.html │ │ │ ├── scalafieldconstructor │ │ │ ├── myFieldConstructorTemplate.scala.html │ │ │ ├── userDeclare.scala.html │ │ │ └── userImport.scala.html │ │ │ └── scalaforms │ │ │ └── views │ │ │ ├── contact │ │ │ └── form.scala.html │ │ │ ├── nested.scala.html │ │ │ ├── repeat.scala.html │ │ │ └── user.scala.html │ ├── images │ │ ├── lifecycle.png │ │ └── lifecycle.xml │ └── index.toc │ ├── http │ ├── ScalaActions.md │ ├── ScalaActionsComposition.md │ ├── ScalaBodyParsers.md │ ├── ScalaContentNegotiation.md │ ├── ScalaErrorHandling.md │ ├── ScalaResults.md │ ├── ScalaRouting.md │ ├── ScalaSessionFlash.md │ ├── code │ │ ├── ScalaActions.scala │ │ ├── ScalaActionsComposition.scala │ │ ├── ScalaBodyParser.scala │ │ ├── ScalaContentNegotiation.scala │ │ ├── ScalaErrorHandling.scala │ │ ├── ScalaResults.scala │ │ ├── ScalaRouting.scala │ │ ├── ScalaSessionFlash.scala │ │ ├── scalaguide.http.routing.defaultvalue.routes │ │ ├── scalaguide.http.routing.fixed.routes │ │ ├── scalaguide.http.routing.query.routes │ │ ├── scalaguide.http.routing.reverse.routes │ │ ├── scalaguide.http.routing.routes │ │ └── scalaguide │ │ │ └── http │ │ │ ├── routing │ │ │ └── views │ │ │ │ └── Clients │ │ │ │ └── display.scala.html │ │ │ └── scalasessionflash │ │ │ └── views │ │ │ └── index.scala.html │ ├── images │ │ └── routesError.png │ └── index.toc │ ├── i18n │ ├── ScalaI18N.md │ ├── code │ │ ├── ScalaI18N.scala │ │ └── scalaguide │ │ │ └── i18n │ │ │ └── messages │ └── index.toc │ ├── index.toc │ ├── json │ ├── ScalaJson.md │ ├── ScalaJsonCombinators.md │ ├── ScalaJsonHttp.md │ ├── ScalaJsonInception.md │ ├── ScalaJsonTransformers.md │ ├── code │ │ ├── ScalaJsonCombinatorsSpec.scala │ │ ├── ScalaJsonHttpSpec.scala │ │ └── ScalaJsonSpec.scala │ └── index.toc │ ├── logging │ ├── ScalaLogging.md │ ├── code │ │ └── ScalaLoggingSpec.scala │ └── index.toc │ ├── sql │ ├── ScalaDatabase.md │ ├── ScalaDatabaseOthers.md │ ├── images │ │ └── dbError.png │ └── index.toc │ ├── tests │ ├── ScalaFunctionalTestingWithScalaTest.md │ ├── ScalaFunctionalTestingWithSpecs2.md │ ├── ScalaTestingWebServiceClients.md │ ├── ScalaTestingWithDatabases.md │ ├── ScalaTestingWithGuice.md │ ├── ScalaTestingWithScalaTest.md │ ├── ScalaTestingWithSpecs2.md │ ├── ScalaTestingYourApplication.md │ ├── code-scalatestplus-play │ │ ├── ExampleControllerSpec.scala │ │ ├── ExampleEssentialActionSpec.scala │ │ ├── ExampleMockitoSpec.scala │ │ ├── ExamplePostSpec.scala │ │ ├── ScalaFunctionalTestSpec.scala │ │ ├── StackSpec.scala │ │ ├── UserServiceSpec.scala │ │ ├── allbrowserspersuite │ │ │ ├── ExampleOverrideBrowsersSpec.scala │ │ │ └── ExampleSpec.scala │ │ ├── allbrowserspertest │ │ │ └── ExampleSpec.scala │ │ ├── mixedfixtures │ │ │ └── ExampleSpec.scala │ │ ├── oneapppersuite │ │ │ └── ExampleSpec.scala │ │ ├── oneapppertest │ │ │ └── ExampleSpec.scala │ │ ├── onebrowserpersuite │ │ │ └── ExampleSpec.scala │ │ ├── onebrowserpertest │ │ │ └── ExampleSpec.scala │ │ ├── oneserverpersuite │ │ │ └── ExampleSpec.scala │ │ ├── oneserverpertest │ │ │ └── ExampleSpec.scala │ │ └── playspec │ │ │ └── ExampleSpec.scala │ ├── code │ │ ├── controllers │ │ │ └── Application.scala │ │ ├── database │ │ │ └── ScalaTestingWithDatabases.scala │ │ ├── models │ │ │ └── User.scala │ │ ├── scalaguide.tests.guice.routes │ │ ├── services │ │ │ ├── UserRepository.scala │ │ │ └── UserService.scala │ │ ├── specs2 │ │ │ ├── ExampleControllerSpec.scala │ │ │ ├── ExampleEssentialActionSpec.scala │ │ │ ├── ExampleMockitoSpec.scala │ │ │ ├── ExamplePlaySpecificationSpec.scala │ │ │ ├── FunctionalExampleControllerSpec.scala │ │ │ ├── FunctionalTemplateSpec.scala │ │ │ ├── HelloWorldSpec.scala │ │ │ ├── ScalaFunctionalTestSpec.scala │ │ │ ├── UserServiceSpec.scala │ │ │ └── WithDbDataSpec.scala │ │ ├── tests │ │ │ └── guice │ │ │ │ ├── Component.scala │ │ │ │ ├── ScalaGuiceApplicationBuilderSpec.scala │ │ │ │ └── controllers │ │ │ │ └── Application.scala │ │ ├── views │ │ │ └── html │ │ │ │ └── index.scala │ │ └── webservice │ │ │ └── ScalaTestingWebServiceClients.scala │ └── index.toc │ ├── upload │ ├── ScalaFileUpload.md │ ├── code │ │ ├── ScalaFileUpload.scala │ │ ├── scalaguide.upload.fileupload.routes │ │ └── scalaguide │ │ │ └── templates │ │ │ └── views │ │ │ └── uploadForm.scala.html │ └── index.toc │ ├── ws │ ├── ScalaOAuth.md │ ├── ScalaOpenID.md │ ├── ScalaWS.md │ ├── code │ │ ├── ScalaOpenIdSpec.scala │ │ └── ScalaWSSpec.scala │ └── index.toc │ └── xml │ ├── ScalaXmlRequests.md │ ├── code │ └── ScalaXmlRequests.scala │ └── index.toc └── project ├── build.properties └── plugins.sbt /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *.swp 3 | *.iml 4 | *.ipr 5 | *.iws 6 | .classpath 7 | .project 8 | .redcar/* 9 | .settings/* 10 | .idea/ 11 | .DS_Store 12 | bin/ 13 | eclipse/* 14 | eclipse/classes/* 15 | precompiled/* 16 | tmp/* 17 | tmp/bytecode/* 18 | test-result/* 19 | lib/* 20 | modules/* 21 | html/* 22 | target 23 | project/project 24 | logs 25 | 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Play Framework ドキュメント日本語翻訳 2 | 3 | ![play_ja_logo](images/play_ja_logo.png) 4 | 5 | このプロジェクトは [playframework](https://www.playframework.com/) のドキュメントを日本語に翻訳するプロジェクトです。 6 | 7 | このプロジェクトの成果は [playframework.com/documentation/ja](https://playframework.com/documentation/ja/) に公開されます。 8 | 9 | 翻訳にご協力頂く際は、[CONTRIBUTING.md](https://github.com/playframework-ja/translation-project/blob/2.3.x/CONTRIBUTING.md) を確認してください。 10 | 11 | 不明な点がある場合は [@garbagetown](https://twitter.com/garbagetown) または Gitter までお気軽にお問い合わせください。 12 | 13 | [![Gitter](https://badges.gitter.im/playframework-ja/translation-project.svg)](https://gitter.im/playframework-ja/translation-project?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 14 | -------------------------------------------------------------------------------- /build.sbt: -------------------------------------------------------------------------------- 1 | resolvers += "Typesafe Releases Repository" at "http://repo.typesafe.com/typesafe/releases/" 2 | 3 | lazy val root = (project in file(".")).enablePlugins(PlayDocsPlugin) 4 | 5 | PlayDocsKeys.docsVersion := "2.2.4" 6 | -------------------------------------------------------------------------------- /conf/application.conf: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2009-2013 Typesafe Inc. 3 | # 4 | 5 | # Reference configuration for Play 6 | 7 | #default timeout for promises 8 | promise.akka.actor.typed.timeout=5s 9 | 10 | play { 11 | application { 12 | 13 | # The error handler. 14 | # Used by Play's built in DI support to locate and bind an error handler. Must be one of the following: 15 | # - A FQCN that implements play.api.http.HttpErrorHandler (Scala). 16 | # - A FQCN that implements play.http.HttpErrorHandler (Java). 17 | # - provided, indicates that the application has bound an instance of play.api.http.HttpErrorHandler through some 18 | # other mechanism. 19 | # If undefined or empty, will attempt to load a class called ErrorHandler in the root package, otherwise if that's 20 | # not found, will default to play.api.http.GlobalSettingsHttpErrorHandler, which delegates to legacy error handling 21 | # methods on Global. 22 | errorHandler = "" 23 | } 24 | 25 | modules { 26 | i18n { 27 | enabled = true 28 | } 29 | akka { 30 | actor-system = "application" 31 | } 32 | } 33 | 34 | akka { 35 | loggers = ["akka.event.Logging$DefaultLogger", "akka.event.slf4j.Slf4jLogger"] 36 | loglevel = WARNING 37 | 38 | actor { 39 | default-dispatcher = { 40 | fork-join-executor { 41 | parallelism-factor = 1.0 42 | parallelism-max = 24 43 | } 44 | } 45 | 46 | } 47 | 48 | } 49 | 50 | crypto { 51 | aes { 52 | transformation = "AES" 53 | } 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /images/play_ja_logo.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/images/play_ja_logo.ai -------------------------------------------------------------------------------- /images/play_ja_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/images/play_ja_logo.png -------------------------------------------------------------------------------- /manual/Home.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # Play %PLAY_VERSION% ドキュメント 6 | 7 | 12 | >Play は、現代の web アプリケーション開発に必要なコンポーネント及び API を統合した生産性の高い Java と Scala の web アプリケーションフレームワークです。 13 | > 14 | > Play の特徴は、ライトウェイト、ステートレス、web フレンドリーなアーキテクチャであること、機能予測のしやすさです。また、Iteratee IO をベースにしたリアクティブモデルのおかげで、スケーラブルなアプリケーションでも CPU、メモリ、スレッドなどのリソース消費が最小限になっています。 15 | 16 | 22 | - [[Play 2.4 の変更点|Highlights24]] / [[Play 2.4 移行ガイド|Migration24]] 23 | - [[Play 2.3 の変更点|Highlights23]] / [[Play 2.3 移行ガイド|Migration23]] 24 | - [[Play 2.2 の変更点|Highlights22]] / [[Play 2.2 移行ガイド|Migration22]] 25 | - [[Play 2.1 の変更点|Highlights21]] / [[Play 2.1 移行ガイド|Migration21]] 26 | 27 | 28 | @toc@ 29 | 30 | ## モジュールとプラグイン 31 | 32 | 35 | [[一時的なモジュールディレクトリ | ModuleDirectory]] 36 | -------------------------------------------------------------------------------- /manual/about/PlayUserGroups.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # Play ユーザーグループ 6 | 7 | 10 | ## ニューヨーク 11 | 12 | http://www.meetup.com/Play-NYC/ 13 | 14 | 17 | ## ベルリン 18 | 19 | http://www.meetup.com/Play-Berlin-Brandenburg/ 20 | 21 | 24 | ## ケルン 25 | 26 | 29 | ### Scala ユーザーグループ ケルン/ボン 30 | 31 | 34 | *(Play について話し合い, プレゼンテーションを行いました。)* 35 | 36 | [Xing](https://www.xing.com/communities/groups/scala-user-group-koeln-bonn-1035441) / [Twitter](https://twitter.com/scalacgn) 37 | 38 | 41 | ## ブエノスアイレス 42 | 43 | http://www.meetup.com/play-argentina/ 44 | 45 | 48 | ## ストックホルム 49 | 50 | http://www.meetup.com/play-stockholm/ 51 | 52 | 55 | ## ベルギー 56 | 57 | http://www.play-be.org 58 | 59 | 62 | ## 日本 63 | 64 | * http://www.playframework-ja.org/ 65 | * https://groups.google.com/forum/?fromgroups#!forum/play_ja 66 | 67 | 70 | ## 韓国 71 | 72 | 75 | #### 韓国 Play! ユーザグループ 76 | 77 | * [Facebook](https://www.facebook.com/groups/playuser) 78 | * [Github](https://github.com/kpug) 79 | * [Slack](https://kpug.slack.com) 80 | 81 | 84 | ## ニューデリー - インド 85 | 86 | http://www.meetup.com/Reactive-Application-Programmers-in-Delhi-NCR/ 87 | 88 | -------------------------------------------------------------------------------- /manual/about/index.toc: -------------------------------------------------------------------------------- 1 | Philosophy:Play の哲学 2 | PlayUserGroups:Play ユーザグループ 3 | -------------------------------------------------------------------------------- /manual/detailedTopics/assets/images/ClosureError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/assets/images/ClosureError.png -------------------------------------------------------------------------------- /manual/detailedTopics/assets/images/coffeeError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/assets/images/coffeeError.png -------------------------------------------------------------------------------- /manual/detailedTopics/assets/images/lessError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/assets/images/lessError.png -------------------------------------------------------------------------------- /manual/detailedTopics/assets/index.toc: -------------------------------------------------------------------------------- 1 | Assets:公開アセットを使う 2 | AssetsCoffeeScript:CoffeeScript を使う 3 | AssetsLess:LESS CSS を使う 4 | AssetsJSHint:JSHint を使う 5 | RequireJS-support:RequireJs を使う 6 | -------------------------------------------------------------------------------- /manual/detailedTopics/build/Build.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/build/Build.pdf -------------------------------------------------------------------------------- /manual/detailedTopics/build/CompilationSpeed.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # コンパイル時間の改善 6 | 7 | 10 | 良いエンジニアリグ習慣でもある以下のガイドラインに従うことで、コンパイル速度を改善することができます: 11 | 12 | 15 | ## サブプロジェクト/モジュールを使う 16 | 17 | 20 | これは、モジュール化から得られるその他の恩恵に追加される、差分コンパイルに関する圧力壁のようなものです。これにより循環のサイズが小さくなり、依存関係が明確になり、必要な場合はコードのサブセットについて作業することができるようになります。また、sbt が独立したモジュールを並列にコンパイルすることもできるようになります。 21 | 22 | 25 | ## public メソッドの戻り値を注釈する 26 | 27 | 30 | 型推論、およびソースファイルをまたがる推論から生じる差分コンパイルのコーナーケースにおける正確性を減らすことで、コンパイルを速くすることができます。 31 | 32 | 35 | ## ソースファイル間の大きな循環を避ける 36 | 37 | 40 | 循環は、巨大な再コンパイルと同じか、またはそれ以上の手順をもたらす傾向があります。sbt 0.13.0 (Play 2.2) 以上では、以前ほど問題にはなりません。 41 | 42 | 45 | ## 継承を最小化する 46 | 47 | 50 | ソースファイル内の公開 API を変更すると、通常はすべての子孫クラスの再コンパイルが必要になります。 -------------------------------------------------------------------------------- /manual/detailedTopics/build/code/SubProjectsAssetsBuilder.scala: -------------------------------------------------------------------------------- 1 | //#assets-builder 2 | package controllers.admin 3 | import play.api.http.LazyHttpErrorHandler 4 | object Assets extends controllers.AssetsBuilder(LazyHttpErrorHandler) 5 | //#assets-builder 6 | -------------------------------------------------------------------------------- /manual/detailedTopics/build/code/aggregate.sbt: -------------------------------------------------------------------------------- 1 | //#content 2 | lazy val common: Project = (project in file("common")) 3 | .enablePlugins(PlayScala) 4 | .settings( 5 | aggregateReverseRoutes := Seq(api, web) 6 | ) 7 | 8 | lazy val api = (project in file("api")) 9 | .enablePlugins(PlayScala) 10 | .dependsOn(common) 11 | 12 | lazy val web = (project in file("web")) 13 | .enablePlugins(PlayScala) 14 | .dependsOn(common) 15 | //#content 16 | 17 | lazy val root = (project in file(".")) 18 | .enablePlugins(PlayScala) 19 | .dependsOn(api, web) 20 | -------------------------------------------------------------------------------- /manual/detailedTopics/build/code/build.sbt: -------------------------------------------------------------------------------- 1 | //#default 2 | name := "foo" 3 | 4 | version := "1.0-SNAPSHOT" 5 | 6 | libraryDependencies ++= Seq( 7 | jdbc, 8 | anorm, 9 | cache 10 | ) 11 | 12 | lazy val root = (project in file(".")).enablePlugins(PlayScala) 13 | //#default -------------------------------------------------------------------------------- /manual/detailedTopics/build/code/detailedtopics.build.subprojects.assets.routes: -------------------------------------------------------------------------------- 1 | #assets-routes 2 | GET /index controllers.admin.Application.index() 3 | 4 | GET /assets/*file controllers.admin.Assets.at(path="/public/lib/myadmin", file) 5 | #assets-routes 6 | -------------------------------------------------------------------------------- /manual/detailedTopics/build/code/enhancer.sbt: -------------------------------------------------------------------------------- 1 | //#plugins.sbt 2 | addSbtPlugin("com.typesafe.sbt" % "sbt-play-enhancer" % "1.1.0") 3 | //#plugins.sbt 4 | 5 | //#disable-project 6 | lazy val nonEnhancedProject = (project in file("non-enhanced")) 7 | .disablePlugins(PlayEnhancer) 8 | //#disable-project 9 | 10 | //#disable-enhancement 11 | playEnhancerEnabled := false 12 | //#disable-enhancement 13 | 14 | //#select-generate 15 | sources in (Compile, playEnhancerGenerateAccessors) := { 16 | ((javaSource in Compile).value / "models" ** "*.java").get 17 | } 18 | //#select-generate 19 | -------------------------------------------------------------------------------- /manual/detailedTopics/build/images/ivy-report.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/build/images/ivy-report.png -------------------------------------------------------------------------------- /manual/detailedTopics/build/index.toc: -------------------------------------------------------------------------------- 1 | Build:ビルドシステム 2 | SBTSettings:sbt 設定について 3 | SBTDependencies:依存性の管理 4 | SBTSubProjects:サブプロジェクトを使う 5 | PlayEnhancer:Play エンハンサ 6 | AggregatingReverseRouters:リバースルートの統合 7 | CompilationSpeed:コンパイル時間の改善 8 | SBTCookbook:SBT クックブック 9 | SBTDebugging:ビルドのデバッグ 10 | -------------------------------------------------------------------------------- /manual/detailedTopics/build/subprojectError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/build/subprojectError.png -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/code/ThreadPoolsJava.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package detailedtopics.configuration.threadpools; 5 | 6 | import org.junit.Test; 7 | import play.Play; 8 | import play.test.FakeApplication; 9 | 10 | import static org.hamcrest.CoreMatchers.*; 11 | import static org.junit.Assert.*; 12 | import static play.test.Helpers.*; 13 | 14 | public class ThreadPoolsJava { 15 | 16 | @Test 17 | public void usingAppClassLoader() throws Exception { 18 | running(fakeApplication(), new Runnable() { 19 | public void run() { 20 | String myClassName = "java.lang.String"; 21 | try { 22 | //#using-app-classloader 23 | Class myClass = Play.application().classloader().loadClass(myClassName); 24 | //#using-app-classloader 25 | assertThat(myClass, notNullValue()); 26 | } catch (ClassNotFoundException e) { 27 | throw new RuntimeException(e); 28 | } 29 | } 30 | }); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/code/CorsFilter.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package detailedtopics.configuration.cors.sapi 5 | 6 | //#filters 7 | import javax.inject.Inject 8 | 9 | import play.api.http.HttpFilters 10 | import play.filters.cors.CORSFilter 11 | 12 | class Filters @Inject() (corsFilter: CORSFilter) extends HttpFilters { 13 | def filters = Seq(corsFilter) 14 | } 15 | //#filters 16 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/code/GzipEncoding.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package detailedtopics.configuration.gzipencoding 5 | 6 | import play.api.test._ 7 | 8 | object GzipEncoding extends PlaySpecification { 9 | 10 | //#filters 11 | import javax.inject.Inject 12 | 13 | import play.api.http.HttpFilters 14 | import play.filters.gzip.GzipFilter 15 | 16 | class Filters @Inject() (gzipFilter: GzipFilter) extends HttpFilters { 17 | def filters = Seq(gzipFilter) 18 | } 19 | //#filters 20 | 21 | "gzip filter" should { 22 | 23 | "allow custom strategies for when to gzip" in { 24 | val filter = 25 | //#should-gzip 26 | new GzipFilter(shouldGzip = (request, response) => 27 | response.headers.get("Content-Type").exists(_.startsWith("text/html"))) 28 | //#should-gzip 29 | 30 | import play.api.mvc._ 31 | running(FakeApplication()) { 32 | header(CONTENT_ENCODING, 33 | filter(Action(Results.Ok("foo")))(gzipRequest).run 34 | ) must beNone 35 | } 36 | } 37 | 38 | } 39 | 40 | def gzipRequest = FakeRequest().withHeaders(ACCEPT_ENCODING -> "gzip") 41 | 42 | 43 | } 44 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/code/SecurityHeaders.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | 5 | package detailedtopics.configuration.securityheaders 6 | 7 | object SecurityHeaders { 8 | 9 | //#filters 10 | import javax.inject.Inject 11 | 12 | import play.api.http.HttpFilters 13 | import play.filters.headers.SecurityHeadersFilter 14 | 15 | class Filters @Inject() (securityHeadersFilter: SecurityHeadersFilter) extends HttpFilters { 16 | def filters = Seq(securityHeadersFilter) 17 | } 18 | //#filters 19 | } 20 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/code/detailedtopics/configuration/cors/Filters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package detailedtopics.configuration.cors; 5 | 6 | //#filters 7 | import play.api.mvc.EssentialFilter; 8 | import play.filters.cors.CORSFilter; 9 | import play.http.HttpFilters; 10 | 11 | import javax.inject.Inject; 12 | 13 | public class Filters implements HttpFilters { 14 | 15 | @Inject 16 | CORSFilter corsFilter; 17 | 18 | public EssentialFilter[] filters() { 19 | return new EssentialFilter[] { corsFilter }; 20 | } 21 | } 22 | //#filters -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/code/detailedtopics/configuration/gzipencoding/Filters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package detailedtopics.configuration.gzipencoding; 5 | 6 | //#filters 7 | import play.api.mvc.EssentialFilter; 8 | import play.filters.gzip.GzipFilter; 9 | import play.http.HttpFilters; 10 | 11 | import javax.inject.Inject; 12 | 13 | public class Filters implements HttpFilters { 14 | 15 | @Inject 16 | GzipFilter gzipFilter; 17 | 18 | public EssentialFilter[] filters() { 19 | return new EssentialFilter[] { gzipFilter }; 20 | } 21 | } 22 | //#filters -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/code/detailedtopics/configuration/headers/Filters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package detailedtopics.configuration.headers; 5 | 6 | //#filters 7 | import play.api.mvc.EssentialFilter; 8 | import play.filters.headers.SecurityHeadersFilter; 9 | import play.http.HttpFilters; 10 | 11 | import javax.inject.Inject; 12 | 13 | public class Filters implements HttpFilters { 14 | 15 | @Inject 16 | SecurityHeadersFilter securityHeadersFilter; 17 | 18 | public EssentialFilter[] filters() { 19 | return new EssentialFilter[] { securityHeadersFilter }; 20 | } 21 | } 22 | //#filters -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/code/filters.sbt: -------------------------------------------------------------------------------- 1 | //#content 2 | libraryDependencies += filters 3 | //#content 4 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/filters/index.toc: -------------------------------------------------------------------------------- 1 | GzipEncoding:gzip エンコーディングの設定 2 | SecurityHeaders:セキュリティヘッダの設定 3 | CorsFilter:CORS の設定 4 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/index.toc: -------------------------------------------------------------------------------- 1 | Configuration:設定ファイルの文法と機能 2 | ApplicationSecret:アプリケーション秘密鍵の設定 3 | SettingsJDBC:JDBC コネクションプールの設定 4 | ThreadPools:Play スレッドプールの設定 5 | SettingsLogger:ログの設定 6 | filters:Play フィルタの設定 7 | ws:WS SSL の設定 8 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/ws/DefaultContext.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # デフォルト SSLContext を使う 6 | 7 | 10 | WS が提供する SSLContext は使いたくないものの、`SSLContext.getDefault` を使いたい場合は、以下のように設定してください: 11 | 12 | ``` 13 | play.ws.ssl.default = true 14 | ``` 15 | 16 | 19 | ## デバッグ 20 | 21 | 24 | デフォルトコンテキストをデバッグする場合、以下のように設定してください。 25 | 26 | ``` 27 | play.ws.ssl.debug { 28 | ssl = true 29 | sslctx = true 30 | defaultctx = true 31 | } 32 | ``` 33 | 34 | 37 | デフォルトの SSLContext を使っている場合、JSSE の振る舞いは [JSSE システムプロパティ](https://docs.oracle.com/javase/jp/8/docs/technotes/guides/security/jsse/JSSERefGuide.html#Customization) の操作を通じてのみ変更することができます。 38 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/ws/code/genca.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # #context 4 | export PW=`cat password` 5 | 6 | # Create a self signed key pair root CA certificate. 7 | keytool -genkeypair -v \ 8 | -alias exampleca \ 9 | -dname "CN=exampleCA, OU=Example Org, O=Example Company, L=San Francisco, ST=California, C=US" \ 10 | -keystore exampleca.jks \ 11 | -keypass:env PW \ 12 | -storepass:env PW \ 13 | -keyalg RSA \ 14 | -keysize 4096 \ 15 | -ext KeyUsage:critical="keyCertSign" \ 16 | -ext BasicConstraints:critical="ca:true" \ 17 | -validity 9999 18 | 19 | # Export the exampleCA public certificate as exampleca.crt so that it can be used in trust stores. 20 | keytool -export -v \ 21 | -alias exampleca \ 22 | -file exampleca.crt \ 23 | -keypass:env PW \ 24 | -storepass:env PW \ 25 | -keystore exampleca.jks \ 26 | -rfc 27 | # #context 28 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/ws/code/genpassword.sh: -------------------------------------------------------------------------------- 1 | # #context 2 | export PW=`pwgen -Bs 10 1` 3 | echo $PW > password 4 | # #context -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/ws/code/genserver.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # #context 4 | export PW=`cat password` 5 | 6 | # Create a server certificate, tied to example.com 7 | keytool -genkeypair -v \ 8 | -alias example.com \ 9 | -dname "CN=example.com, OU=Example Org, O=Example Company, L=San Francisco, ST=California, C=US" \ 10 | -keystore example.com.jks \ 11 | -keypass:env PW \ 12 | -storepass:env PW \ 13 | -keyalg RSA \ 14 | -keysize 2048 \ 15 | -validity 385 16 | 17 | # Create a certificate signing request for example.com 18 | keytool -certreq -v \ 19 | -alias example.com \ 20 | -keypass:env PW \ 21 | -storepass:env PW \ 22 | -keystore example.com.jks \ 23 | -file example.com.csr 24 | 25 | # Tell exampleCA to sign the example.com certificate. Note the extension is on the request, not the 26 | # original certificate. 27 | # Technically, keyUsage should be digitalSignature for DHE or ECDHE, keyEncipherment for RSA. 28 | keytool -gencert -v \ 29 | -alias exampleca \ 30 | -keypass:env PW \ 31 | -storepass:env PW \ 32 | -keystore exampleca.jks \ 33 | -infile example.com.csr \ 34 | -outfile example.com.crt \ 35 | -ext KeyUsage:critical="digitalSignature,keyEncipherment" \ 36 | -ext EKU="serverAuth" \ 37 | -ext SAN="DNS:example.com" \ 38 | -rfc 39 | 40 | # Tell example.com.jks it can trust exampleca as a signer. 41 | keytool -import -v \ 42 | -alias exampleca \ 43 | -file exampleca.crt \ 44 | -keystore example.com.jks \ 45 | -storetype JKS \ 46 | -storepass:env PW << EOF 47 | yes 48 | EOF 49 | 50 | # Import the signed certificate back into example.com.jks 51 | keytool -import -v \ 52 | -alias example.com \ 53 | -file example.com.crt \ 54 | -keystore example.com.jks \ 55 | -storetype JKS \ 56 | -storepass:env PW 57 | 58 | # List out the contents of example.com.jks just to confirm it. 59 | # If you are using Play as a TLS termination point, this is the key store you should present as the server. 60 | keytool -list -v \ 61 | -keystore example.com.jks \ 62 | -storepass:env PW 63 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/ws/code/genserverexp.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # #context 4 | export PW=`cat password` 5 | 6 | # Export example.com's public certificate for use with nginx. 7 | keytool -export -v \ 8 | -alias example.com \ 9 | -file example.com.crt \ 10 | -keypass:env PW \ 11 | -storepass:env PW \ 12 | -keystore example.com.jks \ 13 | -rfc 14 | 15 | # Create a PKCS#12 keystore containing the public and private keys. 16 | keytool -importkeystore -v \ 17 | -srcalias example.com \ 18 | -srckeystore example.com.jks \ 19 | -srcstoretype jks \ 20 | -srcstorepass:env PW \ 21 | -destkeystore example.com.p12 \ 22 | -destkeypass:env PW \ 23 | -deststorepass:env PW \ 24 | -deststoretype PKCS12 25 | 26 | # Export the example.com private key for use in nginx. Note this requires the use of OpenSSL. 27 | openssl pkcs12 \ 28 | -nocerts \ 29 | -nodes \ 30 | -passout env:PW \ 31 | -passin env:PW \ 32 | -in example.com.p12 \ 33 | -out example.com.key 34 | 35 | # Clean up. 36 | rm example.com.p12 37 | # #context 38 | -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/ws/code/gentruststore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # #context 4 | export PW=`cat password` 5 | 6 | # Create a JKS keystore that trusts the example CA, with the default password. 7 | keytool -import -v \ 8 | -alias exampleca \ 9 | -file exampleca.crt \ 10 | -keypass:env PW \ 11 | -storepass changeit \ 12 | -keystore exampletrust.jks << EOF 13 | yes 14 | EOF 15 | 16 | # List out the details of the store password. 17 | keytool -list -v \ 18 | -keystore exampletrust.jks \ 19 | -storepass changeit 20 | 21 | # #context -------------------------------------------------------------------------------- /manual/detailedTopics/configuration/ws/index.toc: -------------------------------------------------------------------------------- 1 | WsSSL:WS SSL の設定 2 | WSQuickStart:WS SSL クイックスタート 3 | CertificateGeneration:X.509 証明書の生成 4 | KeyStores:トラストストアとキーストアの設定 5 | Protocols:プロトコルの設定 6 | CipherSuites:暗号スイートの設定 7 | CertificateValidation:証明書検証の設定 8 | CertificateRevocation:証明書失効の設定 9 | HostnameVerification:ホスト名検証の設定 10 | ExampleSSLConfig:設定例 11 | DefaultContext:デフォルト SSLContext を使う 12 | DebuggingSSL:SSL 接続のデバッグ 13 | LooseSSL:ゆるいオプション 14 | TestingSSL:SSL のテスト 15 | -------------------------------------------------------------------------------- /manual/detailedTopics/database/index.toc: -------------------------------------------------------------------------------- 1 | Developing-with-the-H2-Database:Using an in memory H2 database -------------------------------------------------------------------------------- /manual/detailedTopics/evolutions/images/evolutions.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/evolutions/images/evolutions.png -------------------------------------------------------------------------------- /manual/detailedTopics/evolutions/images/evolutionsError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/evolutions/images/evolutionsError.png -------------------------------------------------------------------------------- /manual/detailedTopics/evolutions/index.toc: -------------------------------------------------------------------------------- 1 | Evolutions:Managing database evolutions -------------------------------------------------------------------------------- /manual/detailedTopics/index.toc: -------------------------------------------------------------------------------- 1 | build:ビルドシステム 2 | assets:公開アセットを使う 3 | configuration:設定 4 | database:データベース 5 | evolutions:Evolutions によるデータベースの管理 6 | production:アプリケーションのデプロイ 7 | -------------------------------------------------------------------------------- /manual/detailedTopics/production/cloud/DeployingCloud.md: -------------------------------------------------------------------------------- 1 | 2 | # Deploying a Play application to a cloud service 3 | 4 | Many third party cloud services have built in support for deploying Play applications. 5 | 6 | - [[Deploying to Heroku|ProductionHeroku]] 7 | - [[Deploying to Cloud Foundry|Deploying-CloudFoundry]] 8 | - [[Deploying to Clever Cloud|Deploying-CleverCloud]] 9 | - [[Deploying to Boxfuse and AWS|Deploying-Boxfuse]] 10 | -------------------------------------------------------------------------------- /manual/detailedTopics/production/cloud/index.toc: -------------------------------------------------------------------------------- 1 | DeployingCloud:クラウドサービスにデプロイする 2 | ProductionHeroku:Heroku にデプロイする 3 | Deploying-CloudFoundry:Cloud Foundry にデプロイする 4 | Deploying-CleverCloud:Clever Cloud にデプロイする 5 | Deploying-Boxfuse:Boxfuse と AWS にデプロイする 6 | -------------------------------------------------------------------------------- /manual/detailedTopics/production/code/assembly.sbt: -------------------------------------------------------------------------------- 1 | //#assembly 2 | import AssemblyKeys._ 3 | 4 | assemblySettings 5 | 6 | mainClass in assembly := Some("play.core.server.NettyServer") 7 | 8 | fullClasspath in assembly += Attributed.blank(PlayKeys.playPackageAssets.value) 9 | //#assembly -------------------------------------------------------------------------------- /manual/detailedTopics/production/code/debian.sbt: -------------------------------------------------------------------------------- 1 | //#debian 2 | lazy val root = (project in file(".")) 3 | .enablePlugins(PlayScala, DebianPlugin) 4 | 5 | maintainer in Linux := "First Lastname " 6 | 7 | packageSummary in Linux := "My custom package summary" 8 | 9 | packageDescription := "My longer package description" 10 | //#debian -------------------------------------------------------------------------------- /manual/detailedTopics/production/code/java/CustomSSLEngineProvider.java: -------------------------------------------------------------------------------- 1 | package java; 2 | 3 | // #javaexample 4 | import play.server.ApplicationProvider; 5 | import play.server.SSLEngineProvider; 6 | 7 | import javax.net.ssl.*; 8 | import java.security.NoSuchAlgorithmException; 9 | 10 | public class CustomSSLEngineProvider implements SSLEngineProvider { 11 | private ApplicationProvider applicationProvider; 12 | 13 | public CustomSSLEngineProvider(ApplicationProvider applicationProvider) { 14 | this.applicationProvider = applicationProvider; 15 | } 16 | 17 | @Override 18 | public SSLEngine createSSLEngine() { 19 | try { 20 | // change it to your custom implementation 21 | return SSLContext.getDefault().createSSLEngine(); 22 | } catch (NoSuchAlgorithmException e) { 23 | throw new RuntimeException(e); 24 | } 25 | } 26 | } 27 | // #javaexample 28 | -------------------------------------------------------------------------------- /manual/detailedTopics/production/code/production.sbt: -------------------------------------------------------------------------------- 1 | //#no-scaladoc 2 | sources in (Compile, doc) := Seq.empty 3 | 4 | publishArtifact in (Compile, packageDoc) := false 5 | //#no-scaladoc 6 | 7 | //#publish-repo 8 | publishTo := Some( 9 | "My resolver" at "https://mycompany.com/repo" 10 | ) 11 | 12 | credentials += Credentials( 13 | "Repo", "https://mycompany.com/repo", "admin", "admin123" 14 | ) 15 | //#publish-repo 16 | -------------------------------------------------------------------------------- /manual/detailedTopics/production/code/rpm.sbt: -------------------------------------------------------------------------------- 1 | //#rpm 2 | lazy val root = (project in file(".")) 3 | .enablePlugins(PlayScala, RpmPlugin) 4 | 5 | maintainer in Linux := "First Lastname " 6 | 7 | packageSummary in Linux := "My custom package summary" 8 | 9 | packageDescription := "My longer package description" 10 | 11 | rpmRelease := "1" 12 | 13 | rpmVendor := "example.com" 14 | 15 | rpmUrl := Some("http://github.com/example/server") 16 | 17 | rpmLicense := Some("Apache v2") 18 | //#rpm 19 | -------------------------------------------------------------------------------- /manual/detailedTopics/production/code/scala/CustomSSLEngineProvider.scala: -------------------------------------------------------------------------------- 1 | package scala 2 | 3 | // #scalaexample 4 | import javax.net.ssl._ 5 | import play.core.ApplicationProvider 6 | import play.server.api._ 7 | 8 | class CustomSSLEngineProvider(appProvider: ApplicationProvider) extends SSLEngineProvider { 9 | 10 | override def createSSLEngine(): SSLEngine = { 11 | // change it to your custom implementation 12 | SSLContext.getDefault.createSSLEngine 13 | } 14 | 15 | } 16 | // #scalaexample 17 | -------------------------------------------------------------------------------- /manual/detailedTopics/production/images/dist.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/production/images/dist.png -------------------------------------------------------------------------------- /manual/detailedTopics/production/images/stage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/detailedTopics/production/images/stage.png -------------------------------------------------------------------------------- /manual/detailedTopics/production/index.toc: -------------------------------------------------------------------------------- 1 | Production:アプリケーションのデプロイ 2 | ProductionConfiguration:運用環境設定 3 | HTTPServer:フロントエンド HTTP サーバの設定 4 | ConfiguringHttps:HTTPS の設定 5 | cloud:クラウドサービスにデプロイする 6 | -------------------------------------------------------------------------------- /manual/experimental/index.toc: -------------------------------------------------------------------------------- 1 | AkkaHttpServer:Akka HTTP サーババックエンド 2 | ReactiveStreamsIntegration:Reactive Streams の統合 3 | -------------------------------------------------------------------------------- /manual/gettingStarted/images/activator.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/activator.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/activatorNew.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/activatorNew.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/comet-clock.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/comet-clock.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/computerdatabase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/computerdatabase.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/console.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/console.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/consoleCompile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/consoleCompile.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/consoleEval.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/consoleEval.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/consoleRun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/consoleRun.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/eclipse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/eclipse.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/errorPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/errorPage.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/forms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/forms.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/helloworld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/helloworld.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/idea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/idea.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/rps-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/rps-screenshot.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/websocket-chat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/websocket-chat.png -------------------------------------------------------------------------------- /manual/gettingStarted/images/zentask.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/gettingStarted/images/zentask.png -------------------------------------------------------------------------------- /manual/gettingStarted/index.toc: -------------------------------------------------------------------------------- 1 | Installing:Play のインストール 2 | NewApplication:新しいアプリケーションを作る 3 | PlayConsole:Play コンソールを使う 4 | IDE:好みの IDE を設定する 5 | Anatomy:Play アプリケーションの構造 6 | Tutorials:Play チュートリアル 7 | Modules:Play モジュール 8 | -------------------------------------------------------------------------------- /manual/hacking/Issues.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # 課題トラッカ 6 | --> 7 | 8 | 11 | Play は課題トラッカに GitHub を利用しています。 12 | 13 | 16 | . 17 | 18 | 21 | ## バグを報告する 22 | 23 | 26 | バグ報告は本当に有難いです。ぜひ少しだけお時間を割いて、バグ報告や新機能のリクエストを課題トラッカに登録してください。また、Play のコードに対するパッチは大歓迎です。通常、パッチが添付されているバグ報告は、パッチが添付されていないものより素早く対応されます。 27 | 28 | 31 | バグ報告にはぜひ、利用されているフレームワークの正確なバージョンや、バグを再現できるコード・スニペット、その他可能な限り多くの関連情報を含めてください。 32 | 33 | 36 | 全てのバグや新機能リクエストが即座に対応されるわけではありません。「完全に壊れている」という類の深刻なバグ以外は、まずチケットを切って話し合いするところから始めましょう。また、パッチ(または Play に pull できるような GitHub 上のブランチ)はあったほうが良いのですが、実際に取り込まれるのは Play のコアに含まれるべき内容だと判断されたものだけです。 37 | -------------------------------------------------------------------------------- /manual/hacking/Repositories.md: -------------------------------------------------------------------------------- 1 | 2 | # Artifact repositories 3 | 4 | ## Typesafe repository 5 | 6 | All Play artifacts are published to the Typesafe repository at . 7 | 8 | > **Note:** it's a Maven2 compatible repository. 9 | 10 | To enable it in your sbt build, you must add a proper resolver (typically in `plugins.sbt`): 11 | 12 | ```scala 13 | // The Typesafe repository 14 | resolvers += "Typesafe Releases" at "https://repo.typesafe.com/typesafe/releases/" 15 | ``` 16 | 17 | ## Accessing snapshots 18 | 19 | Snapshots are published daily from our [[Continuous Integration Server|ThirdPartyTools]] to the Typesafe snapshots repository at . 20 | 21 | > **Note:** it's an ivy style repository. 22 | 23 | ```scala 24 | // The Typesafe snapshots repository 25 | resolvers += Resolver.url("Typesafe Ivy Snapshots Repository", url("https://repo.typesafe.com/typesafe/ivy-snapshots"))(Resolver.ivyStylePatterns) 26 | ``` 27 | 28 | -------------------------------------------------------------------------------- /manual/hacking/ThirdPartyTools.md: -------------------------------------------------------------------------------- 1 | 2 | # 3rd Party Tools 3 | 4 | A big THANK YOU! to these sponsors for their support of open source projects. 5 | 6 | ## Continuous Integration 7 | 8 | ![CloudBees logo](images/cloudbees.png) 9 | 10 | Our continuous integration runs on [Cloudbees](https://www.cloudbees.com/). We not only run CI on major release and master branches, but we also perform github pull request validation using CloudBees functionality. 11 | 12 | 13 | 14 | ## Profiling 15 | 16 | ![YourKit logo](images/yourkit.png) 17 | 18 | We are using [YourKit](https://www.yourkit.com/overview/index.jsp) for profiling our Java and Scala code. YourKit really helps us keep Play's resource usage to the minimum that you'd expect. 19 | -------------------------------------------------------------------------------- /manual/hacking/images/cloudbees.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/hacking/images/cloudbees.png -------------------------------------------------------------------------------- /manual/hacking/images/yourkit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/hacking/images/yourkit.png -------------------------------------------------------------------------------- /manual/hacking/index.toc: -------------------------------------------------------------------------------- 1 | BuildingFromSource:ソースから Play をビルドする 2 | Repositories:リポジトリ 3 | Issues:課題トラッカ 4 | Documentation:ドキュメントガイドライン 5 | Translations:翻訳ガイドライン 6 | WorkingWithGit:git を使う 7 | ThirdPartyTools:サードパーティツール 8 | -------------------------------------------------------------------------------- /manual/index.toc: -------------------------------------------------------------------------------- 1 | Home:Home 2 | gettingStarted:はじめに 3 | working:Play で開発する 4 | detailedTopics:詳細なトピック 5 | experimental:実験的なライブラリ 6 | hacking:Play を Hack する 7 | about:Play について 8 | releases:Play のリリース 9 | ModuleDirectory:一時的なモジュールディレクトリ 10 | -------------------------------------------------------------------------------- /manual/releases/index.toc: -------------------------------------------------------------------------------- 1 | Highlights24:Play 2.4 の変更点 2 | Highlights23:Play 2.3 の変更点 3 | Highlights22:Play 2.2 の変更点 4 | Highlights21:Play 2.1 の変更点 5 | migration24:Play 2.4 移行ガイド 6 | Migration23:Play 2.3 移行ガイド 7 | Migration22:Play 2.2 移行ガイド 8 | Migration21:Play 2.1 移行ガイド 9 | -------------------------------------------------------------------------------- /manual/releases/migration24/code24/MyComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | 5 | //#components-decl 6 | import javax.inject.Inject; 7 | import play.inject.ApplicationLifecycle; 8 | import play.libs.F; 9 | 10 | public interface MyComponent {} 11 | 12 | class MyComponentImpl implements MyComponent { 13 | @Inject 14 | public MyComponentImpl(ApplicationLifecycle lifecycle) { 15 | // previous contents of Plugin.onStart 16 | lifecycle.addStopHook( () -> { 17 | // previous contents of Plugin.onStop 18 | return F.Promise.pure(null); 19 | }); 20 | } 21 | } 22 | //#components-decl -------------------------------------------------------------------------------- /manual/releases/migration24/code24/MyComponent.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scaladoc { 5 | package mycomponent { 6 | 7 | 8 | //#components-decl 9 | import javax.inject.Inject 10 | import play.api.inject.ApplicationLifecycle 11 | import scala.concurrent.Future 12 | 13 | trait MyComponent 14 | 15 | class MyComponentImpl @Inject()(lifecycle: ApplicationLifecycle) extends MyComponent { 16 | // previous contents of Plugin.onStart 17 | lifecycle.addStopHook { () => 18 | // previous contents of Plugin.onStop 19 | Future.successful(()) 20 | } 21 | } 22 | //#components-decl 23 | } 24 | } -------------------------------------------------------------------------------- /manual/releases/migration24/code24/MyModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | 5 | //#module-decl 6 | import play.api.Configuration; 7 | import play.api.Environment; 8 | import play.api.inject.Binding; 9 | import play.api.inject.Module; 10 | 11 | import scala.collection.Seq; 12 | 13 | public class MyModule extends Module { 14 | public Seq> bindings(Environment environment, Configuration configuration) { 15 | return seq( 16 | bind(MyComponent.class).to(MyComponentImpl.class) 17 | ); 18 | } 19 | } 20 | //#module-decl -------------------------------------------------------------------------------- /manual/releases/migration24/code24/MyModule.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scaladoc { 5 | package module { 6 | 7 | import mycomponent._ 8 | //#module-decl 9 | import play.api.Configuration 10 | import play.api.Environment 11 | import play.api.inject.Binding 12 | import play.api.inject.Module 13 | 14 | class MyModule extends Module { 15 | def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = { 16 | Seq( 17 | bind[MyComponent].to[MyComponentImpl] 18 | ) 19 | } 20 | } 21 | //#module-decl 22 | 23 | //#components-decl 24 | import play.api.inject.ApplicationLifecycle 25 | 26 | trait MyComponents { 27 | def applicationLifecycle: ApplicationLifecycle 28 | lazy val component: MyComponent = new MyComponentImpl(applicationLifecycle) 29 | } 30 | //#components-decl 31 | } 32 | } -------------------------------------------------------------------------------- /manual/releases/migration24/index.toc: -------------------------------------------------------------------------------- 1 | Migration24:Play 2.4 移行ガイド 2 | GlobalSettings:`GlobalSettings` の削除 3 | Anorm:Anorm 4 | PluginsToModules:Plugin から Module への移行 5 | -------------------------------------------------------------------------------- /manual/working/index.toc: -------------------------------------------------------------------------------- 1 | !scalaGuide:Scala 開発者のための Play 2 | !javaGuide:Java 開発者のための Play 3 | -------------------------------------------------------------------------------- /manual/working/javaGuide/JavaHome.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # Java 開発者のための Play 6 | 7 | 10 | Play アプリケーションは、`play` パッケージ内にある Java API を使って開発することができます。 11 | 12 | 15 | > (`play.api.mvc` のような) `play.api` パッケージ内の API は Scala 開発者に予約されています。Java 開発者は `play.mvc` などを参照してください。 16 | 17 | @toc@ 18 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/injected.sbt: -------------------------------------------------------------------------------- 1 | //#content 2 | routesGenerator := InjectedRoutesGenerator 3 | //#content -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide.advanced.di.routes: -------------------------------------------------------------------------------- 1 | #content 2 | GET /some/path @controllers.Application.index() 3 | #content -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/CurrentSharePrice.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di; 5 | 6 | //#singleton 7 | import javax.inject.*; 8 | 9 | @Singleton 10 | public class CurrentSharePrice { 11 | private volatile int price; 12 | 13 | public void set(int p) { 14 | price = p; 15 | } 16 | 17 | public int get() { 18 | return price; 19 | } 20 | } 21 | //#singleton 22 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/EnglishHello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di; 5 | 6 | //#implemented-by 7 | public class EnglishHello implements Hello { 8 | 9 | public String sayHello(String name) { 10 | return "Hello " + name; 11 | } 12 | } 13 | //#implemented-by 14 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/GermanHello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di; 5 | 6 | public class GermanHello implements Hello { 7 | @Override 8 | public String sayHello(String name) { 9 | return "Hallo " + name; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/Hello.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di; 5 | 6 | //#implemented-by 7 | import com.google.inject.ImplementedBy; 8 | 9 | @ImplementedBy(EnglishHello.class) 10 | public interface Hello { 11 | 12 | String sayHello(String name); 13 | } 14 | //#implemented-by 15 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/JavaDependencyInjection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di; 5 | 6 | import play.test.*; 7 | import org.junit.Test; 8 | 9 | import static org.junit.Assert.*; 10 | import static org.hamcrest.CoreMatchers.*; 11 | 12 | public class JavaDependencyInjection extends WithApplication { 13 | 14 | @Test 15 | public void fieldInjection() { 16 | assertNotNull(app.injector().instanceOf(javaguide.advanced.di.field.MyComponent.class)); 17 | } 18 | 19 | @Test 20 | public void constructorInjection() { 21 | assertNotNull(app.injector().instanceOf(javaguide.advanced.di.constructor.MyComponent.class)); 22 | } 23 | 24 | @Test 25 | public void singleton() { 26 | app.injector().instanceOf(CurrentSharePrice.class).set(10); 27 | assertThat(app.injector().instanceOf(CurrentSharePrice.class).get(), equalTo(10)); 28 | } 29 | 30 | @Test 31 | public void cleanup() { 32 | app.injector().instanceOf(MessageQueueConnection.class); 33 | stopPlay(); 34 | assertTrue(MessageQueue.stopped); 35 | } 36 | 37 | @Test 38 | public void implementedBy() { 39 | assertThat(app.injector().instanceOf(Hello.class).sayHello("world"), equalTo("Hello world")); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/MessageQueue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di; 5 | 6 | public class MessageQueue { 7 | public static boolean stopped = false; 8 | 9 | public static MessageQueue connect() { 10 | return new MessageQueue(); 11 | } 12 | 13 | public void stop() { 14 | stopped = true; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/MessageQueueConnection.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di; 5 | 6 | //#cleanup 7 | import javax.inject.*; 8 | import play.inject.ApplicationLifecycle; 9 | import play.libs.F; 10 | 11 | import java.util.concurrent.Callable; 12 | 13 | @Singleton 14 | public class MessageQueueConnection { 15 | private final MessageQueue connection; 16 | 17 | @Inject 18 | public MessageQueueConnection(ApplicationLifecycle lifecycle) { 19 | connection = MessageQueue.connect(); 20 | 21 | lifecycle.addStopHook(() -> { 22 | connection.stop(); 23 | return F.Promise.pure(null); 24 | }); 25 | } 26 | 27 | // ... 28 | } 29 | //#cleanup 30 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/constructor/MyComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di.constructor; 5 | 6 | //#constructor 7 | import javax.inject.*; 8 | import play.libs.ws.*; 9 | 10 | public class MyComponent { 11 | private final WSClient ws; 12 | 13 | @Inject 14 | public MyComponent(WSClient ws) { 15 | this.ws = ws; 16 | } 17 | 18 | // ... 19 | } 20 | //#constructor 21 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/controllers/Application.java: -------------------------------------------------------------------------------- 1 | package javaguide.advanced.di.controllers; 2 | 3 | import play.mvc.*; 4 | 5 | public class Application extends Controller { 6 | public Result index() { 7 | return ok(); 8 | } 9 | } -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/field/MyComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di.field; 5 | 6 | //#field 7 | import javax.inject.*; 8 | import play.libs.ws.*; 9 | 10 | public class MyComponent { 11 | @Inject WSClient ws; 12 | 13 | // ... 14 | } 15 | //#field 16 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/guice/CustomApplicationLoader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di.guice; 5 | 6 | //#custom-application-loader 7 | import play.Application; 8 | import play.ApplicationLoader; 9 | import play.Configuration; 10 | import play.inject.guice.GuiceApplicationBuilder; 11 | import play.inject.guice.GuiceApplicationLoader; 12 | import play.libs.Scala; 13 | 14 | public class CustomApplicationLoader extends GuiceApplicationLoader { 15 | 16 | @Override 17 | public GuiceApplicationBuilder builder(ApplicationLoader.Context context) { 18 | Configuration extra = new Configuration("a = 1"); 19 | return initialBuilder 20 | .in(context.environment()) 21 | .loadConfig(extra.withFallback(context.initialConfiguration())) 22 | .overrides(overrides(context)); 23 | } 24 | 25 | } 26 | //#custom-application-loader 27 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/guice/HelloModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di.guice; 5 | 6 | import javaguide.advanced.di.*; 7 | 8 | //#guice-module 9 | import com.google.inject.AbstractModule; 10 | import com.google.inject.name.Names; 11 | 12 | public class HelloModule extends AbstractModule { 13 | protected void configure() { 14 | 15 | bind(Hello.class) 16 | .annotatedWith(Names.named("en")) 17 | .to(EnglishHello.class); 18 | 19 | bind(Hello.class) 20 | .annotatedWith(Names.named("de")) 21 | .to(GermanHello.class); 22 | } 23 | } 24 | //#guice-module 25 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/guice/dynamic/HelloModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di.guice.configured; 5 | 6 | import javaguide.advanced.di.*; 7 | 8 | //#dynamic-guice-module 9 | import com.google.inject.AbstractModule; 10 | import com.google.inject.ConfigurationException; 11 | import com.google.inject.name.Names; 12 | import play.Configuration; 13 | import play.Environment; 14 | 15 | public class HelloModule extends AbstractModule { 16 | 17 | private final Environment environment; 18 | private final Configuration configuration; 19 | 20 | public HelloModule( 21 | Environment environment, 22 | Configuration configuration) { 23 | this.environment = environment; 24 | this.configuration = configuration; 25 | } 26 | 27 | protected void configure() { 28 | // Expect configuration like: 29 | // hello.en = "myapp.EnglishHello" 30 | // hello.de = "myapp.GermanHello" 31 | Configuration helloConf = configuration.getConfig("hello"); 32 | // Iterate through all the languages and bind the 33 | // class associated with that language. Use Play's 34 | // ClassLoader to load the classes. 35 | for (String l: helloConf.subKeys()) { 36 | try { 37 | String bindingClassName = helloConf.getString(l); 38 | Class bindingClass = 39 | environment.classLoader().loadClass(bindingClassName) 40 | .asSubclass(Hello.class); 41 | bind(Hello.class) 42 | .annotatedWith(Names.named(l)) 43 | .to(bindingClass); 44 | } catch (ClassNotFoundException e) { 45 | throw new RuntimeException(e); 46 | } 47 | } 48 | } 49 | } 50 | //#dynamic-guice-module 51 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/guice/eager/HelloModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di.guice.eager; 5 | 6 | import javaguide.advanced.di.*; 7 | 8 | //#eager-guice-module 9 | import com.google.inject.AbstractModule; 10 | import com.google.inject.name.Names; 11 | 12 | public class HelloModule extends AbstractModule { 13 | protected void configure() { 14 | 15 | bind(Hello.class) 16 | .annotatedWith(Names.named("en")) 17 | .to(EnglishHello.class) 18 | .asEagerSingleton(); 19 | 20 | bind(Hello.class) 21 | .annotatedWith(Names.named("de")) 22 | .to(GermanHello.class) 23 | .asEagerSingleton(); 24 | } 25 | } 26 | //#eager-guice-module 27 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/code/javaguide/advanced/di/playlib/HelloModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.di.playlib; 5 | 6 | import javaguide.advanced.di.*; 7 | 8 | //#play-module 9 | import play.api.*; 10 | import play.api.inject.*; 11 | import scala.collection.Seq; 12 | 13 | public class HelloModule extends Module { 14 | @Override 15 | public Seq> bindings(Environment environment, Configuration configuration) { 16 | return seq( 17 | bind(Hello.class).qualifiedWith("en").to(EnglishHello.class), 18 | bind(Hello.class).qualifiedWith("de").to(GermanHello.class) 19 | ); 20 | } 21 | } 22 | //#play-module 23 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/dependencyinjection/index.toc: -------------------------------------------------------------------------------- 1 | JavaDependencyInjection:Guice による依存性の注入 -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/embedding/JavaEmbeddingPlay.md: -------------------------------------------------------------------------------- 1 | 2 | # Embedding a Play server in your application 3 | 4 | While Play apps are most commonly used as their own container, you can also embed a Play server into your own existing application. This can be used in conjunction with the Twirl template compiler and Play routes compiler, but these are of course not necessary, a common use case for embedding a Play application will be because you only have a few very simple routes. 5 | 6 | The simplest way to start an embedded Play server is to use the [`Server`](api/java/play/server/Server.html) factory methods. If all you need to do is provide some straightforward routes, you may decide to use the [[Routing DSL|JavaRoutingDsl]], so you will need the following imports: 7 | 8 | @[imports](code/javaguide/advanced/embedding/JavaEmbeddingPlay.java) 9 | 10 | Then you can create a server using the `forRouter` method: 11 | 12 | @[simple](code/javaguide/advanced/embedding/JavaEmbeddingPlay.java) 13 | 14 | By default, this will start a server on a random port in test mode. You can check the port using the `httpPort` method: 15 | 16 | @[http-port](code/javaguide/advanced/embedding/JavaEmbeddingPlay.java) 17 | 18 | You can configure the server by passing in a `port` and/or `mode`: 19 | 20 | @[config](code/javaguide/advanced/embedding/JavaEmbeddingPlay.java) 21 | 22 | To stop the server once you've started it, simply call the `stop` method: 23 | 24 | @[stop](code/javaguide/advanced/embedding/JavaEmbeddingPlay.java) 25 | 26 | > **Note:** Play requires an application secret to be configured in order to start. This can be configured by providing an `application.conf` file in your application, or using the `play.crypto.secret` system property. -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/embedding/index.toc: -------------------------------------------------------------------------------- 1 | JavaEmbeddingPlay:Play の組み込み -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/extending/code/javaguide/advanced/extending/Actors.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | //#code 5 | //###replace: package actors; 6 | package javaguide.advanced.extending; 7 | 8 | import akka.actor.*; 9 | import play.*; 10 | import play.libs.Akka; 11 | 12 | import javax.inject.Inject; 13 | 14 | public class Actors extends Plugin { 15 | private final Application app; 16 | 17 | private ActorRef myActor; 18 | 19 | @Inject 20 | public Actors(Application app) { 21 | this.app = app; 22 | } 23 | 24 | public void onStart() { 25 | myActor = Akka.system().actorOf(MyActor.props(), "my-actor"); 26 | } 27 | 28 | public static ActorRef getMyActor() { 29 | return Play.application().plugin(Actors.class).myActor; 30 | } 31 | } 32 | //#code 33 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/extending/code/javaguide/advanced/extending/JavaPlugins.java: -------------------------------------------------------------------------------- 1 | package javaguide.advanced.extending; 2 | 3 | import akka.actor.ActorRef; 4 | import org.junit.Test; 5 | import play.Application; 6 | import play.Play; 7 | import play.libs.F; 8 | import play.test.*; 9 | 10 | import java.util.Arrays; 11 | import java.util.HashMap; 12 | import java.util.concurrent.atomic.AtomicReference; 13 | 14 | import static org.junit.Assert.*; 15 | import static play.test.Helpers.*; 16 | import static akka.pattern.Patterns.ask; 17 | 18 | public class JavaPlugins { 19 | 20 | @Test 21 | public void pluginsShouldBeAccessible() { 22 | final AtomicReference myComponentRef = new AtomicReference(); 23 | Application app = fakeApplication(new HashMap(), Arrays.asList(MyPlugin.class.getName())); 24 | running(app, new Runnable() { 25 | public void run() { 26 | //#access-plugin 27 | MyComponent myComponent = Play.application().plugin(MyPlugin.class).getMyComponent(); 28 | //#access-plugin 29 | assertTrue(myComponent.started); 30 | myComponentRef.set(myComponent); 31 | } 32 | }); 33 | assertTrue(myComponentRef.get().stopped); 34 | } 35 | 36 | @Test 37 | public void actorExampleShouldWork() { 38 | Application app = fakeApplication(new HashMap(), Arrays.asList(Actors.class.getName())); 39 | running(app, new Runnable() { 40 | public void run() { 41 | ActorRef actor = Actors.getMyActor(); 42 | assertEquals("hi", F.Promise.wrap(ask(actor, "hi", 20000)).get(20000)); 43 | } 44 | }); 45 | } 46 | 47 | } 48 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/extending/code/javaguide/advanced/extending/MyActor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.extending; 5 | 6 | import akka.actor.*; 7 | 8 | public class MyActor extends UntypedActor { 9 | public static Props props() { 10 | return Props.create(MyActor.class); 11 | } 12 | 13 | public void onReceive(Object message) throws Exception { 14 | sender().tell(message, self()); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/extending/code/javaguide/advanced/extending/MyComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.advanced.extending; 5 | 6 | public class MyComponent { 7 | public boolean started; 8 | public boolean stopped; 9 | public void start() { 10 | started = true; 11 | } 12 | public void stop() { 13 | stopped = true; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/extending/code/javaguide/advanced/extending/MyPlugin.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | //#code 5 | //###replace: package plugins; 6 | package javaguide.advanced.extending; 7 | 8 | import play.Plugin; 9 | 10 | public class MyPlugin extends Plugin { 11 | 12 | private final MyComponent myComponent = new MyComponent(); 13 | 14 | public void onStart() { 15 | myComponent.start(); 16 | } 17 | 18 | public void onStop() { 19 | myComponent.stop(); 20 | } 21 | 22 | public boolean enabled() { 23 | return true; 24 | } 25 | 26 | public MyComponent getMyComponent() { 27 | return myComponent; 28 | } 29 | } 30 | //#code 31 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/extending/index.toc: -------------------------------------------------------------------------------- 1 | JavaPlugins:プラグインの書き方 -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/http/code/javaguide/RequestHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | 5 | //#default 6 | import play.http.HttpRequestHandler; 7 | import play.libs.F; 8 | import play.mvc.Action; 9 | import play.mvc.Http; 10 | import play.mvc.Result; 11 | 12 | import java.lang.reflect.Method; 13 | 14 | public class RequestHandler implements HttpRequestHandler { 15 | 16 | @Override 17 | public Action createAction(Http.Request request, Method actionMethod) { 18 | return new Action.Simple() { 19 | @Override 20 | public F.Promise call(Http.Context ctx) throws Throwable { 21 | return delegate.call(ctx); 22 | } 23 | }; 24 | } 25 | 26 | @Override 27 | public Action wrapAction(Action action) { 28 | return action; 29 | } 30 | } 31 | //#default 32 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/http/code/javaguide/httpfilters/Filters.java: -------------------------------------------------------------------------------- 1 | package httpfilters; 2 | 3 | // #filters 4 | import play.api.Logger; 5 | import play.api.mvc.EssentialFilter; 6 | import play.http.HttpFilters; 7 | import play.filters.gzip.GzipFilter; 8 | import javax.inject.Inject; 9 | 10 | public class Filters implements HttpFilters { 11 | 12 | private final GzipFilter gzip; 13 | 14 | @Inject 15 | public Filters(GzipFilter gzip) { 16 | this.gzip = gzip; 17 | } 18 | 19 | @Override 20 | public EssentialFilter[] filters() { 21 | return new EssentialFilter[] { gzip }; 22 | } 23 | } 24 | //#filters 25 | -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/http/index.toc: -------------------------------------------------------------------------------- 1 | JavaHttpFilters:HTTP フィルタ 2 | JavaHttpRequestHandlers:HTTP リクエストの処理 -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/index.toc: -------------------------------------------------------------------------------- 1 | dependencyinjection:依存性の注入 2 | http:HTTP アーキテクチャ 3 | routing:拡張ルーティング 4 | extending:Play の拡張 5 | embedding:Play の組み込み -------------------------------------------------------------------------------- /manual/working/javaGuide/advanced/routing/index.toc: -------------------------------------------------------------------------------- 1 | JavaRoutingDsl:組み込みルーティング DSL -------------------------------------------------------------------------------- /manual/working/javaGuide/index.toc: -------------------------------------------------------------------------------- 1 | JavaHome:目次 2 | main:主要なコンセプト 3 | advanced:上級編 -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/ConfiguredActor.java: -------------------------------------------------------------------------------- 1 | package javaguide.akka; 2 | 3 | //#injected 4 | import akka.actor.UntypedActor; 5 | import play.Configuration; 6 | 7 | import javax.inject.Inject; 8 | 9 | public class ConfiguredActor extends UntypedActor { 10 | 11 | @Inject Configuration configuration; 12 | 13 | @Override 14 | public void onReceive(Object message) throws Exception { 15 | if (message instanceof ConfiguredActorProtocol.GetConfig) { 16 | sender().tell(configuration.getString("my.config"), self()); 17 | } 18 | } 19 | } 20 | //#injected 21 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/ConfiguredActorProtocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka; 5 | 6 | public class ConfiguredActorProtocol { 7 | 8 | public static class GetConfig {} 9 | } 10 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/ConfiguredChildActor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka; 5 | 6 | //#injectedchild 7 | import akka.actor.UntypedActor; 8 | import com.google.inject.assistedinject.Assisted; 9 | import play.Configuration; 10 | 11 | import javax.inject.Inject; 12 | 13 | public class ConfiguredChildActor extends UntypedActor { 14 | 15 | private final Configuration configuration; 16 | private final String key; 17 | 18 | @Inject 19 | public ConfiguredChildActor(Configuration configuration, @Assisted String key) { 20 | this.configuration = configuration; 21 | this.key = key; 22 | } 23 | 24 | @Override 25 | public void onReceive(Object message) throws Exception { 26 | if (message instanceof ConfiguredChildActorProtocol.GetConfig) { 27 | sender().tell(configuration.getString(key), self()); 28 | } 29 | } 30 | } 31 | //#injectedchild 32 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/ConfiguredChildActorProtocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka; 5 | 6 | //#protocol 7 | import akka.actor.Actor; 8 | 9 | public class ConfiguredChildActorProtocol { 10 | 11 | public static class GetConfig {} 12 | 13 | public interface Factory { 14 | public Actor create(String key); 15 | } 16 | } 17 | //#protocol 18 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/HelloActor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | //#actor 5 | //###replace: package actors; 6 | package javaguide.akka; 7 | 8 | import akka.actor.*; 9 | //###replace: import actors.HelloActorProtocol.*; 10 | import javaguide.akka.HelloActorProtocol.*; 11 | 12 | public class HelloActor extends UntypedActor { 13 | 14 | public static Props props = Props.create(HelloActor.class); 15 | 16 | public void onReceive(Object msg) throws Exception { 17 | if (msg instanceof SayHello) { 18 | sender().tell("Hello, " + ((SayHello) msg).name, self()); 19 | } 20 | } 21 | } 22 | //#actor 23 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/HelloActorProtocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | //#protocol 5 | //###replace: package actors; 6 | package javaguide.akka; 7 | 8 | public class HelloActorProtocol { 9 | 10 | public static class SayHello { 11 | public final String name; 12 | 13 | public SayHello(String name) { 14 | this.name = name; 15 | } 16 | } 17 | } 18 | //#protocol 19 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/ParentActor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka; 5 | 6 | //#injectedparent 7 | import akka.actor.ActorRef; 8 | import akka.actor.UntypedActor; 9 | import play.libs.akka.InjectedActorSupport; 10 | 11 | import javax.inject.Inject; 12 | 13 | public class ParentActor extends UntypedActor implements InjectedActorSupport { 14 | 15 | @Inject ConfiguredChildActorProtocol.Factory childFactory; 16 | 17 | @Override 18 | public void onReceive(Object message) throws Exception { 19 | if (message instanceof ParentActorProtocol.GetChild) { 20 | String key = ((ParentActorProtocol.GetChild) message).key; 21 | ActorRef child = injectedChild(() -> childFactory.create(key), key); 22 | sender().tell(child, self()); 23 | } 24 | } 25 | } 26 | //#injectedparent 27 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/ParentActorProtocol.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka; 5 | 6 | public class ParentActorProtocol { 7 | 8 | public static class GetChild { 9 | public final String key; 10 | 11 | public GetChild(String key) { 12 | this.key = key; 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/akka.conf: -------------------------------------------------------------------------------- 1 | #conf 2 | akka.actor.default-dispatcher.fork-join-executor.pool-size-max = 64 3 | akka.actor.debug.receive = on 4 | #conf -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/ask/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka.ask; 5 | 6 | import javaguide.akka.HelloActor; 7 | import javaguide.akka.HelloActorProtocol.SayHello; 8 | 9 | //#ask 10 | import akka.actor.*; 11 | import play.mvc.*; 12 | import play.libs.F.*; 13 | import javax.inject.*; 14 | 15 | import static akka.pattern.Patterns.ask; 16 | 17 | @Singleton 18 | public class Application extends Controller { 19 | 20 | final ActorRef helloActor; 21 | 22 | @Inject public Application(ActorSystem system) { 23 | helloActor = system.actorOf(HelloActor.props); 24 | } 25 | 26 | public Promise sayHello(String name) { 27 | return Promise.wrap(ask(helloActor, new SayHello(name), 1000)) 28 | .map(response -> ok((String) response)); 29 | } 30 | } 31 | //#ask 32 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/async/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka.async; 5 | 6 | //#async 7 | import play.libs.F.Promise; 8 | import play.mvc.*; 9 | 10 | import static play.libs.F.Promise.promise; 11 | 12 | public class Application extends Controller { 13 | public Promise index() { 14 | return promise(() -> longComputation()) 15 | .map((Integer i) -> ok("Got " + i)); 16 | } 17 | //###skip: 1 18 | public int longComputation() { return 2; } 19 | } 20 | //#async 21 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/factorymodules/MyModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka.factorymodules; 5 | 6 | import javaguide.akka.*; 7 | 8 | //#factorybinding 9 | import com.google.inject.AbstractModule; 10 | import play.libs.akka.AkkaGuiceSupport; 11 | 12 | public class MyModule extends AbstractModule implements AkkaGuiceSupport { 13 | @Override 14 | protected void configure() { 15 | bindActor(ParentActor.class, "parent-actor"); 16 | bindActorFactory(ConfiguredChildActor.class, 17 | ConfiguredChildActorProtocol.Factory.class); 18 | } 19 | } 20 | //#factorybinding 21 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/inject/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka.inject; 5 | import javaguide.akka.ConfiguredActorProtocol; 6 | 7 | //#inject 8 | import akka.actor.ActorRef; 9 | import play.libs.F; 10 | import play.mvc.*; 11 | 12 | import javax.inject.Inject; 13 | import javax.inject.Named; 14 | 15 | import static akka.pattern.Patterns.ask; 16 | 17 | public class Application extends Controller { 18 | 19 | @Inject @Named("configured-actor") 20 | ActorRef configuredActor; 21 | 22 | public F.Promise getConfig() { 23 | return F.Promise.wrap(ask(configuredActor, 24 | new ConfiguredActorProtocol.GetConfig(), 1000) 25 | ).map(response -> ok((String) response)); 26 | } 27 | } 28 | //#inject -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/code/javaguide/akka/modules/MyModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.akka.modules; 5 | import javaguide.akka.ConfiguredActor; 6 | 7 | //#binding 8 | import com.google.inject.AbstractModule; 9 | import play.libs.akka.AkkaGuiceSupport; 10 | 11 | public class MyModule extends AbstractModule implements AkkaGuiceSupport { 12 | @Override 13 | protected void configure() { 14 | bindActor(ConfiguredActor.class, "configured-actor"); 15 | } 16 | } 17 | //#binding 18 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/akka/index.toc: -------------------------------------------------------------------------------- 1 | JavaAkka:Akka との統合 -------------------------------------------------------------------------------- /manual/working/javaGuide/main/async/JavaComet.md: -------------------------------------------------------------------------------- 1 | 2 | # Comet sockets 3 | 4 | ## Using chunked responses to create Comet sockets 5 | 6 | An useful usage of **Chunked responses** is to create Comet sockets. A Comet socket is just a chunked `text/html` response containing only ` 38 | 39 | 40 | ``` 41 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/async/code/javaguide.async.routes: -------------------------------------------------------------------------------- 1 | # Verify the controller's method signature 2 | GET /index controllers.Application.index() 3 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/async/code/javaguide/async/JavaAsync.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.async; 5 | 6 | import org.junit.Test; 7 | import play.libs.F.Function; 8 | import play.libs.F.Function0; 9 | import play.libs.F.Promise; 10 | import play.mvc.Result; 11 | 12 | import static org.hamcrest.CoreMatchers.equalTo; 13 | import static org.junit.Assert.*; 14 | import static play.mvc.Results.ok; 15 | import static play.test.Helpers.*; 16 | 17 | public class JavaAsync { 18 | 19 | @Test 20 | public void promisePi() { 21 | //#promise-pi 22 | Promise promiseOfPIValue = computePIAsynchronously(); 23 | Promise promiseOfResult = promiseOfPIValue.map(pi -> 24 | ok("PI value computed: " + pi) 25 | ); 26 | //#promise-pi 27 | assertThat(promiseOfResult.get(1000).status(), equalTo(200)); 28 | } 29 | 30 | @Test 31 | public void promiseAsync() { 32 | //#promise-async 33 | Promise promiseOfInt = Promise.promise(() -> intensiveComputation()); 34 | //#promise-async 35 | assertEquals(intensiveComputation(), promiseOfInt.get(1000)); 36 | } 37 | 38 | private static Promise computePIAsynchronously() { 39 | return Promise.pure(Math.PI); 40 | } 41 | 42 | private static Integer intensiveComputation() { 43 | return 1 + 1; 44 | } 45 | 46 | } 47 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/async/code/javaguide/async/MyWebSocketActor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.async; 5 | 6 | //#actor 7 | import akka.actor.*; 8 | 9 | public class MyWebSocketActor extends UntypedActor { 10 | 11 | public static Props props(ActorRef out) { 12 | return Props.create(MyWebSocketActor.class, out); 13 | } 14 | 15 | private final ActorRef out; 16 | 17 | public MyWebSocketActor(ActorRef out) { 18 | this.out = out; 19 | } 20 | 21 | public void onReceive(Object message) throws Exception { 22 | if (message instanceof String) { 23 | out.tell("I received your message: " + message, self()); 24 | } 25 | } 26 | } 27 | //#actor 28 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/async/code/javaguide/async/controllers/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.async.controllers; 5 | 6 | import play.mvc.Result; 7 | import play.libs.F.Function; 8 | import play.libs.F.Function0; 9 | import play.libs.F.Promise; 10 | import play.mvc.Controller; 11 | //#async-explicit-ec-imports 12 | import play.libs.HttpExecution; 13 | import scala.concurrent.ExecutionContext; 14 | //#async-explicit-ec-imports 15 | 16 | public class Application extends Controller { 17 | //#async 18 | public Promise index() { 19 | return Promise.promise(() -> intensiveComputation()) 20 | .map((Integer i) -> ok("Got result: " + i)); 21 | } 22 | //#async 23 | 24 | private ExecutionContext myThreadPool = null; 25 | 26 | //#async-explicit-ec 27 | public Promise index2() { 28 | // Wrap an existing thread pool, using the context from the current thread 29 | ExecutionContext myEc = HttpExecution.fromThread(myThreadPool); 30 | return Promise.promise(() -> intensiveComputation(), myEc) 31 | .map((Integer i) -> ok("Got result: " + i), myEc); 32 | } 33 | //#async-explicit-ec 34 | 35 | public int intensiveComputation() { return 2;} 36 | } 37 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/async/index.toc: -------------------------------------------------------------------------------- 1 | JavaAsync:非同期レスポンスの処理 2 | JavaStream:HTTP レスポンスのストリーミング 3 | JavaComet:Comet 4 | JavaWebSockets:WebSocket -------------------------------------------------------------------------------- /manual/working/javaGuide/main/cache/code/javaguide/cache/inject/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.cache.inject; 5 | //#inject 6 | import play.cache.*; 7 | import play.mvc.*; 8 | 9 | import javax.inject.Inject; 10 | 11 | public class Application extends Controller { 12 | 13 | @Inject CacheApi cache; 14 | 15 | // ... 16 | } 17 | //#inject 18 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/cache/code/javaguide/cache/qualified/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.cache.qualified; 5 | 6 | //#qualified 7 | import play.cache.*; 8 | import play.mvc.*; 9 | 10 | import javax.inject.Inject; 11 | 12 | public class Application extends Controller { 13 | 14 | @Inject @NamedCache("session-cache") CacheApi cache; 15 | 16 | // ... 17 | } 18 | //#qualified 19 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/cache/index.toc: -------------------------------------------------------------------------------- 1 | JavaCache:キャッシュを使う -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide.forms.routes: -------------------------------------------------------------------------------- 1 | POST /form controllers.Application.submit 2 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.controllers 5 | 6 | import play.api.mvc._ 7 | 8 | class Application extends Controller { 9 | def submit = Action(Ok) 10 | } 11 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/csrf.scala.html: -------------------------------------------------------------------------------- 1 | @() 2 | 3 | @import scalaguide.forms.csrf.routes 4 | 5 | @* #csrf-call *@ 6 | @import helper._ 7 | 8 | @form(CSRF(routes.ItemsController.save())) { 9 | ... 10 | } 11 | @* #csrf-call *@ 12 | 13 | @* #csrf-input *@ 14 | @form(routes.ItemsController.save()) { 15 | @CSRF.formField 16 | ... 17 | } 18 | @* #csrf-input *@ 19 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/csrf/Filters.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.csrf; 5 | 6 | //#filters 7 | import play.http.HttpFilters; 8 | import play.api.mvc.EssentialFilter; 9 | import play.filters.csrf.CSRFFilter; 10 | import javax.inject.Inject; 11 | 12 | public class Filters implements HttpFilters { 13 | 14 | @Inject CSRFFilter csrfFilter; 15 | 16 | @Override 17 | public EssentialFilter[] filters() { 18 | return new EssentialFilter[] { csrfFilter }; 19 | } 20 | } 21 | //#filters 22 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/form.scala.html: -------------------------------------------------------------------------------- 1 | 2 | @play.filters.csrf.CSRF.Token.getToken.value -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/fullform.scala.html: -------------------------------------------------------------------------------- 1 | @* #full-form *@ 2 | @(myForm: Form[User]) 3 | 4 | @helper.form(action = routes.Application.submit()) { 5 | 6 | @helper.inputText(myForm("email")) 7 | 8 | @helper.inputPassword(myForm("password")) 9 | 10 | } 11 | @* #full-form *@ -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/helpers.scala.html: -------------------------------------------------------------------------------- 1 | @(myForm: Form[User], userForm: Form[UserForm]) 2 | 3 | 4 | @* #form *@ 5 | @helper.form(action = routes.Application.submit()) { 6 | 7 | } 8 | @* #form *@ 9 | 10 | 11 | 12 | @* #form-with-id *@ 13 | @helper.form(action = routes.Application.submit(), 'id -> "myForm") { 14 | 15 | } 16 | @* #form-with-id *@ 17 | 18 | 19 | 20 | @* #extra-params *@ 21 | @helper.inputText(myForm("email"), 'id -> "email", 'size -> 30) 22 | @* #extra-params *@ 23 | 24 | 25 | 26 | @* #generic-input *@ 27 | @helper.input(myForm("email")) { (id, name, value, args) => 28 | 29 | } 30 | @* #generic-input *@ 31 | 32 | 33 | 34 | @* #repeat *@ 35 | @helper.inputText(userForm("name")) 36 | 37 | @helper.repeat(userForm("emails"), min = 1) { emailField => 38 | 39 | @helper.inputText(emailField) 40 | 41 | } 42 | @* #repeat *@ 43 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/html/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.html; 5 | 6 | public class User { 7 | 8 | private String email; 9 | private String password; 10 | 11 | public void setEmail(String email) { 12 | this.email = email; 13 | } 14 | 15 | public String getEmail() { 16 | return email; 17 | } 18 | 19 | public void setPassword(String password) { 20 | this.password = password; 21 | } 22 | 23 | public String getPassword() { 24 | return password; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/html/UserForm.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.html; 5 | 6 | import java.util.List; 7 | 8 | //#code 9 | public class UserForm { 10 | 11 | private String name; 12 | private List emails; 13 | 14 | public void setName(String name) { 15 | this.name = name; 16 | } 17 | 18 | public String getName() { 19 | return name; 20 | } 21 | 22 | public void setEmails(List emails) { 23 | this.emails = emails; 24 | } 25 | 26 | public List getEmails() { 27 | return emails; 28 | } 29 | 30 | } 31 | //#code 32 | 33 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/html/routes/package.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.html 5 | 6 | package object routes { 7 | val Application = javaguide.forms.controllers.routes.Application 8 | } 9 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/myFieldConstructorTemplate.scala.html: -------------------------------------------------------------------------------- 1 | @* #template *@ 2 | @(elements: helper.FieldElements) 3 | 4 |
5 | 6 |
7 | @elements.input 8 | @elements.errors.mkString(", ") 9 | @elements.infos.mkString(", ") 10 |
11 |
12 | @* #template *@ 13 | 14 | foobar -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/u1/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.u1; 5 | 6 | //#user 7 | public class User { 8 | 9 | protected String email; 10 | protected String password; 11 | 12 | public void setEmail(String email) { 13 | this.email = email; 14 | } 15 | 16 | public String getEmail() { 17 | return email; 18 | } 19 | 20 | public void setPassword(String password) { 21 | this.password = password; 22 | } 23 | 24 | public String getPassword() { 25 | return password; 26 | } 27 | 28 | } 29 | //#user 30 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/u2/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.u2; 5 | 6 | import play.data.validation.Constraints.Required; 7 | 8 | //#user 9 | public class User { 10 | 11 | @Required 12 | protected String email; 13 | protected String password; 14 | 15 | public void setEmail(String email) { 16 | this.email = email; 17 | } 18 | 19 | public String getEmail() { 20 | return email; 21 | } 22 | 23 | public void setPassword(String password) { 24 | this.password = password; 25 | } 26 | 27 | public String getPassword() { 28 | return password; 29 | } 30 | 31 | } 32 | //#user 33 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/u3/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.forms.u3; 5 | 6 | import play.data.validation.Constraints; 7 | import static javaguide.forms.JavaForms.authenticate; 8 | 9 | //#user 10 | public class User { 11 | 12 | @Constraints.Required 13 | protected String email; 14 | protected String password; 15 | 16 | public String validate() { 17 | if (authenticate(email, password) == null) { 18 | return "Invalid email or password"; 19 | } 20 | return null; 21 | } 22 | 23 | public void setEmail(String email) { 24 | this.email = email; 25 | } 26 | 27 | public String getEmail() { 28 | return email; 29 | } 30 | 31 | public void setPassword(String password) { 32 | this.password = password; 33 | } 34 | 35 | public String getPassword() { 36 | return password; 37 | } 38 | 39 | } 40 | //#user 41 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/view.scala.html: -------------------------------------------------------------------------------- 1 | @(form: Form[_]) 2 | 3 | @* #global-errors *@ 4 | @if(form.hasGlobalErrors) { 5 |

6 | @form.globalError.message 7 |

8 | } 9 | @* #global-errors *@ 10 | 11 | @* #field-errors *@ 12 | @for(error <- form("email").errors) { 13 |

@error.message

14 | } 15 | @* #field-errors *@ -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/code/javaguide/forms/withFieldConstructor.scala.html: -------------------------------------------------------------------------------- 1 | @(myForm: Form[User]) 2 | 3 | @import helper._ 4 | 5 | @* #field *@ 6 | @implicitField = @{ FieldConstructor(myFieldConstructorTemplate.f) } 7 | 8 | @inputText(myForm("email")) 9 | @* #field *@ 10 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/forms/index.toc: -------------------------------------------------------------------------------- 1 | JavaForms:フォームの定義 2 | JavaFormHelpers:フォームテンプレートヘルパの利用 3 | JavaCsrf:CSRF 対策 -------------------------------------------------------------------------------- /manual/working/javaGuide/main/global/JavaGlobal.md: -------------------------------------------------------------------------------- 1 | 2 | # Application global settings 3 | 4 | ## The Global object 5 | 6 | Defining a `Global` class in your project allows you to handle global settings for your application: 7 | 8 | @[global](code/javaguide/global/simple/Global.java) 9 | 10 | By default, this object is defined in the root package, but you can define it wherever you want and then configure it in your `application.conf` using `application.global` property. 11 | 12 | ## Intercepting application start-up and shutdown 13 | 14 | You can override the `onStart` and `onStop` operation to be notified of the corresponding application lifecycle events: 15 | 16 | @[global](code/javaguide/global/startstop/Global.java) 17 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/global/JavaInterceptors.md: -------------------------------------------------------------------------------- 1 | 2 | # Intercepting requests 3 | 4 | ## Overriding onRequest 5 | 6 | One important aspect of the ```GlobalSettings``` class is that it provides a way to intercept requests and execute business logic before a request is dispatched to an action. 7 | 8 | For example: 9 | 10 | @[global](code/javaguide/global/intercept/Global.java) 11 | 12 | It’s also possible to intercept a specific action method. This can be achieved via [[Action composition| JavaActionsComposition]]. 13 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/global/code/javaguide/global/intercept/Global.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.global.intercept; 5 | 6 | //#global 7 | import play.*; 8 | import play.mvc.Action; 9 | import play.mvc.Http.Request; 10 | import java.lang.reflect.Method; 11 | 12 | public class Global extends GlobalSettings { 13 | 14 | public Action onRequest(Request request, Method actionMethod) { 15 | System.out.println("before each request..." + request.toString()); 16 | return super.onRequest(request, actionMethod); 17 | } 18 | 19 | } 20 | //#global 21 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/global/code/javaguide/global/simple/Global.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.global.simple; 5 | 6 | //#global 7 | import play.*; 8 | 9 | public class Global extends GlobalSettings { 10 | 11 | } 12 | //#global 13 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/global/code/javaguide/global/startstop/Global.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.global.startstop; 5 | 6 | //#global 7 | import play.*; 8 | 9 | public class Global extends GlobalSettings { 10 | 11 | public void onStart(Application app) { 12 | Logger.info("Application has started"); 13 | } 14 | 15 | public void onStop(Application app) { 16 | Logger.info("Application shutdown..."); 17 | } 18 | 19 | } 20 | //#global 21 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/global/index.toc: -------------------------------------------------------------------------------- 1 | JavaGlobal:アプリケーションのグローバル設定 2 | JavaInterceptors:リクエストのインターセプト -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide.http.routing.defaultvalue.routes: -------------------------------------------------------------------------------- 1 | # #clients 2 | # Pagination links, like /clients?page=3 3 | GET /clients controllers.Clients.list(page: Int ?= 1) 4 | # #clients 5 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide.http.routing.fixed.routes: -------------------------------------------------------------------------------- 1 | # #page 2 | # Extract the page parameter from the path, or fix the value for / 3 | GET / controllers.Application.show(page = "home") 4 | GET /:page controllers.Application.show(page) 5 | # #page -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide.http.routing.query.routes: -------------------------------------------------------------------------------- 1 | # #page 2 | # Extract the page parameter from the query string. 3 | # i.e. http://myserver.com/?page=index 4 | GET / controllers.Application.show(page) 5 | # #page -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide.http.routing.reverse.routes: -------------------------------------------------------------------------------- 1 | #hello 2 | # Hello action 3 | GET /hello/:name controllers.Application.hello(name) 4 | #hello 5 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide.http.routing.routes: -------------------------------------------------------------------------------- 1 | 2 | # #static-path 3 | GET /clients/all controllers.Clients.list() 4 | # #static-path 5 | 6 | # #clients-show-comment 7 | # Display a client. 8 | # #clients-show ###skip 9 | GET /clients/:id controllers.Clients.show(id: Long) 10 | # #clients-show #clients-show-comment 11 | 12 | # #spanning-path 13 | GET /files/*name controllers.Application.download(name) 14 | # #spanning-path 15 | 16 | # #regex-path 17 | GET /items/$id<[0-9]+> controllers.Items.show(id: Long) 18 | # #regex-path 19 | 20 | # #home-page 21 | GET / controllers.Application.homePage() 22 | # #home-page 23 | 24 | # #page 25 | # Extract the page parameter from the path. 26 | # i.e. http://myserver.com/index 27 | GET /:page controllers.Application.show(page) 28 | # #page 29 | 30 | # #optional 31 | # The version parameter is optional. E.g. /api/list-all?version=3.0 32 | GET /api/list-all controllers.Api.list(version ?= null) 33 | # #optional 34 | 35 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/JavaErrorHandling.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.http 5 | 6 | import play.api.mvc.Action 7 | import play.api.test._ 8 | 9 | import scala.reflect.ClassTag 10 | 11 | object JavaErrorHandling extends PlaySpecification with WsTestClient { 12 | 13 | def fakeApp[A](implicit ct: ClassTag[A]) = { 14 | FakeApplication( 15 | additionalConfiguration = Map("play.http.errorHandler" -> ct.runtimeClass.getName), 16 | withRoutes = { 17 | case (_, "/error") => Action(_ => throw new RuntimeException("foo")) 18 | } 19 | ) 20 | } 21 | 22 | "java error handling" should { 23 | "allow providing a custom error handler" in new WithServer(fakeApp[root.ErrorHandler]) { 24 | await(wsUrl("/error").get()).body must startWith("A server error occurred: ") 25 | } 26 | 27 | "allow providing a custom error handler" in new WithServer(fakeApp[`def`.ErrorHandler]) { 28 | await(wsUrl("/error").get()).body must not startWith("A server error occurred: ") 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/def/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.http.def; 5 | 6 | //#default 7 | import play.*; 8 | import play.api.OptionalSourceMapper; 9 | import play.api.UsefulException; 10 | import play.api.routing.Router; 11 | import play.http.DefaultHttpErrorHandler; 12 | import play.libs.F.*; 13 | import play.mvc.Http.*; 14 | import play.mvc.*; 15 | 16 | import javax.inject.*; 17 | 18 | public class ErrorHandler extends DefaultHttpErrorHandler { 19 | 20 | @Inject 21 | public ErrorHandler(Configuration configuration, Environment environment, 22 | OptionalSourceMapper sourceMapper, Provider routes) { 23 | super(configuration, environment, sourceMapper, routes); 24 | } 25 | 26 | protected Promise onProdServerError(RequestHeader request, UsefulException exception) { 27 | return Promise.pure( 28 | Results.internalServerError("A server error occurred: " + exception.getMessage()) 29 | ); 30 | } 31 | 32 | protected Promise onForbidden(RequestHeader request, String message) { 33 | return Promise.pure( 34 | Results.forbidden("You're not allowed to access this resource.") 35 | ); 36 | } 37 | } 38 | //#default 39 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/full/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | 5 | //#full-controller 6 | //###replace: package controllers; 7 | package javaguide.http.full; 8 | 9 | import play.*; 10 | import play.mvc.*; 11 | 12 | public class Application extends Controller { 13 | 14 | public Result index() { 15 | return ok("It works!"); 16 | } 17 | 18 | } 19 | //#full-controller 20 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/root/ErrorHandler.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.http.root; 5 | 6 | //#root 7 | import play.http.HttpErrorHandler; 8 | import play.mvc.*; 9 | import play.mvc.Http.*; 10 | import play.libs.F.*; 11 | 12 | public class ErrorHandler implements HttpErrorHandler { 13 | public Promise onClientError(RequestHeader request, int statusCode, String message) { 14 | return Promise.pure( 15 | Results.status(statusCode, "A client error occurred: " + message) 16 | ); 17 | } 18 | 19 | public Promise onServerError(RequestHeader request, Throwable exception) { 20 | return Promise.pure( 21 | Results.internalServerError("A server error occurred: " + exception.getMessage()) 22 | ); 23 | } 24 | } 25 | //#root 26 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/routing/controllers/Api.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.http.routing.controllers; 5 | 6 | import play.mvc.Controller; 7 | import play.mvc.Result; 8 | 9 | public class Api extends Controller { 10 | public Result list(String version) { 11 | return ok("version " + version); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/routing/controllers/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.http.routing.controllers; 5 | 6 | import play.mvc.Controller; 7 | import play.mvc.Result; 8 | 9 | public class Application extends Controller { 10 | 11 | public Result download(String path) { 12 | return ok("download " + path); 13 | } 14 | 15 | public Result homePage() { 16 | return ok("home page"); 17 | } 18 | 19 | //#show-page-action 20 | public Result show(String page) { 21 | String content = Page.getContentOf(page); 22 | response().setContentType("text/html"); 23 | return ok(content); 24 | } 25 | //#show-page-action 26 | 27 | static class Page { 28 | static String getContentOf(String page) { 29 | return "showing page " + page; 30 | } 31 | } 32 | 33 | //#reverse-redirect 34 | // Redirect to /hello/Bob 35 | public Result index() { 36 | return redirect(controllers.routes.Application.hello("Bob")); 37 | } 38 | //#reverse-redirect 39 | 40 | static class controllers { 41 | static javaguide.http.routing.reverse.controllers.routes routes = new javaguide.http.routing.reverse.controllers.routes(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/routing/controllers/Clients.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.http.routing.controllers; 5 | 6 | import play.mvc.Controller; 7 | import play.mvc.Result; 8 | 9 | public class Clients extends Controller { 10 | 11 | //#clients-show-action 12 | public Result show(Long id) { 13 | Client client = clientService.findById(id); 14 | return ok(views.html.Client.show(client)); 15 | } 16 | //#clients-show-action 17 | 18 | public Result list() { 19 | return ok("all clients"); 20 | } 21 | 22 | static class clientService { 23 | static Client findById(Long id) { 24 | return new Client(id); 25 | } 26 | } 27 | 28 | static class Client { 29 | Client(Long id) { 30 | this.id = id; 31 | } 32 | Long id; 33 | String show(Client client) { 34 | return "showing client " + client.id; 35 | } 36 | } 37 | static class views { 38 | static class html { 39 | static Client Client = new Client(0l); 40 | } 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/routing/controllers/Items.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.http.routing.controllers; 5 | 6 | import play.mvc.Controller; 7 | import play.mvc.Result; 8 | 9 | public class Items extends Controller { 10 | public Result show(Long id) { 11 | return ok("showing item " + id); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/routing/reverse/controllers/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | //#controller 5 | //###replace: package controllers; 6 | package javaguide.http.routing.reverse.controllers; 7 | 8 | import play.*; 9 | import play.mvc.*; 10 | 11 | public class Application extends Controller { 12 | 13 | public Result hello(String name) { 14 | return ok("Hello " + name + "!"); 15 | } 16 | 17 | } 18 | //#controller 19 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/code/javaguide/http/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @() 2 | @* #flash-template *@ 3 | @if(flash.containsKey("success")) { 4 | @flash.get("success") 5 | } else { 6 | Welcome! 7 | } 8 | @* #flash-template *@ 9 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/images/routesError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/working/javaGuide/main/http/images/routesError.png -------------------------------------------------------------------------------- /manual/working/javaGuide/main/http/index.toc: -------------------------------------------------------------------------------- 1 | JavaActions:アクション、コントローラ、レスポンス 2 | JavaRouting:HTTP ルーティング 3 | JavaResponse:HTTP レスポンスの操作 4 | JavaSessionFlash:セッションとフラッシュスコープ 5 | JavaBodyParsers:ボディパーサー 6 | JavaActionsComposition:アクションの合成 7 | JavaContentNegotiation:コンテントネゴシエーション 8 | JavaErrorHandling:エラーハンドリング -------------------------------------------------------------------------------- /manual/working/javaGuide/main/i18n/code/javaguide/i18n/helloscalatemplate.scala.html: -------------------------------------------------------------------------------- 1 | @* #template *@ 2 | @Messages("hello") 3 | @* #template *@ -------------------------------------------------------------------------------- /manual/working/javaGuide/main/i18n/code/javaguide/i18n/hellotemplate.scala.html: -------------------------------------------------------------------------------- 1 | @* #template *@ 2 | @import play.i18n._ 3 | @Messages.get("hello") 4 | @* #template *@ -------------------------------------------------------------------------------- /manual/working/javaGuide/main/i18n/code/javaguide/i18n/messages: -------------------------------------------------------------------------------- 1 | #single-apostrophe 2 | info.error=You aren''t logged in! 3 | #single-apostrophe 4 | 5 | #parameter-escaping 6 | example.formatting=When using MessageFormat, '''{0}''' is replaced with the first parameter. 7 | #parameter-escaping 8 | 9 | hello=hello -------------------------------------------------------------------------------- /manual/working/javaGuide/main/i18n/code/javaguide/i18n/messages.en-US: -------------------------------------------------------------------------------- 1 | hello=howdy -------------------------------------------------------------------------------- /manual/working/javaGuide/main/i18n/code/javaguide/i18n/messages.fr: -------------------------------------------------------------------------------- 1 | hello=bonjour -------------------------------------------------------------------------------- /manual/working/javaGuide/main/i18n/index.toc: -------------------------------------------------------------------------------- 1 | JavaI18N:国際化 -------------------------------------------------------------------------------- /manual/working/javaGuide/main/index.toc: -------------------------------------------------------------------------------- 1 | http:HTTP プログラミング 2 | async:非同期 HTTP プログラミング 3 | templates:テンプレートエンジン 4 | forms:フォーム送信とバリデーション 5 | json:Json を使う 6 | xml:XML を使う 7 | upload:ファイルアップロード処理 8 | sql:SQL データベースアクセス 9 | cache:キャッシュを使う 10 | ws:Web サービスの呼び出し 11 | akka:Akka との統合 12 | i18n:国際化 13 | global:アプリケーション Global オブジェクト 14 | tests:アプリケーションのテスト 15 | logging:ロギング 16 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/json/index.toc: -------------------------------------------------------------------------------- 1 | JavaJsonActions:JSON リクエストの送信と処理 -------------------------------------------------------------------------------- /manual/working/javaGuide/main/logging/code/javaguide/logging/Application.java: -------------------------------------------------------------------------------- 1 | package javaguide.logging; 2 | 3 | //#logging-pattern-mix 4 | import play.Logger; 5 | import play.Logger.ALogger; 6 | import play.libs.F; 7 | import play.mvc.Action; 8 | import play.mvc.Controller; 9 | import play.mvc.Http; 10 | import play.mvc.Http.Request; 11 | import play.mvc.Result; 12 | import play.mvc.With; 13 | 14 | public class Application extends Controller { 15 | 16 | private static final ALogger logger = Logger.of(Application.class); 17 | 18 | @With(AccessLoggingAction.class) 19 | public Result index() { 20 | try { 21 | final int result = riskyCalculation(); 22 | return ok("Result=" + result); 23 | } catch (Throwable t) { 24 | logger.error("Exception with riskyCalculation", t); 25 | return internalServerError("Error in calculation: " + t.getMessage()); 26 | } 27 | } 28 | 29 | private static int riskyCalculation() { 30 | return 10 / (new java.util.Random()).nextInt(2); 31 | } 32 | 33 | } 34 | 35 | class AccessLoggingAction extends Action.Simple { 36 | 37 | private ALogger accessLogger = Logger.of("access"); 38 | 39 | public F.Promise call(Http.Context ctx) throws Throwable { 40 | final Request request = ctx.request(); 41 | accessLogger.info("method=" + request.method() + " uri=" + request.uri() + " remote-address=" + request.remoteAddress()); 42 | 43 | return delegate.call(ctx); 44 | } 45 | } 46 | //#logging-pattern-mix -------------------------------------------------------------------------------- /manual/working/javaGuide/main/logging/code/javaguide/logging/Global.java: -------------------------------------------------------------------------------- 1 | package javaguide.logging; 2 | 3 | //#logging-pattern-filter 4 | import java.lang.reflect.Method; 5 | 6 | import play.Application; 7 | import play.GlobalSettings; 8 | import play.Logger; 9 | import play.Logger.ALogger; 10 | import play.mvc.Action; 11 | import play.mvc.Http.Request; 12 | 13 | public class Global extends GlobalSettings { 14 | 15 | private final ALogger accessLogger = Logger.of("access"); 16 | 17 | @Override 18 | @SuppressWarnings("rawtypes") 19 | public Action onRequest(Request request, Method method) { 20 | accessLogger.info("method=" + request.method() + " uri=" + request.uri() + " remote-address=" + request.remoteAddress()); 21 | 22 | return super.onRequest(request, method); 23 | } 24 | 25 | @Override 26 | public void onStart(Application app) { 27 | Logger.info("Application has started"); 28 | } 29 | 30 | @Override 31 | public void onStop(Application app) { 32 | Logger.info("Application has stopped"); 33 | } 34 | 35 | } 36 | //#logging-pattern-filter -------------------------------------------------------------------------------- /manual/working/javaGuide/main/logging/code/javaguide/logging/JavaLogging.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.logging; 5 | 6 | import java.util.Random; 7 | 8 | import static org.hamcrest.CoreMatchers.equalTo; 9 | import static org.junit.Assert.assertThat; 10 | import org.junit.Test; 11 | 12 | //#logging-import 13 | import play.Logger; 14 | //#logging-import 15 | 16 | public class JavaLogging { 17 | 18 | public void testDefaultLogger() { 19 | 20 | //#logging-default-logger 21 | // Log some debug info 22 | Logger.debug("Attempting risky calculation."); 23 | 24 | try { 25 | final int result = riskyCalculation(); 26 | 27 | // Log result if successful 28 | Logger.debug("Result=" + result); 29 | } catch (Throwable t) { 30 | // Log error with message and Throwable. 31 | Logger.error("Exception with riskyCalculation", t); 32 | } 33 | //#logging-default-logger 34 | 35 | assertThat(Logger.underlying().getName(), equalTo("application")); 36 | } 37 | 38 | @Test 39 | public void testCreateLogger() { 40 | 41 | //#logging-create-logger-name 42 | final Logger.ALogger accessLogger = Logger.of("access"); 43 | //#logging-create-logger-name 44 | 45 | assertThat(accessLogger.underlying().getName(), equalTo("access")); 46 | 47 | //#logging-create-logger-class 48 | final Logger.ALogger logger = Logger.of(this.getClass()); 49 | //#logging-create-logger-class 50 | 51 | assertThat(logger.underlying().getName(), equalTo("javaguide.logging.JavaLogging")); 52 | } 53 | 54 | private int riskyCalculation() { 55 | return 10 / (new Random()).nextInt(2); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/logging/index.toc: -------------------------------------------------------------------------------- 1 | JavaLogging:ロギング -------------------------------------------------------------------------------- /manual/working/javaGuide/main/sql/code/jpa.sbt: -------------------------------------------------------------------------------- 1 | PlayKeys.externalizeResources := false 2 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/sql/images/dbError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/working/javaGuide/main/sql/images/dbError.png -------------------------------------------------------------------------------- /manual/working/javaGuide/main/sql/index.toc: -------------------------------------------------------------------------------- 1 | JavaDatabase:JDBC の設定と使用 2 | JavaJPA:JPA との統合 3 | JavaEbean:Ebean ORM を使う 4 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide.tests.guice.routes: -------------------------------------------------------------------------------- 1 | GET / controllers.Application.index() 2 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide.tests.routes: -------------------------------------------------------------------------------- 1 | GET / controllers.Application.index() 2 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/BrowserFunctionalTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.junit.*; 7 | 8 | import play.mvc.*; 9 | import play.test.*; 10 | import play.libs.F.*; 11 | import play.libs.ws.*; 12 | 13 | import static play.test.Helpers.*; 14 | import static org.junit.Assert.*; 15 | 16 | // #test-withbrowser 17 | public class BrowserFunctionalTest extends WithBrowser { 18 | 19 | @Test 20 | public void runInBrowser() { 21 | browser.goTo("/"); 22 | assertNotNull(browser.$("title").getText()); 23 | } 24 | 25 | } 26 | // #test-withbrowser 27 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/DatabaseTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.tests; 5 | 6 | //#database-test 7 | import play.db.Database; 8 | import play.db.Databases; 9 | import play.db.evolutions.*; 10 | import java.sql.Connection; 11 | 12 | import org.junit.*; 13 | import static org.junit.Assert.*; 14 | 15 | public class DatabaseTest { 16 | 17 | Database database; 18 | 19 | @Before 20 | public void setupDatabase() { 21 | database = Databases.inMemory(); 22 | Evolutions.applyEvolutions(database, Evolutions.forDefault(new Evolution( 23 | 1, 24 | "create table test (id bigint not null, name varchar(255));", 25 | "drop table test;" 26 | ))); 27 | } 28 | 29 | @After 30 | public void shutdownDatabase() { 31 | Evolutions.cleanupEvolutions(database); 32 | database.shutdown(); 33 | } 34 | 35 | @Test 36 | public void testDatabase() throws Exception { 37 | Connection connection = database.getConnection(); 38 | connection.prepareStatement("insert into test values (10, 'testing')").execute(); 39 | 40 | assertTrue( 41 | connection.prepareStatement("select * from test where id = 10") 42 | .executeQuery().next() 43 | ); 44 | } 45 | } 46 | //#database-test 47 | 48 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/FakeApplicationTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | import static play.test.Helpers.*; 4 | import static org.junit.Assert.*; 5 | 6 | import org.junit.Test; 7 | 8 | import play.Application; 9 | import play.GlobalSettings; 10 | import play.test.FakeApplication; 11 | import play.test.Helpers; 12 | 13 | public class FakeApplicationTest { 14 | 15 | public static class Computer { 16 | public String name = "Macintosh"; 17 | public String introduced = "1984-01-24"; 18 | 19 | public static Computer findById(long id) { 20 | return new Computer(); 21 | } 22 | } 23 | 24 | String formatted(String s) { 25 | return s; 26 | } 27 | 28 | //#test-running-fakeapp 29 | @Test 30 | public void findById() { 31 | running(fakeApplication(inMemoryDatabase("test")), () -> { 32 | Computer macintosh = Computer.findById(21l); 33 | assertEquals("Macintosh", macintosh.name); 34 | assertEquals("1984-01-24", formatted(macintosh.introduced)); 35 | }); 36 | } 37 | //#test-running-fakeapp 38 | 39 | private void fakeApps() { 40 | 41 | //#test-fakeapp 42 | Application fakeApp = Helpers.fakeApplication(); 43 | 44 | Application fakeAppWithGlobal = fakeApplication(new GlobalSettings() { 45 | @Override 46 | public void onStart(Application app) { 47 | System.out.println("Starting FakeApplication"); 48 | } 49 | }); 50 | 51 | Application fakeAppWithMemoryDb = fakeApplication(inMemoryDatabase("test")); 52 | //#test-fakeapp 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/GitHubClient.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | //#client 4 | import java.util.*; 5 | import java.util.stream.Collectors; 6 | import javax.inject.Inject; 7 | 8 | import com.fasterxml.jackson.databind.JsonNode; 9 | import play.libs.ws.WSClient; 10 | import play.libs.F; 11 | 12 | class GitHubClient { 13 | @Inject WSClient ws; 14 | String baseUrl = "https://api.github.com"; 15 | 16 | public F.Promise> getRepositories() { 17 | return ws.url(baseUrl + "/repositories").get().map(response -> 18 | response.asJson().findValues("full_name").stream() 19 | .map(JsonNode::asText).collect(Collectors.toList()) 20 | ); 21 | } 22 | } 23 | //#client 24 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/GitHubClientTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | //#content 4 | import java.util.*; 5 | import com.fasterxml.jackson.databind.node.*; 6 | import org.junit.*; 7 | import play.api.routing.Router; 8 | import play.libs.Json; 9 | import play.libs.ws.*; 10 | import play.routing.RoutingDsl; 11 | import play.server.Server; 12 | 13 | import static play.mvc.Results.*; 14 | import static org.junit.Assert.*; 15 | import static org.hamcrest.core.IsCollectionContaining.*; 16 | 17 | public class GitHubClientTest { 18 | GitHubClient client; 19 | WSClient ws; 20 | Server server; 21 | 22 | @Before 23 | public void setup() { 24 | Router router = new RoutingDsl() 25 | .GET("/repositories").routeTo(() -> { 26 | ArrayNode repos = Json.newArray(); 27 | ObjectNode repo = Json.newObject(); 28 | repo.put("full_name", "octocat/Hello-World"); 29 | repos.add(repo); 30 | return ok(repos); 31 | }) 32 | .build(); 33 | 34 | server = Server.forRouter(router); 35 | ws = WS.newClient(server.httpPort()); 36 | client = new GitHubClient(); 37 | client.baseUrl = ""; 38 | client.ws = ws; 39 | } 40 | 41 | @After 42 | public void tearDown() { 43 | ws.close(); 44 | server.stop(); 45 | } 46 | 47 | @Test 48 | public void repositories() { 49 | List repos = client.getRepositories().get(10000); 50 | assertThat(repos, hasItem("octocat/Hello-World")); 51 | } 52 | } 53 | //#content 54 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/HamcrestTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | //#test-hamcrest 4 | import static org.hamcrest.CoreMatchers.*; 5 | import static org.junit.Assert.assertThat; 6 | 7 | import org.junit.Test; 8 | 9 | public class HamcrestTest { 10 | 11 | @Test 12 | public void testString() { 13 | String str = "good"; 14 | assertThat(str, allOf(equalTo("good"), startsWith("goo"))); 15 | } 16 | 17 | } 18 | //#test-hamcrest -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/InjectionTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | import static play.test.Helpers.*; 4 | import static org.junit.Assert.*; 5 | 6 | import javax.inject.Inject; 7 | 8 | import com.google.inject.AbstractModule; 9 | import com.google.inject.Guice; 10 | import com.google.inject.Module; 11 | 12 | import org.junit.After; 13 | import org.junit.Before; 14 | import org.junit.Test; 15 | 16 | import play.Application; 17 | import play.ApplicationLoader.Context; 18 | import play.Environment; 19 | import play.inject.guice.GuiceApplicationBuilder; 20 | import play.inject.guice.GuiceApplicationLoader; 21 | import play.test.Helpers; 22 | 23 | public class InjectionTest { 24 | 25 | //#test-injection 26 | @Inject Application application; 27 | 28 | @Before 29 | public void setup() { 30 | Module testModule = new AbstractModule() { 31 | @Override 32 | public void configure() { 33 | // Install custom test binding here 34 | } 35 | }; 36 | 37 | GuiceApplicationBuilder builder = new GuiceApplicationLoader() 38 | .builder(new Context(Environment.simple())) 39 | .overrides(testModule); 40 | Guice.createInjector(builder.applicationModule()).injectMembers(this); 41 | } 42 | 43 | @After 44 | public void teardown() { 45 | Helpers.stop(application); 46 | } 47 | //#test-injection 48 | 49 | } 50 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/JavaTestingWebServiceClients.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | import com.fasterxml.jackson.databind.node.*; 4 | import org.junit.Test; 5 | import play.api.routing.Router; 6 | import play.libs.Json; 7 | import play.libs.ws.WS; 8 | import play.libs.ws.WSClient; 9 | import play.routing.RoutingDsl; 10 | import play.server.Server; 11 | 12 | import java.util.List; 13 | 14 | import static org.hamcrest.core.IsCollectionContaining.*; 15 | import static org.junit.Assert.*; 16 | import static play.mvc.Controller.*; 17 | 18 | public class JavaTestingWebServiceClients { 19 | 20 | @Test 21 | public void mockService() { 22 | //#mock-service 23 | Router router = new RoutingDsl() 24 | .GET("/repositories").routeTo(() -> { 25 | ArrayNode repos = Json.newArray(); 26 | ObjectNode repo = Json.newObject(); 27 | repo.put("full_name", "octocat/Hello-World"); 28 | repos.add(repo); 29 | return ok(repos); 30 | }) 31 | .build(); 32 | 33 | Server server = Server.forRouter(router); 34 | //#mock-service 35 | 36 | server.stop(); 37 | } 38 | 39 | @Test 40 | public void sendResource() { 41 | //#send-resource 42 | Router router = new RoutingDsl() 43 | .GET("/repositories").routeTo(() -> 44 | ok().sendResource("github/repositories.json") 45 | ) 46 | .build(); 47 | //#send-resource 48 | 49 | Server server = Server.forRouter(router); 50 | 51 | WSClient ws = WS.newClient(server.httpPort()); 52 | GitHubClient client = new GitHubClient(); 53 | client.baseUrl = ""; 54 | client.ws = ws; 55 | 56 | try { 57 | List repos = client.getRepositories().get(10000); 58 | assertThat(repos, hasItem("octocat/Hello-World")); 59 | } finally { 60 | ws.close(); 61 | server.stop(); 62 | } 63 | } 64 | 65 | } -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/MockitoTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | //#test-mockito-import 6 | import static org.mockito.Mockito.*; 7 | //#test-mockito-import 8 | 9 | import java.util.List; 10 | 11 | import org.junit.Test; 12 | 13 | public class MockitoTest { 14 | 15 | @Test 16 | public void testMockList() { 17 | 18 | //#test-mockito 19 | // Create and train mock 20 | List mockedList = mock(List.class); 21 | when(mockedList.get(0)).thenReturn("first"); 22 | 23 | // check value 24 | assertEquals("first", mockedList.get(0)); 25 | 26 | // verify interaction 27 | verify(mockedList).get(0); 28 | //#test-mockito 29 | } 30 | 31 | } 32 | 33 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/ServerFunctionalTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.junit.*; 7 | 8 | import play.mvc.*; 9 | import play.test.*; 10 | import play.libs.F.*; 11 | import play.libs.ws.*; 12 | 13 | import static play.test.Helpers.*; 14 | import static org.junit.Assert.*; 15 | 16 | // #test-withserver 17 | public class ServerFunctionalTest extends WithServer { 18 | 19 | @Test 20 | public void testInServer() { 21 | int timeout = 5000; 22 | String url = "http://localhost:" + this.testServer.port() + "/"; 23 | assertEquals(NOT_FOUND, WS.url(url).get().get(timeout).getStatus()); 24 | } 25 | 26 | } 27 | // #test-withserver 28 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/SimpleTest.java: -------------------------------------------------------------------------------- 1 | package javaguide.tests; 2 | 3 | //#test-simple 4 | import static org.junit.Assert.*; 5 | 6 | import org.junit.Test; 7 | 8 | public class SimpleTest { 9 | 10 | @Test 11 | public void testSum() { 12 | int a = 1 + 1; 13 | assertEquals(2, a); 14 | } 15 | 16 | @Test 17 | public void testString() { 18 | String str = "Hello world"; 19 | assertFalse(str.isEmpty()); 20 | } 21 | 22 | } 23 | //#test-simple 24 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/controllers/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.tests.controllers; 5 | 6 | import play.mvc.*; 7 | 8 | public class Application extends Controller { 9 | 10 | public Result index() { 11 | return ok(javaguide.tests.html.index.render("Welcome to Play!")); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/javaguide/tests/index.scala.html: -------------------------------------------------------------------------------- 1 | @(title: String) 2 | 3 |

@title

4 | click me -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/tests/guice/Component.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.tests.guice; 5 | 6 | // #component 7 | public interface Component { 8 | String hello(); 9 | } 10 | // #component 11 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/tests/guice/ComponentModule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.tests.guice; 5 | 6 | // #component-module 7 | import com.google.inject.AbstractModule; 8 | 9 | public class ComponentModule extends AbstractModule { 10 | protected void configure() { 11 | bind(Component.class).to(DefaultComponent.class); 12 | } 13 | } 14 | // #component-module 15 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/tests/guice/DefaultComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.tests.guice; 5 | 6 | // #default-component 7 | public class DefaultComponent implements Component { 8 | public String hello() { 9 | return "default"; 10 | } 11 | } 12 | // #default-component 13 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/tests/guice/MockComponent.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.tests.guice; 5 | 6 | // #mock-component 7 | public class MockComponent implements Component { 8 | public String hello() { 9 | return "mock"; 10 | } 11 | } 12 | // #mock-component 13 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/code/tests/guice/controllers/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.tests.guice.controllers; 5 | 6 | import javaguide.tests.guice.Component; 7 | 8 | // #controller 9 | import play.mvc.*; 10 | import javax.inject.Inject; 11 | import javax.inject.Singleton; 12 | 13 | @Singleton 14 | public class Application extends Controller { 15 | 16 | private final Component component; 17 | 18 | @Inject 19 | public Application(Component component) { 20 | this.component = component; 21 | } 22 | 23 | public Result index() { 24 | return ok(component.hello()); 25 | } 26 | 27 | } 28 | // #controller 29 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/tests/index.toc: -------------------------------------------------------------------------------- 1 | JavaTest:テストの書き方 2 | JavaFunctionalTest:機能テストの書き方 3 | JavaTestingWithGuice:Guice によるテスト 4 | JavaTestingWithDatabases:データベースを使ったテスト 5 | JavaTestingWebServiceClients:web サービスクライアントのテスト 6 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/upload/JavaFileUpload.md: -------------------------------------------------------------------------------- 1 | 2 | # Handling file upload 3 | 4 | ## Uploading files in a form using `multipart/form-data` 5 | 6 | The standard way to upload files in a web application is to use a form with a special `multipart/form-data` encoding, which allows mixing of standard form data with file attachments. Please note: the HTTP method for the form has to be POST (not GET). 7 | 8 | Start by writing an HTML form: 9 | 10 | ``` 11 | @form(action = routes.Application.upload, 'enctype -> "multipart/form-data") { 12 | 13 | 14 | 15 |

16 | 17 |

18 | 19 | } 20 | ``` 21 | 22 | Now let’s define the `upload` action: 23 | 24 | @[syncUpload](code/JavaFileUpload.java) 25 | 26 | ## Direct file upload 27 | 28 | Another way to send files to the server is to use Ajax to upload files asynchronously from a form. In this case, the request body will not be encoded as `multipart/form-data`, but will just contain the plain file contents. 29 | 30 | @[asyncUpload](code/JavaFileUpload.java) 31 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/upload/code/JavaFileUpload.java: -------------------------------------------------------------------------------- 1 | import play.mvc.Controller; 2 | 3 | public class JavaFileUpload { 4 | 5 | static class SyncUpload extends Controller { 6 | //#syncUpload 7 | public static play.mvc.Result upload() { 8 | play.mvc.Http.MultipartFormData body = request().body().asMultipartFormData(); 9 | play.mvc.Http.MultipartFormData.FilePart picture = body.getFile("picture"); 10 | if (picture != null) { 11 | String fileName = picture.getFilename(); 12 | String contentType = picture.getContentType(); 13 | java.io.File file = picture.getFile(); 14 | return ok("File uploaded"); 15 | } else { 16 | flash("error", "Missing file"); 17 | return badRequest(); 18 | } 19 | } 20 | //#syncUpload 21 | } 22 | 23 | static class AsyncUpload extends Controller { 24 | //#asyncUpload 25 | public static play.mvc.Result upload() { 26 | java.io.File file = request().body().asRaw().asFile(); 27 | return ok("File uploaded"); 28 | } 29 | //#asyncUpload 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/upload/index.toc: -------------------------------------------------------------------------------- 1 | JavaFileUpload:multipart/form-data のアップロード -------------------------------------------------------------------------------- /manual/working/javaGuide/main/ws/code/javaguide.ws.routes: -------------------------------------------------------------------------------- 1 | # #ws-openid-routes 2 | GET /openID/login controllers.OpenIDController.login() 3 | POST /openID/login controllers.OpenIDController.loginPost() 4 | GET /openID/callback controllers.OpenIDController.openIDCallback() 5 | # #ws-openid-routes 6 | 7 | # #ws-oauth-routes 8 | GET /twitter/homeTimeline controllers.Twitter.homeTimeline() 9 | GET /twitter/auth controllers.Twitter.auth() 10 | # #ws-oauth-routes -------------------------------------------------------------------------------- /manual/working/javaGuide/main/ws/code/javaguide/ws/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.ws; 5 | 6 | // #ws-controller 7 | import javax.inject.Inject; 8 | 9 | import play.mvc.*; 10 | import play.libs.ws.*; 11 | import play.libs.F.Function; 12 | import play.libs.F.Promise; 13 | 14 | public class Application extends Controller { 15 | 16 | @Inject WSClient ws; 17 | 18 | // ... 19 | } 20 | // #ws-controller 21 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/ws/code/javaguide/ws/JavaWSSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.ws 5 | 6 | import org.specs2.mutable._ 7 | import play.api.test._ 8 | 9 | import play.api.mvc._ 10 | import play.api.libs.json._ 11 | 12 | import play.test.Helpers._ 13 | 14 | import play.api.test.FakeApplication 15 | import play.api.libs.json.JsObject 16 | import javaguide.testhelpers.MockJavaActionHelper 17 | import play.api.http.Status 18 | 19 | object JavaWSSpec extends Specification with Results with Status { 20 | // It's much easier to test this in Scala because we need to set up a 21 | // fake application with routes. 22 | 23 | def fakeApplication = FakeApplication(withRoutes = { 24 | case ("GET", "/feed") => 25 | Action { 26 | val obj: JsObject = Json.obj( 27 | "title" -> "foo", 28 | "commentsUrl" -> "http://localhost:3333/comments" 29 | ) 30 | Ok(obj) 31 | } 32 | case ("GET", "/comments") => 33 | Action { 34 | val obj: JsObject = Json.obj( 35 | "count" -> "10" 36 | ) 37 | Ok(obj) 38 | } 39 | case (_, _) => 40 | Action { 41 | BadRequest("no binding found") 42 | } 43 | }) 44 | 45 | "The Java WS class" should { 46 | "call WS correctly" in new WithServer(app = fakeApplication, port = 3333) { 47 | val result = MockJavaActionHelper.call(app.injector.instanceOf[JavaWS.Controller1], fakeRequest()) 48 | 49 | result.status() must equalTo(OK) 50 | } 51 | 52 | "compose WS calls successfully" in new WithServer(app = fakeApplication, port = 3333) { 53 | val result = MockJavaActionHelper.call(app.injector.instanceOf[JavaWS.Controller2], fakeRequest()) 54 | 55 | result.status() must equalTo(OK) 56 | contentAsString(result) must beEqualTo("Number of comments: 10") 57 | } 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/ws/code/javaguide/ws/login.scala.html: -------------------------------------------------------------------------------- 1 | @(message: String) 2 | 3 | Message: @message -------------------------------------------------------------------------------- /manual/working/javaGuide/main/ws/index.toc: -------------------------------------------------------------------------------- 1 | JavaWS:Play WS API 2 | JavaOpenID:OpenID サーバへの接続 3 | JavaOAuth:OAuth で保護されたリソースへのアクセス -------------------------------------------------------------------------------- /manual/working/javaGuide/main/xml/code/javaguide/xml/JavaXmlRequests.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package javaguide.xml; 5 | 6 | import org.w3c.dom.Document; 7 | import play.libs.XPath; 8 | 9 | import play.mvc.BodyParser; 10 | import play.mvc.Controller; 11 | import play.mvc.Result; 12 | 13 | public class JavaXmlRequests extends Controller { 14 | //#xml-hello 15 | public static Result sayHello() { 16 | Document dom = request().body().asXml(); 17 | if(dom == null) { 18 | return badRequest("Expecting Xml data"); 19 | } else { 20 | String name = XPath.selectText("//name", dom); 21 | if(name == null) { 22 | return badRequest("Missing parameter [name]"); 23 | } else { 24 | return ok("Hello " + name); 25 | } 26 | } 27 | } 28 | //#xml-hello 29 | 30 | //#xml-hello-bodyparser 31 | @BodyParser.Of(BodyParser.Xml.class) 32 | public static Result sayHelloBP() { 33 | Document dom = request().body().asXml(); 34 | if(dom == null) { 35 | return badRequest("Expecting Xml data"); 36 | } else { 37 | String name = XPath.selectText("//name", dom); 38 | if(name == null) { 39 | return badRequest("Missing parameter [name]"); 40 | } else { 41 | return ok("Hello " + name); 42 | } 43 | } 44 | } 45 | //#xml-hello-bodyparser 46 | 47 | //#xml-reply 48 | @BodyParser.Of(BodyParser.Xml.class) 49 | public static Result replyHello() { 50 | Document dom = request().body().asXml(); 51 | if(dom == null) { 52 | return badRequest("Expecting Xml data"); 53 | } else { 54 | String name = XPath.selectText("//name", dom); 55 | if(name == null) { 56 | return badRequest("Missing parameter [name]"); 57 | } else { 58 | return ok("Hello " + name + ""); 59 | } 60 | } 61 | } 62 | //#xml-reply 63 | } 64 | -------------------------------------------------------------------------------- /manual/working/javaGuide/main/xml/index.toc: -------------------------------------------------------------------------------- 1 | JavaXmlRequests:XML リクエストの処理と送信 -------------------------------------------------------------------------------- /manual/working/scalaGuide/ScalaHome.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # Scala 開発者のための Play 6 | 7 | 10 | Play アプリケーションは、`play.api` パッケージ内にある Scala API を使って開発することができます。 11 | 12 | 15 | > (`play.mvc` のような) play パッケージ内の API は Java 開発者に予約されています。Scala 開発者は `play.api.mvc` などを参照してください。 16 | 17 | @toc@ 18 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/dependencyinjection/code/injected.sbt: -------------------------------------------------------------------------------- 1 | //#content 2 | routesGenerator := InjectedRoutesGenerator 3 | //#content -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/dependencyinjection/code/scalaguide.advanced.dependencyinjection.bar.routes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/working/scalaGuide/advanced/dependencyinjection/code/scalaguide.advanced.dependencyinjection.bar.routes -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/dependencyinjection/code/scalaguide.advanced.dependencyinjection.injected.routes: -------------------------------------------------------------------------------- 1 | #injected 2 | GET /some/path @controllers.Application.index 3 | #injected -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/dependencyinjection/code/scalaguide.advanced.dependencyinjection.routes: -------------------------------------------------------------------------------- 1 | #content 2 | GET / controllers.Application.index 3 | GET /foo controllers.Application.foo 4 | -> /bar bar.Routes 5 | GET /assets/*file controllers.Assets.at(path = "/public", file) 6 | #content 7 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/dependencyinjection/index.toc: -------------------------------------------------------------------------------- 1 | ScalaDependencyInjection:実行時の DI 2 | ScalaCompileTimeDependencyInjection:コンパイル時の DI -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/embedding/index.toc: -------------------------------------------------------------------------------- 1 | ScalaEmbeddingPlay:Play の組み込み -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/extending/index.toc: -------------------------------------------------------------------------------- 1 | ScalaPlugins:プラグインの書き方 -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/http/code/EssentialFilter.scala: -------------------------------------------------------------------------------- 1 | package scalaguide.advanced.filters.essential 2 | 3 | // #essential-filter-example 4 | import play.api.Logger 5 | import play.api.mvc._ 6 | import play.api.libs.concurrent.Execution.Implicits.defaultContext 7 | 8 | class LoggingFilter extends EssentialFilter { 9 | def apply(nextFilter: EssentialAction) = new EssentialAction { 10 | def apply(requestHeader: RequestHeader) = { 11 | 12 | val startTime = System.currentTimeMillis 13 | 14 | nextFilter(requestHeader).map { result => 15 | 16 | val endTime = System.currentTimeMillis 17 | val requestTime = endTime - startTime 18 | 19 | Logger.info(s"${requestHeader.method} ${requestHeader.uri}" + 20 | s" took ${requestTime}ms and returned ${result.header.status}") 21 | result.withHeaders("Request-Time" -> requestTime.toString) 22 | 23 | } 24 | } 25 | } 26 | } 27 | // #essential-filter-example 28 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/http/code/FiltersRouting.scala: -------------------------------------------------------------------------------- 1 | package scalaguide.advanced.filters.routing 2 | 3 | // #routing-info-access 4 | import play.api.mvc.{Result, RequestHeader, Filter} 5 | import play.api.{Logger, Routes} 6 | import scala.concurrent.Future 7 | import play.api.libs.concurrent.Execution.Implicits.defaultContext 8 | 9 | object LoggingFilter extends Filter { 10 | def apply(nextFilter: RequestHeader => Future[Result]) 11 | (requestHeader: RequestHeader): Future[Result] = { 12 | 13 | val startTime = System.currentTimeMillis 14 | 15 | nextFilter(requestHeader).map { result => 16 | 17 | val action = requestHeader.tags(Routes.ROUTE_CONTROLLER) + 18 | "." + requestHeader.tags(Routes.ROUTE_ACTION_METHOD) 19 | val endTime = System.currentTimeMillis 20 | val requestTime = endTime - startTime 21 | 22 | Logger.info(s"${action} took ${requestTime}ms" + 23 | s" and returned ${result.header.status}") 24 | 25 | result.withHeaders("Request-Time" -> requestTime.toString) 26 | } 27 | } 28 | } 29 | // #routing-info-access -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/http/code/ScalaHttpFilters.scala: -------------------------------------------------------------------------------- 1 | package scalaguide.advanced.filters 2 | 3 | package simple { 4 | 5 | // #simple-filter 6 | import play.api.Logger 7 | import play.api.mvc._ 8 | import scala.concurrent.Future 9 | import play.api.libs.concurrent.Execution.Implicits.defaultContext 10 | 11 | class LoggingFilter extends Filter { 12 | 13 | def apply(nextFilter: RequestHeader => Future[Result]) 14 | (requestHeader: RequestHeader): Future[Result] = { 15 | 16 | val startTime = System.currentTimeMillis 17 | 18 | nextFilter(requestHeader).map { result => 19 | 20 | val endTime = System.currentTimeMillis 21 | val requestTime = endTime - startTime 22 | 23 | Logger.info(s"${requestHeader.method} ${requestHeader.uri} " + 24 | s"took ${requestTime}ms and returned ${result.header.status}") 25 | 26 | result.withHeaders("Request-Time" -> requestTime.toString) 27 | } 28 | } 29 | } 30 | // #simple-filter 31 | 32 | } 33 | 34 | package httpfilters { 35 | 36 | import simple.LoggingFilter 37 | 38 | // #filters 39 | import javax.inject.Inject 40 | import play.api.http.HttpFilters 41 | import play.filters.gzip.GzipFilter 42 | 43 | class Filters @Inject() ( 44 | gzip: GzipFilter, 45 | log: LoggingFilter 46 | ) extends HttpFilters { 47 | 48 | val filters = Seq(gzip, log) 49 | } 50 | //#filters 51 | } 52 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/http/code/ScalaHttpRequestHandlers.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.advanced.httprequesthandlers 5 | 6 | package simple { 7 | 8 | //#simple 9 | import javax.inject.Inject 10 | import play.api.http._ 11 | import play.api.mvc._ 12 | import play.api.routing.Router 13 | 14 | class SimpleHttpRequestHandler @Inject() (router: Router) extends HttpRequestHandler { 15 | def handlerForRequest(request: RequestHeader) = { 16 | router.routes.lift(request) match { 17 | case Some(handler) => (request, handler) 18 | case None => (request, Action(Results.NotFound)) 19 | } 20 | } 21 | } 22 | //#simple 23 | } 24 | 25 | package virtualhost { 26 | 27 | import play.api.routing.Router 28 | object bar { 29 | type Routes = Router 30 | } 31 | object foo { 32 | type Routes = Router 33 | } 34 | 35 | //#virtualhost 36 | import javax.inject.Inject 37 | import play.api.http._ 38 | import play.api.mvc.RequestHeader 39 | 40 | class VirtualHostRequestHandler @Inject() (errorHandler: HttpErrorHandler, 41 | configuration: HttpConfiguration, filters: HttpFilters, 42 | fooRouter: foo.Routes, barRouter: bar.Routes 43 | ) extends DefaultHttpRequestHandler( 44 | fooRouter, errorHandler, configuration, filters 45 | ) { 46 | 47 | override def routeRequest(request: RequestHeader) = { 48 | request.host match { 49 | case "foo.example.com" => fooRouter.routes.lift(request) 50 | case "bar.example.com" => barRouter.routes.lift(request) 51 | case _ => super.routeRequest(request) 52 | } 53 | } 54 | } 55 | //#virtualhost 56 | 57 | } 58 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/http/index.toc: -------------------------------------------------------------------------------- 1 | HttpApi:HTTP API 2 | ScalaHttpFilters:HTTP フィルタ 3 | ScalaHttpRequestHandlers:HTTP リクエストの処理 -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/index.toc: -------------------------------------------------------------------------------- 1 | iteratees:リアクティブなストリーム処理 2 | http:HTTP アーキテクチャ 3 | dependencyinjection:依存性の注入 4 | routing:拡張ルーティング 5 | extending:Play の拡張 6 | embedding:Play の組み込み -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/iteratees/index.toc: -------------------------------------------------------------------------------- 1 | Iteratees:Iteratees 2 | Enumerators:Enumerators 3 | Enumeratees:Enumeratees -------------------------------------------------------------------------------- /manual/working/scalaGuide/advanced/routing/index.toc: -------------------------------------------------------------------------------- 1 | ScalaSirdRouter:文字列補間ルーティング DSL 2 | ScalaJavascriptRouting:Javascript ルーティング -------------------------------------------------------------------------------- /manual/working/scalaGuide/index.toc: -------------------------------------------------------------------------------- 1 | ScalaHome:目次 2 | main:主要なコンセプト 3 | advanced:上級編 -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/akka/index.toc: -------------------------------------------------------------------------------- 1 | ScalaAkka:Akka との統合 -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/async/index.toc: -------------------------------------------------------------------------------- 1 | ScalaAsync:非同期レスポンス 2 | ScalaStream:HTTP レスポンスのストリーミング 3 | ScalaComet:Comet ソケット 4 | ScalaWebSockets:WebSocket -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/cache/index.toc: -------------------------------------------------------------------------------- 1 | ScalaCache:Cache を使う -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/CustomValidations.scala: -------------------------------------------------------------------------------- 1 | package scalaguide.forms.scalaforms { 2 | 3 | import play.api.data._ 4 | import play.api.data.Forms._ 5 | import play.api.data.validation._ 6 | 7 | import org.junit.runner.RunWith 8 | 9 | import org.specs2.runner.JUnitRunner 10 | 11 | import org.specs2.mutable._ 12 | 13 | @RunWith(classOf[JUnitRunner]) 14 | class CustomValidationsSpec extends Specification { 15 | 16 | // #passwordcheck-constraint 17 | val allNumbers = """\d*""".r 18 | val allLetters = """[A-Za-z]*""".r 19 | 20 | val passwordCheckConstraint: Constraint[String] = Constraint("constraints.passwordcheck")({ 21 | plainText => 22 | val errors = plainText match { 23 | case allNumbers() => Seq(ValidationError("Password is all numbers")) 24 | case allLetters() => Seq(ValidationError("Password is all letters")) 25 | case _ => Nil 26 | } 27 | if (errors.isEmpty) { 28 | Valid 29 | } else { 30 | Invalid(errors) 31 | } 32 | }) 33 | // #passwordcheck-constraint 34 | 35 | val MIN_PASSWORD_LENGTH = 10 36 | 37 | // #passwordcheck-mapping 38 | val passwordCheck: Mapping[String] = nonEmptyText(minLength = 10) 39 | .verifying(passwordCheckConstraint) 40 | // #passwordcheck-mapping 41 | 42 | "password check" should { 43 | 44 | "return invalid with all letters" in { 45 | passwordCheckConstraint("abcdef").must(be_==(Invalid(ValidationError("Password is all letters")))) 46 | } 47 | 48 | "return invalid with all numbers" in { 49 | passwordCheckConstraint("12324").must(be_==(Invalid(ValidationError("Password is all numbers")))) 50 | } 51 | 52 | "return valid with both letters and numbers" in { 53 | passwordCheckConstraint("abc123").must(be_==(Valid)) 54 | } 55 | 56 | } 57 | 58 | } 59 | 60 | 61 | 62 | 63 | } -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/ScalaFieldConstructor.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.forms.scalafieldconstructor { 5 | 6 | import org.specs2.mutable.Specification 7 | import play.api.{Environment, Configuration} 8 | import play.api.i18n.{DefaultLangs, DefaultMessagesApi, Messages} 9 | 10 | object ScalaFieldConstructorSpec extends Specification { 11 | 12 | val conf = Configuration.reference 13 | implicit val messages: Messages = new DefaultMessagesApi(Environment.simple(), conf, new DefaultLangs(conf)).preferred(Seq.empty) 14 | 15 | "field constructors" should { 16 | 17 | "be possible to import" in { 18 | html.userImport(MyForm.form).body must contain("--foo--") 19 | } 20 | 21 | "be possible to declare" in { 22 | html.userDeclare(MyForm.form).body must contain("--foo--") 23 | } 24 | } 25 | } 26 | 27 | object MyForm { 28 | import play.api.data.Form 29 | import play.api.data.Forms._ 30 | import html.models.User 31 | 32 | val form = Form(mapping( 33 | "username" -> text 34 | )(User.apply)(User.unapply)) 35 | } 36 | 37 | package html { 38 | //#form-myfield-helper 39 | object MyHelpers { 40 | import views.html.helper.FieldConstructor 41 | implicit val myFields = FieldConstructor(html.myFieldConstructorTemplate.f) 42 | } 43 | //#form-myfield-helper 44 | 45 | } 46 | 47 | package html.models { 48 | case class User(username:String) 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide.forms.scalaforms.routes: -------------------------------------------------------------------------------- 1 | GET /home/:id controllers.Application.home(id:Int) 2 | 3 | GET /contacts/:id controllers.Application.showContact(id:Int) 4 | 5 | POST /user controllers.Application.userPost 6 | 7 | POST /submit controllers.Application.submit 8 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/csrf.scala.html: -------------------------------------------------------------------------------- 1 | @(implicit req: RequestHeader) 2 | 3 | @import scalaguide.forms.csrf.routes 4 | 5 | @* #csrf-call *@ 6 | @import helper._ 7 | 8 | @form(CSRF(routes.ItemsController.save())) { 9 | ... 10 | } 11 | @* #csrf-call *@ 12 | 13 | @* #csrf-input *@ 14 | @form(routes.ItemsController.save()) { 15 | @CSRF.formField 16 | ... 17 | } 18 | @* #csrf-input *@ 19 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/scalafieldconstructor/myFieldConstructorTemplate.scala.html: -------------------------------------------------------------------------------- 1 | @* #form-myfield *@ 2 | @(elements: helper.FieldElements) 3 | 4 |
5 | 6 |
7 | @elements.input 8 | @elements.errors.mkString(", ") 9 | @elements.infos.mkString(", ") 10 |
11 |
12 | @* #form-myfield *@ 13 | --foo-- 14 | the above is here so the tests can check this field constructor was used. 15 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/scalafieldconstructor/userDeclare.scala.html: -------------------------------------------------------------------------------- 1 | @(myForm: Form[User])(implicit messages: Messages) 2 | 3 | @* #declare-implicit *@ 4 | @implicitField = @{ helper.FieldConstructor(myFieldConstructorTemplate.f) } 5 | @* #declare-implicit *@ 6 | 7 | @* #form *@ 8 | @helper.inputText(myForm("username")) 9 | @* #form *@ 10 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/scalafieldconstructor/userImport.scala.html: -------------------------------------------------------------------------------- 1 | @(myForm: Form[User])(implicit messages: Messages) 2 | 3 | @* #import-myhelper *@ 4 | @import MyHelpers._ 5 | @* #import-myhelper *@ 6 | 7 | @* #form *@ 8 | @helper.inputText(myForm("username")) 9 | @* #form *@ 10 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/scalaforms/views/contact/form.scala.html: -------------------------------------------------------------------------------- 1 | @(contactForm: Form[Contact]) 2 | 3 | 4 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/scalaforms/views/nested.scala.html: -------------------------------------------------------------------------------- 1 | @(userFormNested: Form[UserAddressData])(implicit messages: Messages) 2 | 3 | @import scalaguide.forms.scalaforms.controllers._ 4 | @import scalaguide.forms.scalaforms.controllers.routes 5 | 6 | @helper.form(action = routes.Application.submit) { 7 | @* #form-field-nested *@ 8 | @helper.inputText(userFormNested("name")) 9 | @helper.inputText(userFormNested("address.street")) 10 | @helper.inputText(userFormNested("address.city")) 11 | @* #form-field-nested *@ 12 | }) -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/scalaforms/views/repeat.scala.html: -------------------------------------------------------------------------------- 1 | @(myForm: Form[UserListData])(implicit messages: Messages) 2 | 3 | @import scalaguide.forms.scalaforms.controllers.routes 4 | 5 | @helper.form(action = routes.Application.submit) { 6 | @* #form-field-repeat *@ 7 | @helper.inputText(myForm("name")) 8 | @helper.repeat(myForm("emails"), min = 1) { emailField => 9 | @helper.inputText(emailField) 10 | } 11 | @* #form-field-repeat *@ 12 | }) -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/code/scalaguide/forms/scalaforms/views/user.scala.html: -------------------------------------------------------------------------------- 1 | @* #form-define *@ 2 | @(userForm: Form[UserData])(implicit messages: Messages) 3 | @* #form-define *@ 4 | 5 | @import scalaguide.forms.scalaforms._ 6 | @import scalaguide.forms.scalaforms.controllers.routes 7 | 8 |
9 | @* #form-user-generated *@ 10 |
11 |
12 |
13 |
This field is required!
14 |
Another error
15 |
Required
16 |
Another constraint
17 |
18 | @* #form-user-generated *@ 19 |
20 | 21 | @* #form-user *@ 22 | @helper.form(action = routes.Application.userPost()) { 23 | @helper.inputText(userForm("name")) 24 | @helper.inputText(userForm("age")) 25 | } 26 | @* #form-user *@ 27 | 28 | @* #global-errors *@ 29 | @if(userForm.hasGlobalErrors) { 30 |
    31 | @for(error <- userForm.globalErrors) { 32 |
  • @error.message
  • 33 | } 34 |
35 | } 36 | @* #global-errors *@ 37 | 38 | @helper.form(action = routes.Application.userPost()) { 39 | @* #form-user-parameters *@ 40 | @helper.inputText(userForm("name"), 'id -> "name", 'size -> 30) 41 | @* #form-user-parameters *@ 42 | @helper.inputText(userForm("age")) 43 | @* #form-user-parameters-html *@ 44 | @helper.input(userForm("name")) { (id, name, value, args) => 45 | 46 | } 47 | @* #form-user-parameters-html *@ 48 | } 49 | 50 | 51 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/images/lifecycle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/working/scalaGuide/main/forms/images/lifecycle.png -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/forms/index.toc: -------------------------------------------------------------------------------- 1 | ScalaForms:フォームの送信 2 | ScalaCsrf:CSRF 対策 3 | ScalaCustomValidations:カスタムバリデーション 4 | ScalaCustomFieldConstructors:カスタムフィールドコンストラクタ -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/code/scalaguide.http.routing.defaultvalue.routes: -------------------------------------------------------------------------------- 1 | # #clients 2 | # Pagination links, like /clients?page=3 3 | GET /clients controllers.Clients.list(page: Int ?= 1) 4 | # #clients 5 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/code/scalaguide.http.routing.fixed.routes: -------------------------------------------------------------------------------- 1 | # #page 2 | # Extract the page parameter from the path, or fix the value for / 3 | GET / controllers.Application.show(page = "home") 4 | GET /:page controllers.Application.show(page) 5 | # #page -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/code/scalaguide.http.routing.query.routes: -------------------------------------------------------------------------------- 1 | # #page 2 | # Extract the page parameter from the query string. 3 | GET / controllers.Application.show(page) 4 | # #page -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/code/scalaguide.http.routing.reverse.routes: -------------------------------------------------------------------------------- 1 | # #route 2 | # Hello action 3 | GET /hello/:name controllers.Application.hello(name) 4 | # #route 5 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/code/scalaguide.http.routing.routes: -------------------------------------------------------------------------------- 1 | 2 | # #static-path 3 | GET /clients/all controllers.Clients.list() 4 | # #static-path 5 | 6 | # #clients-show-comment 7 | # Display a client. 8 | # #clients-show ###skip 9 | GET /clients/:id controllers.Clients.show(id: Long) 10 | # #clients-show #clients-show-comment 11 | 12 | # #spanning-path 13 | GET /files/*name controllers.Application.download(name) 14 | # #spanning-path 15 | 16 | # #regex-path 17 | GET /items/$id<[0-9]+> controllers.Items.show(id: Long) 18 | # #regex-path 19 | 20 | # #home-page 21 | GET / controllers.Application.homePage() 22 | # #home-page 23 | 24 | # #page 25 | # Extract the page parameter from the path. 26 | GET /:page controllers.Application.show(page) 27 | # #page 28 | 29 | # #optional 30 | # The version parameter is optional. E.g. /api/list-all?version=3.0 31 | GET /api/list-all controllers.Api.list(version: Option[String]) 32 | # #optional 33 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/code/scalaguide/http/routing/views/Clients/display.scala.html: -------------------------------------------------------------------------------- 1 | @(msg: String) 2 | @msg -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/code/scalaguide/http/scalasessionflash/views/index.scala.html: -------------------------------------------------------------------------------- 1 | @* #flash-template *@ 2 | @()(implicit flash: Flash) 3 | ... 4 | @flash.get("success").getOrElse("Welcome!") 5 | ... 6 | @* #flash-template *@ 7 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/images/routesError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/working/scalaGuide/main/http/images/routesError.png -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/http/index.toc: -------------------------------------------------------------------------------- 1 | ScalaActions:アクション、コントローラ、レスポンス 2 | ScalaRouting:HTTP ルーティング 3 | ScalaResults:レスポンスの操作 4 | ScalaSessionFlash:Session と Flash スコープ 5 | ScalaBodyParsers:ボディパーサー 6 | ScalaActionsComposition:アクションの構成 7 | ScalaContentNegotiation:コンテンツネゴシエーション 8 | ScalaErrorHandling:エラーハンドリング 9 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/i18n/code/ScalaI18N.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.i18n.scalai18n { 5 | import org.junit.runner.RunWith 6 | import org.specs2.runner.JUnitRunner 7 | import play.api.test._ 8 | 9 | import play.api._ 10 | import play.api.mvc._ 11 | import play.api.i18n.{DefaultLangs, DefaultMessagesApi, Messages, MessagesApi} 12 | 13 | @RunWith(classOf[JUnitRunner]) 14 | class ScalaI18nSpec extends PlaySpecification with Controller { 15 | 16 | //#i18n-support 17 | import play.api.i18n.I18nSupport 18 | class MyController(val messagesApi: MessagesApi) extends Controller with I18nSupport { 19 | // ... 20 | //#i18n-support 21 | 22 | "A Scala translation" should { 23 | "escape single quotes" in { 24 | //#apostrophe-messages 25 | Messages("info.error") == "You aren't logged in!" 26 | //#apostrophe-messages 27 | } 28 | 29 | "escape parameter substitution" in { 30 | //#parameter-escaping 31 | Messages("example.formatting") == "When using MessageFormat, '{0}' is replaced with the first parameter." 32 | //#parameter-escaping 33 | } 34 | } 35 | } 36 | 37 | val conf = Configuration.reference ++ Configuration.from(Map("play.i18n.path" -> "scalaguide/i18n")) 38 | val messagesApi = new DefaultMessagesApi(Environment.simple(), conf, new DefaultLangs(conf)) 39 | 40 | new MyController(messagesApi) 41 | 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/i18n/code/scalaguide/i18n/messages: -------------------------------------------------------------------------------- 1 | #apostrophe-messages 2 | info.error=You aren''t logged in! 3 | #apostrophe-messages 4 | 5 | #parameter-escaping 6 | example.formatting=When using MessageFormat, '''{0}''' is replaced with the first parameter. 7 | #parameter-escaping 8 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/i18n/index.toc: -------------------------------------------------------------------------------- 1 | ScalaI18N:国際化 -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/index.toc: -------------------------------------------------------------------------------- 1 | http:HTTP プログラミング 2 | async:非同期 HTTP プログラミング 3 | templates:テンプレートエンジン 4 | forms:フォーム送信とバリデーション 5 | json:Json を使う 6 | xml:XML を使う 7 | upload:ファイルアップロード処理 8 | sql:SQL データベースアクセス 9 | cache:キャッシュを使う 10 | ws:Web サービスの呼び出し 11 | akka:Akka との統合 12 | i18n:国際化 13 | tests:アプリケーションのテスト 14 | logging:ロギング -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/json/index.toc: -------------------------------------------------------------------------------- 1 | ScalaJson:JSON の基本 2 | ScalaJsonHttp:JSON と HTTP 3 | ScalaJsonCombinators:JSON Reads/Writes/Format コンビネータ 4 | ScalaJsonTransformers:JSON トランスフォーマ 5 | ScalaJsonInception:JSON Macro Inception -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/logging/index.toc: -------------------------------------------------------------------------------- 1 | ScalaLogging:ロギング -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/sql/images/dbError.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/playframework-ja/translation-project/62d51de21933cd1d3c7e0b27844730399aa55130/manual/working/scalaGuide/main/sql/images/dbError.png -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/sql/index.toc: -------------------------------------------------------------------------------- 1 | ScalaDatabase:JDBC の設定と利用 2 | slick:Slick によるデータベースアクセス 3 | ScalaAnorm:Anorm によるデータベースアクセス 4 | ScalaDatabaseOthers:その他のデータベースライブラリとの統合 -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/ScalaTestingYourApplication.md: -------------------------------------------------------------------------------- 1 | 2 | 5 | # アプリケーションのテスト 6 | 7 | 10 | アプリケーションのテストを作成するのは複雑な作業となりがちです。Play は [ScalaTest](http://www.scalatest.org) および [specs2](https://etorreborre.github.io/specs2/) をサポートしており、テストの作成をできる限り容易にするヘルパーやスタブを提供しています。 テストフレームワークを Play で使う詳しい方法は、 [[ScalaTest|ScalaTestingWithScalaTest]] あるいは [[specs2|ScalaTestingWithSpecs2]] を参照してください。 11 | 12 | 16 | * [[ScalaTest を使用したアプリケーションのテスト|ScalaTestingWithScalaTest]] 17 | * [[specs2 を使用したアプリケーションのテスト|ScalaTestingWithSpecs2]] 18 | 19 | 22 | ## 高度なテスト 23 | 24 | 27 | アプリケーションの特定のパーツをテストするために、Play は多くのヘルパーを提供しています。 28 | 29 | 33 | * [[Guice の依存性注入を使用したテスト|ScalaTestingWithGuice]] 34 | * [[データベースを使用したテスト|ScalaTestingWithDatabases]] 35 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/ExampleControllerSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest 5 | 6 | // #scalatest-examplecontrollerspec 7 | import scala.concurrent.Future 8 | 9 | import org.scalatest._ 10 | import org.scalatestplus.play._ 11 | 12 | import play.api.mvc._ 13 | import play.api.test._ 14 | import play.api.test.Helpers._ 15 | 16 | class ExampleControllerSpec extends PlaySpec with Results { 17 | 18 | class TestController() extends Controller with ExampleController 19 | 20 | "Example Page#index" should { 21 | "should be valid" in { 22 | val controller = new TestController() 23 | val result: Future[Result] = controller.index().apply(FakeRequest()) 24 | val bodyText: String = contentAsString(result) 25 | bodyText mustBe "ok" 26 | } 27 | } 28 | } 29 | // #scalatest-examplecontrollerspec 30 | 31 | // #scalatest-examplecontroller 32 | trait ExampleController { 33 | this: Controller => 34 | 35 | def index() = Action { 36 | Ok("ok") 37 | } 38 | } 39 | 40 | object ExampleController extends Controller with ExampleController 41 | // #scalatest-examplecontroller 42 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/ExampleEssentialActionSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest 5 | 6 | import org.scalatest._ 7 | import org.scalatestplus.play._ 8 | 9 | import play.api.mvc._ 10 | import play.api.test._ 11 | import Helpers._ 12 | import play.api.mvc.Results._ 13 | import play.api.libs.json.Json 14 | 15 | // #scalatest-exampleessentialactionspec 16 | class ExampleEssentialActionSpec extends PlaySpec { 17 | 18 | "An essential action" should { 19 | "can parse a JSON body" in { 20 | val action: EssentialAction = Action { request => 21 | val value = (request.body.asJson.get \ "field").as[String] 22 | Ok(value) 23 | } 24 | 25 | val request = FakeRequest(POST, "/").withJsonBody(Json.parse("""{ "field": "value" }""")) 26 | 27 | val result = call(action, request) 28 | 29 | status(result) mustEqual OK 30 | contentAsString(result) mustEqual "value" 31 | } 32 | } 33 | } 34 | // #scalatest-exampleessentialactionspec 35 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/ExampleMockitoSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest 5 | 6 | // #scalatest-mockitosugar 7 | import org.scalatest._ 8 | import org.scalatest.mock.MockitoSugar 9 | import org.scalatestplus.play._ 10 | 11 | import org.mockito.Mockito._ 12 | 13 | class ExampleMockitoSpec extends PlaySpec with MockitoSugar { 14 | 15 | "MyService#isDailyData" should { 16 | "return true if the data is from today" in { 17 | val mockDataService = mock[DataService] 18 | when(mockDataService.findData) thenReturn Data(new java.util.Date()) 19 | 20 | val myService = new MyService() { 21 | override def dataService = mockDataService 22 | } 23 | 24 | val actual = myService.isDailyData 25 | actual mustBe true 26 | } 27 | } 28 | } 29 | // #scalatest-mockitosugar 30 | 31 | // #scalatest-mockito-dataservice 32 | case class Data(retrievalDate: java.util.Date) 33 | 34 | trait DataService { 35 | def findData: Data 36 | } 37 | // #scalatest-mockito-dataservice 38 | 39 | class MyService { 40 | import java.util._ 41 | 42 | def dataService: DataService = null // implementation reference... 43 | 44 | def isDailyData: Boolean = { 45 | val retrievalDate = Calendar.getInstance 46 | retrievalDate.setTime(dataService.findData.retrievalDate) 47 | 48 | val today = Calendar.getInstance() 49 | 50 | (retrievalDate.get(Calendar.YEAR) == today.get(Calendar.YEAR) 51 | && retrievalDate.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/ExamplePostSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest 5 | 6 | // #scalatest-examplecontrollerspec 7 | import scala.concurrent.Future 8 | 9 | import org.scalatest._ 10 | import org.scalatestplus.play._ 11 | 12 | import play.api.mvc._ 13 | import play.api.test._ 14 | import play.api.test.Helpers._ 15 | 16 | class ExampleControllerSpec extends PlaySpec with Results { 17 | 18 | //#scalatest-examplepost 19 | trait WithControllerAndRequest { 20 | val testController = new Controller with ApiController 21 | 22 | def fakeRequest(method: String = "GET", route: String = "/") = FakeRequest(method, route) 23 | .withHeaders( 24 | ("Date", "2014-10-05T22:00:00"), 25 | ("Authorization", "username=bob;hash=foobar==") 26 | ) 27 | } 28 | 29 | "REST API" should { 30 | "create a new user" in new WithControllerAndRequest { 31 | val request = fakeRequest("POST", "/user").withJsonBody(Json.parse( 32 | s"""{"first_name": "Alice", 33 | | "last_name": "Doe", 34 | | "credentials": { 35 | | "username": "alice", 36 | | "password": "secret" 37 | | } 38 | |}""".stripMargin)) 39 | val apiResult = call(testController.createUser, request) 40 | status(apiResult) mustEqual CREATED 41 | val jsonResult = contentAsJson(apiResult) 42 | ObjectId.isValid((jsonResult \ "id").as[String]) mustBe true 43 | 44 | // now get the real thing from the DB and check it was created with the correct values: 45 | val newbie = Dao().findByUsername("alice").get 46 | newbie.id.get.toString mustEqual (jsonResult \ "id").as[String] 47 | newbie.firstName mustEqual "Alice" 48 | } 49 | } 50 | //#scalatest-examplepost 51 | } 52 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/StackSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest 5 | 6 | // #scalatest-stackspec 7 | import collection.mutable.Stack 8 | import org.scalatestplus.play._ 9 | 10 | class StackSpec extends PlaySpec { 11 | 12 | "A Stack" must { 13 | "pop values in last-in-first-out order" in { 14 | val stack = new Stack[Int] 15 | stack.push(1) 16 | stack.push(2) 17 | stack.pop() mustBe 2 18 | stack.pop() mustBe 1 19 | } 20 | "throw NoSuchElementException if an empty stack is popped" in { 21 | val emptyStack = new Stack[Int] 22 | a [NoSuchElementException] must be thrownBy { 23 | emptyStack.pop() 24 | } 25 | } 26 | } 27 | } 28 | // #scalatest-stackspec 29 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/UserServiceSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest 5 | 6 | import org.scalatest._ 7 | import org.scalatest.mock.MockitoSugar 8 | import org.scalatestplus.play._ 9 | 10 | import org.mockito.Mockito._ 11 | import org.mockito.Matchers._ 12 | 13 | import scalaguide.tests.models._ 14 | import scalaguide.tests.services._ 15 | 16 | // #scalatest-userservicespec 17 | class UserServiceSpec extends PlaySpec with MockitoSugar { 18 | 19 | "UserService#isAdmin" should { 20 | "be true when the role is admin" in { 21 | val userRepository = mock[UserRepository] 22 | when(userRepository.roles(any[User])) thenReturn Set(Role("ADMIN")) 23 | 24 | val userService = new UserService(userRepository) 25 | 26 | val actual = userService.isAdmin(User("11", "Steve", "user@example.org")) 27 | actual mustBe true 28 | } 29 | } 30 | } 31 | // #scalatest-userservicespec 32 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/allbrowserspersuite/ExampleOverrideBrowsersSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.allbrowserspersuite 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.test.Helpers._ 10 | import play.api.libs.ws._ 11 | import play.api.mvc._ 12 | import Results._ 13 | 14 | // #scalafunctionaltest-allbrowserspersuite 15 | class ExampleOverrideBrowsersSpec extends PlaySpec with OneServerPerSuite with AllBrowsersPerSuite { 16 | 17 | override lazy val browsers = 18 | Vector( 19 | FirefoxInfo(firefoxProfile), 20 | ChromeInfo 21 | ) 22 | 23 | // Override app if you need a FakeApplication with other than 24 | // default parameters. 25 | implicit override lazy val app: FakeApplication = 26 | FakeApplication( 27 | additionalConfiguration = Map("ehcacheplugin" -> "disabled"), 28 | withRoutes = { 29 | case ("GET", "/testing") => 30 | Action( 31 | Results.Ok( 32 | "" + 33 | "Test Page" + 34 | "" + 35 | "" + 36 | "" + 37 | "" 38 | ).as("text/html") 39 | ) 40 | } 41 | ) 42 | 43 | def sharedTests(browser: BrowserInfo) = { 44 | "The AllBrowsersPerSuite trait" must { 45 | "provide a web driver" + browser.name in { 46 | go to (s"http://localhost:$port/testing") 47 | pageTitle mustBe "Test Page" 48 | click on find(name("b")).value 49 | eventually { pageTitle mustBe "scalatest" } 50 | } 51 | } 52 | } 53 | } 54 | // #scalafunctionaltest-allbrowserspersuite 55 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/allbrowserspersuite/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.allbrowserspersuite 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.test.Helpers._ 10 | import play.api.libs.ws._ 11 | import play.api.mvc._ 12 | import Results._ 13 | 14 | // #scalafunctionaltest-allbrowserspersuite 15 | class ExampleSpec extends PlaySpec with OneServerPerSuite with AllBrowsersPerSuite { 16 | 17 | // Override app if you need a FakeApplication with other than 18 | // default parameters. 19 | implicit override lazy val app: FakeApplication = 20 | FakeApplication( 21 | additionalConfiguration = Map("ehcacheplugin" -> "disabled"), 22 | withRoutes = { 23 | case ("GET", "/testing") => 24 | Action( 25 | Results.Ok( 26 | "" + 27 | "Test Page" + 28 | "" + 29 | "" + 30 | "" + 31 | "" 32 | ).as("text/html") 33 | ) 34 | } 35 | ) 36 | 37 | def sharedTests(browser: BrowserInfo) = { 38 | "The AllBrowsersPerSuite trait" must { 39 | "provide a web driver " + browser.name in { 40 | go to (s"http://localhost:$port/testing") 41 | pageTitle mustBe "Test Page" 42 | click on find(name("b")).value 43 | eventually { pageTitle mustBe "scalatest" } 44 | } 45 | } 46 | } 47 | } 48 | // #scalafunctionaltest-allbrowserspersuite 49 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/allbrowserspertest/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.allbrowserspertest 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.test.Helpers._ 10 | import play.api.libs.ws._ 11 | import play.api.mvc._ 12 | import Results._ 13 | 14 | // #scalafunctionaltest-allbrowserspertest 15 | class ExampleSpec extends PlaySpec with OneServerPerSuite with AllBrowsersPerTest { 16 | 17 | // Override app if you need a FakeApplication with other than 18 | // default parameters. 19 | implicit override lazy val app: FakeApplication = 20 | FakeApplication( 21 | additionalConfiguration = Map("ehcacheplugin" -> "disabled"), 22 | withRoutes = { 23 | case ("GET", "/testing") => 24 | Action( 25 | Results.Ok( 26 | "" + 27 | "Test Page" + 28 | "" + 29 | "" + 30 | "" + 31 | "" 32 | ).as("text/html") 33 | ) 34 | } 35 | ) 36 | 37 | def sharedTests(browser: BrowserInfo) = { 38 | "The AllBrowsersPerTest trait" must { 39 | "provide a web driver" + browser.name in { 40 | go to (s"http://localhost:$port/testing") 41 | pageTitle mustBe "Test Page" 42 | click on find(name("b")).value 43 | eventually { pageTitle mustBe "scalatest" } 44 | } 45 | } 46 | } 47 | } 48 | // #scalafunctionaltest-allbrowserspertest 49 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/oneapppersuite/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.oneapppersuite 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.{Play, Application} 10 | 11 | // #scalafunctionaltest-oneapppersuite 12 | class ExampleSpec extends PlaySpec with OneAppPerSuite { 13 | 14 | // Override app if you need a FakeApplication with other than 15 | // default parameters. 16 | implicit override lazy val app: FakeApplication = 17 | FakeApplication( 18 | additionalConfiguration = Map("ehcacheplugin" -> "disabled") 19 | ) 20 | 21 | "The OneAppPerSuite trait" must { 22 | "provide a FakeApplication" in { 23 | app.configuration.getString("ehcacheplugin") mustBe Some("disabled") 24 | } 25 | "start the FakeApplication" in { 26 | Play.maybeApplication mustBe Some(app) 27 | } 28 | } 29 | } 30 | // #scalafunctionaltest-oneapppersuite 31 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/oneapppertest/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.oneapppertest 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.{Play, Application} 10 | 11 | // #scalafunctionaltest-oneapppertest 12 | class ExampleSpec extends PlaySpec with OneAppPerTest { 13 | 14 | // Override app if you need a FakeApplication with other than 15 | // default parameters. 16 | implicit override def newAppForTest(td: TestData): FakeApplication = 17 | FakeApplication( 18 | additionalConfiguration = Map("ehcacheplugin" -> "disabled") 19 | ) 20 | 21 | "The OneAppPerTest trait" must { 22 | "provide a new FakeApplication for each test" in { 23 | app.configuration.getString("ehcacheplugin") mustBe Some("disabled") 24 | } 25 | "start the FakeApplication" in { 26 | Play.maybeApplication mustBe Some(app) 27 | } 28 | } 29 | } 30 | // #scalafunctionaltest-oneapppertest 31 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/onebrowserpersuite/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.onebrowserpersuite 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.test.Helpers._ 10 | import play.api.libs.ws._ 11 | import play.api.mvc._ 12 | import Results._ 13 | 14 | // #scalafunctionaltest-onebrowserpersuite 15 | class ExampleSpec extends PlaySpec with OneServerPerSuite with OneBrowserPerSuite with HtmlUnitFactory { 16 | 17 | // Override app if you need a FakeApplication with other than 18 | // default parameters. 19 | implicit override lazy val app: FakeApplication = 20 | FakeApplication( 21 | additionalConfiguration = Map("ehcacheplugin" -> "disabled"), 22 | withRoutes = { 23 | case ("GET", "/testing") => 24 | Action( 25 | Results.Ok( 26 | "" + 27 | "Test Page" + 28 | "" + 29 | "" + 30 | "" + 31 | "" 32 | ).as("text/html") 33 | ) 34 | } 35 | ) 36 | 37 | "The OneBrowserPerTest trait" must { 38 | "provide a web driver" in { 39 | go to (s"http://localhost:$port/testing") 40 | pageTitle mustBe "Test Page" 41 | click on find(name("b")).value 42 | eventually { pageTitle mustBe "scalatest" } 43 | } 44 | } 45 | } 46 | // #scalafunctionaltest-onebrowserpersuite 47 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/onebrowserpertest/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.onebrowserpertest 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.test.Helpers._ 10 | import play.api.libs.ws._ 11 | import play.api.mvc._ 12 | import Results._ 13 | 14 | // #scalafunctionaltest-onebrowserpertest 15 | class ExampleSpec extends PlaySpec with OneServerPerTest with OneBrowserPerTest with HtmlUnitFactory { 16 | 17 | // Override newAppForTest if you need a FakeApplication with other than 18 | // default parameters. 19 | override def newAppForTest(testData: TestData): FakeApplication = 20 | new FakeApplication( 21 | additionalConfiguration = Map("ehcacheplugin" -> "disabled"), 22 | withRoutes = { 23 | case ("GET", "/testing") => 24 | Action( 25 | Results.Ok( 26 | "" + 27 | "Test Page" + 28 | "" + 29 | "" + 30 | "" + 31 | "" 32 | ).as("text/html") 33 | ) 34 | } 35 | ) 36 | 37 | "The OneBrowserPerTest trait" must { 38 | "provide a web driver" in { 39 | go to (s"http://localhost:$port/testing") 40 | pageTitle mustBe "Test Page" 41 | click on find(name("b")).value 42 | eventually { pageTitle mustBe "scalatest" } 43 | } 44 | } 45 | } 46 | // #scalafunctionaltest-onebrowserpertest 47 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/oneserverpersuite/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.oneserverpersuite 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.test.Helpers._ 10 | import play.api.libs.ws._ 11 | import play.api.mvc._ 12 | import Results._ 13 | 14 | // #scalafunctionaltest-oneserverpersuite 15 | class ExampleSpec extends PlaySpec with OneServerPerSuite { 16 | 17 | // Override app if you need a FakeApplication with other than 18 | // default parameters. 19 | implicit override lazy val app: FakeApplication = 20 | FakeApplication( 21 | additionalConfiguration = Map("ehcacheplugin" -> "disabled"), 22 | withRoutes = { 23 | case ("GET", "/") => Action { Ok("ok") } 24 | } 25 | ) 26 | 27 | "test server logic" in { 28 | val myPublicAddress = s"localhost:$port" 29 | val testPaymentGatewayURL = s"http://$myPublicAddress" 30 | // The test payment gateway requires a callback to this server before it returns a result... 31 | val callbackURL = s"http://$myPublicAddress/callback" 32 | // await is from play.api.test.FutureAwaits 33 | val response = await(WS.url(testPaymentGatewayURL).withQueryString("callbackURL" -> callbackURL).get()) 34 | 35 | response.status mustBe (OK) 36 | } 37 | } 38 | // #scalafunctionaltest-oneserverpersuite 39 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code-scalatestplus-play/oneserverpertest/ExampleSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.scalatest.oneserverpertest 5 | 6 | import play.api.test._ 7 | import org.scalatest._ 8 | import org.scalatestplus.play._ 9 | import play.api.test.Helpers._ 10 | import play.api.libs.ws._ 11 | import play.api.mvc._ 12 | import Results._ 13 | 14 | // #scalafunctionaltest-oneserverpertest 15 | class ExampleSpec extends PlaySpec with OneServerPerTest { 16 | 17 | // Override newAppForTest if you need a FakeApplication with other than 18 | // default parameters. 19 | override def newAppForTest(testData: TestData): FakeApplication = 20 | new FakeApplication( 21 | additionalConfiguration = Map("ehcacheplugin" -> "disabled"), 22 | withRoutes = { 23 | case ("GET", "/") => Action { Ok("ok") } 24 | } 25 | ) 26 | 27 | "The OneServerPerTest trait" must { 28 | "test server logic" in { 29 | val myPublicAddress = s"localhost:$port" 30 | val testPaymentGatewayURL = s"http://$myPublicAddress" 31 | // The test payment gateway requires a callback to this server before it returns a result... 32 | val callbackURL = s"http://$myPublicAddress/callback" 33 | // await is from play.api.test.FutureAwaits 34 | val response = await(WS.url(testPaymentGatewayURL).withQueryString("callbackURL" -> callbackURL).get()) 35 | 36 | response.status mustBe (OK) 37 | } 38 | } 39 | } 40 | // #scalafunctionaltest-oneserverpertest 41 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests 5 | 6 | package controllers 7 | 8 | import play.api.mvc._ 9 | 10 | object Application extends Controller { 11 | def index() = Action { 12 | Ok("Hello Bob") as("text/plain") 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/models/User.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests 5 | 6 | package models 7 | 8 | // #scalatest-models 9 | case class Role(name:String) 10 | 11 | case class User(id: String, name: String, email:String) 12 | // #scalatest-models 13 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/scalaguide.tests.guice.routes: -------------------------------------------------------------------------------- 1 | GET / controllers.Application.index() 2 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/services/UserRepository.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests 5 | 6 | package services 7 | 8 | import models._ 9 | 10 | // #scalatest-repository 11 | trait UserRepository { 12 | def roles(user:User) : Set[Role] 13 | } 14 | // #scalatest-repository 15 | 16 | 17 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/services/UserService.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests 5 | 6 | package services 7 | 8 | import models._ 9 | 10 | // #scalatest-userservice 11 | class UserService(userRepository : UserRepository) { 12 | 13 | def isAdmin(user:User) : Boolean = { 14 | userRepository.roles(user).contains(Role("ADMIN")) 15 | } 16 | } 17 | // #scalatest-userservice 18 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/ExampleControllerSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.specs2 5 | 6 | // #scalatest-examplecontrollerspec 7 | import play.api.mvc._ 8 | import play.api.test._ 9 | import scala.concurrent.Future 10 | 11 | object ExampleControllerSpec extends PlaySpecification with Results { 12 | 13 | class TestController() extends Controller with ExampleController 14 | 15 | "Example Page#index" should { 16 | "should be valid" in { 17 | val controller = new TestController() 18 | val result: Future[Result] = controller.index().apply(FakeRequest()) 19 | val bodyText: String = contentAsString(result) 20 | bodyText must be equalTo "ok" 21 | } 22 | } 23 | } 24 | // #scalatest-examplecontrollerspec 25 | 26 | // #scalatest-examplecontroller 27 | trait ExampleController { 28 | this: Controller => 29 | 30 | def index() = Action { 31 | Ok("ok") 32 | } 33 | } 34 | 35 | object ExampleController extends Controller with ExampleController 36 | // #scalatest-examplecontroller 37 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/ExampleEssentialActionSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.specs2 5 | 6 | import play.api.mvc._ 7 | import play.api.test._ 8 | import play.api.mvc.Results._ 9 | import play.api.libs.json.Json 10 | 11 | // #scalatest-exampleessentialactionspec 12 | object ExampleEssentialActionSpec extends PlaySpecification { 13 | 14 | "An essential action" should { 15 | "can parse a JSON body" in { 16 | val action: EssentialAction = Action { request => 17 | val value = (request.body.asJson.get \ "field").as[String] 18 | Ok(value) 19 | } 20 | 21 | val request = FakeRequest(POST, "/").withJsonBody(Json.parse("""{ "field": "value" }""")) 22 | 23 | val result = call(action, request) 24 | 25 | status(result) mustEqual OK 26 | contentAsString(result) mustEqual "value" 27 | } 28 | } 29 | } 30 | // #scalatest-exampleessentialactionspec 31 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/ExampleMockitoSpec.scala: -------------------------------------------------------------------------------- 1 | package scalaguide.tests.specs2 2 | 3 | // #specs2-mockito 4 | import org.specs2.mock._ 5 | import org.specs2.mutable._ 6 | 7 | import java.util._ 8 | 9 | class ExampleMockitoSpec extends Specification with Mockito { 10 | 11 | "MyService#isDailyData" should { 12 | "return true if the data is from today" in { 13 | val mockDataService = mock[DataService] 14 | mockDataService.findData returns Data(retrievalDate = new java.util.Date()) 15 | 16 | val myService = new MyService() { 17 | override def dataService = mockDataService 18 | } 19 | 20 | val actual = myService.isDailyData 21 | actual must equalTo(true) 22 | } 23 | } 24 | 25 | } 26 | // #specs2-mockito 27 | 28 | // #specs2-mockito-dataservice 29 | trait DataService { 30 | def findData: Data 31 | } 32 | 33 | case class Data(retrievalDate: java.util.Date) 34 | // #specs2-mockito-dataservice 35 | 36 | class MyService { 37 | def dataService: DataService = null // implementation reference... 38 | 39 | def isDailyData: Boolean = { 40 | val retrievalDate = Calendar.getInstance 41 | retrievalDate.setTime(dataService.findData.retrievalDate) 42 | 43 | val today = Calendar.getInstance() 44 | 45 | (retrievalDate.get(Calendar.YEAR) == today.get(Calendar.YEAR) 46 | && retrievalDate.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) 47 | } 48 | } -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/ExamplePlaySpecificationSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.specs2 5 | 6 | import play.api.test._ 7 | 8 | // #scalafunctionaltest-playspecification 9 | object ExamplePlaySpecificationSpec extends PlaySpecification { 10 | "The specification" should { 11 | 12 | "have access to HeaderNames" in { 13 | USER_AGENT must be_===("User-Agent") 14 | } 15 | 16 | "have access to Status" in { 17 | OK must be_===(200) 18 | } 19 | } 20 | } 21 | // #scalafunctionaltest-playspecification 22 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/FunctionalExampleControllerSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.specs2 5 | 6 | import scalaguide.tests.controllers 7 | 8 | import play.api.test._ 9 | import play.api.test.Helpers._ 10 | 11 | object FunctionalExampleControllerSpec extends PlaySpecification { 12 | 13 | // #scalafunctionaltest-functionalexamplecontrollerspec 14 | "respond to the index Action" in { 15 | val result = controllers.Application.index()(FakeRequest()) 16 | 17 | status(result) must equalTo(OK) 18 | contentType(result) must beSome("text/plain") 19 | contentAsString(result) must contain("Hello Bob") 20 | } 21 | // #scalafunctionaltest-functionalexamplecontrollerspec 22 | } 23 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/FunctionalTemplateSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalatest.tests.specs2 5 | 6 | import org.specs2.mutable._ 7 | 8 | import play.api.mvc._ 9 | 10 | import play.api.test._ 11 | import play.api.test.Helpers._ 12 | 13 | object FunctionalTemplateSpec extends Specification { 14 | 15 | // #scalatest-functionaltemplatespec 16 | "render index template" in new WithApplication { 17 | val html = views.html.index("Coco") 18 | 19 | contentAsString(html) must contain("Hello Coco") 20 | } 21 | // #scalatest-functionaltemplatespec 22 | 23 | } 24 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/HelloWorldSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.specs2 5 | 6 | // #scalatest-helloworldspec 7 | import org.specs2.mutable._ 8 | 9 | class HelloWorldSpec extends Specification { 10 | 11 | "The 'Hello world' string" should { 12 | "contain 11 characters" in { 13 | "Hello world" must have size(11) 14 | } 15 | "start with 'Hello'" in { 16 | "Hello world" must startWith("Hello") 17 | } 18 | "end with 'world'" in { 19 | "Hello world" must endWith("world") 20 | } 21 | } 22 | } 23 | // #scalatest-helloworldspec 24 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/UserServiceSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.specs2 5 | 6 | import org.specs2.mock._ 7 | import org.specs2.mutable._ 8 | 9 | import scalaguide.tests.models._ 10 | import scalaguide.tests.services._ 11 | 12 | // #scalatest-userservicespec 13 | object UserServiceSpec extends Specification with Mockito { 14 | 15 | "UserService#isAdmin" should { 16 | "be true when the role is admin" in { 17 | val userRepository = mock[UserRepository] 18 | userRepository.roles(any[User]) returns Set(Role("ADMIN")) 19 | 20 | val userService = new UserService(userRepository) 21 | val actual = userService.isAdmin(User("11", "Steve", "user@example.org")) 22 | actual must beTrue 23 | } 24 | } 25 | } 26 | // #scalatest-userservicespec 27 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/specs2/WithDbDataSpec.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.specs2 5 | 6 | import play.api.test._ 7 | import play.api.test.Helpers._ 8 | 9 | import org.specs2.execute.{Result, AsResult} 10 | 11 | /** 12 | * 13 | */ 14 | class WithDbDataSpec extends PlaySpecification { 15 | 16 | // #scalafunctionaltest-withdbdata 17 | abstract class WithDbData extends WithApplication { 18 | override def around[T: AsResult](t: => T): Result = super.around { 19 | setupData() 20 | t 21 | } 22 | 23 | def setupData() { 24 | // setup data 25 | } 26 | } 27 | 28 | "Computer model" should { 29 | 30 | "be retrieved by id" in new WithDbData { 31 | // your test code 32 | } 33 | "be retrieved by email" in new WithDbData { 34 | // your test code 35 | } 36 | } 37 | // #scalafunctionaltest-withdbdata 38 | } 39 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/tests/guice/Component.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.guice 5 | 6 | // #component 7 | trait Component { 8 | def hello: String 9 | } 10 | 11 | class DefaultComponent extends Component { 12 | def hello = "default" 13 | } 14 | 15 | class MockComponent extends Component { 16 | def hello = "mock" 17 | } 18 | // #component 19 | 20 | // #component-module 21 | import play.api.{ Environment, Configuration } 22 | import play.api.inject.Module 23 | 24 | class ComponentModule extends Module { 25 | def bindings(env: Environment, conf: Configuration) = Seq( 26 | bind[Component].to[DefaultComponent] 27 | ) 28 | } 29 | // #component-module 30 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/tests/guice/controllers/Application.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package scalaguide.tests.guice 5 | package controllers 6 | 7 | // #controller 8 | import play.api.mvc._ 9 | import javax.inject.Inject 10 | 11 | class Application @Inject() (component: Component) extends Controller { 12 | def index() = Action { 13 | Ok(component.hello) 14 | } 15 | } 16 | // #controller 17 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/code/views/html/index.scala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2015 Typesafe Inc. 3 | */ 4 | package views.html 5 | 6 | import play.api.mvc._ 7 | 8 | import scala.concurrent.{ExecutionContext, Future} 9 | import ExecutionContext.Implicits.global 10 | 11 | object index extends Results { 12 | 13 | def apply(input:String) : Future[Result] = { 14 | Future( 15 | Ok("Hello Coco") as("text/html") 16 | ) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/tests/index.toc: -------------------------------------------------------------------------------- 1 | ScalaTestingYourApplication:アプリケーションのテスト 2 | ScalaTestingWithScalaTest:ScalaTest によるテスト 3 | ScalaFunctionalTestingWithScalaTest:ScalaTest による機能テスト 4 | ScalaTestingWithSpecs2:Specs2 によるテスト 5 | ScalaFunctionalTestingWithSpecs2:Specs2 による機能テスト 6 | ScalaTestingWithGuice:Guice によるテスト 7 | ScalaTestingWithDatabases:データベースを使ったテスト 8 | ScalaTestingWebServiceClients:web サービスクライアントのテスト 9 | -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/upload/code/scalaguide.upload.fileupload.routes: -------------------------------------------------------------------------------- 1 | GET / controllers.Application.index() 2 | 3 | # #application-upload-routes 4 | POST / controllers.Application.upload() 5 | # #application-upload-routes -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/upload/code/scalaguide/templates/views/uploadForm.scala.html: -------------------------------------------------------------------------------- 1 | @import scalaguide.upload.fileupload.controllers._ 2 | @* #file-upload-form *@ 3 | @helper.form(action = routes.Application.upload, 'enctype -> "multipart/form-data") { 4 | 5 | 6 | 7 |

8 | 9 |

10 | 11 | } 12 | @* #file-upload-form *@ -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/upload/index.toc: -------------------------------------------------------------------------------- 1 | ScalaFileUpload:multipart/form-data のアップロード -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/ws/index.toc: -------------------------------------------------------------------------------- 1 | ScalaWS:The Play WS API 2 | ScalaOpenID:OpenID サーバへの接続 3 | ScalaOAuth:OAuth によリ保護されたデータへのアクセス -------------------------------------------------------------------------------- /manual/working/scalaGuide/main/xml/index.toc: -------------------------------------------------------------------------------- 1 | ScalaXmlRequests:XML リクエストの処理と送信 -------------------------------------------------------------------------------- /project/build.properties: -------------------------------------------------------------------------------- 1 | sbt.version=0.13.5 2 | -------------------------------------------------------------------------------- /project/plugins.sbt: -------------------------------------------------------------------------------- 1 | addSbtPlugin("com.typesafe.play" % "play-docs-sbt-plugin" % "2.4.0") --------------------------------------------------------------------------------