Merge rome-certiorem-webapp into rome

This commit is contained in:
mishako 2016-02-13 19:04:42 +01:00
commit dffa60f62b
15 changed files with 420 additions and 0 deletions

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
/.classpath
/.project
/.settings
/target

4
README.md Normal file
View file

@ -0,0 +1,4 @@
rome-certiorem-webapp
=====================
Example project using rome-certiorem

61
pom.xml Normal file
View file

@ -0,0 +1,61 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.rometools</groupId>
<artifactId>rome-parent</artifactId>
<version>1.6.0-SNAPSHOT</version>
</parent>
<artifactId>rome-certiorem-webapp</artifactId>
<packaging>war</packaging>
<name>rome-certiorem-webapp</name>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<connection>scm:git:git@github.com:rometools/rome-certiorem-webapp.git</connection>
<developerConnection>scm:git:git@github.com:rometools/rome-certiorem-webapp.git</developerConnection>
<url>https://github.com/rometools/rome-certiorem-webapp/</url>
</scm>
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.rometools</groupId>
<artifactId>rome-certiorem</artifactId>
<version>1.5.0</version>
</dependency>
<dependency>
<groupId>com.google.inject.extensions</groupId>
<artifactId>guice-servlet</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,27 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rometools.certiorem.webapp;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.rometools.certiorem.hub.Hub;
import com.rometools.certiorem.web.AbstractHubServlet;
/**
*
* @author robert.cooper
*/
@Singleton
public class HubServlet extends AbstractHubServlet {
private static final long serialVersionUID = 1L;
@Inject
public HubServlet(final Hub hub) {
super(hub);
}
}

View file

@ -0,0 +1,42 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rometools.certiorem.webapp;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Singleton;
import com.rometools.certiorem.pub.NotificationException;
import com.rometools.certiorem.pub.Publisher;
/**
*
* @author robert.cooper
*/
@Singleton
public class NotifyTest extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(NotifyTest.class);
@Override
public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws ServletException {
final Publisher pub = new Publisher();
try {
pub.sendUpdateNotification("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml");
} catch (final NotificationException ex) {
LOG.error(null, ex);
throw new ServletException(ex);
}
}
}

View file

@ -0,0 +1,71 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rometools.certiorem.webapp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Provides;
import com.google.inject.Singleton;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;
import com.rometools.certiorem.hub.Hub;
import com.rometools.certiorem.hub.data.ram.InMemoryHubDAO;
import com.rometools.certiorem.hub.notify.standard.UnthreadedNotifier;
import com.rometools.certiorem.hub.verify.standard.UnthreadedVerifier;
import com.rometools.certiorem.sub.Subscriptions;
import com.rometools.certiorem.sub.data.ram.InMemorySubDAO;
import com.rometools.certiorem.sub.request.AsyncRequester;
import com.rometools.fetcher.FeedFetcher;
import com.rometools.fetcher.impl.HashMapFeedInfoCache;
import com.rometools.fetcher.impl.HttpURLFeedFetcher;
/**
*
* @author robert.cooper
*/
public class ServerModule extends GuiceServletContextListener {
private static final Logger LOG = LoggerFactory.getLogger(ServerModule.class);
@Override
protected Injector getInjector() {
return Guice.createInjector(new AbstractModule() {
@Override
protected void configure() {
}
@Provides
@Singleton
public Hub buildHub() {
final FeedFetcher fetcher = new HttpURLFeedFetcher(new HashMapFeedInfoCache());
final Hub hub = new Hub(new InMemoryHubDAO(), new UnthreadedVerifier(), new UnthreadedNotifier(), fetcher);
return hub;
}
@Provides
@Singleton
public Subscriptions buildSubs() {
LOG.debug("buildSubs");
final Subscriptions subs = new Subscriptions(new HashMapFeedInfoCache(), new AsyncRequester(), "http://localhost/webapp/subscriptions/",
new InMemorySubDAO());
return subs;
}
}, new ServletModule() {
@Override
protected void configureServlets() {
serve("/hub*").with(HubServlet.class);
serve("/subscriptions/*").with(SubServlet.class);
serve("/test/sub").with(SubTest.class);
serve("/test/pub").with(NotifyTest.class);
}
});
}
}

View file

@ -0,0 +1,27 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rometools.certiorem.webapp;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.rometools.certiorem.sub.Subscriptions;
import com.rometools.certiorem.web.AbstractSubServlet;
/**
*
* @author robert.cooper
*/
@Singleton
public class SubServlet extends AbstractSubServlet {
private static final long serialVersionUID = 1L;
@Inject
public SubServlet(final Subscriptions subscriptions) {
super(subscriptions);
}
}

