From ebc1e2d05b2152a680ea037bd0918e0e904eb2b3 Mon Sep 17 00:00:00 2001 From: Imran M Yousuf Date: Fri, 24 Apr 2009 11:48:34 +0600 Subject: [PATCH] Refactor smart-rs API into 2 modules Smart-RS will now be concerned with JAX-RS related functionalities only. The newly introduced Smart-ExIm will be concerned with export and import of resources with respect to their URIs. It is independent of JAX-RS or any other RESTful framework for that matter. Smart ExIm will be broken down into API, which will contain the common code base and ExIm provider modules concerned with specific media type export and import. Also updated Jersey version to the stable one. Also fixed the site page title of a HTML page. Signed-off-by: Imran M Yousuf --- pom.xml | 3 +- smart-exim/pom.xml | 46 +++++++++++++++++++ {smart-rs => smart-exim/smart-exim-api}/pom.xml | 51 +++++----------------- .../smartitengineering/exim/AssociationConfig.java | 0 .../exim/EximResourceConfig.java | 0 .../java/com/smartitengineering/exim/Exporter.java | 3 +- .../java/com/smartitengineering/exim/Importer.java | 3 +- .../exim/impl/AssociationConfigImpl.java | 0 .../exim/impl/EximResourceConfigImpl.java | 0 .../smart-exim-api}/src/site/site.xml | 4 +- .../java/com/smartitengineering/exim/AppTest.java | 38 ++++++++++++++++ {smart-version => smart-exim}/src/site/site.xml | 0 smart-rs/pom.xml | 9 +--- .../com/smartitengineering/rs/SmartProvider.java | 10 ++++- .../smartitengineering/rs/SmartProviderTest.java | 12 ++--- smart-version/src/site/site.xml | 2 +- 16 files changed, 116 insertions(+), 65 deletions(-) create mode 100644 smart-exim/pom.xml copy {smart-rs => smart-exim/smart-exim-api}/pom.xml (61%) rename {smart-rs => smart-exim/smart-exim-api}/src/main/java/com/smartitengineering/exim/AssociationConfig.java (100%) rename {smart-rs => smart-exim/smart-exim-api}/src/main/java/com/smartitengineering/exim/EximResourceConfig.java (100%) rename {smart-rs => smart-exim/smart-exim-api}/src/main/java/com/smartitengineering/exim/Exporter.java (98%) rename {smart-rs => smart-exim/smart-exim-api}/src/main/java/com/smartitengineering/exim/Importer.java (98%) rename {smart-rs => smart-exim/smart-exim-api}/src/main/java/com/smartitengineering/exim/impl/AssociationConfigImpl.java (100%) rename {smart-rs => smart-exim/smart-exim-api}/src/main/java/com/smartitengineering/exim/impl/EximResourceConfigImpl.java (100%) copy {smart-version => smart-exim/smart-exim-api}/src/site/site.xml (94%) create mode 100644 smart-exim/smart-exim-api/src/test/java/com/smartitengineering/exim/AppTest.java copy {smart-version => smart-exim}/src/site/site.xml (100%) diff --git a/pom.xml b/pom.xml index 3a0c566..a7d94ed 100644 --- a/pom.xml +++ b/pom.xml @@ -421,13 +421,14 @@ smart-dao-queryparam smart-rs docs + smart-exim 2.3 0.2-SNAPSHOT 0.4-SNAPSHOT 1.3-SNAPSHOT - 1.0.3-SNAPSHOT + 1.0.3 2.2-SNAPSHOT 1.5.6 3.1 diff --git a/smart-exim/pom.xml b/smart-exim/pom.xml new file mode 100644 index 0000000..bad4760 --- /dev/null +++ b/smart-exim/pom.xml @@ -0,0 +1,46 @@ + + + + + smart-dao + com.smartitengineering + 0.4-SNAPSHOT + + 4.0.0 + com.smartitengineering + smart-exim + smart-exim + pom + 0.4-SNAPSHOT + + + + org.apache.maven.plugins + maven-assembly-plugin + ${assembly.version} + + + + + smart-exim-api + + diff --git a/smart-rs/pom.xml b/smart-exim/smart-exim-api/pom.xml similarity index 61% copy from smart-rs/pom.xml copy to smart-exim/smart-exim-api/pom.xml index a8167a4..03165a5 100644 --- a/smart-rs/pom.xml +++ b/smart-exim/smart-exim-api/pom.xml @@ -17,26 +17,19 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * --> - + - smart-dao + smart-exim com.smartitengineering 0.4-SNAPSHOT 4.0.0 - com.smartitengineering - smart-rs - smart-rs + com.smartitengineering.smart-exim + smart-exim-api + smart-exim-api 0.4-SNAPSHOT - - An export/import utility for exporting and importing domain objects in - different formats. Initially the target is to support XML and JSON since - they are most widely used formats for data transfer. This module will - also implement provider for JAX-RS. - @@ -48,9 +41,10 @@ - javax.ws.rs - jsr311-api - ${jaxrs.version} + junit + junit + ${junit.version} + test com.smartitengineering @@ -62,30 +56,5 @@ dom4j ${dom4j.version} - - com.sun.jersey - jersey-server - ${jersey.version} - test - - - junit - junit - ${junit.version} - test - - - org.jmock - jmock - ${jmock.version} - test - - - org.jmock - jmock-junit3 - ${jmock.version} - test - - diff --git a/smart-rs/src/main/java/com/smartitengineering/exim/AssociationConfig.java b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/AssociationConfig.java similarity index 100% rename from smart-rs/src/main/java/com/smartitengineering/exim/AssociationConfig.java rename to smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/AssociationConfig.java diff --git a/smart-rs/src/main/java/com/smartitengineering/exim/EximResourceConfig.java b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/EximResourceConfig.java similarity index 100% rename from smart-rs/src/main/java/com/smartitengineering/exim/EximResourceConfig.java rename to smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/EximResourceConfig.java diff --git a/smart-rs/src/main/java/com/smartitengineering/exim/Exporter.java b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/Exporter.java similarity index 98% rename from smart-rs/src/main/java/com/smartitengineering/exim/Exporter.java rename to smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/Exporter.java index 228e920..75baadc 100644 --- a/smart-rs/src/main/java/com/smartitengineering/exim/Exporter.java +++ b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/Exporter.java @@ -24,7 +24,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.List; import java.util.Map; -import javax.ws.rs.core.MediaType; /** * This API provides SPIs to use it to export objects to a stream of media type @@ -88,5 +87,5 @@ public interface Exporter { * Provides the {@link MediaType} that is supported by this exporter. * @return The supported media type */ - MediaType getMediaType(); + String getMediaType(); } diff --git a/smart-rs/src/main/java/com/smartitengineering/exim/Importer.java b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/Importer.java similarity index 98% rename from smart-rs/src/main/java/com/smartitengineering/exim/Importer.java rename to smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/Importer.java index 35f7760..d205a65 100644 --- a/smart-rs/src/main/java/com/smartitengineering/exim/Importer.java +++ b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/Importer.java @@ -24,7 +24,6 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.List; import java.util.Map; -import javax.ws.rs.core.MediaType; /** * This API provides SPIs to use it to import objects from stream of media type @@ -73,5 +72,5 @@ public interface Importer { * Provides the {@link MediaType} that is supported by this importer. * @return The supported media type */ - MediaType getMediaType(); + String getMediaType(); } diff --git a/smart-rs/src/main/java/com/smartitengineering/exim/impl/AssociationConfigImpl.java b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/impl/AssociationConfigImpl.java similarity index 100% rename from smart-rs/src/main/java/com/smartitengineering/exim/impl/AssociationConfigImpl.java rename to smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/impl/AssociationConfigImpl.java diff --git a/smart-rs/src/main/java/com/smartitengineering/exim/impl/EximResourceConfigImpl.java b/smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/impl/EximResourceConfigImpl.java similarity index 100% rename from smart-rs/src/main/java/com/smartitengineering/exim/impl/EximResourceConfigImpl.java rename to smart-exim/smart-exim-api/src/main/java/com/smartitengineering/exim/impl/EximResourceConfigImpl.java diff --git a/smart-version/src/site/site.xml b/smart-exim/smart-exim-api/src/site/site.xml similarity index 94% copy from smart-version/src/site/site.xml copy to smart-exim/smart-exim-api/src/site/site.xml index e00de94..ed9f503 100644 --- a/smart-version/src/site/site.xml +++ b/smart-exim/smart-exim-api/src/site/site.xml @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --> - + @@ -28,8 +28,6 @@ - - diff --git a/smart-exim/smart-exim-api/src/test/java/com/smartitengineering/exim/AppTest.java b/smart-exim/smart-exim-api/src/test/java/com/smartitengineering/exim/AppTest.java new file mode 100644 index 0000000..a7be6b3 --- /dev/null +++ b/smart-exim/smart-exim-api/src/test/java/com/smartitengineering/exim/AppTest.java @@ -0,0 +1,38 @@ +package com.smartitengineering.exim; + +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + +/** + * Unit test for simple App. + */ +public class AppTest + extends TestCase +{ + /** + * Create the test case + * + * @param testName name of the test case + */ + public AppTest( String testName ) + { + super( testName ); + } + + /** + * @return the suite of tests being tested + */ + public static Test suite() + { + return new TestSuite( AppTest.class ); + } + + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( true ); + } +} diff --git a/smart-version/src/site/site.xml b/smart-exim/src/site/site.xml similarity index 100% copy from smart-version/src/site/site.xml copy to smart-exim/src/site/site.xml diff --git a/smart-rs/pom.xml b/smart-rs/pom.xml index a8167a4..fda4c66 100644 --- a/smart-rs/pom.xml +++ b/smart-rs/pom.xml @@ -53,16 +53,11 @@ ${jaxrs.version} - com.smartitengineering - smart-domain + com.smartitengineering.smart-exim + smart-exim-api ${project.version} - dom4j - dom4j - ${dom4j.version} - - com.sun.jersey jersey-server ${jersey.version} diff --git a/smart-rs/src/main/java/com/smartitengineering/rs/SmartProvider.java b/smart-rs/src/main/java/com/smartitengineering/rs/SmartProvider.java index 13ee2b1..16d1158 100644 --- a/smart-rs/src/main/java/com/smartitengineering/rs/SmartProvider.java +++ b/smart-rs/src/main/java/com/smartitengineering/rs/SmartProvider.java @@ -170,14 +170,20 @@ public class SmartProvider if (exporter == null || exporter.getMediaType() == null) { return; } - getExporters().put(exporter.getMediaType(), exporter); + String mediaTypeStr = exporter.getMediaType(); + String[] types = mediaTypeStr.split("/"); + MediaType mediaType = new MediaType(types[0], types[1]); + getExporters().put(mediaType, exporter); } public void setImporter(Importer importer) { if (importer == null || importer.getMediaType() == null) { return; } - getImporters().put(importer.getMediaType(), importer); + String mediaTypeStr = importer.getMediaType(); + String[] types = mediaTypeStr.split("/"); + MediaType mediaType = new MediaType(types[0], types[1]); + getImporters().put(mediaType, importer); } public Map getExporters() { diff --git a/smart-rs/src/test/java/com/smartitengineering/rs/SmartProviderTest.java b/smart-rs/src/test/java/com/smartitengineering/rs/SmartProviderTest.java index 8f1e486..72026d6 100644 --- a/smart-rs/src/test/java/com/smartitengineering/rs/SmartProviderTest.java +++ b/smart-rs/src/test/java/com/smartitengineering/rs/SmartProviderTest.java @@ -80,7 +80,7 @@ public class SmartProviderTest exactly(1).of(mockExporter).getMediaType(); will(returnValue(null)); exactly(2).of(mockExporter).getMediaType(); - will(returnValue(MediaType.APPLICATION_XML_TYPE)); + will(returnValue(MediaType.APPLICATION_XML_TYPE.toString())); } }); smartProvider.setExporter(mockExporter); @@ -95,7 +95,7 @@ public class SmartProviderTest exactly(1).of(mockImporter).getMediaType(); will(returnValue(null)); exactly(2).of(mockImporter).getMediaType(); - will(returnValue(MediaType.APPLICATION_XML_TYPE)); + will(returnValue(MediaType.APPLICATION_XML_TYPE.toString())); } }); smartProvider.setImporter(mockImporter); @@ -112,7 +112,7 @@ public class SmartProviderTest { exactly(2).of(mockExporter).getMediaType(); - will(returnValue(MediaType.APPLICATION_JSON_TYPE)); + will(returnValue(MediaType.APPLICATION_JSON_TYPE.toString())); } }); smartProvider.setExporter(mockExporter); @@ -215,7 +215,7 @@ public class SmartProviderTest { exactly(2).of( mockImporter).getMediaType(); - will(returnValue(MediaType.APPLICATION_JSON_TYPE)); + will(returnValue(MediaType.APPLICATION_JSON_TYPE.toString())); } }); smartProvider.setImporter(mockImporter); @@ -296,9 +296,9 @@ public class SmartProviderTest { exactly(2).of( mockExporter).getMediaType(); - will(returnValue(MediaType.APPLICATION_XML_TYPE)); + will(returnValue(MediaType.APPLICATION_XML_TYPE.toString())); exactly(2).of(mockImporter).getMediaType(); - will(returnValue(MediaType.APPLICATION_XML_TYPE)); + will(returnValue(MediaType.APPLICATION_XML_TYPE.toString())); } }); smartProvider.setExporter(mockExporter); diff --git a/smart-version/src/site/site.xml b/smart-version/src/site/site.xml index e00de94..b02567c 100644 --- a/smart-version/src/site/site.xml +++ b/smart-version/src/site/site.xml @@ -20,7 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA --> - + -- 2.11.4.GIT