Skip to content

Commit

Permalink
Manual conversion of Guice7 module for 3.x (tools.jackson)
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 22, 2023
1 parent 904595d commit 49e659d
Show file tree
Hide file tree
Showing 10 changed files with 201 additions and 197 deletions.
10 changes: 5 additions & 5 deletions guice7/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.fasterxml.jackson.module</groupId>
<groupId>tools.jackson.module</groupId>
<artifactId>jackson-modules-base</artifactId>
<version>2.16.0-SNAPSHOT</version>
<version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>jackson-module-guice7</artifactId>
<name>Jackson module: Guice 7+ (jakarta.inject)</name>
Expand All @@ -30,7 +30,7 @@
<version.guice>7.0.0</version.guice>

<!-- Generate PackageVersion.java into this directory. -->
<packageVersion.dir>com/fasterxml/jackson/module/guice7</packageVersion.dir>
<packageVersion.dir>tools/jackson/module/guice7</packageVersion.dir>
<packageVersion.package>${project.groupId}.guice7</packageVersion.package>
<!-- default OSGi imports, exports should work fine -->
</properties>
Expand All @@ -42,11 +42,11 @@
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<groupId>tools.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package com.fasterxml.jackson.module.guice7;
package tools.jackson.module.guice7;

import com.fasterxml.jackson.annotation.JacksonInject;
import com.fasterxml.jackson.databind.introspect.*;

import tools.jackson.databind.cfg.MapperConfig;
import tools.jackson.databind.introspect.*;

import com.google.inject.BindingAnnotation;
import com.google.inject.Key;

Expand All @@ -13,21 +16,15 @@ public class GuiceAnnotationIntrospector extends NopAnnotationIntrospector
{
private static final long serialVersionUID = 1L;

@Override // since 2.9
public JacksonInject.Value findInjectableValue(AnnotatedMember m) {
@Override
public JacksonInject.Value findInjectableValue(MapperConfig<?> config, AnnotatedMember m) {
Object id = _findGuiceInjectId(m);
if (id == null) {
return null;
}
return JacksonInject.Value.forId(id);
}

@Deprecated // since 2.9
@Override
public Object findInjectableValueId(AnnotatedMember m) {
return _findGuiceInjectId(m);
}

private Object _findGuiceInjectId(AnnotatedMember m)
{
/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.fasterxml.jackson.module.guice7;
package tools.jackson.module.guice7;

import com.fasterxml.jackson.databind.BeanProperty;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.InjectableValues;
import tools.jackson.databind.BeanProperty;
import tools.jackson.databind.DeserializationContext;
import tools.jackson.databind.InjectableValues;
import com.google.inject.Injector;
import com.google.inject.Key;

Expand All @@ -19,4 +19,10 @@ public Object findInjectableValue(
{
return injector.getInstance((Key<?>) valueId);
}

@Override
public InjectableValues snapshot() {
// 22-May-2023, tatu: Not sure if and how this could work really...
return this;
}
}

0 comments on commit 49e659d

Please sign in to comment.