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 / ChatController.java
Created April 19, 2012 08:37
Spring 3.2's async demo
package org.springframework.samples.async.chat;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@keesun
keesun / WebMvcConfigTests-Context.xml
Created April 16, 2012 15:53
Mvc namespace based configuration
<?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:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd">
<mvc:annotation-driven/>
<mvc:default-servlet-handler />
</beans>
@keesun
keesun / WebConfigTest.java
Created April 16, 2012 09:15
Test for web configuration using @configuration
package cantabille.config;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
/**
@keesun
keesun / WebConfig.java
Created April 16, 2012 09:12
Web configuration using @configuration
package cantabille.config;
import cantabille.modules.ModulesPackageMarker;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.servlet.config.annotation.DefaultServletHandlerConfigurer;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
@keesun
keesun / PathVariableTests.java
Created April 13, 2012 02:28
PathVariable Tests
package pathvariable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.stereotype.Controller;
import org.springframework.test.web.server.MockMvc;
import org.springframework.test.web.server.setup.MockMvcBuilders;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@keesun
keesun / ImportKey.java
Created April 13, 2012 02:02
Making keystore
import java.security.*;
import java.io.IOException;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.DataInputStream;
import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.security.spec.*;
import java.security.cert.Certificate;
@keesun
keesun / SampleWebAppInitializer.java
Created April 2, 2012 13:50
Spring 3.1's WebApplicationInitializer Sample
public class SampleWebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
AnnotationConfigWebApplicationContext ac = new AnnotationConfigWebApplicationContext();
// ac.register(AppConfig.java);
ServletContextListener listener = new ContextLoaderListener(ac);
servletContext.addListener(listener);
AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
@keesun
keesun / FlashAPI.java
Created April 2, 2012 13:44
Spring 3.1's FlashMap API
public class FlashAPI {
@Test
public void makeFlashMap(){
FlashMap fm = new FlashMap();
fm.put("message", "hi");
fm.setTargetRequestPath("/user/list");
fm.startExpirationPeriod(10);
}
@keesun
keesun / pom.xml
Created April 2, 2012 12:58
Servlet 3.0 maven dependency
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
@keesun
keesun / CorsInterceptor.java
Created March 30, 2012 00:16
CORS Spring Interceptor Demo
package cors;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @author Keesun Baik