juneau-shaded-core
The juneau-shaded-core artifact bundles all core Juneau modules for general marshalling and configuration work. At 2.0 MB, it's the smallest shaded artifact and ideal for applications that don't need REST functionality.
What's Included
This artifact includes the following Juneau modules:
- juneau-common - Core utilities and common classes
- juneau-assertions - Fluent-style assertions API
- juneau-bct - Bean-Centric Testing framework
- juneau-config - Configuration file API
- juneau-marshall - Serializers and parsers (JSON, XML, HTML, MessagePack, etc.)
Serialization Formats Supported
- JSON - Multiple flavors (standard, simplified, lax)
- XML - Standard and namespaced XML
- HTML - HTML5 and table-based serialization
- URL-Encoding - URL-encoded form data
- UON - URL-Encoded Object Notation
- OpenAPI - OpenAPI-style serialization
- MessagePack - Binary serialization
- PlainText - Simple text serialization
- CSV - Comma-separated values
- SOAP/XML - SOAP-style XML
Use Cases
Use juneau-shaded-core when you need:
- Serialization/Deserialization - Convert POJOs to/from various formats
- Configuration Management - Use the Config API for application settings
- Testing - Use the assertion and BCT frameworks for unit tests
- Data Transformation - Convert between different data formats
- No REST APIs - You don't need REST client or server functionality
Maven Dependency
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-shaded-core</artifactId>
<version>${juneau.version}</version>
</dependency>
Bazel Dependency
maven_jar(
name = "juneau_core",
artifact = "org.apache.juneau:juneau-shaded-core:${juneau.version}",
)
# Add to your java_library or java_binary
java_library(
name = "my_lib",
srcs = ["MyCode.java"],
deps = ["@juneau_core//jar"],
)
External Dependencies
juneau-shaded-core requires the following external dependencies:
Optional
- Jakarta XML Bind API 3.0+ - For XML serialization support
Example Usage
Basic Serialization
import org.apache.juneau.json.*;
import org.apache.juneau.xml.*;
public class SerializationExample {
public static void main(String[] args) throws Exception {
Person person = new Person("John Smith", 42);
// Serialize to JSON
String json = Json.of(person);
System.out.println(json);
// Output: {name:"John Smith",age:42}
// Serialize to XML
String xml = Xml.of(person);
System.out.println(xml);
// Output: <object><name>John Smith</name><age>42</age></object>
// Parse back from JSON
Person p2 = Json.to(json, Person.class);
}
}
Configuration Management
import org.apache.juneau.config.*;
public class ConfigExample {
public static void main(String[] args) throws Exception {
Config config = Config.create("myapp.cfg").build();
// Get values with defaults
String host = config.get("Server/host").orElse("localhost");
int port = config.get("Server/port").asInteger().orElse(8080);
// Set values
config.set("Server/host", "example.com");
config.commit();
}
}
Bean-Centric Testing
import static org.apache.juneau.junit.bct.BctAssertions.*;
public class BctExample {
@Test
public void testPerson() {
Person person = new Person("John", 42);
assertBean(person)
.is("name", "John")
.is("age", 42);
assertBean(person).asJson()
.is("{name:'John',age:42}");
}
}
Performance Characteristics
- Serialization: Fast, memory-efficient
- Parsing: Safe from deserialization attacks
- JAR Size: 2.0 MB (smallest shaded artifact)
- Startup Time: Minimal - no classpath scanning or code generation
Migration from Individual Modules
If you're currently using individual core modules:
Before:
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-marshall</artifactId>
<version>${juneau.version}</version>
</dependency>
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-config</artifactId>
<version>${juneau.version}</version>
</dependency>
<!-- ... more dependencies -->
After:
<dependency>
<groupId>org.apache.juneau</groupId>
<artifactId>juneau-shaded-core</artifactId>
<version>${juneau.version}</version>
</dependency>
All imports and API usage remain exactly the same!
Next Steps
- Need REST client functionality? Use juneau-shaded-rest-client
- Need REST server functionality? Use juneau-shaded-rest-server
- Need everything? Use juneau-shaded-all
- Learn about marshalling: See Marshalling Basics
- Learn about configuration: See Config Basics
Share feedback or follow-up questions for this page directly through GitHub.