aboutsummaryrefslogtreecommitdiff
path: root/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java')
-rw-r--r--juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java31
1 files changed, 13 insertions, 18 deletions
diff --git a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java
index 5e035dac..db37edc4 100644
--- a/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java
+++ b/juick-ws/src/main/java/com/juick/ws/configuration/WebsocketConfiguration.java
@@ -9,7 +9,6 @@ import com.mitchellbosecke.pebble.loader.Loader;
import com.mitchellbosecke.pebble.loader.ServletLoader;
import com.mitchellbosecke.pebble.spring4.PebbleViewResolver;
import com.mitchellbosecke.pebble.spring4.extension.SpringExtension;
-import org.apache.commons.dbcp2.BasicDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@@ -40,29 +39,22 @@ import java.util.concurrent.Executors;
@Configuration
@EnableWebSocket
@ComponentScan(basePackages = {"com.juick"})
-@PropertySource(value = "classpath:juick.conf", ignoreResourceNotFound = true)
+@PropertySource(value = {"classpath:juick.conf", "file:${user.home}/juick.conf"})
public class WebsocketConfiguration extends WebMvcConfigurationSupport implements WebSocketConfigurer {
@Inject
- Environment env;
+ private Environment env;
@Inject
- ExecutorService service;
+ private JdbcTemplate jdbc;
+ @Inject
+ private ServletContext servletContext;
+
@Bean
- WebsocketComponent wsHandler() {
+ public WebsocketComponent wsHandler() {
return new WebsocketComponent();
}
@Bean
- JdbcTemplate jdbc() {
- BasicDataSource dataSource = new BasicDataSource();
- dataSource.setDriverClassName(env.getProperty("datasource_driver", "com.mysql.jdbc.Driver"));
- dataSource.setUrl(env.getProperty("datasource_url"));
- return new JdbcTemplate(dataSource);
- }
- @Inject
- private ServletContext servletContext;
-
- @Bean
- public Loader templateLoader(){
+ public Loader templateLoader() {
return new ServletLoader(servletContext);
}
@@ -87,10 +79,12 @@ public class WebsocketConfiguration extends WebMvcConfigurationSupport implement
viewResolver.setPebbleEngine(pebbleEngine());
return viewResolver;
}
+
@Bean
public XMPPConnection ws() {
- return new XMPPConnection(env, service);
+ return new XMPPConnection(env, service());
}
+
@Bean
public ExecutorService service() {
return Executors.newCachedThreadPool();
@@ -102,9 +96,10 @@ public class WebsocketConfiguration extends WebMvcConfigurationSupport implement
mapping.setUseSuffixPatternMatch(false);
return mapping;
}
+
@Override
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
- ((ServletWebSocketHandlerRegistry)registry).setOrder(2);
+ ((ServletWebSocketHandlerRegistry) registry).setOrder(2);
registry.addHandler(wsHandler(), "/**").setAllowedOrigins("*");
}