Skip to content

Instantly share code, notes, and snippets.

View keesun's full-sized avatar
📺
On Air

Keesun Baik (a.k.a, Whiteship) keesun

📺
On Air
View GitHub Profile
@keesun
keesun / LoginPage.groovy
Last active August 29, 2015 14:01
Geb test with Spock
package pages
import geb.Page
/**
* @author Keeun Baik
*/
class LoginPage extends Page {
static url = "/users/loginform"
@keesun
keesun / WebAppInitializer.java
Created November 24, 2011 05:10
Spring 3.1's MVC Web Application Initializer
public class WebAppIntializer implements WebApplicationInitializer {
 
    @Override
    public void onStartup(ServletContext servletContext) throws ServletException {
        //parent
        AnnotationConfigWebApplicationContext rootContext = new AnnotationConfigWebApplicationContext();
        rootContext.register(AppConfig.class);
 
        servletContext.addListener(new ContextLoaderListener(rootContext));
//        new ContextLoader(rootContext).initWebApplicationContext(servletContext);
@keesun
keesun / AppConfig.java
Created November 24, 2011 08:55
Spring 3.1 Application Configuration
@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = "whiteship", excludeFilters = {@ComponentScan.Filter(Configuration.class), @ComponentScan.Filter(Controller.class)})
public class AppConfig {
@Bean(destroyMethod = "shutdown")
public DataSource dataSource(){
return new EmbeddedDatabaseBuilder()
.setName("bookDB")
.setType(EmbeddedDatabaseType.H2)
@keesun
keesun / WebConfig.java
Created November 24, 2011 08:57
Spring 3.1 Web Application Configuration
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "whiteship",
useDefaultFilters = false,
includeFilters = @ComponentScan.Filter(Controller.class))
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
@keesun
keesun / pom.xml
Created January 12, 2012 23:49
Dependencies for Servlet 3.0
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
@keesun
keesun / TestServlet.java
Created January 12, 2012 23:51
Servlet 3.0's Annotation based Servlet registration sample
@WebServlet(urlPatterns = "/test")
public class TestServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
res.setContentType(MediaType.TEXT_PLAIN_VALUE);
PrintWriter out = res.getWriter();
out.write("Hello");
out.close();
}
@keesun
keesun / SpringServlet.java
Created January 12, 2012 23:53
Restration of Spring DispatcherServlet with Servlet 3.0's annotation
@WebServlet(urlPatterns = "/spring/*",
initParams = {
@WebInitParam(name = "contextConfigLocation", value = "classpath*:/spring.xml")})
public class SpringServlet extends DispatcherServlet {
}
@keesun
keesun / AppConfig.java
Created January 18, 2012 13:36
Spring 3.1's TestContext
package sandbox.testcontext.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author Keesun Baik
*/
@Configuration
public class AppConfig {
@keesun
keesun / AppConfig.java
Created January 18, 2012 13:57
Spring 3.1's extends @configuration
@Configuration
public class AppConfig extends HelloConfig {
@Override
public Hello hello() {
Hello h = super.hello();
h.setName("Keesun");
return h;
}
}
@keesun
keesun / AppConfig.java
Created January 18, 2012 14:05
Spring 3.1's @import
@Configuration
@Import(HelloConfig.class)
public class AppConfig {
@Override
public Hello hello() {
Hello h = super.hello();
h.setName("Keesun");
return h;
}
}