Skip to content

Commit 009e91b

Browse files
committed
Polish
1 parent debe7e8 commit 009e91b

32 files changed

+47484
-49
lines changed

.classpath

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<classpathentry kind="src" path="src/main/java" including="**/*.java|**/*.aj"/>
55
<classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
66
<classpathentry kind="output" path="target/classes"/>
7-
<classpathentry kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar"/>
7+
<classpathentry kind="var" path="M2_REPO/javax/el/el-api/1.0/el-api-1.0.jar" sourcepath="M2_REPO/javax/el/el-api/1.0/el-api-1.0-sources.jar"/>
88
<classpathentry kind="var" path="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0.jar" sourcepath="M2_REPO/javax/annotation/jsr250-api/1.0/jsr250-api-1.0-sources.jar"/>
99
<classpathentry kind="var" path="M2_REPO/javax/servlet/jstl/1.2/jstl-1.2.jar" sourcepath="M2_REPO/javax/servlet/jstl/1.2/jstl-1.2-sources.jar"/>
1010
<classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.1/jta-1.1.jar" sourcepath="M2_REPO/javax/transaction/jta/1.1/jta-1.1-sources.jar"/>
@@ -15,7 +15,7 @@
1515
<classpathentry kind="var" path="M2_REPO/org/atmosphere/atmosphere-compat-jbossweb/0.7-SNAPSHOT/atmosphere-compat-jbossweb-0.7-SNAPSHOT.jar"/>
1616
<classpathentry kind="var" path="M2_REPO/org/atmosphere/atmosphere-compat-tomcat/0.7-SNAPSHOT/atmosphere-compat-tomcat-0.7-SNAPSHOT.jar"/>
1717
<classpathentry kind="var" path="M2_REPO/org/atmosphere/atmosphere-compat-weblogic/0.7-SNAPSHOT/atmosphere-compat-weblogic-0.7-SNAPSHOT.jar"/>
18-
<classpathentry kind="var" path="M2_REPO/org/atmosphere/atmosphere-runtime/0.7-SNAPSHOT/atmosphere-runtime-0.7-SNAPSHOT.jar"/>
18+
<classpathentry kind="var" path="M2_REPO/org/atmosphere/atmosphere-runtime/0.7-SNAPSHOT/atmosphere-runtime-0.7-SNAPSHOT.jar" sourcepath="M2_REPO/org/atmosphere/atmosphere-runtime/0.7-SNAPSHOT/atmosphere-runtime-0.7-SNAPSHOT-sources.jar"/>
1919
<classpathentry kind="var" path="M2_REPO/cglib/cglib-nodep/2.2/cglib-nodep-2.2.jar" sourcepath="M2_REPO/cglib/cglib-nodep/2.2/cglib-nodep-2.2-sources.jar"/>
2020
<classpathentry kind="var" path="M2_REPO/com/google/closure/closure-templates/20100708/closure-templates-20100708.jar"/>
2121
<classpathentry kind="var" path="M2_REPO/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0.jar" sourcepath="M2_REPO/commons-beanutils/commons-beanutils/1.8.0/commons-beanutils-1.8.0-sources.jar"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#Mon Sep 20 14:52:02 PDT 2010
2+
//com.springsource.sts.config.flow.coordinates\:http\://www.springframework.org/schema/integration\:/spring-html5/src/main/webapp/WEB-INF/spring/comet-config.xml=<?xml version\="1.0" encoding\="UTF-8"?>\n<graph/>
3+
eclipse.preferences.version=1

.settings/org.eclipse.jdt.core.prefs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#Fri Sep 17 09:19:37 PDT 2010
1+
#Mon Sep 20 13:52:36 PDT 2010
22
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
33
eclipse.preferences.version=1
44
org.eclipse.jdt.core.compiler.source=1.6

.settings/org.eclipse.wst.common.component

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<project-modules id="moduleCoreId" project-version="2.0">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project-modules id="moduleCoreId" project-version="1.5.0">
23
<wb-module deploy-name="spring-html5">
34
<property name="context-root" value="spring-html5"/>
45
<wb-resource deploy-path="/" source-path="src/main/webapp"/>
@@ -194,5 +195,9 @@
194195
</dependent-module>
195196
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
196197
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/resources"/>
198+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
199+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/resources"/>
200+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
201+
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
197202
</wb-module>
198-
</project-modules>
203+
</project-modules>

