Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

cleanup for s2g12012

  • Loading branch information...
commit ab5be2f8e7e0b41d4b6235585c8adefbc92e328a 1 parent e913548
@joshlong joshlong authored
View
44 cf-workers-batch/src/main/java/org/cloudfoundry/workers/stocks/batch/BatchConfiguration.java
@@ -115,17 +115,18 @@ public CloudEnvironment cloudEnvironment() {
* TODO make the SQL a little smarter about not recreating the tables unless
* they don't exist.
*
- */
+ */
@Bean
public DataSourceInitializer dataSourceInitializer() {
DataSourceInitializer dsi = new DataSourceInitializer();
dsi.setDataSource(dsConfig.dataSource());
ResourceDatabasePopulator resourceDatabasePopulator = new ResourceDatabasePopulator();
String[] scripts = "/batch_%s.sql,/stocks_%s.sql".split(",");
- String scriptSuffix = cloudEnvironment().isCloudFoundry() ? "psql" : "h2";
- for (String s : scripts){
- ClassPathResource classPathResource =
- new ClassPathResource(String.format(s, scriptSuffix)) ;
+ String scriptSuffix = cloudEnvironment().isCloudFoundry() ? "psql"
+ : "h2";
+ for (String s : scripts) {
+ ClassPathResource classPathResource = new ClassPathResource(
+ String.format(s, scriptSuffix));
resourceDatabasePopulator.addScript(classPathResource);
}
dsi.setDatabasePopulator(resourceDatabasePopulator);
@@ -284,35 +285,16 @@ public StockSymbolLookup process(String tickerSymbol)
jdbcBatchItemWriter
.setSql("INSERT INTO STOCKS_DATA( DATE_ANALYSED, HIGH_PRICE, LOW_PRICE, CLOSING_PRICE, SYMBOL) VALUES ( :da, :hp, :lp, :cp, :s ) ");
jdbcBatchItemWriter.setDataSource(dsConfig.dataSource());
- jdbcBatchItemWriter
- .setItemSqlParameterSourceProvider(new ItemSqlParameterSourceProvider<StockSymbolLookup>() {
+ jdbcBatchItemWriter.setItemSqlParameterSourceProvider(new ItemSqlParameterSourceProvider<StockSymbolLookup>() {
@Override
- public SqlParameterSource createSqlParameterSource(
- StockSymbolLookup item) {
+ public SqlParameterSource createSqlParameterSource( StockSymbolLookup item) {
return new MapSqlParameterSource()
- .addValue(
- "da",
- new java.sql.Date(dateOfAnalysis
- .getTime()), Types.DATE)
- .addValue("hp", item.getHighPrice(),
- Types.DOUBLE)
- .addValue("lp", item.getLowPrice(),
- Types.DOUBLE)
+ .addValue( "da", new java.sql.Date(dateOfAnalysis.getTime()), Types.DATE)
+ .addValue("hp", item.getHighPrice(), Types.DOUBLE)
+ .addValue("lp", item.getLowPrice(), Types.DOUBLE)
.addValue("s", item.getTicker())
- .addValue("si", item.getId(), Types.BIGINT) // stock
- // id
- // has
- // to
- // be
- // the
- // same
- // as
- // in
- // the
- // Symbol
- // lookup
- .addValue("cp", item.getLastValueWhileOpen(),
- Types.DOUBLE);
+ .addValue("si", item.getId(), Types.BIGINT)
+ .addValue("cp", item.getLastValueWhileOpen(), Types.DOUBLE);
}
});
View
40 cf-workers-batch/src/main/resources/log4j.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %t %-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Loggers -->
+ <logger name="org.springframework">
+ <level value="warn" />
+ </logger>
+
+ <logger name="org.springframework.integration">
+ <level value="debug" />
+ </logger>
+
+ <logger name="org.springframework.integration.endpoint.PollingConsumer">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.amqp">
+ <level value="debug" />
+ </logger>
+
+ <logger name="org.springframework.amqp.rabbit.listener">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="debug" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
5 ...main/java/org/cloudfoundry/workers/stocks/YahooPipesQuotesApiStockSymbolLookupClient.java
@@ -70,15 +70,16 @@ public StockSymbolLookup lookupSymbol(String symbol) throws Throwable {
buildStockUrl(symbol));
response = response.substring(response.indexOf("(") + 1);
response = response.substring(0, response.lastIndexOf(")")).trim();
- logger.info(response);
+// logger.info(response);
JsonNode jsonNode = new ObjectMapper().readTree(response);
+ logger.info( "LOOKUP REQUEST FOR SYMBOL: "+ symbol);
return convertJsonNodeToStockSymbolLookup(jsonNode);
}
private StockSymbolLookup convertJsonNodeToStockSymbolLookup(
JsonNode jsonNode) {
JsonNode jsonNode1 = jsonNode.get("query").get("results").get("quote");
- logger.info(ToStringBuilder.reflectionToString(jsonNode1));
+ //logger.info(ToStringBuilder.reflectionToString(jsonNode1));
String symbol = jsonNode1.get("symbol").getValueAsText();
String range = jsonNode1.get("DaysRange").getValueAsText();
String parts[] = range.split("\\s+-\\s+");
View
4 cf-workers-integration-service/pom.xml
@@ -46,6 +46,10 @@
<groupId>org.springframework.integration</groupId>
<artifactId>spring-integration-core</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework.integration</groupId>
+ <artifactId>spring-integration-file</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-integration</artifactId>
View
18 ...java/org/cloudfoundry/workers/stocks/integration/service/config/ServiceConfiguration.java
@@ -16,25 +16,34 @@
package org.cloudfoundry.workers.stocks.integration.service.config;
+import javax.inject.Inject;
+
+import org.aopalliance.intercept.MethodInterceptor;
+import org.aopalliance.intercept.MethodInvocation;
+import org.cloudfoundry.runtime.env.ApplicationInstanceInfo;
+import org.cloudfoundry.runtime.env.CloudEnvironment;
import org.cloudfoundry.workers.common.config.CloudRabbitConnectionFactoryConfiguration;
import org.cloudfoundry.workers.common.config.LocalRabbitConnectionFactoryConfiguration;
import org.cloudfoundry.workers.common.config.RabbitConnectionFactoryConfiguration;
import org.cloudfoundry.workers.stocks.StockSymbolLookupClient;
import org.cloudfoundry.workers.stocks.YahooPipesQuotesApiStockSymbolLookupClient;
-import org.springframework.amqp.core.*;
+import org.springframework.amqp.core.AmqpAdmin;
+import org.springframework.amqp.core.Binding;
+import org.springframework.amqp.core.BindingBuilder;
+import org.springframework.amqp.core.DirectExchange;
+import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.core.RabbitAdmin;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.transaction.RabbitTransactionManager;
import org.springframework.amqp.support.converter.JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
+import org.springframework.aop.framework.ProxyFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.client.RestTemplate;
-import javax.inject.Inject;
-
/**
* Configuration for the service that actually does the stock symbol lookup.
@@ -58,8 +67,9 @@ public RestTemplate restTemplate() {
@Bean
public StockSymbolLookupClient client() {
- return new YahooPipesQuotesApiStockSymbolLookupClient(restTemplate());
+ return new YahooPipesQuotesApiStockSymbolLookupClient(restTemplate());
}
+
@Bean
public RabbitTemplate rabbitTemplate() throws Throwable {
View
20 cf-workers-integration-service/src/main/resources/log4j.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %t %-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
6 cf-workers-integration-service/src/main/resources/symbol-lookup-gateway-service.xml
@@ -10,6 +10,7 @@
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
<channel id="inboundSymbolsRequests"/>
<amqp:inbound-gateway request-channel="inboundSymbolsRequests"
@@ -18,6 +19,7 @@
connection-factory="connectionFactory"/>
- <service-activator ref="client" input-channel="inboundSymbolsRequests" requires-reply="true"/>
-
+ <service-activator ref="client" input-channel="inboundSymbolsRequests" requires-reply="true"/>
+
+
</beans:beans>
View
4 cf-workers-integration-webclient/pom.xml
@@ -71,6 +71,10 @@
<artifactId>spring-integration-core</artifactId>
</dependency>
<dependency>
+ <groupId>org.springframework.integration</groupId>
+ <artifactId>spring-integration-file</artifactId>
+ </dependency>
+ <dependency>
<groupId>org.springframework.batch</groupId>
<artifactId>spring-batch-integration</artifactId>
</dependency>
Please sign in to comment.
Something went wrong with that request. Please try again.