Skip to content

Repository files navigation

MetaObjects Dynamic Framework

Build Status: ✅ All Tests Passing | Migration CompleteMaven Central: Maven CentralLicense: License

🎯 Migration Status: Successfully migrated to MetaObjects Core 6.2.6+ 📊 Test Results: 40+ tests passing across all modules 🔧 Build Output: Optimized for clean, minimal console output

Overview

MetaObjects Dynamic Framework provides runtime object construction, data management, persistence, and web integration capabilities built on top of the MetaObjects Core metadata framework.

Key Features

🏗️ Dynamic Object Construction

  • DataObject: Runtime object construction with type-safe property access
  • ValueObject: Immutable value objects with builder patterns
  • Managed Objects: Database-mapped objects with automatic CRUD operations

🗄️ Persistence & Data Management

  • ObjectManager (OM): Abstract persistence layer
  • ObjectManagerDB (OMDB): SQL database persistence with automatic schema generation
  • ObjectManagerNoSQL (OMNOSQL): NoSQL database support (MongoDB, etc.)

🌐 Web Integration

  • MetaViews: Metadata-driven UI component generation
  • Spring Integration: Full Spring Boot and Spring Web support
  • REST APIs: Automatic REST controller generation

📱 Demo Application

  • FishStore Demo: Complete e-commerce application showcasing all features

Architecture

MetaObjects Dynamic extends the core metadata framework with runtime capabilities:

MetaObjects Core (metadata framework)
↓ depends on
MetaObjects Dynamic (runtime objects)
↓ used by
Your Application (business logic)

Quick Start

Maven Dependencies

<dependency>
<groupId>com.metaobjects</groupId>
<artifactId>metaobjects-dynamic-core</artifactId>
<version>6.2.6-SNAPSHOT</version>
</dependency>
<!-- For database persistence -->
<dependency>
<groupId>com.metaobjects</groupId>
<artifactId>metaobjects-omdb</artifactId>
<version>6.2.6-SNAPSHOT</version>
</dependency>
<!-- For web integration -->
<dependency>
<groupId>com.metaobjects</groupId>
<artifactId>metaobjects-web-spring</artifactId>
<version>6.2.6-SNAPSHOT</version>
</dependency>

Basic Usage

1. Define Metadata

{
"metadata": {
"package": "com.example.model",
"children": [
{
"object": {
"name": "User",
"subType": "managed",
"children": [
{"field": {"name": "id", "subType": "long"}},
{"field": {"name": "name", "subType": "string", "@required": true}},
{"field": {"name": "email", "subType": "string", "@required": true}},
{"identity": {"name": "user_pk", "subType": "primary", "@fields": ["id"], "@generation": "increment"}}
]
}
}
]
}
}

2. Create Runtime Objects

// Load metadataMetaDataLoaderloader = newFileMetaDataLoader();
loader.setSourceURIs(Arrays.asList(URI.create("classpath:metadata/model.json")));
loader.init();
// Get metadata for UserMetaObjectuserMeta = loader.getMetaObjectByName("User");
// Create a DataObjectDataObjectuser = newDataObject(userMeta);
user.setProperty("name", "John Doe");
user.setProperty("email", "john@example.com");
// Create a ValueObject (immutable)ValueObjectuserValue = ValueObject.builder(userMeta)
.property("name", "Jane Doe")
.property("email", "jane@example.com")
.build();

3. Database Persistence

// Setup database persistenceObjectManagerDBomdb = newObjectManagerDB();
omdb.setDataSource(dataSource);
// Create database schema automaticallyMetaClassDBValidatorServicevalidator = newMetaClassDBValidatorService();
validator.setObjectManager(omdb);
validator.setAutoCreate(true);
validator.init();
// Save objectsObjectConnectionconnection = omdb.getConnection();
omdb.createObject(connection, user);

4. Web Integration (Spring)