pom.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -528,10 +528,10 @@
528528
<plugin>
529529
<groupId>org.mortbay.jetty</groupId>
530530
<artifactId>jetty-maven-plugin</artifactId>
531-
<version>7.1.2.v20100523</version>
531+
<version>8.0.0.M1</version>
532532
<configuration>
533533
<webAppConfig>
534-
<contextPath>/${project.name}</contextPath>
534+
<contextPath>/spring-html5</contextPath>
535535
</webAppConfig>
536536
</configuration>
537537
</plugin>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package com.springsource.html5.visualization;
2+
3+
import java.util.List;
4+
5+
import org.springframework.batch.item.ItemWriter;
6+
import org.springframework.integration.Message;
7+
import org.springframework.integration.MessageChannel;
8+
import org.springframework.integration.support.MessageBuilder;
9+
10+
public class CommitRecordItemWriter implements ItemWriter<CommitRecord> {
11+
12+
private final MessageChannel outputChannel;
13+
14+
private CommitRecord prevRecord = null;
15+
16+
public CommitRecordItemWriter(MessageChannel outputChannel) {
17+
this.outputChannel = outputChannel;
18+
}
19+
20+
@Override
21+
public void write(List<? extends CommitRecord> items) throws Exception {
22+
for (CommitRecord item : items) {
23+
if (prevRecord == null || !item.getUsername().equals(prevRecord.getUsername()) || item.getTimestamp() != prevRecord.getTimestamp()) { //!item.getModuleName().equals(prevRecord.getModuleName()) || item.getTimestamp() != prevRecord.getTimestamp()) {
24+
Message<?> message = MessageBuilder.withPayload(item).build();
25+
outputChannel.send(message);
26+
prevRecord = item;
27+
}
28+
//No-op otherwise
29+
}
30+
}
31+
}

src/main/java/com/springsource/html5/visualization/CommitRecordProcessingConfiguration.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import org.springframework.core.io.ResourceLoader;
1414
import org.springframework.integration.MessageChannel;
1515