View file

@ -0,0 +1,67 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.rometools.certiorem.webapp;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.rometools.certiorem.sub.Subscriptions;
import com.rometools.certiorem.sub.data.Subscription;
import com.rometools.certiorem.sub.data.SubscriptionCallback;
import com.rometools.fetcher.impl.SyndFeedInfo;
/**
*
* @author robert.cooper
*/
@Singleton
public class SubTest extends HttpServlet {
private static final Logger LOG = LoggerFactory.getLogger(SubTest.class);
private static final long serialVersionUID = 1L;
private final Subscriptions subs;
@Inject
public SubTest(final Subscriptions subs) {
this.subs = subs;
}
@Override
public void doGet(final HttpServletRequest request, final HttpServletResponse response) {
subs.subscribe("http://localhost/webapp/hub", "http://localhost/webapp/research-atom.xml", true, -1L, null, new SubscriptionCallback() {
@Override
public void onFailure(final Exception e) {
e.printStackTrace();
}
@Override
public void onSubscribe(final Subscription subscribed) {
LOG.debug("Subscribed {} {}", subscribed.getId(), subscribed.getSourceUrl());
}
@Override
public void onNotify(final Subscription subscribed, final SyndFeedInfo feedInfo) {
// TODO Auto-generated method stub
}
@Override
public void onUnsubscribe(final Subscription subscribed) {
// TODO Auto-generated method stub
}
});
}
}

1
src/main/resources/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
# needed to commit empty folder

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
<sun-web-app error-url="">
<context-root>/webapp</context-root>
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</sun-web-app>

View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>rome-certiorem-webapp</display-name>
<session-config>
<session-timeout>30</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>guiceFilter</filter-name>
<filter-class>com.google.inject.servlet.GuiceFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>guiceFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<display-name>Guice config</display-name>
<listener-class>com.rometools.certiorem.example.ServerModule</listener-class>
</listener>
</web-app>

13
src/main/webapp/index.jsp Normal file
View file

@ -0,0 +1,13 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
</body>
</html>

View file

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" ?>
<feed version="0.3" xmlns="http://purl.org/atom/ns#"
xmlns:g="http://base.google.com/ns/1.0">
<title>The name of your feed</title>
<link href="The URL to the HTML website"
rel="alternate" type="text/html"/>
<modified>2003-12-13T18:30:02Z</modified>
<author>
<name>The name of the author</name>
</author>
<entry>
<title>Analysis of tsunami on the economy</title>
<summary>Analysis of the recent tsumani on the economy</summary>
<link rel="alternate" type="text/html"
href="http://provider-website.com/item1-info-page.html"/>
<id>tag:providers-website-item1.com,2003:3.2397</id>
<issued>2003-12-13T08:29:29-04:00</issued>
<modified>2003-12-13T18:30:02Z</modified>
<g:image_link>http://www.providers-website.com/image1.jpg</g:image_link>
<g:expiration_date>2005-12-20</g:expiration_date>
<g:label>Economy</g:label>
<g:label>Tsunami</g:label>
<g:publish_date>2005-02-25</g:publish_date>
<g:author>James Smith</g:author>
<g:publication_name>Tsunami and the Economy</g:publication_name>
<g:publication_volume>III</g:publication_volume>
<g:pages>5</g:pages>
</entry>
<entry>
<title>Google and the internet</title>
<summary>Analysis of Google's impact on the internet</summary>
<link rel="alternate" type="text/html"
href="http://provider-website.com/item2-info-page.html"/>
<id>tag:providers-website-item1.com,2003:3.2397</id>
<issued>2003-12-13T08:29:29-04:00</issued>
<modified>2003-12-13T18:30:02Z</modified>
<g:image_link>http://www.providers-website.com/image2.jpg</g:image_link>
<g:expiration_date>2005-12-20</g:expiration_date>
<g:label>Internet</g:label>
<g:label>Search Engine</g:label>
<g:publish_date>2004-01-29</g:publish_date>
<g:author>Sue Smith</g:author>
<g:publication_name>Google and the Internet</g:publication_name>
<g:publication_volume>VI</g:publication_volume>
<g:pages>23</g:pages>
</entry>
</feed>

1
src/test/java/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
# needed to commit empty folder

1
src/test/resources/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
# needed to commit empty folder