@RestController@RequestMapping("/api/users")
publicclassUserController {
@AutowiredprivateObjectManagerDBomdb;
@AutowiredprivateMetaDataLoaderloader;
@GetMappingpublicList<DataObject> getUsers() {
MetaObjectuserMeta = loader.getMetaObjectByName("User");
returnomdb.getAllObjects(userMeta);
}
@PostMappingpublicDataObjectcreateUser(@RequestBodyMap<String, Object> userData) {
MetaObjectuserMeta = loader.getMetaObjectByName("User");
DataObjectuser = newDataObject(userMeta);
userData.forEach(user::setProperty);
returnomdb.createObject(user);
}
}

Module Overview

ModuleDescriptionKey Classes
dynamicCore dynamic object implementationsDataObject, ValueObject
omAbstract object manager interfaceObjectManager, ObjectConnection
omdbSQL database persistenceObjectManagerDB, MetaClassDBValidator
omnosqlNoSQL database persistenceMongoDBManager, ColumnarManager
webWeb components and viewsMetaView, TextView, FormView
web-springSpring framework integrationMetaDataAutoConfiguration
demoFishStore demo applicationComplete e-commerce example

Advanced Features

Type-Safe Property Access

// Type-safe property access with validationDataObjectuser = newDataObject(userMeta);
user.setStringProperty("name", "John Doe");
user.setLongProperty("id", 123L);
// Automatic validation based on metadatauser.setProperty("email", "invalid-email"); // Throws ValidationException

Automatic Database Schema Generation

// Automatic table creation from metadataMetaClassDBValidatorServicevalidator = newMetaClassDBValidatorService();
validator.setAutoCreate(true);
validator.init();
// Generates:// CREATE TABLE users (// id BIGINT AUTO_INCREMENT PRIMARY KEY,// name VARCHAR(255) NOT NULL,// email VARCHAR(255) NOT NULL// );

Metadata-Driven UI Components

// Automatic form generation from metadataMetaViewRendererrenderer = newMetaViewRenderer();
StringformHtml = renderer.renderForm(userMeta, user);
// Generates HTML form with proper validation, labels, and input types

Building from Source

git clone https://github.com/metaobjectsdev/metaobjects-dynamic.git
cd metaobjects-dynamic
mvn clean install

Build Features

  • Clean Output: Minimal console output for better readability
  • Fast Testing: Test output redirected to files for clean builds
  • JaCoCo Coverage: Optimized to avoid system package instrumentation warnings
# Standard clean build (quiet output)
mvn clean install
# Verbose output for debugging
mvn clean install -X
# Quick build with even less output
mvn clean install -q

Prerequisites

  • Java 17 or higher
  • Maven 3.6 or higher
  • MetaObjects Core 6.2.6+ (automatically resolved from Maven Central)

Migration Notes

Migration Complete: This project has been successfully migrated from the legacy core dependency structure to the updated MetaObjects Core 6.2.6+ framework. All modules are building and testing successfully.

Troubleshooting

Common Build Issues

🔧 Verbose Test Output

If you need verbose logging for debugging:

# Delete the test logging configuration
rm src/test/resources/logback-test.xml
# Or change log levels in the file from WARN to DEBUG

🔧 JaCoCo Instrumentation Warnings

The build is configured to exclude system packages. If you see warnings:

# These are normal and don't affect functionality:# "WARNING: sun.misc.Unsafe::staticFieldBase has been called"

🔧 Type Registration Issues

If you encounter MetaData type registration problems:

  1. Ensure CoreObjectsMetaDataProvider is properly registered
  2. Check that DataMetaObject.registerTypes() and ValueMetaObject.registerTypes() are called
  3. Verify service files in META-INF/services/ are intact

🔧 Derby Database Test Failures

If OMDB tests fail with Derby driver issues:

<!-- Ensure all Derby artifacts are included -->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbyshared</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derbytools</artifactId>
<scope>test</scope>
</dependency>

Documentation

Contributing

We welcome contributions! Please see our Contributing Guide for details.

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for your changes
  5. Submit a pull request

Support

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

Related Projects


MetaObjects Dynamic Framework - Bringing your metadata to life with runtime object construction and enterprise-grade persistence.

About

MetaObjects Support for Dynamic Runtime Behaviors that are Metadata Driven

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages