Browse Source

prepare jfinal-1.8

James 11 years ago
parent
commit
38a44fc654

+ 8 - 4
.classpath

@@ -1,12 +1,16 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src"/>
-	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
-	<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
 		<attributes>
-			<attribute name="owner.project.facets" value="java"/>
+			<attribute name="maven.pomderived" value="true"/>
 		</attributes>
 	</classpathentry>
-	<classpathentry kind="output" path="WebRoot/WEB-INF/classes"/>
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+		<attributes>
+			<attribute name="maven.pomderived" value="true"/>
+			<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
+		</attributes>
+	</classpathentry>
+	<classpathentry kind="output" path="webapp/WEB-INF/classes"/>
 </classpath>

+ 3 - 1
.gitignore

@@ -13,4 +13,6 @@ build
 *.iws
 out
 
-*.jar
+*.jar
+/webapp/WEB-INF/classes
+/webapp/WEB-INF/target

+ 7 - 1
.project

@@ -21,6 +21,11 @@
 			</arguments>
 		</buildCommand>
 		<buildCommand>
+			<name>org.eclipse.m2e.core.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
 			<name>org.eclipse.wst.validation.validationbuilder</name>
 			<arguments>
 			</arguments>
@@ -29,8 +34,9 @@
 	<natures>
 		<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
 		<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
-		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
 		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.eclipse.m2e.core.maven2Nature</nature>
+		<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
 		<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
 	</natures>
 </projectDescription>

+ 2 - 1
.settings/.jsdtscope

@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
-	<classpathentry kind="src" path="WebRoot"/>
+	<classpathentry kind="src" path="webapp"/>
+	<classpathentry kind="src" path="webapp/WEB-INF/target/m2e-wtp/web-resources"/>
 	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
 		<attributes>

+ 0 - 1
.settings/org.eclipse.core.resources.prefs

@@ -1,3 +1,2 @@
-#Tue Sep 11 23:24:31 CST 2012
 eclipse.preferences.version=1
 encoding/<project>=UTF-8

+ 5 - 1
.settings/org.eclipse.jdt.core.prefs

@@ -1,8 +1,12 @@
-#Tue Sep 11 23:24:18 CST 2012
 eclipse.preferences.version=1
 org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
 org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
 org.eclipse.jdt.core.compiler.source=1.6

+ 4 - 0
.settings/org.eclipse.m2e.core.prefs

@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1

+ 3 - 2
.settings/org.eclipse.wst.common.component

@@ -1,9 +1,10 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project-modules id="moduleCoreId" project-version="1.5.0">
     <wb-module deploy-name="jfinal">
-        <wb-resource deploy-path="/" source-path="/WebRoot" tag="defaultRootSource"/>
+        <wb-resource deploy-path="/" source-path="/webapp/WEB-INF/target/m2e-wtp/web-resources"/>
+        <wb-resource deploy-path="/" source-path="/webapp" tag="defaultRootSource"/>
         <wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
         <property name="context-root" value="jfinal"/>
-        <property name="java-output-path" value="/jfinal/WebRoot/WEB-INF/classes"/>
+        <property name="java-output-path" value="/jfinal/webapp/WEB-INF/classes"/>
     </wb-module>
 </project-modules>

+ 0 - 2
.settings/org.eclipse.wst.common.project.facet.core.xml

@@ -1,7 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <faceted-project>
-  <fixed facet="jst.web"/>
-  <fixed facet="java"/>
   <fixed facet="wst.jsdt.web"/>
   <installed facet="jst.web" version="2.5"/>
   <installed facet="wst.jsdt.web" version="1.0"/>

+ 2 - 0
.settings/org.eclipse.wst.validation.prefs

@@ -0,0 +1,2 @@
+disabled=06target
+eclipse.preferences.version=1

+ 93 - 93
README.rst

