Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Code formatted

  • Loading branch information...
commit 8048a6cee1be1ca991d1361282cf5d5a1a429175 1 parent e7017f3
@jacekolszak authored
View
2  eclipse-formatter.xml
@@ -199,7 +199,7 @@
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
-<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="200"/>
+<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/>
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
View
3  src/main/java/controllers/AmfController.java
@@ -17,7 +17,8 @@
* </code>
*/
public String hello() {
- return "Hello from server :)"; // will return the string to the Flash client
+ return "Hello from server :)"; // will return the string to the Flash
+ // client
}
/**
View
3  src/main/java/controllers/AuthController.java
@@ -23,7 +23,8 @@ public Response submitLoginForm() {
return redirect().action("sample", "index");
}
} else {
- flash("error", "Wrong credentials"); // flash is a special attributes scope (persisted in session for the next request only)
+ flash("error", "Wrong credentials"); // flash is a special attributes scope (persisted in session for the
+ // next request only)
return render("login");
}
}
View
14 src/main/java/controllers/BeforeController.java
@@ -4,7 +4,8 @@
import framework.Response;
/**
- * This example shows how simple authentication can be made using before advice. For more sophisticated intecepting use standard JavaServlet filters.
+ * This example shows how simple authentication can be made using before advice. For more sophisticated intecepting use
+ * standard JavaServlet filters.
*/
public class BeforeController {
@@ -12,11 +13,16 @@
* Runs before every action in this controller (or derived controllers)
*/
public Response before() {
- Boolean session = session("authenticated"); // returns the value of "authenticated" session's attribute
+ Boolean session = session("authenticated"); // returns the value of
+ // "authenticated" session's
+ // attribute
boolean authenticated = session != null && session;
if (!authenticated) {
- session("returnUrl", req().getURL()); // sets session attribute "returnUrl" to the request URL
- return redirect().action("auth", "login"); // redirects to action in different controller
+ session("returnUrl", req().getURL()); // sets session attribute
+ // "returnUrl" to the request
+ // URL
+ return redirect().action("auth", "login"); // redirects to action in
+ // different controller
} else {
return null; // execute action methods
}
View
9 src/main/java/controllers/FormsController.java
@@ -12,7 +12,8 @@
static {
// validation rules specified in CreateUserForm class will be used for action createUser
- validateParams("createUser", CreateUserForm.class).input("validatedForm"); // if validation error occurs go back to validatedForm action
+ validateParams("createUser", CreateUserForm.class).input("validatedForm"); // if validation error occurs go back
+ // to validatedForm action
}
/**
@@ -38,7 +39,8 @@ public Response createUser() {
public static class CreateUserForm {
static {
- required("name", "street"); // name and street parameters are required which means that they shouldn't be null or empty
+ required("name", "street"); // name and street parameters are required which means that they shouldn't be
+ // null or empty
registerValidator("postalCode", new PostalCodeValidator()); // for postalCode parameter use custom validator
}
@@ -56,7 +58,8 @@ public Response createUser() {
public static class PostalCodeValidator implements Validator {
public void validates(String field, Object value, Errors errors) {
- if (value != null && !String.valueOf(value).trim().isEmpty()) { // validate only if parameter is given and is not empty
+ if (value != null && !String.valueOf(value).trim().isEmpty()) { // validate only if parameter is given and
+ // is not empty
String val = value.toString();
if (!val.matches("\\d\\d-\\d\\d\\d")) {
errors.add(field, field + " has wrong format"); // add error message for field
View
5 src/main/java/controllers/IocController.java
@@ -7,8 +7,9 @@
public class IocController {
/**
- * Egg Framework autimatically injects Application instance into every controller with "app" field (autowire by name) Only this one instance can be injected into controllers. You cannot inject
- * particular services into controller. Use fields or getters in Application instance returning services references.
+ * Egg Framework autimatically injects Application instance into every controller with "app" field (autowire by
+ * name) Only this one instance can be injected into controllers. You cannot inject particular services into
+ * controller. Use fields or getters in Application instance returning services references.
*/
private Application app;
View
16 src/main/java/controllers/SampleController.java
@@ -8,17 +8,20 @@
import framework.Response;
/**
- * Shows basic usage of Egg Framework. Controller is a class containing a list of action methods. Every action is reponsible for handling one type of HTTP request. Egg Framework is using Convention
- * over Configuration, which means that the amount of configuration is very limited and conventions are used to configure the application automatically. For instance every action defined in controller
- * class is accessible from following url: http://localhost:8080/$controllerClassNameWithoutControllerSuffix/$action
+ * Shows basic usage of Egg Framework. Controller is a class containing a list of action methods. Every action is
+ * reponsible for handling one type of HTTP request. Egg Framework is using Convention over Configuration, which means
+ * that the amount of configuration is very limited and conventions are used to configure the application automatically.
+ * For instance every action defined in controller class is accessible from following url:
+ * http://localhost:8080/$controllerClassNameWithoutControllerSuffix/$action
*/
public class SampleController {
/**
* Go to http://localhost:8080/sample/index.html to see this page. <br />
* <br />
- * This action automatically render sample/index.html Groovy template. To change the template edit the src/main/resources/sample/index.html file. To change the layout edit the
- * src/main/resources/sample/layout.html file.
+ * This action automatically render sample/index.html Groovy template. To change the template edit the
+ * src/main/resources/sample/index.html file. To change the layout edit the src/main/resources/sample/layout.html
+ * file.
*/
public void index() {
attr("name", "Egg Framework"); // sets an attribute named "name"
@@ -77,7 +80,8 @@ public Response redirectTest() {
}
/**
- * Go to http://localhost:8080/sample/configTest.html to see this page. You can access config.properties from every possible place (controllers, view, services etc.).
+ * Go to http://localhost:8080/sample/configTest.html to see this page. You can access config.properties from every
+ * possible place (controllers, view, services etc.).
*/
public Response configTest() {
return renderText(f("The application is in %s mode", config("mode")));
View
5 src/main/java/framework/AMFGateway.java
@@ -20,8 +20,9 @@
import flex.messaging.io.amf.MessageBody;
/**
- * Gateway is a place where Flash client connects and sends messages. Every Flash remoting action is executed through this gateway. This class can be compared to FrontController but it adds the
- * functionality of handling many incoming messages in a single HTTP request
+ * Gateway is a place where Flash client connects and sends messages. Every Flash remoting action is executed through
+ * this gateway. This class can be compared to FrontController but it adds the functionality of handling many incoming
+ * messages in a single HTTP request
*/
public class AMFGateway extends HttpServlet {
View
8 src/main/java/framework/GlobalHelpers.java
@@ -659,7 +659,8 @@ public static int sum(Iterable<Integer> numbers) {
}
/**
- * VERY EXPERIMENTAL FEATURE. Generate piece of code depdening on passed object. It can generate ready to use HTML code for tables, forms, combo boxes etc.
+ * VERY EXPERIMENTAL FEATURE. Generate piece of code depdening on passed object. It can generate ready to use HTML
+ * code for tables, forms, combo boxes etc.
*/
public static void scaffold(String name, Object o) throws IOException, IllegalArgumentException, IllegalAccessException {
Writer out = out();
@@ -701,8 +702,9 @@ public static AsyncForward asyncForward() {
* This method should be used in service.Application.start() method. It creates and add a rule to the routing.
*
* @param matchPattern
- * A pattern which will be matched against an action path. You can use literals and parameters here. Parameter must be prefixed by dollar "$" sign. Sample pattern:
- * "/someLiteral/$param1". For more details see {@link Rule}
+ * A pattern which will be matched against an action path. You can use literals and parameters here.
+ * Parameter must be prefixed by dollar "$" sign. Sample pattern: "/someLiteral/$param1". For more
+ * details see {@link Rule}
*/
public static Rule match(String matchPattern) {
Rule rule = new Rule(matchPattern);
View
4 src/main/java/framework/ReloadingClassLoader.java
@@ -24,8 +24,8 @@
import org.apache.commons.jci.stores.ResourceStoreClassLoader;
/**
- * The ReloadingClassLoader uses a delegation mechansim to allow classes to be reloaded. That means that loadClass calls may return different results if the class was change in the underlying
- * ResoruceStore.
+ * The ReloadingClassLoader uses a delegation mechansim to allow classes to be reloaded. That means that loadClass calls
+ * may return different results if the class was change in the underlying ResoruceStore.
*
* @author tcurdt
*/
View
11 src/main/java/framework/ReloadingServer.java
@@ -27,12 +27,15 @@
import org.apache.commons.jci.stores.FileResourceStore;
/**
- * Run this class in order to run a web server with you application. Remember to specify java.library.path JVM option pointing to libs directory (-Djava.library.path=libs).
+ * Run this class in order to run a web server with you application. Remember to specify java.library.path JVM option
+ * pointing to libs directory (-Djava.library.path=libs).
*
- * EXPERIMENTAL. Use with caution cause it generates PermGen exceptions on SunJVM and OutOfMemoryException in JRockit (memory leaks). At this moment a better approach is to use Server class instead
- * and JRebel tool for automatic reloading.
+ * EXPERIMENTAL. Use with caution cause it generates PermGen exceptions on SunJVM and OutOfMemoryException in JRockit
+ * (memory leaks). At this moment a better approach is to use Server class instead and JRebel tool for automatic
+ * reloading.
*
- * TODO Server does not need to be stopped every time class file change. This class should check also if application was started already. If it wasn't then do nothing
+ * TODO Server does not need to be stopped every time class file change. This class should check also if application was
+ * started already. If it wasn't then do nothing
*
* @author Jacek Olszak
*/
View
3  src/main/java/framework/Routing.java
@@ -25,7 +25,8 @@
import framework.Rule.Pattern;
/**
- * Routing class responsible for matching servlet paths to patterns. It is pretty fast - for 20 routes it takes 0,15ms on Intel i5 2500k
+ * Routing class responsible for matching servlet paths to patterns. It is pretty fast - for 20 routes it takes 0,15ms
+ * on Intel i5 2500k
*
* @author Jacek Olszak
*
View
3  src/main/java/framework/Rule.java
@@ -30,7 +30,8 @@
* /$controller/$action/$id <br>
* /$controller/$action <br>
* </code> <br>
- * Parameter names are starting with dollar '$' sign and can contain any character. The exceptions are following characters: '/' (slash), ' ' (space), '.' (dot) and '-' (dash). Examples:<br>
+ * Parameter names are starting with dollar '$' sign and can contain any character. The exceptions are following
+ * characters: '/' (slash), ' ' (space), '.' (dot) and '-' (dash). Examples:<br>
* <code>
* /articles/$id-$category/$region gives the following parts: '/articles/' literal, 'id' parameter, '-' literal, 'category' parameter, '/' literal, 'region' parameter
* </code>
View
3  src/main/java/framework/Server.java
@@ -16,7 +16,8 @@
package framework;
/**
- * Run this class in order to run a web server with your application. To enable automatic reloading use JRebel ( {@link http ://www.zeroturnaround.com/jrebel/} )
+ * Run this class in order to run a web server with your application. To enable automatic reloading use JRebel (
+ * {@link http ://www.zeroturnaround.com/jrebel/} )
*
* @author Jacek Olszak
*/
View
3  src/main/java/framework/Template.java
@@ -86,7 +86,8 @@ private static String generateSourceFile(String template) throws IOException, Fi
final String name = file.getName();
Long date = filemodificationDates.get(name);
- long lastModified = !productionMode ? file.lastModified() : -1; // omit lastModified() method call in production mode (performance optimization)
+ long lastModified = !productionMode ? file.lastModified() : -1; // omit lastModified() method call in production
+ // mode (performance optimization)
if (date == null || (!productionMode && date < lastModified)) {
FileWriter generatedSourceWriter = new FileWriter(groovySourceFile);
try {
Please sign in to comment.
Something went wrong with that request. Please try again.