forked from spring-attic/spring-framework-issues
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Add project for SPR9157
- Loading branch information
Ferenc Gratzer
authored and
Ferenc Gratzer
committed
Feb 25, 2012
1 parent
4a9d255
commit b7ea3de
Showing
12 changed files
with
448 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
http://localhost:8080/spr9157/environments.html | ||
http://localhost:8080/spr9157/environment.html?environment=name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>org.springframework.issues</groupId> | ||
<artifactId>spr9157</artifactId> | ||
<version>0.1</version> | ||
<packaging>war</packaging> | ||
<name>SPR-9157 :: Spring3 converter</name> | ||
<description>SPR-9157 - Spring 3 converter</description> | ||
|
||
<properties> | ||
<java-version>1.6</java-version> | ||
<spring.version>3.0.7.RELEASE</spring.version> | ||
<slf4j.version>1.6.4</slf4j.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-webmvc</artifactId> | ||
<version>${spring.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>1.0.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>servlet-api</artifactId> | ||
<version>2.4</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet.jsp</groupId> | ||
<artifactId>jsp-api</artifactId> | ||
<version>2.0</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>jstl</artifactId> | ||
<version>1.1.2</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.3.2</version> | ||
<configuration> | ||
<source>${java-version}</source> | ||
<target>${java-version}</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.3.1</version> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-source-plugin</artifactId> | ||
<version>2.1.2</version> | ||
<executions> | ||
<execution> | ||
<id>attach-sources</id> | ||
<goals> | ||
<goal>jar</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>2.11</version> | ||
<configuration> | ||
<argLine>-Xms64m -Xmx512m -XX:MaxPermSize=128m</argLine> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-war-plugin</artifactId> | ||
<version>2.1.1</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
57 changes: 57 additions & 0 deletions
57
SPR-9157/src/main/java/org/springframework/issues/spr9157/Environment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.springframework.issues.spr9157; | ||
|
||
/** | ||
* Environment. | ||
*/ | ||
public class Environment { | ||
private Long id; | ||
private String name; | ||
|
||
@SuppressWarnings("unused") | ||
private Environment() { | ||
// Hibernate | ||
} | ||
|
||
public Environment(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public Long getId() { | ||
return id; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
final int prime = 31; | ||
int result = 1; | ||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (this == obj) { | ||
return true; | ||
} | ||
if (!(obj instanceof Environment)) { | ||
return false; | ||
} | ||
Environment other = (Environment) obj; | ||
return getName().equals(other.getName()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("Environment [id=").append(id).append(", name=").append(name).append("]"); | ||
return builder.toString(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...rc/main/java/org/springframework/issues/spr9157/web/controller/EnvironmentController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.springframework.issues.spr9157.web.controller; | ||
|
||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.issues.spr9157.Environment; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
/** | ||
* Controller for managing environment. | ||
*/ | ||
@Controller | ||
public class EnvironmentController { | ||
private static final Logger LOG = LoggerFactory.getLogger(EnvironmentController.class); | ||
|
||
@RequestMapping(value = "/environments.html", method = RequestMethod.GET) | ||
public ModelAndView getEnvironments() { | ||
LOG.debug("environments"); | ||
return new ModelAndView("environments"); | ||
} | ||
|
||
@RequestMapping(value = "/environment.html", method = RequestMethod.GET) | ||
public ModelAndView getEnvironment(@RequestParam Environment environment) { | ||
LOG.debug("environment: {}", environment); | ||
ModelAndView mav = new ModelAndView("environment"); | ||
mav.addObject("environment", environment); | ||
return mav; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
SPR-9157/src/main/java/org/springframework/issues/spr9157/web/util/EnvironmentConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.springframework.issues.spr9157.web.util; | ||
|
||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.core.convert.converter.Converter; | ||
import org.springframework.issues.spr9157.Environment; | ||
import org.springframework.util.StringUtils; | ||
|
||
/** | ||
* Environment converter. | ||
*/ | ||
public class EnvironmentConverter implements Converter<String, Environment> { | ||
private static final Logger LOG = LoggerFactory.getLogger(EnvironmentConverter.class); | ||
|
||
public Environment convert(String source) { | ||
LOG.debug("source: {}", source); | ||
if (!StringUtils.hasText(source)) { | ||
return null; | ||
} | ||
return new Environment(source.trim()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<configuration> | ||
|
||
<!-- Makes the logger system available via JMX --> | ||
<jmxConfigurator /> | ||
|
||
<!-- Auto-define an appender that sends the console messages to the Logback Eclipse console plugin --> | ||
<!-- <consolePlugin /> --> | ||
|
||
<!-- APPENDERS --> | ||
|
||
<!-- A debug file appender --> | ||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<file>C:\\Temp\\logDebug.log</file> | ||
|
||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> | ||
<FileNamePattern>${logback.debugFile}.%i.log</FileNamePattern> | ||
<MinIndex>1</MinIndex> | ||
<MaxIndex>5</MaxIndex> | ||
</rollingPolicy> | ||
|
||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> | ||
<MaxFileSize>20MB</MaxFileSize> | ||
</triggeringPolicy> | ||
|
||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern>%date %-5level %logger [%thread] [%file : %line] - %msg%n</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<!-- An error file appender --> | ||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | ||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter"> | ||
<level>WARN</level> | ||
</filter> | ||
|
||
<file>C:\\Temp\\logError.log</file> | ||
|
||
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy"> | ||
<FileNamePattern>${logback.errorFile}.%i.log</FileNamePattern> | ||
<MinIndex>1</MinIndex> | ||
<MaxIndex>2</MaxIndex> | ||
</rollingPolicy> | ||
|
||
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy"> | ||
<MaxFileSize>20MB</MaxFileSize> | ||
</triggeringPolicy> | ||
|
||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern>%date %-5level %logger [%thread] [%file : %line] - %msg%n</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<!-- An appender that sends the messages to console --> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<layout class="ch.qos.logback.classic.PatternLayout"> | ||
<Pattern>%date %-5level %logger{36} [%thread] [%file : %line] - %msg%n</Pattern> | ||
</layout> | ||
</appender> | ||
|
||
<!-- LOGGERS --> | ||
|
||
<!-- The root logger sends the messages > INFO to all the appenders (the ERROR_FILE filters internally only to WARNS and ERRORS)--> | ||
<root level="INFO"> | ||
<appender-ref ref="STDOUT" /> | ||
<appender-ref ref="DEBUG_FILE" /> | ||
<appender-ref ref="ERROR_FILE" /> | ||
<!-- <appender-ref ref="lilithMultiplex" /> --> | ||
</root> | ||
|
||
<!-- The root logger sends all the messages coming from package com.kiko.store to the appenders inherited from the ROOT logger--> | ||
<logger name="hu.ferengra" level="ALL"> | ||
</logger> | ||
|
||
<logger name="org.springframework" level="ALL"> | ||
</logger> | ||
|
||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" | ||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> | ||
|
||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:mvc="http://www.springframework.org/schema/mvc" | ||
xmlns:util="http://www.springframework.org/schema/util" xmlns:security="http://www.springframework.org/schema/security" | ||
xsi:schemaLocation=" | ||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd | ||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd | ||
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd | ||
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd | ||
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd | ||
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.0.xsd"> | ||
|
||
<context:component-scan base-package="org.springframework.issues.spr9157.web" use-default-filters="false"> | ||
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> | ||
</context:component-scan> | ||
|
||
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> | ||
<property name="alwaysUseFullPath" value="true" /> | ||
</bean> | ||
|
||
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"> | ||
<property name="cacheSeconds" value="0" /> | ||
<property name="webBindingInitializer"> | ||
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer"> | ||
<property name="conversionService" ref="conversionService" /> | ||
</bean> | ||
</property> | ||
<property name="alwaysUseFullPath" value="true" /> | ||
</bean> | ||
|
||
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver"> | ||
<property name="order" value="0" /> | ||
</bean> | ||
|
||
<!-- Resolves logical view names to JSP views --> | ||
<bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> | ||
<property name="order" value="1" /> | ||
<property name="prefix" value="/WEB-INF/views/" /> | ||
<property name="suffix" value=".jsp" /> | ||
</bean> | ||
|
||
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean"> | ||
<property name="converters"> | ||
<set> | ||
<bean class="org.springframework.issues.spr9157.web.util.EnvironmentConverter" /> | ||
</set> | ||
</property> | ||
</bean> | ||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Spring 3 Converter</title> | ||
</head> | ||
Environment: <%= request.getAttribute("environment") %> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> | ||
<jsp:text> | ||
<![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ]]> | ||
</jsp:text> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Spring 3 Converter</title> | ||
</head> | ||
Environments | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> | ||
<jsp:text> | ||
<![CDATA[ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ]]> | ||
</jsp:text> | ||
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<title>Spring 3 Converter</title> | ||
</head> | ||
Index | ||
</html> |
Oops, something went wrong.