@@ -1,93 +1,93 @@
-===========================
-JAVA 极速WEB+ORM框架 JFinal
-===========================
-
-    JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。在拥有Java语言所有优势的同时再拥有ruby、python等动态语言的开发效率!为您节约更多时间,去陪恋人、家人和朋友 ;)
-
-JFinal有如下主要特点
-------------------------
-#. MVC架构,设计精巧,使用简单
-#. 遵循COC原则,零配置,无xml
-#. 独创Db + Record模式,灵活便利
-#. ActiveRecord支持,使数据库开发极致快速
-#. 自动加载修改后的java文件,开发过程中无需重启web server
-#. AOP支持,拦截器配置灵活,功能强大
-#. Plugin体系结构,扩展性强
-#. 多视图支持,支持FreeMarker、JSP、Velocity
-#. 强大的Validator后端校验功能
-#. 功能齐全,拥有struts2的绝大部分功能
-#. 体积小仅218K,且无第三方依赖
-
-**JFinal 极速开发QQ群欢迎您的加入: 222478625、326297041、196337924**
-
-**以下是JFinal实现Blog管理的示例:**
-
-**1. 控制器(支持FreeMarker、JSP、Velocity、JSON等等以及自定义视图渲染)**
-
-:: 
- 
-    @Before(BlogInterceptor.class)
-    public class BlogController extends Controller {
-        public void index() {
-            setAttr("blogList", Blog.dao.find("select * from blog"));
-        }
-        public void add() {
-        }
-	
-        @Before(BlogValidator.class)
-        public void save() {
-            getModel(Blog.class).save();
-        }
-	
-        public void edit() {
-            setAttr("blog", Blog.dao.findById(getParaToInt()));
-        }
-	
-        @Before(BlogValidator.class)
-        public void update() {
-            getModel(Blog.class).update();
-        }
-	
-        public void delete() {
-            Blog.dao.deleteById(getParaToInt());
-        }
-    }
-
-**2.Model(无xml、无annotaion、无attribute、无getter、无setter、new
-Blog()这行代码也不是必须)**
-:: 
-  
-     public class Blog extends Model {
-           public static final Blog dao = new Blog();
-     }
-
-**3.Validator(API引导式校验,比xml校验方便N倍,有代码检查不易出错)**
-
-::
-
-    public class BlogValidator extends Validator {
-        protected void validate(Controller controller) {
-            validateRequiredString("blog.title", "titleMsg", "请输入Blog标题!");
-            validateRequiredString("blog.content", "contentMsg", "请输入Blog内容!");
-        }
-	
-        protected void handleError(Controller controller) {
-            controller.keepModel(Blog.class);
-        }
-    }
-
-**4.拦截器(在此demo中仅为示例,本demo不需要此拦截器)**
-
-::
-   
-    public class BlogInterceptor implements Interceptor {
-        public void intercept(ActionInvocation ai) {
-            System.out.println("Before invoking " + ai.getActionKey());
-            ai.invoke();
-            System.out.println("After invoking " + ai.getActionKey());
-        }
-    }
-
-
-
-**JFinal 官方网站:http://www.jfinal.com**
+===========================
+JAVA 极速WEB+ORM框架 JFinal
+===========================
+
+    JFinal 是基于 Java 语言的极速 WEB + ORM 框架,其核心设计目标是开发迅速、代码量少、学习简单、功能强大、轻量级、易扩展、Restful。在拥有Java语言所有优势的同时再拥有ruby、python等动态语言的开发效率!为您节约更多时间,去陪恋人、家人和朋友 ;)
+
+JFinal有如下主要特点
+------------------------
+#. MVC架构,设计精巧,使用简单
+#. 遵循COC原则,零配置,无xml
+#. 独创Db + Record模式,灵活便利
+#. ActiveRecord支持,使数据库开发极致快速
+#. 自动加载修改后的java文件,开发过程中无需重启web server
+#. AOP支持,拦截器配置灵活,功能强大
+#. Plugin体系结构,扩展性强
+#. 多视图支持,支持FreeMarker、JSP、Velocity
+#. 强大的Validator后端校验功能
+#. 功能齐全,拥有struts2的绝大部分功能
+#. 体积小仅218K,且无第三方依赖
+
+**JFinal 极速开发QQ群欢迎您的加入: 222478625、326297041、196337924**
+
+**以下是JFinal实现Blog管理的示例:**
+
+**1. 控制器(支持FreeMarker、JSP、Velocity、JSON等等以及自定义视图渲染)**
+
+:: 
+ 
+    @Before(BlogInterceptor.class)
+    public class BlogController extends Controller {
+        public void index() {
+            setAttr("blogList", Blog.dao.find("select * from blog"));
+        }
+        public void add() {
+        }
+	
+        @Before(BlogValidator.class)
+        public void save() {
+            getModel(Blog.class).save();
+        }
+	
+        public void edit() {
+            setAttr("blog", Blog.dao.findById(getParaToInt()));
+        }
+	
+        @Before(BlogValidator.class)
+        public void update() {
+            getModel(Blog.class).update();
+        }
+	
+        public void delete() {
+            Blog.dao.deleteById(getParaToInt());
+        }
+    }
+
+**2.Model(无xml、无annotaion、无attribute、无getter、无setter、new
+Blog()这行代码也不是必须)**
+:: 
+  
+     public class Blog extends Model {
+           public static final Blog dao = new Blog();
+     }
+
+**3.Validator(API引导式校验,比xml校验方便N倍,有代码检查不易出错)**
+
+::
+
+    public class BlogValidator extends Validator {
+        protected void validate(Controller controller) {
+            validateRequiredString("blog.title", "titleMsg", "请输入Blog标题!");
+            validateRequiredString("blog.content", "contentMsg", "请输入Blog内容!");
+        }
+	
+        protected void handleError(Controller controller) {
+            controller.keepModel(Blog.class);
+        }
+    }
+
+**4.拦截器(在此demo中仅为示例,本demo不需要此拦截器)**
+
+::
+   
+    public class BlogInterceptor implements Interceptor {
+        public void intercept(ActionInvocation ai) {
+            System.out.println("Before invoking " + ai.getActionKey());
+            ai.invoke();
+            System.out.println("After invoking " + ai.getActionKey());
+        }
+    }
+
+
+
+**JFinal 官方网站:http://www.jfinal.com**

