]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1610] Use Jackson as jaxrs provider for cxf for performance reasons.
authorOlivier Lamy <olamy@apache.org>
Thu, 1 Mar 2012 10:28:16 +0000 (10:28 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 1 Mar 2012 10:28:16 +0000 (10:28 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295496 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/pom.xml
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-api/src/main/java/org/apache/archiva/admin/model/beans/LegacyArtifactPath.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/ArchivaRestError.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/AbstractArchivaRestTest.java
pom.xml

index 2b261a5888a65865f4b9a588063b793f755850f1..06a0cb752e7958b69a06a1ef2046286f2beddc0a 100644 (file)
       <groupId>javax.xml.bind</groupId>
       <artifactId>jaxb-api</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-core-asl</artifactId>
+    </dependency>
     <dependency>
       <groupId>commons-collections</groupId>
       <artifactId>commons-collections</artifactId>
               org.apache.commons.collections;version="[3.2,4)",
               org.apache.commons.lang;version="[2.4,3)",
               org.codehaus.plexus.redback.users,
-              org.apache.maven.index.context;resolution:=optional
+              org.apache.maven.index.context;resolution:=optional,
+              org.codehaus.jackson.annotate
             </Import-Package>
           </instructions>
         </configuration>
index 1f4abdca8671ca22b78d49a9352e6c87542cd5b2..4b34741fb92a95a7d206e8bab58d24e7e186b7b6 100644 (file)
@@ -18,6 +18,9 @@ package org.apache.archiva.admin.model.beans;
  * under the License.
  */
 
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+
 import javax.xml.bind.annotation.XmlRootElement;
 import java.io.Serializable;
 
@@ -76,27 +79,32 @@ public class LegacyArtifactPath
         return path.equals( this.path );
     }
 
+    @JsonIgnore
     public String getGroupId()
     {
         return artifact.split( ":" )[0];
     }
 
+    @JsonIgnore
     public String getArtifactId()
     {
         return artifact.split( ":" )[1];
     }
 
+    @JsonIgnore
     public String getVersion()
     {
         return artifact.split( ":" )[2];
     }
 
+    @JsonIgnore
     public String getClassifier()
     {
         String classifier = artifact.split( ":" )[3];
         return classifier.length() > 0 ? classifier : null;
     }
 
+    @JsonIgnore
     public String getType()
     {
         return artifact.split( ":" )[4];
index 889ac242c290c2575f1196f6caf27ce2b009bb83..a89ea690901f4099c4d1ffdf94c944ca87ce05cc 100644 (file)
           </exclusion>
         </exclusions>
     </dependency>
-    <!--
     <dependency>
       <groupId>org.codehaus.jackson</groupId>
       <artifactId>jackson-jaxrs</artifactId>
     </dependency>
-    -->
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-xc</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.jackson</groupId>
+      <artifactId>jackson-core-asl</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.apache.cxf</groupId>
       <artifactId>cxf-bundle-jaxrs</artifactId>
           <groupId>org.eclipse.jetty</groupId>
           <artifactId>jetty-server</artifactId>
         </exclusion>
+        <exclusion>
+          <groupId>org.codehaus.jettison</groupId>
+          <artifactId>jettison</artifactId>
+        </exclusion>
       </exclusions>
     </dependency>
     <dependency>
index bdfd314ac971bcd9ac5ef26f3f637aae325f322d..100340fa99fe4d29e738a9b37062212fd172a00c 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.archiva.rest.services;
  */
 
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
 
 import javax.xml.bind.annotation.XmlRootElement;
 
index b0aace80812d0c7ec7d2d92d7d0bed8b366f8fb3..1342487ae664c5b40e9f9937d8bd3edbe11e4719 100644 (file)
   <context:annotation-config/>
   <context:component-scan
       base-package="org.apache.archiva.rest.services"/>
-  <!-- convertTypesToStrings -->
 
-  <bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.JSONProvider">
-    <!-- without that String 2.0 are transformed to 2 which is not correct for versions -->
-    <!-- side effect json boolean are string rather than boolean -->
-    <property name="convertTypesToStrings" value="true"/>
-    <!--property name="serializeAsArray" value="true"/--> 
-
-  </bean>
 
   <jaxrs:server id="archivaServices" address="/archivaServices">
 
     <jaxrs:providers>
-      <ref bean="jsonProvider"/>
-      <!--
       <bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
-      -->
+
       <ref bean="authenticationInterceptor#rest"/>
       <ref bean="permissionInterceptor#rest"/>
       <ref bean="archivaRestServiceExceptionMapper"/>
index 880492246eb74e062732ecbfe3553e1de549dc6d..8c78f5ddeb3425fd3bbd92f0dbe5690aa18c7903 100644 (file)
@@ -36,11 +36,13 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.cxf.jaxrs.client.JAXRSClientFactory;
 import org.apache.cxf.jaxrs.client.WebClient;
+import org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider;
 import org.codehaus.redback.rest.services.AbstractRestServicesTest;
 import org.junit.Before;
 
 import javax.ws.rs.core.MediaType;
 import java.io.File;
+import java.util.Collections;
 import java.util.Date;
 
 /**
@@ -100,13 +102,16 @@ public abstract class AbstractArchivaRestTest
     {
         RepositoriesService service =
             JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                       RepositoriesService.class );
+                                       RepositoriesService.class,
+                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
         if ( authzHeader != null )
         {
             WebClient.client( service ).header( "Authorization", authzHeader );
         }
         WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
+        WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
+        WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
         return service;
 
     }
@@ -115,13 +120,16 @@ public abstract class AbstractArchivaRestTest
     {
         ManagedRepositoriesService service =
             JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                       ManagedRepositoriesService.class );
+                                       ManagedRepositoriesService.class,
+                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
         if ( authzHeader != null )
         {
             WebClient.client( service ).header( "Authorization", authzHeader );
         }
         WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
+        WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
+        WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
         return service;
 
     }
@@ -129,13 +137,15 @@ public abstract class AbstractArchivaRestTest
     protected PingService getPingService()
     {
         return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                          PingService.class );
+                                          PingService.class,
+                                          Collections.singletonList( new JacksonJaxbJsonProvider() ) );
     }
 
     protected RemoteRepositoriesService getRemoteRepositoriesService()
     {
         return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                          RemoteRepositoriesService.class );
+                                          RemoteRepositoriesService.class,
+                                          Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
 
     }
@@ -143,17 +153,21 @@ public abstract class AbstractArchivaRestTest
     protected RepositoryGroupService getRepositoryGroupService()
     {
         return JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                          RepositoryGroupService.class );
+                                          RepositoryGroupService.class,
+                                          Collections.singletonList( new JacksonJaxbJsonProvider() ) );
     }
 
     protected ProxyConnectorService getProxyConnectorService()
     {
         ProxyConnectorService service =
             JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                       ProxyConnectorService.class );
+                                       ProxyConnectorService.class,
+                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
         WebClient.client( service ).header( "Authorization", authorizationHeader );
         WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
+        WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
+        WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
         return service;
     }
 
@@ -161,10 +175,13 @@ public abstract class AbstractArchivaRestTest
     {
         NetworkProxyService service =
             JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                       NetworkProxyService.class );
+                                       NetworkProxyService.class,
+                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
         WebClient.client( service ).header( "Authorization", authorizationHeader );
         WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 300000 );
+        WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
+        WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
         return service;
     }
 
@@ -172,7 +189,8 @@ public abstract class AbstractArchivaRestTest
     {
         ArchivaAdministrationService service =
             JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                       ArchivaAdministrationService.class );
+                                       ArchivaAdministrationService.class,
+                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
         WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
         WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
@@ -187,13 +205,16 @@ public abstract class AbstractArchivaRestTest
         // START SNIPPET: cxf-searchservice-creation
         SearchService service =
             JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                       SearchService.class );
+                                       SearchService.class,
+                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
         if ( authzHeader != null )
         {
             WebClient.client( service ).header( "Authorization", authzHeader );
         }
         WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
+        WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
+        WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
         return service;
         // END SNIPPET: cxf-searchservice-creation
 
@@ -203,13 +224,16 @@ public abstract class AbstractArchivaRestTest
     {
         CommonServices service =
             JAXRSClientFactory.create( getBaseUrl() + "/" + getRestServicesPath() + "/archivaServices/",
-                                       CommonServices.class );
+                                       CommonServices.class,
+                                       Collections.singletonList( new JacksonJaxbJsonProvider() ) );
 
         if ( authzHeader != null )
         {
             WebClient.client( service ).header( "Authorization", authzHeader );
         }
         WebClient.getConfig( service ).getHttpConduit().getClient().setReceiveTimeout( 100000000 );
+        WebClient.client( service ).accept( MediaType.APPLICATION_JSON_TYPE );
+        WebClient.client( service ).type( MediaType.APPLICATION_JSON_TYPE );
         return service;
     }
 
diff --git a/pom.xml b/pom.xml
index 8f508a36bd28e022e5b37b31b7c5b619fb1842c1..0af8fc5beddbbed07408386ae972f351ad44e9f1 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -93,6 +93,7 @@
     <httpclient.core.version>4.1.4</httpclient.core.version>
     <javaxMailVersion>1.4</javaxMailVersion>
     <jettyVersion>7.4.5.v20110725</jettyVersion>
+    <jacksonVersion>1.9.5</jacksonVersion>
     <!-- restore when we will be able to use a derby in memory database -->
     <redbackTestJdbcUrl>jdbc:derby:memory:users-test;create=true</redbackTestJdbcUrl>
     <redbackTestJdbcDriver>org.apache.derby.jdbc.EmbeddedDriver</redbackTestJdbcDriver>
       <dependency>
         <groupId>org.codehaus.jackson</groupId>
         <artifactId>jackson-jaxrs</artifactId>
-        <version>1.9.5</version>
+        <version>${jacksonVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.jackson</groupId>
+        <artifactId>jackson-xc</artifactId>
+        <version>${jacksonVersion}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.codehaus.jackson</groupId>
+        <artifactId>jackson-core-asl</artifactId>
+        <version>${jacksonVersion}</version>
       </dependency>
       <dependency>
         <groupId>org.apache.cxf</groupId>
             <groupId>commons-logging</groupId>
             <artifactId>commons-logging</artifactId>
           </exclusion>
+          <exclusion>
+            <groupId>org.codehaus.jettison</groupId>
+            <artifactId>jettison</artifactId>
+          </exclusion>
         </exclusions>
       </dependency>