This project includes the resources needed to develop a Data Adapter for the Lighstreamer - Basic Stock-List Demo - HTML Client that is pluggable into Lightstreamer Server.
The Stock-List demos simulate a market data feed and front-end for stock quotes. They show a list of stock symbols and updates prices and other fields displayed on the page in real-time.
The project is comprised of source code and a deployment example.
The Stock-List Data Adapter is comprised of three Java classes.
Contains the data generation logic (that is, the actual feed simulator). This is a broadcast feed, which delivers all the generated data, with no notion of subscriptions.
Handles the data delivery from the ExternalFeedSimulator to the DemoDataProvider, to better decouple the two classes.
Implements the DataProvider interface to handle the communication with Lightstreamer Kernel. Leverages the ExternalFeedListener to get the data originated by the ExternalFeedSimulator. Injects the received data into Lightstreamer Kernel or filters it out based on the subscriptions/unsubscriptions received from the Kernel.
See the source code comments for further details.
The Metadata Adapter functionalities are absolved by the LiteralBasedProvider
in Lightstreamer Java In-Process Adapter SDK, a simple full implementation of a Metadata Adapter, already provided by Lightstreamer server.
This Adapter Set is configured and will be referenced by the clients as DEMO
.
The adapters.xml
file for the Stock-List Demo, should look like:
<?xml version="1.0"?>
<!-- Mandatory. Define an Adapter Set and sets its unique ID. -->
<adapters_conf id="DEMO">
<metadata_provider>
<adapter_class>com.lightstreamer.adapters.metadata.LiteralBasedProvider</adapter_class>
<!-- Optional.
See LiteralBasedProvider javadoc. -->
<!--
<param name="max_bandwidth">40</param>
<param name="max_frequency">3</param>
<param name="buffer_size">30</param>
<param name="distinct_snapshot_length">10</param>
<param name="prefilter_frequency">5</param>
<param name="allowed_users">user123,user456</param>
-->
<!-- Optional.
See LiteralBasedProvider javadoc. -->
<param name="item_family_1">item.*</param>
<param name="modes_for_item_family_1">MERGE</param>
</metadata_provider>
<data_provider name="QUOTE_ADAPTER">
<adapter_class>com.lightstreamer.examples.stocklist_demo.adapters.StockQuotesDataAdapter</adapter_class>
<!-- Optional for StockQuotesDataAdapter.
Configuration file for the Adapter's own logging.
Logging is managed through log4j. -->
<param name="log_config_refresh_seconds">10</param>
</data_provider>
</adapters_conf>
NOTE: not all configuration options of an Adapter Set are exposed by the file suggested above.
You can easily expand your configurations using the generic template, see the Java In-Process Adapter Interface Project for details.
Please refer here for more details about Lightstreamer Adapters.
If you want to install a version of the Stock-List Demo in your local Lightstreamer Server, follow these steps:
- Download Lightstreamer Server (Lightstreamer Server comes with a free non-expiring demo license for 20 connected users) from Lightstreamer Download page, and install it, as explained in the
GETTING_STARTED.TXT
file in the installation home directory. - Make sure that Lightstreamer Server is not running.
- Get the
deploy.zip
file of the latest release, unzip it, and copy theStockList
folder into theadapters
folder of your Lightstreamer Server installation. - Launch Lightstreamer Server.
- Test the Adapter, launching the Basic Stock-List Demo - HTML Client listed in Clients Using This Adapter.
To build your own version of stocklist-adapter-java-x.y.z.jar
instead of using the one provided in the deploy.zip
file from the Install section above, you have two options:
either use Maven (or other build tools) to take care of dependencies and building (recommended) or gather the necessary jars yourself and build it manually.
For the sake of simplicity only the Maven case is detailed here.
You can easily build and run this application using Maven through the pom.xml file located in the root folder of this project. As an alternative, you can use an alternative build tool (e.g. Gradle, Ivy, etc.) by converting the provided pom.xml file.
Assuming Maven is installed and available in your path you can build the demo by running
mvn install dependency:copy-dependencies
- Lightstreamer Java In-Process Adapter SDK
- LiteralBasedProvider Metadata Adapter
- Lightstreamer - Portfolio Demo - Java Adapter
- Lightstreamer - Stock-List Demo - Java Remote Adapter
- Lightstreamer - Stock-List Demo - .NET Adapter
- Lightstreamer - Stock-List Demo - Java (JMS) Adapter
- Compatible with Lightstreamer SDK for Java In-Process Adapters since 6.0
- For a version of this example compatible with Lightstreamer SDK for Java Adapters version 5.1, please refer to this tag.