+ 0 - 11
WebRoot/WEB-INF/classes/com/jfinal/server/Run_Configurations.txt

@@ -1,11 +0,0 @@
-Run Configurations... / Debug Configurations...
-
-1: Main
-    project(required) ---> your_project_name
-    Main class(required) ---> com.jfinal.core.JFinal
-
-2: Argument
-    Program arguments(optional) ---> WebRoot 80 / 5
-    VM arguments(optional) ---> -XX:PermSize=64M -XX:MaxPermSize=256M
-
-

+ 8 - 1
pom.xml

@@ -4,7 +4,7 @@
 	<artifactId>jfinal</artifactId>
 	<packaging>jar</packaging>
 	<name>JFinal</name>
-	<version>1.6-SNAPSHOT</version>
+	<version>1.8-SNAPSHOT</version>
 	<url>http://jfinal.googlecode.com</url>
 	<description>JFinal is a simple, light, rapid,independent, extensible Java WEB + ORM framework. The feature of JFinal looks like ruby on rails especially ActiveRecord.</description>
 	
@@ -143,6 +143,9 @@
 				</excludes>
 			</testResource>
 		</testResources>
+		<!-- directory>${project.basedir}/target</directory -->
+	    <directory>${project.basedir}/webapp/WEB-INF/target</directory><!-- vi -->
+		
 		<plugins>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
@@ -157,6 +160,7 @@
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
 				<artifactId>maven-gpg-plugin</artifactId>
+				<version>1.1</version>
 				<executions>
 				  <execution>
 					<id>sign-artifacts</id>
@@ -166,6 +170,9 @@
 					</goals>
 				  </execution>
 				</executions>
+				<configuration>
+					<skip>false</skip>
+				</configuration>
 			</plugin>
 
 		</plugins>

+ 1 - 0
src/com/jfinal/core/ActionReporter.java

@@ -48,6 +48,7 @@ final class ActionReporter {
 		doReport(controller, action);
 	}
 	
