Skip to content

Commit

Permalink
OGM-285 Using Jackson 2 annotations in CouchDB to match default provi…
Browse files Browse the repository at this point in the history
…der used in WildFly 8.1
  • Loading branch information
gunnarmorling authored and DavideD committed Jun 12, 2014
1 parent 694f423 commit 1bfe115
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 55 deletions.
16 changes: 8 additions & 8 deletions couchdb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<artifactId>resteasy-jackson2-provider</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>

<!-- Required if you use the OGM mass indexer -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
import java.util.HashMap;
import java.util.Map;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.Document;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
* Represents a CouchDB design document. Design documents are special CouchDB documents containing application logic in
* form of JavaScript, more specifically views (which apply map/reduce routines) and lists (which render other documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
import java.util.ArrayList;
import java.util.List;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.EntityDocument;
import org.hibernate.ogm.datastore.couchdb.dialect.model.impl.CouchDBTupleSnapshot;
import org.hibernate.ogm.datastore.spi.Tuple;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
* Represents the Result of the REST call associated with the {@link TuplesDesignDocument}
*
Expand Down Expand Up @@ -52,9 +53,9 @@ public EntityDocument getValue() {
return value;
}

@SuppressWarnings("unused") //invoked reflectively
void setValue(EntityDocument value) {
this.value = value;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
*/
package org.hibernate.ogm.datastore.couchdb.dialect.backend.json.designdocument.impl;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.Document;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.EntityDocument;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;

/**
* Creates a CouchDB Design Document with a view used to retrieve the entities of a given table.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonTypeName;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;

/**
* Represents an association stored as a separate CouchDB document.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
*/
package org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl;

import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonTypeInfo;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.ObjectWriter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;

/**
* Every Json document in CouchDB contains, The field '_id' representing the id of the document and '_rev' representing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@
import java.util.Map.Entry;
import java.util.regex.Pattern;

import org.codehaus.jackson.annotate.JsonAnyGetter;
import org.codehaus.jackson.annotate.JsonAnySetter;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.annotate.JsonTypeName;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.hibernate.ogm.datastore.couchdb.util.impl.Identifier;
import org.hibernate.ogm.datastore.spi.Tuple;
import org.hibernate.ogm.grid.EntityKey;

import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;

/**
* Contains the information related to a {@link Tuple}. The use of this class is to serialize and deserialize the JSON
* stored in CouchDB; Documents have the following structure:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/
package org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl;

import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

/**
* Used to serialize and deserialize a REST CouchDB response to a PUT and a DELETE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/
package org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl;

import org.codehaus.jackson.annotate.JsonTypeName;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;

/**
* Used to serialize and deserialize sequence objects.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.http.impl.client.BasicAuthCache;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.protocol.BasicHttpContext;
import org.codehaus.jackson.map.ObjectMapper;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
Expand All @@ -41,6 +40,8 @@
import org.junit.BeforeClass;
import org.junit.Test;

import com.fasterxml.jackson.databind.ObjectMapper;

/**
* Tests the access of a CouchDB database which requires authentication. The test assumes a database in the default
* configuration (i.e. without authentication enabled) and does the following preparation steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
*/
package org.hibernate.ogm.datastore.couchdb.utils.backend.json.designdocument;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.designdocument.impl.DesignDocument;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.AssociationDocument;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.Document;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.EntityDocument;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;

/**
* Creates a CouchDB Design Document with a view and list used to retrieve the number of associations stored in the
* database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
*/
package org.hibernate.ogm.datastore.couchdb.utils.backend.json.designdocument;

import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.designdocument.impl.DesignDocument;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.Document;
import org.hibernate.ogm.datastore.couchdb.dialect.backend.json.impl.EntityDocument;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;

/**
* Creates a CouchDB Design Document with a view and list used to retrieve the number of entities stored in the
* database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class CouchDBModuleMemberRegistrationIT extends ModuleMemberRegistrationS
public static Archive<?> createTestArchive() {
return new ModuleMemberRegistrationDeployment.Builder( CouchDBModuleMemberRegistrationIT.class )
.persistenceXml( persistenceXml() )
.manifestDependencies( "org.hibernate:ogm services, org.hibernate.ogm.couchdb services" )
.addAsWebInfResource( "jboss-deployment-structure.xml" )
.createDeployment();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Hibernate OGM, Domain model persistence for NoSQL datastores
~
~ License: GNU Lesser General Public License (LGPL), version 2.1 or later
~ See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
-->
<jboss-deployment-structure
xmlns="urn:jboss:deployment-structure:1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<deployment>
<dependencies>
<module name="org.hibernate" slot="ogm" services="export" />
<module name="org.hibernate.ogm.couchdb" slot="main" services="export" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" services="import"/>
</dependencies>
<exclusions>
<!-- Use Jackson 2 provider; Implicitly the case on WF 8.1 but it's required for EAP 6.x -->
<module name="org.jboss.resteasy.resteasy-jackson-provider"/>
</exclusions>
</deployment>
</jboss-deployment-structure>
2 changes: 1 addition & 1 deletion modules/wildfly/src/main/modules/ogm/couchdb/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<module name="org.hibernate" export="true" services="import" slot="${hibernate.ogm.module.slot}" />
<module name="javax.ws.rs.api" />
<module name="javax.persistence.api" />
<module name="org.jboss.resteasy.resteasy-jackson-provider" />
<module name="org.jboss.resteasy.resteasy-jackson2-provider" />
<module name="org.jboss.resteasy.resteasy-jaxrs" />
<module name="org.jboss.logging" />
</dependencies>
Expand Down
22 changes: 6 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
<shrinkwrapVersion>1.1.1</shrinkwrapVersion>
<slf4jVersion>1.7.5</slf4jVersion>
<resteasyVersion>3.0.6.Final</resteasyVersion>
<jacksonVersion>1.9.13</jacksonVersion>
<jacksonVersion>2.2.1</jacksonVersion>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--
Following is the default jgroups mcast address. If you find the testsuite runs very slowly, there
Expand Down Expand Up @@ -382,7 +382,7 @@
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>${resteasyVersion}</version>
</dependency>
<dependency>
Expand Down Expand Up @@ -414,23 +414,13 @@
</dependency>

<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jacksonVersion}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jacksonVersion}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>${jacksonVersion}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jacksonVersion}</version>
</dependency>

Expand Down
5 changes: 5 additions & 0 deletions src/main/build-config/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@
<module name="WhitespaceAfter">
<property name="tokens" value="TYPECAST" />
</module>

<module name="IllegalImport">
<!-- Making sure Jackson 1.x is not used; Jackson 2.x should be used instead-->
<property name="illegalPkgs" value="org.codehaus.jackson"/>
</module>
</module>

<!-- We are not using NewLineAtEndOfFile because the new line chars change
Expand Down

0 comments on commit 1bfe115

Please sign in to comment.