Permalink
Browse files

init code.

  • Loading branch information...
arden committed Apr 10, 2011
0 parents commit 9fdc3265906fbdf349856dcceb9bcc4c0f061e1c
@@ -0,0 +1,2 @@
+
+/.idea
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+ <component name="FacetManager">
+ <facet type="Python" name="Python">
+ <configuration sdkName="" />
+ </facet>
+ </component>
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
+ <exclude-output />
+ <content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+ </content>
+ <orderEntry type="inheritedJdk" />
+ <orderEntry type="sourceFolder" forTests="false" />
+ <orderEntry type="library" name="Play-1.2" level="project" />
+ </component>
+</module>
+
@@ -0,0 +1 @@
+play.path=D:\play-1.2RC2
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<project name="play-loader" default="build" basedir=".">
+ <property file="build.properties" />
+ <target name="check" unless="play.path">
+ <fail message="Please specify Play framework path using -Dplay.path=/path/to/framework/home" />
+ </target>
+
+ <path id="project.classpath">
+ <pathelement path="${play.path}/framework/classes"/>
+ <fileset dir="${play.path}/framework/lib">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${play.path}/framework">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="lib">
+ <include name="*.jar"/>
+ </fileset>
+ </path>
+
+ <target name="build" depends="compile">
+ <mkdir dir="lib" />
+ <copy todir="tmp/classes">
+ <fileset dir="src">
+ <include name="**/*.properties"/>
+ <include name="**/*.xml"/>
+ <include name="**/play.plugins"/>
+ <include name="**/play.static"/>
+ </fileset>
+ </copy>
+ <jar destfile="lib/play-loader.jar" basedir="tmp/classes">
+ <manifest>
+ <section name="Play-module">
+ <attribute name="Specification-Title" value="play-loader"/>
+ </section>
+ </manifest>
+ </jar>
+ <delete dir="tmp" />
+ </target>
+
+ <target name="compile" depends="check">
+ <mkdir dir="tmp/classes" />
+ <javac srcdir="src" destdir="tmp/classes" target="1.5" debug="true">
+ <classpath refid="project.classpath" />
+ </javac>
+ </target>
+
+</project>
@@ -0,0 +1,35 @@
+# Here you can create play commands that are specific to the module, and extend existing commands
+
+MODULE = 'play-loader'
+
+# Commands that are specific to your module
+
+COMMANDS = ['play-loader:hello']
+
+def execute(**kargs):
+ command = kargs.get("command")
+ app = kargs.get("app")
+ args = kargs.get("args")
+ env = kargs.get("env")
+
+ if command == "play-loader:hello":
+ print "~ Hello"
+
+
+# This will be executed before any command (new, run...)
+def before(**kargs):
+ command = kargs.get("command")
+ app = kargs.get("app")
+ args = kargs.get("args")
+ env = kargs.get("env")
+
+
+# This will be executed after any command (new, run...)
+def after(**kargs):
+ command = kargs.get("command")
+ app = kargs.get("app")
+ args = kargs.get("args")
+ env = kargs.get("env")
+
+ if command == "new":
+ pass
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
+1000:play.modules.loader.LoaderPlugin
@@ -0,0 +1,29 @@
+package play.modules.loader;
+
+import play.Logger;
+import play.Play;
+import play.PlayPlugin;
+import play.vfs.VirtualFile;
+
+/**
+ * 让Play加载自定义的java类文件
+ *
+ * @author arden
+ */
+public class LoaderPlugin extends PlayPlugin {
+
+ public void onLoad() {
+ String pattern = (String) Play.configuration.get("loader.path");
+ if (pattern != null) {
+ VirtualFile appRoot = VirtualFile.open(Play.applicationPath);
+ String[] paths = pattern.split(",");
+ if (paths != null) {
+ for (int i = 0; i < paths.length; i++) {
+ Play.javaPath.add(appRoot.child(paths[i]));
+ }
+ }
+ } else {
+ Logger.info("Missing configuration 'loader.path', loader will be ignored!");
+ }
+ }
+}

0 comments on commit 9fdc326

Please sign in to comment.