Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Learn How to Rapidly Create a Customized CMS with this Java Framework!

DZone's Guide to

Learn How to Rapidly Create a Customized CMS with this Java Framework!

A look at how this CMS allows you to focus on one thing and one thing only, the definition of your own domain.

· Web Dev Zone ·
Free Resource

Learn how to add document editing and viewing to your web app on .Net (C#), Node.JS, Java, PHP, Ruby, etc.

Over the years of being a freelance developer for small to medium businesses, there has been one constant, CRUD applications. They usually consisted of some sort of ‘backend’ that handled the content of an app or website.

Well, for a website, the solution is easy; Wordpress, or maybe Joomla?

Well what, about apps? Back to square one...

I Present to You, Elepy.

Elepy (also on GitHub) is an open-source Headless Content Management Framework for Java and Kotlin. The framework comes bundled with an Admin Control Panel that lets you easily control your content.

The framework lets you focus on one thing and one thing only, the definition of your own domain.

Don’t Believe Me? Just Watch!

Creation of a content type is as easy as annotating the POJOs that define your domain.

import com.elepy.annotations.*;
import com.elepy.models.TextType;

@RestModel(slug = "/products", name = "Name")
public class Product {

    @Identifier
    private String id;

    @Number(minimum = 0)
    private BigDecimal price;

    @Unique
    @Searchable
    private String name;

    @DateTime(maxDate = "2050-01-01")
    private Date expirationDate;

    @Text(TextType.TEXTAREA)
    private String shortDescription;

    @Text(TextType.HTML)
    @PrettyName("This is a detailed description of the Product")
    private String longDescription;


    // Getters and setters. I like to use Project Lombok to automate this :D

}


What about the Database?

Well by default, Elepy uses MongoDB, but provides support for the different flavors of SQL through a Hibernate/JPA extension.

import com.elepy.Elepy;
import com.elepy.admin.ElepyAdminPanel;
import com.mongodb.DB;
import com.mongodb.MongoClient;

public class Main {

    public static void main(String[] args) {

        MongoClient mongoClient = someMongoClientWithConfiguration; // Configure your MongoClient
        DB exampleDB = mongoClient.getDB("example1");

        new Elepy()
                .connectDB(exampleDB)
                .onPort(7777)
                .addModel(Product.class)
                .addExtension(new ElepyAdminPanel())

                //Start Elepy!
                .start();
    }

}

Well, What Now?

That’s it, you just created a CMS!

By navigating to http://localhost:7777/admin, you can log in and administrate your content. Username and Password (in version 1): admin

What Else Can Elepy Do?

Well, it’s a long list. A growing list, because Elepy 2 is under construction! To name a few features: pagination, searching, sorting, and 25+ annotations.

But the true beauty of Elepy lies in its customizability and extendability. It has an entire plugin/module ecosystem, a dependency injection micro-framework, and a routing micro-framework that you can make use of. The best part is that every part of the framework can be extended or replaced. Everything from the presentation to the data access layer.

Keep Up With Elepy

Extend your web service functionality with docx, xlsx and pptx editing. Check out ONLYOFFICE document editors for integration.

Topics:
java ,rest api ,kotlin ,headless cms ,web dev

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}