### HelloWorld Implementation Example in Java Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md This Java code provides the implementation for the 'HelloWorld' service. It extends an abstract class and overrides the 'sayHello' method to process the input language parameter and return a localized greeting message, demonstrating a model-driven algorithm. ```java package org.openmdx.example.helloworld1.aop2; import javax.jmi.reflect.RefException; import org.openmdx.base.aop2.AbstractObject; import org.openmdx.example.helloworld1.jmi1.HelloWorldSayHelloParams; import org.openmdx.example.helloworld1.jmi1.Helloworld1Package; import org.openmdx.example.helloworld1.jmi1.SayHelloResult; public class HelloWorldImpl extends AbstractObject { public HelloWorldImpl( S same, N next ) { super(same, next); System.out.println("Plugin: instantiating HelloWorldImpl"); } public SayHelloResult sayHello( HelloWorldSayHelloParams params ) throws RefException { System.out.println("Plugin: invoking sayHello(language=" + params.getLanguage() + ")"); String language = params.getLanguage(); String message = null; if("de".equals(language)) { message = "hallo welt"; } else if("fr".equals(language)) { message = "bonjour monde"; } ``` -------------------------------- ### REST/JCA Interaction Example Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md Example of performing an object retrieval using REST/JCA. ```APIDOC ## REST/JCA Object Retrieval Example ### Description This example demonstrates how to retrieve an object using the REST/JCA protocol, treating the remote persistence manager as a JCA resource. ### Method `GET` (via JCA InteractionSpec) ### Endpoint (Implicitly defined by JCA resource) ### Request Example ```java javax.resource.cci.Connection conn = connectionFactory.getConnection( new RestConnectionSpec(user, password) ); javax.resource.cci.RecordFactory rf = connectionFactory.getRecordFactory(); javax.resource.cci.Interaction interaction = conn.createInteraction(); InteractionSpec ispec = InteractionSpecs.getRestInteractionSpecs(true).GET; javax.resource.cci.IndexedRecord input = factory.createIndexedRecord(Multiplicities.LIST); input.add(object_xri); javax.resource.cci.Record output = interaction.execute(ispec, input); ``` ### Response #### Success Response The retrieved object is contained within a JCA record. ``` -------------------------------- ### Build and Run openMDX Examples with Gradle Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This section details how to clone the openMDX examples repository, checkout a specific version, and build the sample applications (HelloWorld and Workshop) using Gradle. It also includes running JUnit tests and the expected successful output. ```bash # Clone the examples repository git clone https://github.com/openmdx/openmdx-example.git openmdx-example cd openmdx-example # Checkout matching version and build git checkout openmdx-v2.17.10 gradle clean gradle assemble # Generate Eclipse project files gradle eclipse # Import projects: helloworld, workshop # Run the JUnit tests gradle test # Expected output: # > Task :helloworld:test # TestHelloWorld_1 > testHelloWorld() PASSED # # > Task :workshop:test # TestWorkshop_1 > testVolatile() PASSED # TestWorkshop_1 > testStandard() PASSED # # BUILD SUCCESSFUL ``` -------------------------------- ### HelloWorld Client Example in Java Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md This Java client demonstrates how to interact with the 'HelloWorld' service generated via JMI. It shows the process of obtaining a PersistenceManager, retrieving the HelloWorld object, invoking the 'sayHello' method with a language parameter, and printing the returned message. ```java import org.openmdx.example.helloworld1.*; javax.jdo.PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("EntityManagerFactory"); javax.jdo.PersistenceManager pm = pmf.getPersistenceManager("guest", "guest"); HelloWorld helloWorld = (HelloWorld)pm.getObjectById(HELLOWORLD_XRI); HelloWorldPackage helloWorldPkg = (HelloWorldPackage)helloWorld.refOutermostPackage().refPackage(Helloworld1Package.class.getName()); pm.currentTransaction().begin(); org.openmdx.example.helloworld1.SayHelloResult hResult = helloWorld.sayHello( helloWorldPkg.createHelloWorldSayHelloParams("en") ); pm.currentTransaction().commit(); System.out.println("Client: sayHello[en]=" + hResult.getMessage()); ``` -------------------------------- ### Build openMDX from Source using Bash Source: https://context7.com/openmdx/openmdx-documentation/llms.txt Provides instructions for cloning and building the openMDX project from source using Gradle. It outlines the necessary prerequisites, environment variable setup, and the Gradle commands for cleaning and assembling the project. ```bash # Prerequisites: JDK 8, JDK 11, Gradle 6.9, Git # Set environment variables: export JRE_18=/usr/lib/jvm/java-8-openjdk-amd64/jre export PATH=$PATH:/path/to/jdk-11/bin # Clone the openMDX repository git clone https://github.com/openmdx/openmdx.git openmdx cd openmdx # Checkout a specific version and build git checkout openmdx-v2.17.10 gradle clean gradle assemble ``` -------------------------------- ### Implement Business Logic with AOP2 Plug-ins in Java Source: https://context7.com/openmdx/openmdx-documentation/llms.txt Shows how to implement business logic using aspect-oriented plug-ins (AOP2) that extend `AbstractObject`. This example demonstrates intercepting method invocations and implementing model-defined operations, specifically the `sayHello` operation. ```java package org.openmdx.example.helloworld1.aop2; import javax.jmi.reflect.RefException; import org.openmdx.base.aop2.AbstractObject; import org.openmdx.example.helloworld1.jmi1.HelloWorldSayHelloParams; import org.openmdx.example.helloworld1.jmi1.Helloworld1Package; import org.openmdx.example.helloworld1.jmi1.SayHelloResult; public class HelloWorldImpl extends AbstractObject { public HelloWorldImpl(S same, N next) { super(same, next); System.out.println("Plugin: instantiating HelloWorldImpl"); } // Implement the sayHello operation defined in the model public SayHelloResult sayHello(HelloWorldSayHelloParams params) throws RefException { System.out.println("Plugin: invoking sayHello(language=" + params.getLanguage() + ")"); String language = params.getLanguage(); String message; if ("de".equals(language)) { message = "hallo welt"; } else if ("fr".equals(language)) { message = "bonjour monde"; } else { message = "hello world"; } // Create result using the package factory return ((Helloworld1Package) this.sameObject() .refOutermostPackage() .refPackage(Helloworld1Package.class.getName())) .createSayHelloResult(message); } } ``` -------------------------------- ### REST/JCA Object Retrieval using Java Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md Demonstrates how to retrieve an object using the REST/JCA protocol. It involves establishing a JCA connection with REST-specific connection details, creating an interaction, and executing a GET request with the object's XRI. The output is returned as a JCA record. ```java javax.resource.cci.Connection conn = connectionFactory.getConnection( new RestConnectionSpec(user, password) ); javax.resource.cci.RecordFactory rf = connectionFactory.getRecordFactory(); javax.resource.cci.Interaction interaction = conn.createInteraction(); InteractionSpec ispec = InteractionSpecs.getRestInteractionSpecs(true).GET; javax.resource.cci.IndexedRecord input = factory.createIndexedRecord(Multiplicities.LIST); input.add(object_xri); javax.resource.cci.Record output = interaction.execute(ispec, input); ``` -------------------------------- ### Configure JDBC Datasource for TomEE Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This XML snippet shows how to configure a JDBC datasource for the openMDX workshop example within Apache TomEE. It specifies the driver, URL, username, password, and JTA management for the connection. ```xml JdbcDriver org.hsqldb.jdbcDriver JdbcUrl jdbc:hsqldb:hsql://127.0.0.1:9002/WORKSHOP UserName sa Password manager99 JtaManaged true ``` -------------------------------- ### REST/JCA Communication Layer in Java Source: https://context7.com/openmdx/openmdx-documentation/llms.txt Illustrates how openMDX uses REST as a unified communication protocol, mapping object operations to REST methods (GET, PUT, POST, DELETE). This snippet shows establishing a JCA connection and performing GET and POST operations. ```java import javax.resource.cci.*; import org.openmdx.base.resource.spi.RestConnectionSpec; import org.openmdx.kernel.resource.InteractionSpecs; import org.openmdx.base.naming.Path; import org.openmdx.base.rest.cci.Multiplicities; // Establish JCA connection Connection conn = connectionFactory.getConnection( new RestConnectionSpec("user", "password") ); RecordFactory rf = connectionFactory.getRecordFactory(); Interaction interaction = conn.createInteraction(); // GET operation - retrieve an object by XRI InteractionSpec getSpec = InteractionSpecs.getRestInteractionSpecs(true).GET; IndexedRecord input = rf.createIndexedRecord(Multiplicities.LIST); input.add(new Path("xri://@openmdx*org.openmdx.example/provider/Example/segment/Standard")); Record output = interaction.execute(getSpec, input); // Output contains the retrieved object as a JCA record // POST operation - invoke a method InteractionSpec postSpec = InteractionSpecs.getRestInteractionSpecs(true).POST; // ... prepare input with object XRI, method name, and parameters interaction.close(); conn.close(); ``` -------------------------------- ### Generate JMI Interface from UML Model Class (Java) Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This Java code snippet demonstrates a generated JMI interface from a UML model class named 'HelloWorld'. It extends both the cci2 and jmi1 variants and includes an example operation 'sayHello'. Generated files include Java interfaces, JPA classes, and model XML files. ```java // Generated JMI interface from UML model class HelloWorld package org.openmdx.example.helloworld1.jmi1; public interface HelloWorld extends org.openmdx.example.helloworld1.cci2.HelloWorld, org.openmdx.base.jmi1.Segment { // Operation defined in UML model public org.openmdx.example.helloworld1.jmi1.SayHelloResult sayHello( org.openmdx.example.helloworld1.jmi1.HelloWorldSayHelloParams in ); } // Generated files location after build: // - Java interfaces: ./build/generated/sources/java/main/ // - JPA classes: package suffix jpa3 // - Model XML files: used at runtime for MOF repository // - All artifacts: ./build/generated/sources/model/openmdx-workshop-models.zip ``` -------------------------------- ### Java Hello World Client with openMDX Persistence Manager Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md Demonstrates a simple 'hello world' client using the openMDX persistence manager to invoke a remote or local 'sayHello()' service. It shows how to obtain a PersistenceManager, retrieve an object, call a method, and manage transactions. Dependencies include the openMDX core libraries and generated Java interfaces from a UML model. ```java import org.openmdx.example.helloworld1.*; javax.jdo.PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("EntityManagerFactory"); javax.jdo.PersistenceManager pm = pmf.getPersistenceManager("guest", "guest"); HelloWorld helloWorld = (HelloWorld)pm.getObjectById(HELLOWORLD_XRI); HelloWorldPackage helloWorldPkg = (HelloWorldPackage)helloWorld.refOutermostPackage().refPackage(Helloworld1Package.class.getName()); pm.currentTransaction().begin(); org.openmdx.example.helloworld1.SayHelloResult hResult = helloWorld.sayHello( helloWorldPkg.createHelloWorldSayHelloParams("en") ); pm.currentTransaction().commit(); System.out.println("Client: sayHello[en]=" + hResult.getMessage()); ``` -------------------------------- ### Build openMDX using Gradle Source: https://github.com/openmdx/openmdx-documentation/blob/master/Sdk/BuildFromSource.md Commands to navigate into the cloned directory, checkout a specific version, clean previous builds, and assemble the project using Gradle. Requires Git, JDK 8/11, and Gradle 6.9. ```bash cd openmdx git checkout openmdx-v2.17.10 gradle clean gradle assemble ``` -------------------------------- ### Create SayHelloResult in Java Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md This Java code snippet demonstrates how to create a 'SayHelloResult' object. It retrieves a specific package ('Helloworld1Package') from the outermost package and then uses it to create the result. This is likely part of a service or API implementation. ```java else { message = "hello world"; } return ((Helloworld1Package)this.sameObject().refOutermostPackage().refPackage( Helloworld1Package.class.getName()) ).createSayHelloResult(message); } } ``` -------------------------------- ### JMI Interface for HelloWorld in Java Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md This Java code defines the JMI interface for a 'HelloWorld' service. It extends other interfaces and declares a 'sayHello' method that takes parameters and returns a result, adhering to the Java Metadata Interface (JMI) standard for platform-independent modeling. ```java package org.openmdx.example.helloworld1.jmi1; public interface HelloWorld extends org.openmdx.example.helloworld1.cci2.HelloWorld, org.openmdx.base.jmi1.Segment{ public org.openmdx.example.helloworld1.jmi1.SayHelloResult sayHello( org.openmdx.example.helloworld1.jmi1.HelloWorldSayHelloParams in ); } ``` -------------------------------- ### Clone openMDX Repository using Git Source: https://github.com/openmdx/openmdx-documentation/blob/master/Sdk/BuildFromSource.md Clones the openMDX source code from the official GitHub repository. This is the first step in building the project from source. ```bash git clone https://github.com/openmdx/openmdx.git openmdx ``` -------------------------------- ### Create Database Schema with Gradle Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This sequence of Gradle commands outlines the process of generating database schemas from openMDX models. It involves building the application to generate orm.xml, creating a database-independent schema, editing it, and finally generating database-specific SQL scripts. ```bash # Step 1: Build generates orm.xml in build/resources/main/META-INF/orm.xml gradle assemble # Step 2: Create database-independent schema from orm.xml gradle -Pdatabase.name="hsqldb-2" create-schema # Output: build/generated/sources/sql/openjpa-schema.xml # Step 3: Edit openjpa-schema.xml - remove non-project tables # Keep only tables with your project prefix (e.g., OOMEP1WS_) # Remove manually-implemented views # Step 4: Generate database-specific SQL scripts gradle -Pdatabase.name="hsqldb-2" create-sql # Output: build/generated/sources/sql/hsqldb-2-build.sql # Step 5: Execute SQL script in database manager # Run hsqldb-2-build.sql to create the schema # Supported databases: # - PostgreSQL # - HSQLDB # - MySQL # - Microsoft SQL Server # - Oracle # - DB/2 ``` -------------------------------- ### Invoke Business Operations in Java Source: https://context7.com/openmdx/openmdx-documentation/llms.txt Demonstrates how to invoke business operations defined in the UML model, which are mapped to Java methods. It shows parameter and result typing according to the model specification using PersistenceManager and HelloWorld objects. ```java import org.openmdx.example.helloworld1.jmi1.*; // Complete example of invoking the sayHello operation PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("EntityManagerFactory"); PersistenceManager pm = pmf.getPersistenceManager("guest", "guest"); HelloWorld helloWorld = (HelloWorld) pm.getObjectById(HELLOWORLD_XRI); HelloWorldPackage helloWorldPkg = (HelloWorldPackage) helloWorld .refOutermostPackage() .refPackage(Helloworld1Package.class.getName()); pm.currentTransaction().begin(); // Invoke sayHello with different language parameters SayHelloResult resultEn = helloWorld.sayHello( helloWorldPkg.createHelloWorldSayHelloParams("en") ); System.out.println("English: " + resultEn.getMessage()); // Output: hello world SayHelloResult resultDe = helloWorld.sayHello( helloWorldPkg.createHelloWorldSayHelloParams("de") ); System.out.println("German: " + resultDe.getMessage()); // Output: hallo welt SayHelloResult resultFr = helloWorld.sayHello( helloWorldPkg.createHelloWorldSayHelloParams("fr") ); System.out.println("French: " + resultFr.getMessage()); // Output: bonjour monde pm.currentTransaction().commit(); ``` -------------------------------- ### RESTful Operations Source: https://github.com/openmdx/openmdx-documentation/blob/master/Introduction.md Mapping of openMDX persistence operations to RESTful HTTP methods. ```APIDOC ## RESTful Operations ### Description This section outlines the mapping of common openMDX persistence operations to their corresponding RESTful HTTP methods. ### Method Mappings - **Object Retrievals**: Mapped to `GET ` - **Queries**: Mapped to `GET ` - **Object Modifications**: Mapped to `PUT ` - **Object Creations**: Mapped to `POST ` - **Method Invocations**: Mapped to `POST ` - **Object Removals**: Mapped to `DELETE ` ``` -------------------------------- ### Configure User for TomEE Access Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This XML snippet demonstrates how to configure a user with the 'Guest' role in Tomcat's user configuration file (tomcat-users.xml). This is necessary for accessing certain functionalities or APIs deployed on TomEE. ```xml ``` -------------------------------- ### Initialize JDO Persistence Manager Factory in Java Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This snippet demonstrates how to obtain a PersistenceManagerFactory using a configuration ID from 'jdoconfig.xml'. It then creates a PersistenceManager instance, which is the entry point for openMDX operations, and can be configured for local or remote transports. ```java import javax.jdo.JDOHelper; import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; // Get the persistence manager factory using configuration ID from jdoconfig.xml PersistenceManagerFactory pmf = JDOHelper.getPersistenceManagerFactory("EntityManagerFactory"); // Create a persistence manager with user credentials PersistenceManager pm = pmf.getPersistenceManager("guest", "guest"); // The persistence manager is now ready for object operations // Configuration determines whether local or remote transports are used ``` -------------------------------- ### Generate Eclipse Project Files with Gradle Source: https://github.com/openmdx/openmdx-documentation/blob/master/Sdk/BuildFromSource.md Generates the necessary project files for Eclipse IDE integration. This command allows developers to import the openMDX sub-projects (client, core, portal, security, tomcat) into their Eclipse workspace. ```bash gradle eclipse ``` -------------------------------- ### Create Operation Parameters using JMI Package Factory in Java Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This Java snippet illustrates how to use JMI (Java Metadata Interface) package factories to create parameter objects for invoking operations. It accesses the package factory through the object's outermost package reference. ```java import org.openmdx.example.helloworld1.jmi1.HelloWorld; import org.openmdx.example.helloworld1.jmi1.HelloWorldPackage; import org.openmdx.example.helloworld1.jmi1.Helloworld1Package; import org.openmdx.example.helloworld1.jmi1.HelloWorldSayHelloParams; // Get the HelloWorld object HelloWorld helloWorld = (HelloWorld) pm.getObjectById(HELLOWORLD_XRI); // Access the package factory through the object's outermost package HelloWorldPackage helloWorldPkg = (HelloWorldPackage) helloWorld .refOutermostPackage() .refPackage(Helloworld1Package.class.getName()); // Create operation parameters using the package factory HelloWorldSayHelloParams params = helloWorldPkg.createHelloWorldSayHelloParams("en"); ``` -------------------------------- ### Retrieve Object by XRI using Persistence Manager in Java Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This code shows how to retrieve a business object using its XRI (eXtensible Resource Identifier) with the openMDX PersistenceManager. The framework handles the underlying data access, whether it's local or remote, transparently. ```java import javax.jdo.PersistenceManager; import org.openmdx.example.helloworld1.jmi1.HelloWorld; // XRI uniquely identifies the object in the openMDX object space String HELLOWORLD_XRI = "xri://@openmdx*org.openmdx.example.helloworld1/provider/HelloWorld/segment/Standard"; // Retrieve the HelloWorld service object HelloWorld helloWorld = (HelloWorld) pm.getObjectById(HELLOWORLD_XRI); // Access object properties - retrieval is cached and optimized System.out.println("Retrieved object: " + helloWorld.refMofId()); ``` -------------------------------- ### Manage Transactions with JDO in Java Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This Java code demonstrates JDO-compliant transaction management within openMDX. It shows how to begin, commit, and rollback transactions, ensuring data consistency for operations performed on business objects. ```java import javax.jdo.PersistenceManager; import javax.jdo.Transaction; import org.openmdx.example.helloworld1.jmi1.HelloWorld; import org.openmdx.example.helloworld1.jmi1.SayHelloResult; PersistenceManager pm = pmf.getPersistenceManager("guest", "guest"); Transaction tx = pm.currentTransaction(); try { // Begin the unit of work tx.begin(); // Retrieve object and invoke operations within transaction HelloWorld helloWorld = (HelloWorld) pm.getObjectById(HELLOWORLD_XRI); HelloWorldPackage pkg = (HelloWorldPackage) helloWorld .refOutermostPackage() .refPackage(Helloworld1Package.class.getName()); SayHelloResult result = helloWorld.sayHello( pkg.createHelloWorldSayHelloParams("en") ); // Commit the transaction tx.commit(); System.out.println("Result: " + result.getMessage()); } catch (Exception e) { // Rollback on error if (tx.isActive()) { tx.rollback(); } throw e; } finally { pm.close(); } ``` -------------------------------- ### JDO Configuration (jdoconfig.xml) Source: https://context7.com/openmdx/openmdx-documentation/llms.txt This XML file configures the JDO persistence manager factory for openMDX applications. It specifies the persistence manager class, transaction type, optimistic locking, implementation packages, and references an additional properties file. ```xml ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.