Giter VIP home page Giter VIP logo

lite-beans's Introduction

LiteBeans Project

LiteBeans is implementation of the java.beans package based on the Apache Harmony project.

Problem

The java.desktop module introduced in JDK 9 encapsulates all AWT, Swing, Image and Sound packages from Java standard libraries.

In addition to that, it contains the java.beans package with helper classes to interact with Java Beans, specifically bean introspection and property change listeners.

Due to its tight dependency with AWT and Swing, it cannot be easily removed from java.desktop module, causing any thirdparty library that uses java.beans package to be dependent of all java.desktop classes.

The extra overhead of java.desktop module adds 12mb of size into the JVM installation and increases memory usage.

Solution

Implemented java.beans package with only java.base module dependency based on Apache Harmony project source code.

The implementation is a subset of official JDK java.beans classes, it does not implement the full interface.

However, it adds enough classes to be used by Object Mapping (xml, json) libraries and Dependency Injection (Spring, CDI) frameworks in a transparent way.

The total size of LiteBeans library is less than 150kb.

Usage

Using as a java.beans alternative

  1. Add Maven Dependency
<dependency>
    <groupId>com.github.panga</groupId>
    <artifactId>lite-beans</artifactId>
    <version>1.0.0</version>
</dependency>
  1. Find all ocurrencies of import java.beans and replace with import lite.beans.

Using as a module patch (hacking JPMS)

  1. Add Maven Dependency or download the JAR (notice the classifier)
<dependency>
    <groupId>com.github.panga</groupId>
    <artifactId>lite-beans</artifactId>
    <version>1.0.0</version>
    <classifier>patch</classifier>
</dependency>
  1. Run your application in a minimal JRE without java.desktop module:
java \
    --patch-module java.base=lite-beans-1.0.0-patch.jar \
    --add-exports java.base/java.beans=acme.myapp \
    --module-path target/modules --module acme.myapp \

Note: See usage in https://github.com/panga/hammock-jpms example.

Contributors

License

Apache License 2.0

lite-beans's People

Contributors

panga avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

cybernetics

lite-beans's Issues

PropertyDescriptor are gathered in an indeterministic way

Great lib which really improves java.beans.Introspector performance (30 seconds instead of 100 seconds in my current case).

But I noticed that as introspection is done, the result is not always the same. Sometimes, instead of having a propertyDescriptor like that:

[name=foo
 readMethod=getFoo,
 writeMethod=setFoo]

I receive:

[[name=foo
 readMethod=null,
 writeMethod=setFoo],
 [name=foo
 readMethd=getFoo,
 writeMethod=null]]

I don't get why the behavior is not constant, though you implemented a field comparator which should handle properties always in the same order, but it actually happens !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.