Skip to content

Dirigible - Extend, Embed, Reuse

The latest major upgrade of Dirigible to 3.x opens the door for scenarios like building custom stacks, standardized application CI, embedded Dirigible and many more ...

Overview

With the latest major upgrade to Eclipse Dirigible 3.x, there are a lot of improvements starting from the project structure and stretching all the way up to the entirely new Web IDE. Some of them are: - New Web IDE - Entity Data Modeler - Support for Business Processes - Standardized Applications CI (WebJars) - Keycloak Integration - 200+ Maven Artifacts - OSGi Free Modules - and many more ...

In this post, we will emphasize on the improved CI process and the scenarios it unlocks. For example, with the 200+ Maven Artifacts, the customization of Dirigible is more flexible than ever. Custom Dirigible Stack can be built with ease, or only some modules can be added as dependencies in existing projects (e.g. SQL & Persistency modules). Finally, having a hybrid (embedded) deployment is another interesting capability that is worth looking at (e.g. in existing Spring Stack).

Custom Stack

Custom-Dirigible-Stack

Building a custom Dirigible stack is the second-best option to run in production (if the pre-built releases don't fit the project needs). The Helium Custom Stack tutorial explores in detail all aspects of building a custom Dirigible stack: 1. Setting up maven project(s) layout 2. Building WebJar(s) 3. Exposing an Enterprise JavaScript API (both Java facade and JavaScript API) 4. Consuming Dirigible dependencies

Reuse of Modules

Modules-Re-Use

With 200+ Maven artifacts, it's obvious that some modules can be reused even in non-Dirigible related projects. For example, the SQL builder and the ORM can be consumed on their own:

Database - SQL Builder:

  1. Builder:
    ...
    import org.eclipse.dirigible.database.sql.SqlFactory;
    ...
    
    public class StudentsDao {
    
        private static SqlFactory sqlFactory;
    
        public List<StudentEntity> searchByFirstName(String name) {
            String sql = getSqlFactory()
                    .select()
                    .column("*")
                    .from("STUDENTS")
                    .where("STUDENT_FIRST_NAME like ?")
                    .build();
            return query(sql, name);
        }
    
        private SqlFactory getSqlFactory() {
            if (sqlFactory == null) {
                Connection connection = null;
                try {
                    connection = getConnection();
                    sqlFactory = SqlFactory.getNative(connection);
                } finally {
                    closeConnection(connection);
                }
            }
            return sqlFactory;
        }
    ...
    
  2. Dependency:
    <dependency>
        <groupId>org.eclipse.dirigible</groupId>
        <artifactId>dirigible-database-sql</artifactId>
        <version>3.2.8</version>
    </dependency>
    

Database - ORM:

Dirigible's ORM is compatible with the Java Persistence API:

  1. Entity

    ...
    import javax.persistence.Column;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.Table;
    ...
    
    @Table(name = "STUDENTS")
    public class StudentEntity {
    
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "STUDENT_ID", columnDefinition = "BIGINT")
        private Long id;
    ...
    
    1. DAO:
    ...
    import org.eclipse.dirigible.database.persistence.PersistenceManager;
    ...
    
    public class StudentsDao {
    
        private PersistenceManager<StudentEntity> persistenceManager = new PersistenceManager<>();
    
        public StudentEntity find(Long id) {
            Connection connection = null;
            try {
                connection = getConnection();
                return persistenceManager.find(connection, StudentEntity.class, id);
            } finally {
                closeConnection(connection);
            }
        }
    
        public List<StudentEntity> query(String sql, Object... values) {
            Connection connection = null;
            try {
                connection = getConnection();
                return persistenceManager.query(connection, StudentEntity.class, sql, values);
            } finally {
                closeConnection(connection);
            }
        }
    ...
    
    1. Dependency

    <dependency>
        <groupId>org.eclipse.dirigible</groupId>
        <artifactId>dirigible-database-persistence</artifactId>
        <version>3.2.8</version>
    </dependency>
    

Embedded Dirigible

Embedded-Dirigible

The last option is the hybrid/embedded deployment, where a legacy application is running in coexistence with part of the Dirigible stack. The setup targets the scenarios where there is a lot of legacy (Java) code, but the low-code/no-code and In-System Development capabilities of Dirigible are desired.

...
import org.eclipse.dirigible.runtime.core.embed.EmbeddedDirigible;
...

public void callDirigible() {
    EmbeddedDirigible dirigible = new EmbeddedDirigible();
    dirigible.load("./content");
    dirigible.executeJavaScript("project/api.js");
}
...

For more details about this setup, check out the embedded Dirigible sample.

Resources

Experiment with the single-click deployment of the following demos from EclipseCon 2018:

  1. Run on Dirigible (GitHub)

  2. Run on Dirigible (GitHub)

  3. Run on Dirigible (GitHub)

  4. Run on Dirigible (GitHub)

  5. Run on Dirigible (GitHub)