From 137612dba32d97d913d0094e18546eba9135f7fb Mon Sep 17 00:00:00 2001 From: Erwan Loisant Date: Mon, 14 Mar 2011 10:45:23 +0100 Subject: [PATCH] Code cleanup --- framework/src/play/cache/MemcachedImpl.java | 2 +- .../play/classloading/ApplicationClasses.java | 1 - .../classloading/ApplicationClassloader.java | 2 -- framework/src/play/data/binding/Binder.java | 1 - framework/src/play/data/binding/Unbinder.java | 1 - .../src/play/data/validation/Validation.java | 1 - framework/src/play/db/DBPlugin.java | 1 - framework/src/play/db/Model.java | 1 - framework/src/play/db/jpa/Blob.java | 10 ++++------ framework/src/play/i18n/Messages.java | 1 - framework/src/play/libs/Time.java | 19 ++++++++----------- framework/src/play/mvc/ActionInvoker.java | 2 -- framework/src/play/mvc/Router.java | 1 - .../ConfigurablePluginDisablingPlugin.java | 1 + framework/src/play/server/PlayHandler.java | 1 - framework/src/play/server/ServletWrapper.java | 1 - .../templates/GroovyTemplateCompiler.java | 1 - .../src/play/templates/TemplateLoader.java | 1 - framework/src/play/test/Fixtures.java | 1 - framework/src/play/test/TestEngine.java | 1 - 20 files changed, 14 insertions(+), 36 deletions(-) diff --git a/framework/src/play/cache/MemcachedImpl.java b/framework/src/play/cache/MemcachedImpl.java index c0aa2af931..593e49d9f5 100644 --- a/framework/src/play/cache/MemcachedImpl.java +++ b/framework/src/play/cache/MemcachedImpl.java @@ -38,7 +38,7 @@ public static MemcachedImpl getInstance(boolean forceClientInit) throws IOExcept } else if (forceClientInit) { // When you stop the client, it sets the interrupted state of this thread to true. If you try to reinit it with the same thread in this state, // Memcached client errors out. So a simple call to interrupted() will reset this flag - Thread.currentThread().interrupted(); + Thread.interrupted(); uniqueInstance.initClient(); } return uniqueInstance; diff --git a/framework/src/play/classloading/ApplicationClasses.java b/framework/src/play/classloading/ApplicationClasses.java index 96755c703f..55e1a4a4e8 100644 --- a/framework/src/play/classloading/ApplicationClasses.java +++ b/framework/src/play/classloading/ApplicationClasses.java @@ -9,7 +9,6 @@ import java.util.Map; import play.Logger; import play.Play; -import play.PlayPlugin; import play.exceptions.UnexpectedException; import play.vfs.VirtualFile; diff --git a/framework/src/play/classloading/ApplicationClassloader.java b/framework/src/play/classloading/ApplicationClassloader.java index 732e0f0ddc..c074c18f34 100644 --- a/framework/src/play/classloading/ApplicationClassloader.java +++ b/framework/src/play/classloading/ApplicationClassloader.java @@ -24,10 +24,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.log4j.PatternLayout; import play.Logger; import play.Play; -import play.PlayPlugin; import play.vfs.VirtualFile; import play.cache.Cache; import play.classloading.ApplicationClasses.ApplicationClass; diff --git a/framework/src/play/data/binding/Binder.java b/framework/src/play/data/binding/Binder.java index e1d2163c77..a81b23e1d9 100644 --- a/framework/src/play/data/binding/Binder.java +++ b/framework/src/play/data/binding/Binder.java @@ -15,7 +15,6 @@ import play.Logger; import play.Play; -import play.PlayPlugin; import play.data.Upload; import play.data.binding.types.*; import play.data.validation.Validation; diff --git a/framework/src/play/data/binding/Unbinder.java b/framework/src/play/data/binding/Unbinder.java index 7425660e5c..649cead5fd 100644 --- a/framework/src/play/data/binding/Unbinder.java +++ b/framework/src/play/data/binding/Unbinder.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Map; import play.Play; -import play.PlayPlugin; import play.data.binding.types.DateBinder; /** diff --git a/framework/src/play/data/validation/Validation.java b/framework/src/play/data/validation/Validation.java index ba5eb0263b..a91bffd5f5 100644 --- a/framework/src/play/data/validation/Validation.java +++ b/framework/src/play/data/validation/Validation.java @@ -11,7 +11,6 @@ import java.util.regex.Pattern; import net.sf.oval.configuration.annotation.AbstractAnnotationCheck; import play.Play; -import play.PlayPlugin; import play.classloading.enhancers.LocalvariablesNamesEnhancer.LocalVariablesNamesTracer; import play.exceptions.UnexpectedException; diff --git a/framework/src/play/db/DBPlugin.java b/framework/src/play/db/DBPlugin.java index bb81624816..9f3350e389 100644 --- a/framework/src/play/db/DBPlugin.java +++ b/framework/src/play/db/DBPlugin.java @@ -3,7 +3,6 @@ import com.mchange.v2.c3p0.ComboPooledDataSource; import java.io.File; -import java.io.FileInputStream; import java.io.PrintWriter; import java.io.StringWriter; import java.sql.Connection; diff --git a/framework/src/play/db/Model.java b/framework/src/play/db/Model.java index 4d6434e87a..26320ae5f6 100644 --- a/framework/src/play/db/Model.java +++ b/framework/src/play/db/Model.java @@ -4,7 +4,6 @@ import java.lang.reflect.Field; import java.util.List; import play.Play; -import play.PlayPlugin; import play.exceptions.UnexpectedException; public interface Model { diff --git a/framework/src/play/db/jpa/Blob.java b/framework/src/play/db/jpa/Blob.java index bf43b773e2..3e0f28e76f 100644 --- a/framework/src/play/db/jpa/Blob.java +++ b/framework/src/play/db/jpa/Blob.java @@ -8,9 +8,11 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Types; -import org.hibernate.Hibernate; + import org.hibernate.HibernateException; +import org.hibernate.type.StringType; import org.hibernate.usertype.UserType; + import play.Play; import play.db.Model.BinaryField; import play.exceptions.UnexpectedException; @@ -84,12 +86,8 @@ public int hashCode(Object o) throws HibernateException { return o.hashCode(); } - // TODO: After we switch to Hibernate 3.6, Hibernate.STRING must be changed to - // Hibernate.StringType.INSTANCE (how stupid is that to deprecate stuff before offering - // an alternative? - @SuppressWarnings("deprecation") public Object nullSafeGet(ResultSet rs, String[] names, Object o) throws HibernateException, SQLException { - String val = (String) Hibernate.STRING.nullSafeGet(rs, names[0]); + String val = (String) StringType.INSTANCE.nullSafeGet(rs, names[0]); if(val == null || val.length() == 0 || !val.contains("|")) { return new Blob(); } diff --git a/framework/src/play/i18n/Messages.java b/framework/src/play/i18n/Messages.java index 382aa0729e..db3cf7cbfd 100644 --- a/framework/src/play/i18n/Messages.java +++ b/framework/src/play/i18n/Messages.java @@ -9,7 +9,6 @@ import java.util.regex.Pattern; import play.Play; -import play.PlayPlugin; import play.data.binding.Binder; /** diff --git a/framework/src/play/libs/Time.java b/framework/src/play/libs/Time.java index f823683055..f63fe84a55 100644 --- a/framework/src/play/libs/Time.java +++ b/framework/src/play/libs/Time.java @@ -15,6 +15,8 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.lang.NotImplementedException; + /** * Time utils */ @@ -196,7 +198,7 @@ public static Date parseCRONExpression(String cron) { * month". *

* The '#' character is allowed for the day-of-week field. This character is - * used to specify "the nth" XXX day of the month. For example, the + * used to specify "the nth" xxx day of the month. For example, the * value of "6#3" in the day-of-week field means the third Friday of * the month (day 6 = Friday and "#3" = the 3rd one in the month). * Other examples: "2#1" = the first Monday of the month and @@ -356,8 +358,6 @@ public Date getNextInvalidTimeAfter(Date date) { Date newDate = null; - //TODO: (QUARTZ-481) IMPROVE THIS! The following is a BAD solution to this problem. Performance will be very bad here, depending on the cron expression. It is, however A solution. - //keep getting the next included time until it's farther than one second // apart. At that point, lastDate is the last valid fire time. We return // the second immediately following it. @@ -1256,8 +1256,8 @@ protected Date getTimeAfter(Date afterTime) { continue; } } else if (dayOfWSpec && !dayOfMSpec) { // get day by day of week rule - if (lastdayOfWeek) { // are we looking for the last XXX day of - // the month? + if (lastdayOfWeek) { + // are we looking for the last day of the month? int dow = daysOfWeek.first().intValue(); // desired // d-o-w int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w @@ -1300,7 +1300,7 @@ protected Date getTimeAfter(Date afterTime) { } } else if (nthdayOfWeek != 0) { - // are we looking for the Nth XXX day in the month? + // are we looking for the Nth day in the month? int dow = daysOfWeek.first().intValue(); // desired // d-o-w int cDow = cl.get(Calendar.DAY_OF_WEEK); // current d-o-w @@ -1383,7 +1383,6 @@ protected Date getTimeAfter(Date afterTime) { } else { // dayOfWSpec && !dayOfMSpec throw new UnsupportedOperationException( "Support for specifying both a day-of-week AND a day-of-month parameter is not implemented."); - // TODO: } cl.set(Calendar.DAY_OF_MONTH, day); @@ -1473,8 +1472,7 @@ protected void setCalendarHour(Calendar cal, int hour) { * that the CronExpression matches. */ protected Date getTimeBefore(Date endTime) { - // TODO: implement QUARTZ-423 - return null; + throw new NotImplementedException(); } /** @@ -1482,8 +1480,7 @@ protected Date getTimeBefore(Date endTime) { * CronExpression will match. */ public Date getFinalFireTime() { - // TODO: implement QUARTZ-423 - return null; + throw new NotImplementedException(); } protected boolean isLeapYear(int year) { diff --git a/framework/src/play/mvc/ActionInvoker.java b/framework/src/play/mvc/ActionInvoker.java index 8fa3edb68d..455a9318ef 100644 --- a/framework/src/play/mvc/ActionInvoker.java +++ b/framework/src/play/mvc/ActionInvoker.java @@ -14,10 +14,8 @@ import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.apache.log4j.PatternLayout; import play.Logger; import play.Play; -import play.PlayPlugin; import play.cache.CacheFor; import play.classloading.enhancers.ControllersEnhancer.ControllerInstrumentation; import play.classloading.enhancers.ControllersEnhancer.ControllerSupport; diff --git a/framework/src/play/mvc/Router.java b/framework/src/play/mvc/Router.java index d07c06ff37..3f1da805b4 100644 --- a/framework/src/play/mvc/Router.java +++ b/framework/src/play/mvc/Router.java @@ -17,7 +17,6 @@ import play.Logger; import play.Play; import play.Play.Mode; -import play.PlayPlugin; import play.vfs.VirtualFile; import play.exceptions.NoRouteFoundException; import play.exceptions.UnexpectedException; diff --git a/framework/src/play/plugins/ConfigurablePluginDisablingPlugin.java b/framework/src/play/plugins/ConfigurablePluginDisablingPlugin.java index 5489a5a24b..bb8578cf2e 100644 --- a/framework/src/play/plugins/ConfigurablePluginDisablingPlugin.java +++ b/framework/src/play/plugins/ConfigurablePluginDisablingPlugin.java @@ -89,6 +89,7 @@ public void onConfigurationRead() { } + @SuppressWarnings("unchecked") private Class resolveClass(String pluginClassName) { try{ return (Class)getClass().getClassLoader().loadClass(pluginClassName); diff --git a/framework/src/play/server/PlayHandler.java b/framework/src/play/server/PlayHandler.java index b0b9670c06..ed76c5b0fe 100644 --- a/framework/src/play/server/PlayHandler.java +++ b/framework/src/play/server/PlayHandler.java @@ -48,7 +48,6 @@ import play.Invoker.InvocationContext; import play.Logger; import play.Play; -import play.PlayPlugin; import play.exceptions.PlayException; import play.exceptions.UnexpectedException; import play.i18n.Messages; diff --git a/framework/src/play/server/ServletWrapper.java b/framework/src/play/server/ServletWrapper.java index ce85750ece..0b16c2be54 100644 --- a/framework/src/play/server/ServletWrapper.java +++ b/framework/src/play/server/ServletWrapper.java @@ -5,7 +5,6 @@ import play.Invoker.InvocationContext; import play.Logger; import play.Play; -import play.PlayPlugin; import play.data.validation.Validation; import play.exceptions.PlayException; import play.exceptions.UnexpectedException; diff --git a/framework/src/play/templates/GroovyTemplateCompiler.java b/framework/src/play/templates/GroovyTemplateCompiler.java index dab1bc856d..145f1ce466 100644 --- a/framework/src/play/templates/GroovyTemplateCompiler.java +++ b/framework/src/play/templates/GroovyTemplateCompiler.java @@ -11,7 +11,6 @@ import java.util.Map; import java.util.regex.Pattern; import play.Play; -import play.PlayPlugin; import play.exceptions.TemplateCompilationException; import play.templates.GroovyInlineTags.CALL; diff --git a/framework/src/play/templates/TemplateLoader.java b/framework/src/play/templates/TemplateLoader.java index 4d760a84ae..a1c6cfee10 100644 --- a/framework/src/play/templates/TemplateLoader.java +++ b/framework/src/play/templates/TemplateLoader.java @@ -8,7 +8,6 @@ import play.Logger; import play.Play; -import play.PlayPlugin; import play.vfs.VirtualFile; import play.exceptions.TemplateCompilationException; import play.exceptions.TemplateNotFoundException; diff --git a/framework/src/play/test/Fixtures.java b/framework/src/play/test/Fixtures.java index 63d13236f9..ea47018416 100644 --- a/framework/src/play/test/Fixtures.java +++ b/framework/src/play/test/Fixtures.java @@ -26,7 +26,6 @@ import play.Logger; import play.Play; -import play.PlayPlugin; import play.classloading.ApplicationClasses; import play.data.binding.Binder; import play.data.binding.types.DateBinder; diff --git a/framework/src/play/test/TestEngine.java b/framework/src/play/test/TestEngine.java index 22f8f4406a..90387add32 100644 --- a/framework/src/play/test/TestEngine.java +++ b/framework/src/play/test/TestEngine.java @@ -17,7 +17,6 @@ import play.Logger; import play.Play; -import play.PlayPlugin; import play.vfs.VirtualFile; /**