From dd4251cdfa1a01ce1e5365b0f25a2429788c4309 Mon Sep 17 00:00:00 2001 From: Tor-Einar Skog <tor-einar.skog@bioforsk.no> Date: Fri, 21 Nov 2014 09:17:28 +0100 Subject: [PATCH] Adaptation to separating out the models. Cleaning up dependency mess --- pom.xml | 27 +++++++++---- .../vips/core/VIPSCoreApplication.java | 3 +- .../vips/core/service/ModelResourceImpl.java | 40 ++++++++++--------- .../vips/model/factory/ModelFactory.java | 1 - .../WEB-INF/jboss-deployment-structure.xml | 29 ++++++++++++++ 5 files changed, 73 insertions(+), 27 deletions(-) create mode 100644 src/main/webapp/WEB-INF/jboss-deployment-structure.xml diff --git a/pom.xml b/pom.xml index 6ea7869..ba8ff6d 100644 --- a/pom.xml +++ b/pom.xml @@ -26,9 +26,21 @@ <dependency> <groupId>org.jboss.resteasy</groupId> <artifactId>resteasy-jaxrs</artifactId> - <version>3.0.2.Final</version> + <version>3.0.9.Final</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-core-asl</artifactId> + <version>1.9.12</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.codehaus.jackson</groupId> + <artifactId>jackson-mapper-asl</artifactId> + <version>1.9.12</version> + <scope>provided</scope> + </dependency> <dependency> <groupId>javax.persistence</groupId> <artifactId>persistence-api</artifactId> @@ -44,20 +56,20 @@ <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> - <version>0.9.9-RC1</version> + <version>0.9.9</version> </dependency> <dependency> <groupId>no.bioforsk.vips.common</groupId> <artifactId>VIPSCommon</artifactId> <version>1.0-SNAPSHOT</version> - <!--scope>provided</scope--> + <scope>provided</scope> </dependency> <dependency> <groupId>com.thetransactioncompany</groupId> <artifactId>cors-filter</artifactId> <version>1.7.1</version> </dependency> - <dependency> + <!--dependency> <groupId>no.bioforsk.vips.model.</groupId> <artifactId>NaerstadModel</artifactId> <version>1.0-SNAPSHOT</version> @@ -74,19 +86,20 @@ </dependency> <dependency> <groupId>no.bioforsk.vips</groupId> - <artifactId>GenericPathogenPlantInfectionModel</artifactId> + <artifactId>GrassDryingModel</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>no.bioforsk.vips</groupId> - <artifactId>GrassDryingModel</artifactId> + <artifactId>GenericPathogenPlantInfectionModel</artifactId> <version>1.0-SNAPSHOT</version> - </dependency> + </dependency--> <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <type>jar</type> + <scope>provided</scope> </dependency> </dependencies> diff --git a/src/main/java/no/bioforsk/vips/core/VIPSCoreApplication.java b/src/main/java/no/bioforsk/vips/core/VIPSCoreApplication.java index 1e10216..e890e15 100644 --- a/src/main/java/no/bioforsk/vips/core/VIPSCoreApplication.java +++ b/src/main/java/no/bioforsk/vips/core/VIPSCoreApplication.java @@ -25,7 +25,7 @@ import javax.ws.rs.core.Application; /** * Responsible for adding REST resources - * @copyright 2013 {@link http://www.bioforsk.no Bioforsk} + * @copyright 2013-2014 {@link http://www.bioforsk.no Bioforsk} * @author Tor-Einar Skog <tor-einar.skog@bioforsk.no> */ @ApplicationPath("/") @@ -56,5 +56,6 @@ public class VIPSCoreApplication extends Application */ private void addRestResourceClasses(Set<Class<?>> resources) { resources.add(no.bioforsk.vips.core.config.JacksonConfig.class); + resources.add(no.bioforsk.vips.core.service.ModelResourceImpl.class); } } \ No newline at end of file diff --git a/src/main/java/no/bioforsk/vips/core/service/ModelResourceImpl.java b/src/main/java/no/bioforsk/vips/core/service/ModelResourceImpl.java index 0eed04c..03a9a37 100644 --- a/src/main/java/no/bioforsk/vips/core/service/ModelResourceImpl.java +++ b/src/main/java/no/bioforsk/vips/core/service/ModelResourceImpl.java @@ -22,7 +22,10 @@ package no.bioforsk.vips.core.service; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; +import javax.ws.rs.GET; +import javax.ws.rs.Path; import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; import no.bioforsk.vips.entity.ModelConfiguration; @@ -38,6 +41,7 @@ import no.bioforsk.vips.model.factory.ModelFactory; * @copyright 2013 {@link http://www.bioforsk.no Bioforsk} * @author Tor-Einar Skog <tor-einar.skog@bioforsk.no> */ +//@Path("") public class ModelResourceImpl implements ModelResource{ /** @@ -55,9 +59,9 @@ public class ModelResourceImpl implements ModelResource{ * Lists all models available in this instance, using default language (English) * @return list of all models available */ - //@GET - //@Path("models/json") - //@Produces("application/json;charset=UTF-8") + @GET + @Path("models/json") + @Produces("application/json;charset=UTF-8") @Override public Response printModelListJSON() { @@ -69,9 +73,9 @@ public class ModelResourceImpl implements ModelResource{ * Lists all models available in this instance, using default language (English) * @return list of all models available */ - //@GET - //@Path("models/json/{language}") - //@Produces("application/json;charset=UTF-8") + @GET + @Path("models/json/{language}") + @Produces("application/json;charset=UTF-8") @Override public Response printModelListJSON(@PathParam("language") String language) { @@ -109,9 +113,9 @@ public class ModelResourceImpl implements ModelResource{ * Lists all models available in this instance, using default language (English) * @return list of all models available */ - //@GET - //@Path("models/{language}") - //@Produces("text/plain;charset=UTF-8") + @GET + @Path("models/{language}") + @Produces("text/plain;charset=UTF-8") @Override public Response printModelList(@PathParam("language") String language) { @@ -148,9 +152,9 @@ public class ModelResourceImpl implements ModelResource{ * @param language two-letter code (<a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO-639-2</a>) * @return */ - //@GET - //@Path("models/{modelId}/usage/{language}") - //@Produces("text/plain;charset=UTF-8") + @GET + @Path("models/{modelId}/usage/{language}") + @Produces("text/plain;charset=UTF-8") @Override public Response printModelUsage(@PathParam("modelId") String modelId, @PathParam("language") String language) { @@ -164,9 +168,9 @@ public class ModelResourceImpl implements ModelResource{ * @param language two-letter code (<a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO-639-2</a>) * @return */ - //@GET - //@Path("models/{modelId}/usage") - //@Produces("text/plain;charset=UTF-8") + @GET + @Path("models/{modelId}/usage") + @Produces("text/plain;charset=UTF-8") @Override public Response printModelUsage(@PathParam("modelId") String modelId) { @@ -178,9 +182,9 @@ public class ModelResourceImpl implements ModelResource{ * @param modelId the requested model * @return */ - //@GET - //@Path("models/{modelId}/sampleconfig") - //@Produces("text/plain;charset=UTF-8") + @GET + @Path("models/{modelId}/sampleconfig") + @Produces("text/plain;charset=UTF-8") @Override public Response printModelSampleConfig(@PathParam("modelId") String modelId) { diff --git a/src/main/java/no/bioforsk/vips/model/factory/ModelFactory.java b/src/main/java/no/bioforsk/vips/model/factory/ModelFactory.java index d89b5f7..04c4bcb 100644 --- a/src/main/java/no/bioforsk/vips/model/factory/ModelFactory.java +++ b/src/main/java/no/bioforsk/vips/model/factory/ModelFactory.java @@ -143,7 +143,6 @@ public class ModelFactory { for(Class<? extends Model> subType : subTypes) { try { - Model model = subType.newInstance(); if(models.get(model.getModelId().toString()) == null) { diff --git a/src/main/webapp/WEB-INF/jboss-deployment-structure.xml b/src/main/webapp/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000..557a618 --- /dev/null +++ b/src/main/webapp/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,29 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Copyright (c) 2014 Bioforsk <http://www.bioforsk.no/>. + +This file is part of VIPSCore. +VIPSCore is free software: you can redistribute it and/or modify +it under the terms of the Bioforsk Open Source License as published by +Bioforsk, either version 1 of the License, or (at your option) any +later version. + +VIPSCore is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +Bioforsk Open Source License for more details. + +You should have received a copy of the Bioforsk Open Source License +along with VIPSCore. If not, see <http://www.bioforsk.no/licenses/>. + +--> +<jboss-deployment-structure> + <deployment> + <dependencies> + <module name="no.bioforsk.vips.modelcontainer"/> + <module name="no.bioforsk.vips.VIPSCommon" export="true"/> + <module name="org.codehaus.jackson.jackson-core-asl" /> + <module name="org.codehaus.jackson.jackson-mapper-asl" /> + </dependencies> + </deployment> +</jboss-deployment-structure> -- GitLab