[jackson-jaxrs-providers] 13/162: Create a shared package; will move things in there soon

Timo Aaltonen tjaalton at moszumanska.debian.org
Mon Sep 8 22:16:23 UTC 2014


This is an automated email from the git hooks/post-receive script.

tjaalton pushed a commit to branch master
in repository jackson-jaxrs-providers.

commit 50046066225b7c864c74532bcc040b5f4234278c
Author: Tatu Saloranta <tsaloranta at gmail.com>
Date:   Mon Feb 4 15:32:11 2013 -0800

    Create a shared package; will move things in there soon
---
 base/pom.xml                                       |  59 +++++++++++
 .../jaxrs/base}/JsonMappingExceptionMapper.java    |   4 +-
 .../jaxrs/base}/JsonParseExceptionMapper.java      |   4 +-
 .../jaxrs/base}/util/AnnotationBundleKey.java      |   4 +-
 .../jackson/jaxrs/base}/util/ClassKey.java         |   7 +-
 .../fasterxml/jackson/jaxrs/base}/util/LRUMap.java |   4 +-
 .../jackson/jaxrs/json/JacksonJsonProvider.java    |   6 +-
 .../jaxrs/json/JsonMappingExceptionMapper.java     |   4 +-
 .../jaxrs/json/JsonParseExceptionMapper.java       |   4 +-
 .../jaxrs/json/util/AnnotationBundleKey.java       | 110 ---------------------
 .../jackson/jaxrs/json/util/ClassKey.java          |  92 -----------------
 .../jaxrs/json/util/TestAnnotationBundleKey.java   |   2 +
 .../jackson/jaxrs/smile/JacksonSmileProvider.java  |   4 +-
 .../jaxrs/smile/util/AnnotationBundleKey.java      | 110 ---------------------
 .../jackson/jaxrs/smile/util/ClassKey.java         |  92 -----------------
 .../fasterxml/jackson/jaxrs/smile/util/LRUMap.java |  26 -----
 .../jackson/jaxrs/xml/JacksonXMLProvider.java      |   6 +-
 .../fasterxml/jackson/jaxrs/xml/util/LRUMap.java   |  26 -----
 18 files changed, 90 insertions(+), 474 deletions(-)

diff --git a/base/pom.xml b/base/pom.xml
new file mode 100644
index 0000000..ab265ee
--- /dev/null
+++ b/base/pom.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ |  Copyright 2012 FasterXML.com
+ |
+ |  Licensed under the Apache License, Version 2.0 (the "License");
+ |  you may not use this file except in compliance with the License.
+ |  You may obtain a copy of the License at
+ |
+ |  http://www.apache.org/licenses/LICENSE-2.0
+ |
+ |  Unless required by applicable law or agreed to in writing, software
+ |  distributed under the License is distributed on an "AS IS" BASIS,
+ |  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ |  See the License for the specific language governing permissions and
+ |  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+  <modelVersion>4.0.0</modelVersion> 
+
+  <parent>
+    <groupId>com.fasterxml.jackson.jaxrs</groupId>
+    <artifactId>jackson-jaxrs-providers</artifactId>
+    <version>2.2.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>jackson-jaxrs-base</artifactId>
+  <name>Jackson-JAXRS-base</name>
+  <description>Pile of code that is shared by all Jackson-based JAX-RS
+providers.
+  </description>
+
+  <properties>
+    <osgi.export>${project.groupId}.base.*;version=${project.version}</osgi.export>
+    <osgi.import>com.fasterxml.jackson.annotation
+,com.fasterxml.jackson.core
+,com.fasterxml.jackson.core.type
+,com.fasterxml.jackson.core.util
+,com.fasterxml.jackson.databind
+,com.fasterxml.jackson.databind.introspect
+,com.fasterxml.jackson.databind.type
+,com.fasterxml.jackson.databind.util
+</osgi.import>
+  </properties>
+
+  <dependencies>
+    <!-- Extends Jackson core, mapper -->
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-core</artifactId>
+      <version>${version.jackson.core}</version>
+    </dependency>
+    <dependency>
+      <groupId>com.fasterxml.jackson.core</groupId>
+      <artifactId>jackson-databind</artifactId>
+      <version>${version.jackson.core}</version>
+    </dependency>
+    <!-- test deps should come from parent -->
+  </dependencies>
+</project>
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonMappingExceptionMapper.java b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/JsonMappingExceptionMapper.java
similarity index 91%
copy from json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonMappingExceptionMapper.java
copy to base/src/main/java/com/fasterxml/jackson/jaxrs/base/JsonMappingExceptionMapper.java
index 7d07679..2e9a060 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonMappingExceptionMapper.java
+++ b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/JsonMappingExceptionMapper.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.jaxrs.json;
+package com.fasterxml.jackson.jaxrs.base;
 
 import com.fasterxml.jackson.databind.JsonMappingException;
 