16-
//@Configuration
16+
@Configuration
1717
public class CommitRecordProcessingConfiguration implements ResourceLoaderAware{
1818

1919
private ResourceLoader resourceLoader;
@@ -33,7 +33,7 @@ public ItemReader<CommitRecord> commitRecordReader() {
3333

3434
@Bean
3535
public ItemWriter<CommitRecord> commitRecordWriter() {
36-
MessageSendingItemWriter<CommitRecord> writer = new MessageSendingItemWriter<CommitRecord>(commitRecordChannel);
36+
CommitRecordItemWriter writer = new CommitRecordItemWriter(commitRecordChannel);
3737
return writer;
3838
}
3939

src/main/java/com/springsource/html5/visualization/MessageSendingItemWriter.java

-24
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.springsource.petclinic.web;
2+
3+
import org.springframework.batch.core.Job;
4+
import org.springframework.batch.core.JobParameters;
5+
import org.springframework.batch.core.launch.JobLauncher;
6+
import org.springframework.beans.factory.annotation.Autowired;
7+
import org.springframework.stereotype.Controller;
8+
import org.springframework.web.bind.annotation.RequestMapping;
9+
10+
@Controller
11+
@RequestMapping("/commitRecordProcessor")
12+
public class CommitRecordProcessorController {
13+
14+
@Autowired
15+
private JobLauncher jobLauncher;
16+
17+
@Autowired
18+
private Job job;
19+
20+
@RequestMapping(params="command=start")
21+
public String startJob() throws Exception {
22+
jobLauncher.run(job, new JobParameters());
23+
return "redirect:/comettest.html";
24+
}
25+
}

src/main/java/org/springframework/web/servlet/resource/CacheManifestHttpRequestHandler.java

+19-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.Arrays;
1212
import java.util.Date;
1313
import java.util.List;
14+
import java.util.concurrent.atomic.AtomicBoolean;
1415

1516
import javax.servlet.ServletException;
1617
import javax.servlet.http.HttpServletRequest;
@@ -38,6 +39,11 @@ public class CacheManifestHttpRequestHandler extends WebContentGenerator impleme
3839

3940
private static final MediaType CONTENT_TYPE = new MediaType("text","cache-manifest", Charset.forName("UTF-8"));
4041

42+
//TODO - This is a crude way of handling Chrome's duplicate request -
43+
//could be improved later with a configurable refresh period, but since this is
44+
//intended to be a development-time setting, this might be good enough
45+
//private AtomicBoolean expired = new AtomicBoolean(true);
46+
4147
private boolean alwaysRegenerate = false;
4248

4349
private List<Resource> cachedResources;
@@ -46,6 +52,9 @@ public class CacheManifestHttpRequestHandler extends WebContentGenerator impleme
4652

4753
public CacheManifestHttpRequestHandler() {
4854
super(METHOD_GET, METHOD_HEAD);
55+
//if (alwaysRegenerate) {
56+
// setCacheSeconds(5);
57+
//}
4958
}
5059

5160
public void handleRequest(HttpServletRequest request,
@@ -73,7 +82,11 @@ protected CacheManifest getCacheManifest(HttpServletRequest request) throws IOEx
7382
//TODO - Implement handling for NETWORK and FALLBACK sections of manifest
7483
String key = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
7584
CacheManifest manifest = store.get(key);
76-
if (manifest != null && manifest.getHash().equals(getHash())) {
85+
if (manifest != null && alwaysRegenerate && (manifest.getTimestamp() + 5000L) >= new Date().getTime()) {
86+
return manifest;
87+
}
88+
String hash = getHash();
89+
if (manifest != null && manifest.getHash().equals(hash)) {
7790
return manifest;
7891
}
7992

@@ -88,8 +101,7 @@ protected CacheManifest getCacheManifest(HttpServletRequest request) throws IOEx
88101
}
89102
writer.println(NETWORK_SECTION);
90103
writer.println("*");
91-
String hash = getHash();
92-
writer.println("#SHA-1: "+getHash());
104+
writer.println("#SHA-1: "+hash);
93105
writer.flush();
94106
writer.close();
95107

@@ -148,4 +160,8 @@ public static char[] encode(byte[] bytes) {
148160
return result;
149161
}
150162
}
163+
164+
public void setAlwaysRegenerate(boolean alwaysRegenerate) {
165+
this.alwaysRegenerate = alwaysRegenerate;
166+
}
151167
}

src/main/resources/META-INF/spring/applicationContext.xml

+21
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,25 @@
6161
<bean class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean" id="entityManagerFactory">
6262
<property name="dataSource" ref="dataSource"/>
6363
</bean>
64+
65+
<bean id="batchTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
66+
<property name="dataSource" ref="dataSource" />
67+
</bean>
68+
69+
<bean id="jobRepository"
70+
class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
71+
<property name="transactionManager" ref="batchTransactionManager" />
72+
</bean>
73+
74+
<bean id="jobLauncher"
75+
class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
76+
<property name="jobRepository" ref="jobRepository" />
77+
<property name="taskExecutor">
78+
<bean class="org.springframework.core.task.SimpleAsyncTaskExecutor" />
79+
</property>
80+
</bean>
81+
82+
<import resource="integration-config.xml" />
83+
<import resource="batch-config.xml" />
84+
6485
</beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans:beans xmlns="http://www.springframework.org/schema/batch"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:beans="http://www.springframework.org/schema/beans"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
6+
http://www.springframework.org/schema/batch http://www.springframework.org/schema/batch/spring-batch-2.1.xsd">
7+
8+
<job id="commitLogProcessingJob">
9+
<step id="parseCommitLog">
10+
<tasklet transaction-manager="batchTransactionManager">
11+
<chunk reader="commitRecordReader" writer="commitRecordWriter" commit-interval="1"/>
12+
</tasklet>
13+
</step>
14+
</job>
15+
16+
</beans:beans>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans:beans xmlns="http://www.springframework.org/schema/integration"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:beans="http://www.springframework.org/schema/beans"
5+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
6+
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd">
7+
8+
<publish-subscribe-channel id="commitRecordChannel" />
9+
10+
<logging-channel-adapter channel="commitRecordChannel" level="INFO" />
11+
12+
</beans:beans>

src/main/resources/log4j.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#Updated at Thu Sep 16 14:44:50 PDT 2010
22
#Thu Sep 16 14:44:50 PDT 2010
33
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4-
log4j.rootLogger=DEBUG, stdout
4+
log4j.rootLogger=info, stdout
55
log4j.appender.R.File=application.log
66
log4j.appender.R.MaxFileSize=100KB
77
log4j.appender.R.layout=org.apache.log4j.PatternLayout

0 commit comments

Comments
 (0)