This repository was archived by the owner on Dec 15, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 10 files changed +145
-8
lines changed
java/org/springframework/issues/spr9157 Expand file tree Collapse file tree 10 files changed +145
-8
lines changed Original file line number Diff line number Diff line change 9
9
<description >SPR-9157 - Spring 3 converter</description >
10
10
11
11
<properties >
12
- <java-version >1.6 </java-version >
12
+ <java-version >1.5 </java-version >
13
13
<spring .version>3.0.7.RELEASE</spring .version>
14
14
<slf4j .version>1.6.4</slf4j .version>
15
15
</properties >
Original file line number Diff line number Diff line change
1
+ package org .springframework .issues .spr9157 .model ;
2
+
3
+ /**
4
+ * Enhanced environment.
5
+ *
6
+ * @author ferengra
7
+ */
8
+ public interface EnhancedEnvironment extends Environment {
9
+
10
+ String getDescription ();
11
+ }
Original file line number Diff line number Diff line change
1
+ package org .springframework .issues .spr9157 .model ;
2
+
3
+ /**
4
+ * Enhanced environment implementation.
5
+ *
6
+ * @author ferengra
7
+ */
8
+ public class EnhancedEnvironmentImpl extends EnvironmentImpl implements EnhancedEnvironment {
9
+ private String description ;
10
+
11
+ @ SuppressWarnings ("unused" )
12
+ private EnhancedEnvironmentImpl () {
13
+ // Hibernate
14
+ }
15
+
16
+ public EnhancedEnvironmentImpl (String name , String description ) {
17
+ super (name );
18
+ this .description = description ;
19
+ }
20
+
21
+ public String getDescription () {
22
+ return description ;
23
+ }
24
+
25
+ public void setDescription (String description ) {
26
+ this .description = description ;
27
+ }
28
+ }
Original file line number Diff line number Diff line change
1
+ package org .springframework .issues .spr9157 .model ;
2
+
3
+ /**
4
+ * Environment.
5
+ *
6
+ * @author ferengra
7
+ */
8
+ public interface Environment {
9
+
10
+ String getName ();
11
+ }
Original file line number Diff line number Diff line change
1
+ package org .springframework .issues .spr9157 .model ;
2
+
3
+ /**
4
+ * Environment implementation.
5
+ *
6
+ * @author ferengra
7
+ */
8
+ public class EnvironmentImpl implements Environment {
9
+ private Long id ;
10
+ private String name ;
11
+
12
+ protected EnvironmentImpl () {
13
+ // Hibernate
14
+ }
15
+
16
+ public EnvironmentImpl (String name ) {
17
+ this .name = name ;
18
+ }
19
+
20
+ public String getName () {
21
+ return name ;
22
+ }
23
+
24
+ public void setName (String name ) {
25
+ this .name = name ;
26
+ }
27
+
28
+ public Long getId () {
29
+ return id ;
30
+ }
31
+
32
+ @ Override
33
+ public int hashCode () {
34
+ final int prime = 31 ;
35
+ int result = 1 ;
36
+ result = prime * result + ((getName () == null ) ? 0 : getName ().hashCode ());
37
+ return result ;
38
+ }
39
+
40
+ @ Override
41
+ public boolean equals (Object obj ) {
42
+ if (this == obj ) {
43
+ return true ;
44
+ }
45
+ if (!(obj instanceof EnhancedEnvironmentImpl )) {
46
+ return false ;
47
+ }
48
+ EnhancedEnvironmentImpl other = (EnhancedEnvironmentImpl ) obj ;
49
+ return getName ().equals (other .getName ());
50
+ }
51
+
52
+ @ Override
53
+ public String toString () {
54
+ StringBuilder builder = new StringBuilder ();
55
+ builder .append ("EnvironmentImpl [id=" ).append (id ).append (", name=" ).append (name ).append ("]" );
56
+ return builder .toString ();
57
+ }
58
+ }
Original file line number Diff line number Diff line change 1
1
package org .springframework .issues .spr9157 .web .controller ;
2
2
3
-
4
3
import org .slf4j .Logger ;
5
4
import org .slf4j .LoggerFactory ;
6
- import org .springframework .issues .spr9157 .Environment ;
5
+ import org .springframework .issues .spr9157 .model . EnhancedEnvironment ;
7
6
import org .springframework .stereotype .Controller ;
8
7
import org .springframework .web .bind .annotation .RequestMapping ;
9
8
import org .springframework .web .bind .annotation .RequestMethod ;
12
11
13
12
/**
14
13
* Controller for managing environment.
14
+ *
15
+ * @author ferengra
15
16
*/
16
17
@ Controller
17
18
public class EnvironmentController {
@@ -24,7 +25,7 @@ public ModelAndView getEnvironments() {
24
25
}
25
26
26
27
@ RequestMapping (value = "/environment.html" , method = RequestMethod .GET )
27
- public ModelAndView getEnvironment (@ RequestParam Environment environment ) {
28
+ public ModelAndView getEnvironment (@ RequestParam EnhancedEnvironment environment ) {
28
29
LOG .debug ("environment: {}" , environment );
29
30
ModelAndView mav = new ModelAndView ("environment" );
30
31
mav .addObject ("environment" , environment );
Original file line number Diff line number Diff line change 1
1
package org .springframework .issues .spr9157 .web .util ;
2
2
3
-
4
3
import org .slf4j .Logger ;
5
4
import org .slf4j .LoggerFactory ;
6
5
import org .springframework .core .convert .converter .Converter ;
7
- import org .springframework .issues .spr9157 .Environment ;
6
+ import org .springframework .issues .spr9157 .model .EnhancedEnvironmentImpl ;
7
+ import org .springframework .issues .spr9157 .model .Environment ;
8
8
import org .springframework .util .StringUtils ;
9
9
10
10
/**
11
11
* Environment converter.
12
+ *
13
+ * @author ferengra
12
14
*/
13
15
public class EnvironmentConverter implements Converter <String , Environment > {
14
16
private static final Logger LOG = LoggerFactory .getLogger (EnvironmentConverter .class );
@@ -18,6 +20,6 @@ public Environment convert(String source) {
18
20
if (!StringUtils .hasText (source )) {
19
21
return null ;
20
22
}
21
- return new Environment ( source .trim ());
23
+ return new EnhancedEnvironmentImpl ( source . trim (), source .trim ());
22
24
}
23
25
}
Original file line number Diff line number Diff line change 46
46
</set >
47
47
</property >
48
48
</bean >
49
+
50
+ <bean class =" org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" >
51
+ <property name =" defaultErrorView" value =" errorInternal" />
52
+ <property name =" warnLogCategory" value =" spr9157" />
53
+ </bean >
49
54
</beans >
Original file line number Diff line number Diff line change 1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
2
1
<%@ page contentType =" text/html; charset=UTF-8" pageEncoding =" UTF-8" %>
2
+ <jsp:text >
3
+ <![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ]]>
4
+ </jsp:text >
3
5
4
6
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
7
<head >
Original file line number Diff line number Diff line change
1
+ <%@ page contentType =" text/html; charset=UTF-8" pageEncoding =" UTF-8" %>
2
+ <%@ page isErrorPage =" true" %>
3
+ <%@ page import =" org.slf4j.LoggerFactory" %>
4
+ <jsp:text >
5
+ <![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ]]>
6
+ </jsp:text >
7
+
8
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
9
+ <head >
10
+ <title >Spring 3 Converter</title >
11
+ </head >
12
+ <body >
13
+ Error<br />
14
+ <%
15
+ LoggerFactory . getLogger(" InternalError" ). error(" Exception occured: " , exception);
16
+ % >
17
+ <%= exception. toString() % > <br />
18
+ </body >
19
+ </html >
You can’t perform that action at this time.
0 commit comments