microBean™ Jackson/CDI Integration


License

License

Categories

Categories

Jackson Data JSON
GroupId

GroupId

org.microbean
ArtifactId

ArtifactId

microbean-jackson-cdi
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

microBean™ Jackson/CDI Integration
microBean™ Jackson/CDI Integration
Project URL

Project URL

https://microbean.github.io/microbean-jackson-cdi
Project Organization

Project Organization

microBean™
Source Code Management

Source Code Management

https://github.com/microbean/microbean-jackson-cdi/

Download microbean-jackson-cdi

How to add to project

<!-- https://jarcasting.com/artifacts/org.microbean/microbean-jackson-cdi/ -->
<dependency>
    <groupId>org.microbean</groupId>
    <artifactId>microbean-jackson-cdi</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.microbean/microbean-jackson-cdi/
implementation 'org.microbean:microbean-jackson-cdi:1.0.0'
// https://jarcasting.com/artifacts/org.microbean/microbean-jackson-cdi/
implementation ("org.microbean:microbean-jackson-cdi:1.0.0")
'org.microbean:microbean-jackson-cdi:jar:1.0.0'
<dependency org="org.microbean" name="microbean-jackson-cdi" rev="1.0.0">
  <artifact name="microbean-jackson-cdi" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.microbean', module='microbean-jackson-cdi', version='1.0.0')
)
libraryDependencies += "org.microbean" % "microbean-jackson-cdi" % "1.0.0"
[org.microbean/microbean-jackson-cdi "1.0.0"]

Dependencies

compile (3)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-annotations jar
com.fasterxml.jackson.core : jackson-core jar
com.fasterxml.jackson.core : jackson-databind jar

provided (2)

Group / Artifact Type Version
jakarta.enterprise : jakarta.enterprise.cdi-api jar 2.0.2
jakarta.inject : jakarta.inject-api jar 1.0

runtime (1)

Group / Artifact Type Version
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

microBean™ Jackson CDI Integration

Build Status Maven Central

The microBean™ Jackson CDI Integration project provides a CDI portable extension that allows ObjectMapper instances to be injected in your CDI-based application.

Installation

Declare a dependency in your CDI-based Maven project:

<dependency>
  <groupId>org.microbean</groupId>
  <artifactId>microbean-jackson-cdi</artifactId>
  <version>1.0.0</version>
</dependency>

Usage

Inject an ObjectMapper into a CDI bean:

import javax.enterprise.inject.Default;
import javax.inject.Inject;
import com.fasterxml.jackson.databind.ObjectMapper;

// This will be the default ObjectMapper.
@Inject
private ObjectMapper objectMapper;

// This will be the same ObjectMapper as above.
@Inject
@Default
private ObjectMapper defaultObjectMapper;

// This will be another ObjectMapper.
@Inject
@YourQualifierHere
private ObjectMapper specialObjectMapper;

Customization

To customize the ObjectMapper created by the portable extension furnished by this project, observe an ObjectMapper-typed CDI event:

private static final void onDefaultObjectMapperCreation(@Observes final ObjectMapper objectMapperBeingCreated) {
  // The ObjectMapper received here is the default one and is in the process of
  // being registered in application scope.  You may customize it here, but do
  // not retain a reference to it.  Here is an arbitrary example.
  objectMapperBeingCreated.setLocale(java.util.Locale.getDefault());
}

private static final void onQualifiedObjectMapperCreation(@Observes @YourQualifierHere final ObjectMapper yellowObjectManagerBeingCreated) {
  // The ObjectMapper received here is the @YourQualifierHere-qualified one from
  // the example above and is in the process of being registered in application
  // scope.  You may customize it here, but do not retain a reference to it.
  // Here is an arbitrary example.
  yellowObjectMapperBeingCreated.setTimeZone(java.util.TimeZone.getTimeZone("GMT-8"));
}
org.microbean

microBean™

At the intersection of Java, Kubernetes and the enterprise.

Versions

Version
1.0.0