Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhrobbins committed Jan 28, 2014
1 parent f4bd3ad commit 1dcbb5f
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 4 deletions.
4 changes: 0 additions & 4 deletions FlashCards_WebServices/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@
<war>../FlashCards_GWT/target/FlashCards_GwtClient.war</war>
<contextPath>/gwt</contextPath>
</contextHandler>
<contextHandler implementation="org.eclipse.jetty.webapp.WebAppContext">
<war>../FlashCards_Struts/target/FlashCards_Struts.war</war>
<contextPath>/struts</contextPath>
</contextHandler>
</contextHandlers>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.IOException;
import java.util.List;
import java.util.Properties;

import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;

Expand All @@ -22,6 +26,8 @@
import org.robbins.flashcards.webservices.exceptions.GenericWebServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.dao.InvalidDataAccessApiUsageException;

import com.sun.jersey.api.JResponse;
Expand All @@ -34,6 +40,7 @@ public abstract class AbstractGenericResource<T, Serializable> extends AbstractR

protected abstract GenericCrudFacade<T> getFacade();


@GET
@ApiOperation(value = "List")
@Override
Expand Down Expand Up @@ -198,4 +205,33 @@ private void merge(T source, T target) {
}
}
}

@Override
@GET
@Path("/status")
@Produces("text/plain")
@Consumes("text/plain")
@ApiOperation(value = "Status")
public String status() {
String version = getClass().getPackage().getImplementationVersion();
if (version == null) {
try {
Resource resource = getContext().getResource("/META-INF/MANIFEST.MF");
Properties prop = PropertiesLoaderUtils.loadProperties(resource);
version = prop.getProperty("Implementation-Version");
if (null == version) {
throw new GenericWebServiceException(
Response.Status.INTERNAL_SERVER_ERROR,
"Unable to determine status");
}
LOGGER.debug("Version: " + version);
} catch (IOException e) {
LOGGER.error(e.toString());
throw new GenericWebServiceException(
Response.Status.INTERNAL_SERVER_ERROR,
"Unable to determine status", e);
}
}
return version;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,24 @@
import java.util.Set;
import java.util.StringTokenizer;

import javax.inject.Inject;

import org.apache.cxf.common.util.StringUtils;
import org.springframework.context.ApplicationContext;

public abstract class AbstractResource {

@Inject
private ApplicationContext context;

public ApplicationContext getContext() {
return context;
}

public void setContext(ApplicationContext context) {
this.context = context;
}

// Convert the vectorized 'fields' parameter to a Set<String>
protected Set<String> getFieldsAsSet(String fields) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,6 @@ JResponse<List<T>> list(Integer page, Integer size, String sort,
Response delete(Long id);

Response update(Long id, T updatedEntity);

String status();
}
30 changes: 30 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@
<gwt.maven.plugin.version>2.5.1</gwt.maven.plugin.version>
<maven.compiler.plugin.version>3.1</maven.compiler.plugin.version>
<maven.failsafe.plugin.version>2.14</maven.failsafe.plugin.version>
<maven.jar.plugin.version>2.4</maven.jar.plugin.version>
<maven.site.plugin.version>3.3</maven.site.plugin.version>
<maven.source.plugin.version>2.2.1</maven.source.plugin.version>
<maven.surefire.plugin.version>2.14</maven.surefire.plugin.version>
<maven.war.plugin>2.4</maven.war.plugin>
<site.maven.plugin.version>0.9</site.maven.plugin.version>
<swagger.maven.plugin.version>1.1.3-SNAPSHOT</swagger.maven.plugin.version>

Expand Down Expand Up @@ -837,6 +839,34 @@
<artifactId>maven-jxr-plugin</artifactId>
<version>${jxr.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.plugin.version}</version>
<inherited>true</inherited>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven.war.plugin}</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
</manifest>
</archive>
<archiveClasses>true</archiveClasses>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
Expand Down

0 comments on commit 1dcbb5f

Please sign in to comment.