All Downloads are FREE. Search and download functionalities are using the official Maven repository.

javolution.doc-files.overview.html Maven / Gradle / Ivy

The newest version!

Javolution - JavaTM Solution for Real-Time and Embedded Systems.

License:

Permission to use, copy, modify, and distribute this software is freely granted, provided that copyright notices are preserved (the full license text can be found here).

Javolution's users are encouraged to show their support with the button.

Overview:

Although JavaTM has been very successful on the server-side; It has few shortcomings limiting its adoption for others domains such as real-time, embedded or high-performance applications. For these, the Javolution library provides important "pieces" missing from the JavaTM core library and making the JavaTM platform even more attractive.

Usage:

Javolution can be used as a standard OSGi bundle.

import org.osgi.framework.*;
import org.osgi.util.tracker.ServiceTracker;
public class MyActivator implements BundleActivator { 
    ServiceTracker<XMLInputFactory, XMLInputFactory> tracker; 
    public void start(BundleContext bc) throws Exception {
        tracker = new ServiceTracker<>(bc, XMLInputFactory.class, null);
        tracker.open();
        parse();
    }
    public void stop(BundleContext bc) throws Exception {
        tracker.close();
    }
    public void parse() throws XMLStreamException {
        XMLInputFactory factory = tracker.getService();  
        factory.setProperty(XMLInputFactory.IS_COALESCING, true); // Configures.

        // Instantiates a new reader.
        String xml = "<test>This is a test</test>";
        CharSequenceReader in = new CharSequenceReader().setInput(xml);
        XMLStreamReader reader = factory.createXMLStreamReader(in);
       
        // Parses XML.
       while (reader.hasNext()) {
          int eventType = reader.next();
          if (eventType == XMLStreamConstants.CHARACTERS) {
              System.out.println(reader.getText());
          }
       }
 
       // Closes the reader which may be recycled back to the factory.
      reader.close();
   }          
}

Or as a standard Java library (does not require OSGi runtime).

import javolution.osgi.internal.OSGiServices;
public class Main {
    public static void main(String[] args) throws XMLStreamException {
        XMLInputFactory factory = OSGiServices.getXMLInputFactory();  
        factory.setProperty(XMLInputFactory.IS_COALESCING, true); // Configures.
        
        // Instantiates a reader.
        String xml = "<test>This is a test</test>";
        CharSequenceReader in = new CharSequenceReader().setInput(xml);
        XMLStreamReader reader = factory.createXMLStreamReader(in);
        
        // Parses XML.
        while (reader.hasNext()) {
           int eventType = reader.next();
           if (eventType == XMLStreamConstants.CHARACTERS) {
              System.out.println(reader.getText());
           }
        }
 
        // Closes the reader which may be recycled back to the factory.
        reader.close();
    }
}

Services:

Javolution publishes the following OSGi services.

Published Service Description
{@link javolution.xml.stream.XMLInputFactory} StAX-like version of javax.xml.stream.XMLInputFactory avoiding {@code String} allocations.
{@link javolution.xml.stream.XMLOutputFactory} StAX-like version of javax.xml.stream.XMLOutputFactory using {@code CharSequence} instead of {@code String}

These services can be accessed through the standard OSGi registry or using {@code javolution.osgi.internal.OSGiServices} when running outside OSGi.

Javolution listen to the following OSGi services.

Subscribed Service Description
{@code org.osgi.service.log.LogService} OSGi service to log messages.
{@link javolution.context.LogContext} Service to support asynchronous logging.
{@link javolution.context.ConcurrentContext} Service to support concurrent executions.
{@link javolution.context.LocalContext} Service to support locally scoped settings.
{@link javolution.context.SecurityContext} Service granting security authorizations.
{@link javolution.text.TextContext} Service to support text parsing/formatting.
{@link javolution.xml.XMLContext} Service to support XML serialization/deserialization.




© 2015 - 2024 Weber Informatics LLC | Privacy Policy