GithubHelp home page GithubHelp logo

jaxo's Introduction

Introduction Build Status

JAXP, JAXB, JAXWS, these XML stuffs can not work well together with OSGi due to class loading strategy. Also nearly all of them are not thread-safe and have critical performance problem if without proper pooling.

Core Bundle

The core bundle wraps latest implementations, pools, and finally provides services.

One should note that this bundle is absolutely not high configurable since we believe JAXP and JAXB is completely over engineered and nobody would ever configure it as it is supposed to be, so either you like this project or you think it sucks.

One good example is javax.xml.parser.DocumentBuilderFactory, by default we set it as namespace awared, and no validation enabled. The reason is, if someone ask you to use JAXP or JAXB, they surely want you to use damn namespace because it is both cool and zhuangbilable, so why not eanbling it by default; and you certainly can validate the DOM after it is built, so validation is no disabled.

This bundle is not an implementation of OSGi Service Platform Service Compendium 702 XML Parser Service Specification. One of the most important reason is checked exception which is a completely failure design of JAXP and JAXP. It just sucks. Another reason is this specification is too simple to be used in reality. So forget about it.

Build and Run

> mvn clean install

> mvn pax:provision

Details

com.honnix.jaxo.core

This bundle provides following OSGi services:

  • CoreService

    This service uses ThreadLocal to cache DocumentBuilder, XPath, etc. The client only needs to get and use without concerning about return back.

  • PoolableCoreSerivce

    This service uses object pool to cache DocumentBuilder, XPath, etc. Since this is a pool, the client needs to get, use and then return it back, otherwise the object will be lost.

    For each kind of pool, it can be configured separately through standard OSGi ConfigAdmin service. Each configuration key is prefixed with the class name, for example:

    • javax.xml.parsers.DocumentBuilder.maxIdle=4
    • javax.xml.parsers.DocumentBuilder.minIdle=2
    • javax.xml.parsers.DocumentBuilder.maxActive=6
    • javax.xml.parsers.DocumentBuilder.maxWait=100
    • javax.xml.parsers.DocumentBuilder.timeBetweenEvictionRunsMillis=100
    • javax.xml.parsers.DocumentBuilder.minEvictableIdleTimeMillis=1000
    • javax.xml.xpath.XPath.maxIdle=4
    • javax.xml.xpath.XPath.minIdle=2
    • javax.xml.xpath.XPath.maxActive=6
    • javax.xml.xpath.XPath.maxWait=100
    • javax.xml.xpath.XPath.timeBetweenEvictionRunsMillis=100
    • javax.xml.xpath.XPath.minEvictableIdleTimeMillis=1000

    For what these configurations mean, please refer to Apache Commons Pool.

    Currently, following types of objects can be configured:

    • javax.xml.parsers.DocumentBuilder
    • javax.xml.parsers.SAXParser
    • javax.xml.xpath.XPath
    • javax.xml.transform.Transformer
    • javax.xml.validation.Validator

    service.pid equals to service name, and if not configured, default values provided by Apache Commons Pool will be used.

com.honnix.jaxo.example

This bundle acts as an example of how to use services. It is very simple, so just read through the source code. One thing need to mention is maven dependency. The client should define dependencies:

<dependency>
  <groupId>com.honnix.jaxo</groupId>
  <artifactId>com.honnix.jaxo.core</artifactId>
  <version>${release.version}</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>xml-apis</groupId>
  <artifactId>xml-apis</artifactId>
  <version>1.4.01</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>javax.xml.bind</groupId>
  <artifactId>jaxb-api</artifactId>
  <version>2.2.6</version>
  <scope>provided</scope>
</dependency>
<dependency>
  <groupId>javax.xml.ws</groupId>
  <artifactId>jaxws-api</artifactId>
  <version>2.2.8</version>
  <scope>provided</scope>
</dependency>

And the client should not delegate javax.xml to bootstrap class loader.

Acknowledgement

Quality ensured by Travis CI.

jaxo's People

Contributors

honnix avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar  avatar

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.