@@ -9,6 +9,8 @@ import javax.ws.rs.ext.Provider;
 /**
  * Implementation if {@link ExceptionMapper} to send down a "400 Bad Request"
  * response in the event that unmappable JSON is received.
+ *
+ * @since 2.2
  */
 @Provider
 public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonParseExceptionMapper.java b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/JsonParseExceptionMapper.java
similarity index 90%
copy from json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonParseExceptionMapper.java
copy to base/src/main/java/com/fasterxml/jackson/jaxrs/base/JsonParseExceptionMapper.java
index 429caf1..55b0d0d 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonParseExceptionMapper.java
+++ b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/JsonParseExceptionMapper.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.jaxrs.json;
+package com.fasterxml.jackson.jaxrs.base;
 
 import com.fasterxml.jackson.core.JsonParseException;
 
@@ -9,6 +9,8 @@ import javax.ws.rs.ext.Provider;
 /**
  * Implementation of {@link ExceptionMapper} to send down a "400 Bad Request"
  * in the event unparsable JSON is received.
+ *
+ * @since 2.2
  */
 @Provider
 public class JsonParseExceptionMapper implements ExceptionMapper<JsonParseException> {
diff --git a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/AnnotationBundleKey.java b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/AnnotationBundleKey.java
similarity index 98%
rename from xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/AnnotationBundleKey.java
rename to base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/AnnotationBundleKey.java
index 7596429..4023e18 100644
--- a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/AnnotationBundleKey.java
+++ b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/AnnotationBundleKey.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.jaxrs.xml.util;
+package com.fasterxml.jackson.jaxrs.base.util;
 
 import java.lang.annotation.Annotation;
 
@@ -7,6 +7,8 @@ import java.lang.annotation.Annotation;
  * given a sequence of Annotations.
  * This is mostly used for reusing introspected information on
  * JAX-RS end points.
+ *
+ * @since 2.2
  */
 public final class AnnotationBundleKey
 {
diff --git a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/ClassKey.java b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/ClassKey.java
similarity index 94%
rename from xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/ClassKey.java
rename to base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/ClassKey.java
index c76bf8d..587d48a 100644
--- a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/ClassKey.java
+++ b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/ClassKey.java
@@ -1,4 +1,4 @@
-package com.fasterxml.jackson.jaxrs.xml.util;
+package com.fasterxml.jackson.jaxrs.base.util;
 
 /**
  * Efficient key class, used instead of using <code>Class</code>.
@@ -12,9 +12,8 @@ package com.fasterxml.jackson.jaxrs.xml.util;
  *<p>
  * Note: since class is not strictly immutable, caller must
  * know what it is doing, if changing field values.
- *<p>
- * NOTE: cut'n pasted from 'databind' package for 2.0, to reduce
- * tight coupling
+ *
+ * @since 2.2
  */
 public final class ClassKey
     implements Comparable<ClassKey>
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/LRUMap.java b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/LRUMap.java
similarity index 89%
rename from json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/LRUMap.java
rename to base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/LRUMap.java
index fa4a956..40a607f 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/LRUMap.java
+++ b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/util/LRUMap.java
@@ -1,10 +1,12 @@
-package com.fasterxml.jackson.jaxrs.json.util;
+package com.fasterxml.jackson.jaxrs.base.util;
 
 import java.util.LinkedHashMap;
 import java.util.Map;
 
 /**
  * Helper for simple bounded LRU maps used for reusing lookup values.
+ *
+ * @since 2.2
  */
 @SuppressWarnings("serial")
 public class LRUMap<K,V> extends LinkedHashMap<K,V>
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
index a388b3f..0909d55 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
+++ b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
@@ -16,10 +16,12 @@ import javax.ws.rs.ext.*;
 import com.fasterxml.jackson.core.*;
 import com.fasterxml.jackson.databind.*;
 import com.fasterxml.jackson.databind.util.LRUMap;
+
+import com.fasterxml.jackson.jaxrs.base.util.AnnotationBundleKey;
+import com.fasterxml.jackson.jaxrs.base.util.ClassKey;
+
 import com.fasterxml.jackson.jaxrs.json.annotation.EndpointConfig;
 import com.fasterxml.jackson.jaxrs.json.cfg.MapperConfigurator;
-import com.fasterxml.jackson.jaxrs.json.util.AnnotationBundleKey;
-import com.fasterxml.jackson.jaxrs.json.util.ClassKey;
 
 /**
  * Basic implementation of JAX-RS abstractions ({@link MessageBodyReader},
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonMappingExceptionMapper.java b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonMappingExceptionMapper.java
index 7d07679..7926ac2 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonMappingExceptionMapper.java
+++ b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonMappingExceptionMapper.java
@@ -7,9 +7,9 @@ import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.Provider;
 
 /**
- * Implementation if {@link ExceptionMapper} to send down a "400 Bad Request"
- * response in the event that unmappable JSON is received.
+ * @deprecated Use {@link com.fasterxml.jackson.jaxrs.base.JsonMappingExceptionMapper} instead.
  */
+ at Deprecated
 @Provider
 public class JsonMappingExceptionMapper implements ExceptionMapper<JsonMappingException> {
     public Response toResponse(JsonMappingException exception) {
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonParseExceptionMapper.java b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonParseExceptionMapper.java
index 429caf1..d51b9d8 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonParseExceptionMapper.java
+++ b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JsonParseExceptionMapper.java
@@ -7,9 +7,9 @@ import javax.ws.rs.ext.ExceptionMapper;
 import javax.ws.rs.ext.Provider;
 
 /**
- * Implementation of {@link ExceptionMapper} to send down a "400 Bad Request"
- * in the event unparsable JSON is received.
+ * @deprecated Use {@link com.fasterxml.jackson.jaxrs.base.JsonParseExceptionMapper} instead.
  */
+ at Deprecated
 @Provider
 public class JsonParseExceptionMapper implements ExceptionMapper<JsonParseException> {
     public Response toResponse(JsonParseException exception) {
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/AnnotationBundleKey.java b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/AnnotationBundleKey.java
deleted file mode 100644
index e06e01f..0000000
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/AnnotationBundleKey.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.fasterxml.jackson.jaxrs.json.util;
-
-import java.lang.annotation.Annotation;
-
-/**
- * Helper class used to allow efficient caching of information,
- * given a sequence of Annotations.
- * This is mostly used for reusing introspected information on
- * JAX-RS end points.
- */
-public final class AnnotationBundleKey
-{
-    private final static Annotation[] NO_ANNOTATIONS = new Annotation[0];
-    
-    private final Annotation[] _annotations;
-    
-    private final boolean _annotationsCopied;
-
-    private final int _hashCode;
-    
-    /*
-    /**********************************************************
-    /* Construction
-    /**********************************************************
-     */
-    
-    public AnnotationBundleKey(Annotation[] annotations)
-    {
-        if (annotations == null || annotations.length == 0) {
-            annotations = NO_ANNOTATIONS;
-            _annotationsCopied = true;
-            _hashCode = -1;
-        } else {
-            _annotationsCopied = false;
-            _hashCode = calcHash(annotations);
-        }
-        _annotations = annotations;  
-    }
-
-    private AnnotationBundleKey(Annotation[] annotations, int hashCode)
-    {
-        _annotations = annotations;            
-        _annotationsCopied = true;
-        _hashCode = hashCode;
-    }
-
-    private final static int calcHash(Annotation[] annotations)
-    {
-        /* hmmh. Can't just base on Annotation type; chances are that Annotation
-         * instances use identity hash, which has to do.
-         */
-        final int len = annotations.length;
-        int hash = len;
-        for (int i = 0; i < len; ++i) {
-            hash = (hash * 31) + annotations[i].hashCode();
-        }
-        return hash;
-    }
-    
-    /**
-     * Method called to create a safe immutable copy of the key; used when
-     * adding entry with this key -- lookups are ok without calling the method.
-     */
-    public AnnotationBundleKey immutableKey() {
-        if (_annotationsCopied) {
-            return this;
-        }
-        int len = _annotations.length;
-        Annotation[] newAnnotations = new Annotation[len];
-        System.arraycopy(_annotations, 0, newAnnotations, 0, len);
-        return new AnnotationBundleKey(newAnnotations, _hashCode);
-    }
-    
-    /*
-    /**********************************************************
-    /* Overridden methods
-    /**********************************************************
-     */
-
-    @Override
-    public String toString() {
-        return "[Annotations: "+_annotations.length+", hash 0x"+Integer.toHexString(_hashCode)
-                +", copied: "+_annotationsCopied+"]";
-    }
-
-    @Override
-    public boolean equals(Object o)
-    {
-        if (o == this) return true;
-        if (o == null) return false;
-        if (o.getClass() != getClass()) return false;
-        AnnotationBundleKey other = (AnnotationBundleKey) o;
-        if (other._hashCode != _hashCode) return false;
-        return _equals(other._annotations);
-    }
-    
-    private final boolean _equals(Annotation[] otherAnn)
-    {
-        final int len = _annotations.length;
-        if (otherAnn.length != len) {
-            return false;
-        }
-        for (int i = 0; i < len; ++i) {
-            if (_annotations[i] != otherAnn[i]) {
-                return false;
-            }
-        }
-        return true;
-    }
-}
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/ClassKey.java b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/ClassKey.java
deleted file mode 100644
index 7251774..0000000
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/util/ClassKey.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.fasterxml.jackson.jaxrs.json.util;
-
-/**
- * Efficient key class, used instead of using <code>Class</code>.
- * The reason for having a separate key class instead of
- * directly using {@link Class} as key is mostly
- * to allow for redefining <code>hashCode</code> method --
- * for some strange reason, {@link Class} does not
- * redefine {@link Object#hashCode} and thus uses identity
- * hash, which is pretty slow. This makes key access using
- * {@link Class} unnecessarily slow.
- *<p>
- * Note: since class is not strictly immutable, caller must
- * know what it is doing, if changing field values.
- *<p>
- * NOTE: cut'n pasted from 'databind' package for 2.0, to reduce
- * tight coupling
- */
-public final class ClassKey
-    implements Comparable<ClassKey>
-{
-    private String _className;
-
-    private Class<?> _class;
-
-    /**
-     * Let's cache hash code straight away, since we are
-     * almost certain to need it.
-     */
-    private int _hashCode;
-
-    public ClassKey() 
-    {
-        _class = null;
-        _className = null;
-        _hashCode = 0;
-    }
-
-    public ClassKey(Class<?> clz)
-    {
-        _class = clz;
-        _className = clz.getName();
-        _hashCode = _className.hashCode();
-    }
-
-    public void reset(Class<?> clz)
-    {
-        _class = clz;
-        _className = clz.getName();
-        _hashCode = _className.hashCode();
-    }
-
-    /*
-    /**********************************************************
-    /* Comparable
-    /**********************************************************
-     */
-
-    // Just need to sort by name, ok to collide (unless used in TreeMap/Set!)
-    //@Override
-    public int compareTo(ClassKey other) {
-        return _className.compareTo(other._className);
-    }
-    
-    /*
-    /**********************************************************
-    /* Standard methods
-    /**********************************************************
-     */
-
-    @Override
-        public boolean equals(Object o)
-    {
-        if (o == this) return true;
-        if (o == null) return false;
-        if (o.getClass() != getClass()) return false;
-        ClassKey other = (ClassKey) o;
-
-        /* Is it possible to have different Class object for same name + class loader combo?
-         * Let's assume answer is no: if this is wrong, will need to uncomment following functionality
-         */
-        /*
-        return (other._className.equals(_className))
-            && (other._class.getClassLoader() == _class.getClassLoader());
-        */
-        return other._class == _class;
-    }
-
-    @Override public int hashCode() { return _hashCode; }
-
-    @Override public String toString() { return _className; }    
-}
diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java
index 459b29f..e6318d8 100644
--- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/util/TestAnnotationBundleKey.java
@@ -3,6 +3,8 @@ package com.fasterxml.jackson.jaxrs.json.util;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Method;
 
+import com.fasterxml.jackson.jaxrs.base.util.AnnotationBundleKey;
+
 import com.fasterxml.jackson.jaxrs.json.JaxrsTestBase;
 import com.fasterxml.jackson.jaxrs.json.annotation.JSONP;
 
diff --git a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/JacksonSmileProvider.java b/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/JacksonSmileProvider.java
index 4c9d867..132aa02 100644
--- a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/JacksonSmileProvider.java
+++ b/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/JacksonSmileProvider.java
@@ -16,10 +16,10 @@ import javax.ws.rs.ext.*;
 import com.fasterxml.jackson.core.*;
 import com.fasterxml.jackson.databind.*;
 import com.fasterxml.jackson.databind.util.LRUMap;
+import com.fasterxml.jackson.jaxrs.base.util.AnnotationBundleKey;
+import com.fasterxml.jackson.jaxrs.base.util.ClassKey;
 import com.fasterxml.jackson.jaxrs.smile.annotation.EndpointConfig;
 import com.fasterxml.jackson.jaxrs.smile.cfg.MapperConfigurator;
-import com.fasterxml.jackson.jaxrs.smile.util.AnnotationBundleKey;
-import com.fasterxml.jackson.jaxrs.smile.util.ClassKey;
 
 /**
  * Basic implementation of JAX-RS abstractions ({@link MessageBodyReader},
diff --git a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/AnnotationBundleKey.java b/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/AnnotationBundleKey.java
deleted file mode 100644
index d1e299e..0000000
--- a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/AnnotationBundleKey.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.fasterxml.jackson.jaxrs.smile.util;
-
-import java.lang.annotation.Annotation;
-
-/**
- * Helper class used to allow efficient caching of information,
- * given a sequence of Annotations.
- * This is mostly used for reusing introspected information on
- * JAX-RS end points.
- */
-public final class AnnotationBundleKey
-{
-    private final static Annotation[] NO_ANNOTATIONS = new Annotation[0];
-    
-    private final Annotation[] _annotations;
-    
-    private final boolean _annotationsCopied;
-
-    private final int _hashCode;
-    
-    /*
-    /**********************************************************
-    /* Construction
-    /**********************************************************
-     */
-    
-    public AnnotationBundleKey(Annotation[] annotations)
-    {
-        if (annotations == null || annotations.length == 0) {
-            annotations = NO_ANNOTATIONS;
-            _annotationsCopied = true;
-            _hashCode = -1;
-        } else {
-            _annotationsCopied = false;
-            _hashCode = calcHash(annotations);
-        }
-        _annotations = annotations;  
-    }
-
-    private AnnotationBundleKey(Annotation[] annotations, int hashCode)
-    {
-        _annotations = annotations;            
-        _annotationsCopied = true;
-        _hashCode = hashCode;
-    }
-
-    private final static int calcHash(Annotation[] annotations)
-    {
-        /* hmmh. Can't just base on Annotation type; chances are that Annotation
-         * instances use identity hash, which has to do.
-         */
-        final int len = annotations.length;
-        int hash = len;
-        for (int i = 0; i < len; ++i) {
-            hash = (hash * 31) + annotations[i].hashCode();
-        }
-        return hash;
-    }
-    
-    /**
-     * Method called to create a safe immutable copy of the key; used when
-     * adding entry with this key -- lookups are ok without calling the method.
-     */
-    public AnnotationBundleKey immutableKey() {
-        if (_annotationsCopied) {
-            return this;
-        }
-        int len = _annotations.length;
-        Annotation[] newAnnotations = new Annotation[len];
-        System.arraycopy(_annotations, 0, newAnnotations, 0, len);
-        return new AnnotationBundleKey(newAnnotations, _hashCode);
-    }
-    
-    /*
-    /**********************************************************
-    /* Overridden methods
-    /**********************************************************
-     */
-
-    @Override
-    public String toString() {
-        return "[Annotations: "+_annotations.length+", hash 0x"+Integer.toHexString(_hashCode)
-                +", copied: "+_annotationsCopied+"]";
-    }
-
-    @Override
-    public boolean equals(Object o)
-    {
-        if (o == this) return true;
-        if (o == null) return false;
-        if (o.getClass() != getClass()) return false;
-        AnnotationBundleKey other = (AnnotationBundleKey) o;
-        if (other._hashCode != _hashCode) return false;
-        return _equals(other._annotations);
-    }
-    
-    private final boolean _equals(Annotation[] otherAnn)
-    {
-        final int len = _annotations.length;
-        if (otherAnn.length != len) {
-            return false;
-        }
-        for (int i = 0; i < len; ++i) {
-            if (_annotations[i] != otherAnn[i]) {
-                return false;
-            }
-        }
-        return true;
-    }
-}
diff --git a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/ClassKey.java b/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/ClassKey.java
deleted file mode 100644
index 274f6b4..0000000
--- a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/ClassKey.java
+++ /dev/null
@@ -1,92 +0,0 @@
-package com.fasterxml.jackson.jaxrs.smile.util;
-
-/**
- * Efficient key class, used instead of using <code>Class</code>.
- * The reason for having a separate key class instead of
- * directly using {@link Class} as key is mostly
- * to allow for redefining <code>hashCode</code> method --
- * for some strange reason, {@link Class} does not
- * redefine {@link Object#hashCode} and thus uses identity
- * hash, which is pretty slow. This makes key access using
- * {@link Class} unnecessarily slow.
- *<p>
- * Note: since class is not strictly immutable, caller must
- * know what it is doing, if changing field values.
- *<p>
- * NOTE: cut'n pasted from 'databind' package for 2.0, to reduce
- * tight coupling
- */
-public final class ClassKey
-    implements Comparable<ClassKey>
-{
-    private String _className;
-
-    private Class<?> _class;
-
-    /**
-     * Let's cache hash code straight away, since we are
-     * almost certain to need it.
-     */
-    private int _hashCode;
-
-    public ClassKey() 
-    {
-        _class = null;
-        _className = null;
-        _hashCode = 0;
-    }
-
-    public ClassKey(Class<?> clz)
-    {
-        _class = clz;
-        _className = clz.getName();
-        _hashCode = _className.hashCode();
-    }
-
-    public void reset(Class<?> clz)
-    {
-        _class = clz;
-        _className = clz.getName();
-        _hashCode = _className.hashCode();
-    }
-
-    /*
-    /**********************************************************
-    /* Comparable
-    /**********************************************************
-     */
-
-    // Just need to sort by name, ok to collide (unless used in TreeMap/Set!)
-    //@Override
-    public int compareTo(ClassKey other) {
-        return _className.compareTo(other._className);
-    }
-    
-    /*
-    /**********************************************************
-    /* Standard methods
-    /**********************************************************
-     */
-
-    @Override
-        public boolean equals(Object o)
-    {
-        if (o == this) return true;
-        if (o == null) return false;
-        if (o.getClass() != getClass()) return false;
-        ClassKey other = (ClassKey) o;
-
-        /* Is it possible to have different Class object for same name + class loader combo?
-         * Let's assume answer is no: if this is wrong, will need to uncomment following functionality
-         */
-        /*
-        return (other._className.equals(_className))
-            && (other._class.getClassLoader() == _class.getClassLoader());
-        */
-        return other._class == _class;
-    }
-
-    @Override public int hashCode() { return _hashCode; }
-
-    @Override public String toString() { return _className; }    
-}
diff --git a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/LRUMap.java b/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/LRUMap.java
deleted file mode 100644
index aae4d8b..0000000
--- a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/util/LRUMap.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.fasterxml.jackson.jaxrs.smile.util;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Helper for simple bounded LRU maps used for reusing lookup values.
- */
- at SuppressWarnings("serial")
-public class LRUMap<K,V> extends LinkedHashMap<K,V>
-{
-    protected final int _maxEntries;
-    
-    public LRUMap(int initialEntries, int maxEntries)
-    {
-        super(initialEntries, 0.8f, true);
-        _maxEntries = maxEntries;
-    }
-
-    @Override
-    protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
-    {
-        return size() > _maxEntries;
-    }
-
-}
diff --git a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/JacksonXMLProvider.java b/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/JacksonXMLProvider.java
index 122080e..c673b90 100644
--- a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/JacksonXMLProvider.java
+++ b/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/JacksonXMLProvider.java
@@ -17,10 +17,12 @@ import com.fasterxml.jackson.core.*;
 import com.fasterxml.jackson.databind.*;
 import com.fasterxml.jackson.databind.util.LRUMap;
 import com.fasterxml.jackson.dataformat.xml.XmlMapper;
+
+import com.fasterxml.jackson.jaxrs.base.util.AnnotationBundleKey;
+import com.fasterxml.jackson.jaxrs.base.util.ClassKey;
+
 import com.fasterxml.jackson.jaxrs.xml.annotation.EndpointConfig;
 import com.fasterxml.jackson.jaxrs.xml.cfg.MapperConfigurator;
-import com.fasterxml.jackson.jaxrs.xml.util.AnnotationBundleKey;
-import com.fasterxml.jackson.jaxrs.xml.util.ClassKey;
 
 /**
  * Basic implementation of JAX-RS abstractions ({@link MessageBodyReader},
diff --git a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/LRUMap.java b/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/LRUMap.java
deleted file mode 100644
index a7313aa..0000000
--- a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/util/LRUMap.java
+++ /dev/null
@@ -1,26 +0,0 @@
-package com.fasterxml.jackson.jaxrs.xml.util;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Helper for simple bounded LRU maps used for reusing lookup values.
- */
- at SuppressWarnings("serial")
-public class LRUMap<K,V> extends LinkedHashMap<K,V>
-{
-    protected final int _maxEntries;
-    
-    public LRUMap(int initialEntries, int maxEntries)
-    {
-        super(initialEntries, 0.8f, true);
-        _maxEntries = maxEntries;
-    }
-
-    @Override
-    protected boolean removeEldestEntry(Map.Entry<K,V> eldest)
-    {
-        return size() > _maxEntries;
-    }
-
-}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-jaxrs-providers.git



More information about the pkg-java-commits mailing list