All Projects → metamug → mason

metamug / mason

Licence: other
REST APIs with JSP tags, SQL and much more.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to mason

LPU-Java-2022-1
LPU Java JEE Sessions 2022 Batch 1
Stars: ✭ 30 (+25%)
Mutual labels:  jsp, jdbc
Java Interview Questions
1000+ Java Interview Questions
Stars: ✭ 212 (+783.33%)
Mutual labels:  jsp, jdbc
shoppingPro
此项目是橘子网上商城的功能,按照我自己的想法实现的一个自营模式的商城应用。 目前实现了前台的功能,后台的功能,主要有登录,注册,商品展示,购物车等模块。后台面有添加商品,删除商品,商品上下架,订单管理,管理员管理,实现了E支付功能和百度地图功能.为了便于此项目日后的完善和扩展, 我采用了前后端分离的架构设计。前端主要使用javaScript,jquery,AjAX,JSP构建的单页web应用, 通过使用指令,服务,模板,控制器完成前端的MVC分层,各个模板页面的效果实现则使用了基本的CSS3等技术, 结合JS完成页面的基本交互效果。由于有实现数据库和后台模块等功能,通过AJax请求完成整个前台功能的数据交互, 后期再考虑实现一个后台管理系统及数据库系统,还有前端页面资源的异步加载及优化。
Stars: ✭ 28 (+16.67%)
Mutual labels:  jsp, jdbc
liferay-portal-oracledb-support
Liferay Portal 7 Community Edition Oracle Database Support ** NO LONGER MAINTAINED **. Refer to this repository: https://github.com/amusarra/liferay-portal-database-all-in-one-support
Stars: ✭ 13 (-45.83%)
Mutual labels:  jdbc
delta
DDD-centric event-sourcing library for the JVM
Stars: ✭ 15 (-37.5%)
Mutual labels:  jdbc
ServletContainer
A servlet container which can parse static resource,servlet and jsp.
Stars: ✭ 20 (-16.67%)
Mutual labels:  jsp
jsql
Programing like SQL syntax with Java
Stars: ✭ 17 (-29.17%)
Mutual labels:  jdbc
acolyte
🐯 Mockup/testing JDBC & MongoDB driver (or Chmeee's son on the Ringworld).
Stars: ✭ 58 (+141.67%)
Mutual labels:  jdbc
avro-schema-generator
Library for generating avro schema files (.avsc) based on DB tables structure
Stars: ✭ 38 (+58.33%)
Mutual labels:  jdbc
rxkotlin-jdbc
Fluent RxJava JDBC extension functions for Kotlin
Stars: ✭ 27 (+12.5%)
Mutual labels:  jdbc
vok-orm
Mapping rows from a SQL database to POJOs in its simplest form
Stars: ✭ 13 (-45.83%)
Mutual labels:  jdbc
WebStore-Spring-MVC
WebStore is a full fledged online shopping system built in Spring-MVC. It uses JSP for view templating and MySql at the database end.
Stars: ✭ 29 (+20.83%)
Mutual labels:  jsp
OpenAM
OpenAM is an open access management solution that includes Authentication, SSO, Authorization, Federation, Entitlements and Web Services Security.
Stars: ✭ 476 (+1883.33%)
Mutual labels:  jdbc
jdbdt
JDBDT: Java Database Delta Testing
Stars: ✭ 12 (-50%)
Mutual labels:  jdbc
nimble-orm
一个灵活轻量级的基于Spring jdbcTemplate的ORM
Stars: ✭ 36 (+50%)
Mutual labels:  jdbc
StackMob-3
A plugin designed for bukkit servers, aiming to reduce the lag that both the server and players experience.
Stars: ✭ 23 (-4.17%)
Mutual labels:  jdbc
baymax
铜板街轻量级JDBC层分库分表框架
Stars: ✭ 45 (+87.5%)
Mutual labels:  jdbc
php-jdbc-bridge
Service and library to allow a PHP application to interface with a database via JDBC
Stars: ✭ 20 (-16.67%)
Mutual labels:  jdbc
incubator-linkis
Linkis helps easily connect to various back-end computation/storage engines(Spark, Python, TiDB...), exposes various interfaces(REST, JDBC, Java ...), with multi-tenancy, high performance, and resource control.
Stars: ✭ 2,459 (+10145.83%)
Mutual labels:  jdbc
AbacusUtil
Release the power in Java programming
Stars: ✭ 77 (+220.83%)
Mutual labels:  jdbc

🧱 MASON

Build Status Maven Central javadoc.io Coverage Status LGPL v2.1 License Gitter

Mason is an open-source, lightweight data access layer for REST resources designed to be used in Java web applications. It handles incoming API requests and routes the parameters to these resources.

<dependency>
  <groupId>com.metamug</groupId>
  <artifactId>mason</artifactId>
  <version>4.8</version>
</dependency>

Motivation

Use JSP tags for editing database queries and request handling. To hot deploy REST APIs without compiling/deploying Java classes. Build REST APIs with JSP tags.

<jsp:directive.include file="../fragments/mason-init.jspf"/>
<%-- customer.jsp --%>
<m:resource>
    <m:request method="GET">
     	<sql:query var="customers" dataSource="${datasource}"> 
		SELECT name, address, phone, type from retail_customer 
    	</sql:query>
     	<c:set target="${output}" property="customers" value="${customers}"/>
    </m:request>
</m:resource>

Sample Project

Mason Resources

Mason turns your Plain Old JSPs (with neat tag libraries) into REST Resources. Mason doesn't encourage using scriptlets in Resource JSPs.

You can handle GET, POST, PUT, DELETE requests in your JSP. Mason has been tested with tomcat 9. jstl.jar shipped with tomcat is make jstl work.

Learn more about jsp configurations here. https://tomcat.apache.org/tomcat-9.0-doc/jasper-howto.html

Mason Query

You can write database queries inside the resource JSP files as seen in the above example or you can place them in {webAppDir}/WEB-INF/classes/query.properties file and reference them inside the JSP files for reuse.

Features?

  • Request Processing
  • Mapping resource URI to JSP
  • HTTP BASIC and JWT Authentication
  • Convert SQL Results into JSON/XML based on Accept Header 🌟
  • Make External API Requests
  • Pagination
  • Many more

Mason Jar

Mason Jar

Clone and package the project with mvn

mvn clean package

After that you can find mtg-mason-1.0.jar inside the target folder. You can use this jar as a dependency in your Java webapp.

How to use mason in your Webapp

  1. Place the mason jar file in {webAppDir}/WEB-INF/lib

  2. Download jstl jar file and place it inside {webAppDir}/WEB-INF/lib

  3. Create a folder {webAppDir}/WEB-INF/resources/{resourceVersion} and place your jsp files here. For example, mywebapp/WEB-INF/resources/v1.0/foo.jsp.

  4. Import mtg-mason.tld inside your jsp file. This taglib is present inside the mason jar and enables usage of the mtg prefix. You will also need to import the jstl taglib. Your jsp file should contain the following

<% @taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<% @taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<% @taglib uri="mtg-mason.tld" prefix="m" %>
<%@ page trimDirectiveWhitespaces="true" %>
  1. Add the following filter and listener inside {webAppDir}/WEB-INF/web.xml
<filter>
    <filter-name>Router</filter-name>
    <filter-class>com.metamug.mason.Router</filter-class>
</filter>

<filter-mapping>
    <filter-name>Router</filter-name>
    <url-pattern>/*</url-pattern>
    <init-param>
        <param-name>datasource</param-name>
        <param-value>jdbc/mason</param-value>
    </init-param>
</filter-mapping>

All requests made to the jsp resources are routed through this filter.

  1. Configure your data source in {webAppDir}/META-INF/context.xml file.

You can take a look at the sample webapp.

JDBC Drivers

Except for javaee-web-api since that would be present in your application server and any one out of HSQL, MySQL or PostgreSQL dependency. We also support Oracle database but due to its licensing we can't ship oracle jdbc driver along. So in case you are using Oracle database, you'll have to manually install its driver as a dependency in your project.

Instructions regarding how to do the same in below link(s) (You can refer either of them). https://www.mkyong.com/maven/how-to-add-oracle-jdbc-driver-in-your-maven-local-repository/ OR https://stackoverflow.com/a/1074971/4800126

Data Format Support

Mason supports application/xml, applicaton/json and application/json+dataset Read More about how it is used here. https://metamug.com/docs/api-request

Scripting Support

Mason supports groovy for writing scripts. You need to keep the scripts in {webAppDir}/WEB-INF/scripts

Example Script

//test.groovy
def params = _request.getParams()
res['message'] = 'Hello ' + params['name']

The script can be invoked using script tag in jsp resource.

<m:script file="test.groovy" var="res" />

How To Contribute

Fork this repo and submit a PR against the listed issues. Any donations for this project will be paid to individual developers working in their personal capacity on this project. To reward them for their contribution and keeping Mason a community project.

SonarCloud Bugs SonarCloud Vulnerabilities Total alerts Language grade: Java

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].