+	@SuppressWarnings("unchecked")
 	private static final void doReport(Controller controller, Action action) {
 		StringBuilder sb = new StringBuilder("\nJFinal action report -------- ").append(sdf.format(new Date())).append(" ------------------------------\n");
 		Class<? extends Controller> cc = action.getControllerClass();

+ 3 - 2
src/com/jfinal/core/ModelInjector.java

@@ -31,9 +31,10 @@ import com.jfinal.plugin.activerecord.TableMapping;
  */
 final class ModelInjector {
 	
+	@SuppressWarnings("unchecked")
 	public static <T> T inject(Class<?> modelClass, HttpServletRequest request, boolean skipConvertError) {
 		String modelName = modelClass.getSimpleName();
-		return inject(modelClass, StringKit.firstCharToLowerCase(modelName), request, skipConvertError);
+		return (T)inject(modelClass, StringKit.firstCharToLowerCase(modelName), request, skipConvertError);
 	}
 	
 	@SuppressWarnings({ "rawtypes", "unchecked" })
@@ -77,7 +78,7 @@ final class ModelInjector {
 		}
 	}
 	
-	@SuppressWarnings("rawtypes")
+	@SuppressWarnings({"rawtypes", "unchecked"})
 	private static final void injectActiveRecordModel(Model<?> model, String modelName, HttpServletRequest request, boolean skipConvertError) {
 		Table table = TableMapping.me().getTable(model.getClass());
 		

+ 1 - 1
src/com/jfinal/ext/interceptor/Restful.java

@@ -40,7 +40,7 @@ import com.jfinal.core.Controller;
  * POST		/user			--->	save	
  * GET		/user/edit/id	--->	edit
  * PUT		/user/id		--->	update
- * DELECT	/user/id		--->	delete
+ * DELETE	/user/id		--->	delete
  */
 public class Restful implements Interceptor {
 	

+ 0 - 1
src/com/jfinal/ext/interceptor/SessionInViewInterceptor.java

@@ -69,7 +69,6 @@ class JFinalSession extends HashMap implements HttpSession {
 		return session.getAttribute(key);
 	}
 	
-	@SuppressWarnings("unchecked")
 	public Enumeration getAttributeNames() {
 		return session.getAttributeNames();
 	}

+ 1 - 1
src/com/jfinal/plugin/activerecord/Db.java

@@ -122,7 +122,7 @@ public class Db {
 	}
 	
 	public static <T> T queryColumn(String sql) {
-		return queryColumn(sql, NULL_PARA_ARRAY);
+		return (T)queryColumn(sql, NULL_PARA_ARRAY);
 	}
 	
 	public static String queryStr(String sql, Object... paras) {

+ 15 - 8
src/com/jfinal/plugin/activerecord/Model.java

@@ -23,8 +23,6 @@ import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
@@ -359,8 +357,7 @@ public abstract class Model<M extends Model> implements Serializable {
 	 */
 	public boolean delete() {
 		Table table = getTable();
-		String pKey = table.getPrimaryKey();
-		Object id = attrs.get(pKey);
+		Object id = attrs.get(table.getPrimaryKey());
 		if (id == null)
 			throw new ActiveRecordException("You can't delete model without id.");
 		return deleteById(table, id);
@@ -378,8 +375,17 @@ public abstract class Model<M extends Model> implements Serializable {
 	}
 	
 	private boolean deleteById(Table table, Object id) {
-		String sql = getConfig().dialect.forModelDeleteById(table);
-		return Db.update(sql, id) >= 1;
+		Config config = getConfig();
+		Connection conn = null;
+		try {
+			conn = config.getConnection();
+			String sql = config.dialect.forModelDeleteById(table);
+			return Db.update(config, conn, sql, id) >= 1;
+		} catch (Exception e) {
+			throw new ActiveRecordException(e);
+		} finally {
+			config.close(conn);
+		}
 	}
 	
 	/**
@@ -581,8 +587,9 @@ public abstract class Model<M extends Model> implements Serializable {
 	 */
 	public M keep(String... attrs) {
 		if (attrs != null && attrs.length > 0) {
-			Map<String, Object> newAttrs = new HashMap<String, Object>(attrs.length);
-			Set<String> newModifyFlag = new HashSet<String>();
+			Config config = getConfig();
+			Map<String, Object> newAttrs = config.containerFactory.getAttrsMap();	// new HashMap<String, Object>(attrs.length);
+			Set<String> newModifyFlag = config.containerFactory.getModifyFlagSet();	// new HashSet<String>();
 			for (String a : attrs) {
 				if (this.attrs.containsKey(a))	// prevent put null value to the newColumns
 					newAttrs.put(a, this.attrs.get(a));

+ 2 - 2
src/com/jfinal/plugin/activerecord/Record.java

@@ -17,7 +17,6 @@
 package com.jfinal.plugin.activerecord;
 
 import java.io.Serializable;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 import java.util.Map.Entry;
@@ -142,9 +141,10 @@ public class Record implements Serializable {
 	 * Keep columns of this record and remove other columns.
 	 * @param columns the column names of the record
 	 */
+	@SuppressWarnings("unchecked")
 	public Record keep(String... columns) {
 		if (columns != null && columns.length > 0) {
-			Map<String, Object> newColumns = new HashMap<String, Object>(columns.length);
+			Map<String, Object> newColumns = getConfig().containerFactory.getColumnsMap();	// new HashMap<String, Object>(columns.length);
 			for (String c : columns)
 				if (this.columns.containsKey(c))	// prevent put null value to the newColumns
 					newColumns.put(c, this.columns.get(c));

+ 1 - 0
src/com/jfinal/plugin/ehcache/CacheInterceptor.java

@@ -94,6 +94,7 @@ public class CacheInterceptor implements Interceptor {
 		return sb.toString();
 	}
 	
+	@SuppressWarnings("unchecked")
 	private void cacheAction(String cacheName, String cacheKey, Controller controller) {
 		HttpServletRequest request = controller.getRequest();
 		Map<String, Object> cacheData = new HashMap<String, Object>();

+ 1 - 0
src/com/jfinal/render/VelocityRender.java

@@ -74,6 +74,7 @@ public class VelocityRender extends Render {
 		}
 	}
 	
+	@SuppressWarnings("unchecked")
 	public void render() {
 		 if (notInit) {
 			 Velocity.init(properties);	// Velocity.init("velocity.properties");	// setup

WebRoot/META-INF/MANIFEST.MF → webapp/META-INF/MANIFEST.MF


+ 2 - 0
webapp/WEB-INF/.gitignore

@@ -0,0 +1,2 @@
+classes
+target

WebRoot/WEB-INF/lib/1_lib_description.txt → webapp/WEB-INF/lib/1_lib_description.txt


WebRoot/WEB-INF/web.xml → webapp/WEB-INF/web.xml


WebRoot/favicon.ico → webapp/favicon.ico