Java-Connector

Java-Connector

Java Wrapper for Infinity JSON V3 API

How to install

Either download any of these jars and import them into you project:

Or download the source and reference the core and spring modules and build it using gradle.

Requires Java 1.8 or later. If running Java 1.7 or under please use an older version of the library available in the GitHub history.

Javadoc for the latest release is available herearrow-up-right. Javadoc for the latest Spring specific implementation is available herearrow-up-right.

How to use

The Infinity Connector is easily configured if running Spring.

Spring

Simply add the following code to the Spring configuration class marked with @Configuration:

An ILoop54Client is then injectable by using the @Autowire annotation

Multiple instances

If you are using multiple instances of the Infinity engine within you application you instead need to do the following:

And then inject the ILoop54ClientProvider interface into your application with the @Autowire annotation. And obtain a specific instance using the getNamed method with the same name as above:

Using the ILoop54Client

The ILoop54Client contains methods for making all public API calls to the Loop54 e-commerce search engine. It contains both synchronous and asynchronous variants of all methods.

To add parameters to the SearchRequest you could do this:

All other request types also have their own types to use:

But wait! I’m not using Spring

There is still hope for you. If not using the above mentioned frameworks you can implement some of the functionality yourself and use the client just as well. You will need to implement the IRemoteClientInfoProvider interface and the IRemoteClientInfo interface and after doing that you can create a new instance of ILoop54Client like this:

And you are good to go!

Features

  • Native support for search, autoComplete, createEvent, getEntities, getEntitiesByAttribute and getRelatedEntities call. With intuitive APIs to call them.

  • Handles user identification using random-generated cookies.

  • Uses X-Forwarded-For as client IP if it’s available.

  • Configurable HTTP timeout.

  • GZIP support.

  • Relays HTTP data to engine:

    • Referer

    • UserAgent

    • Library version

Building and testing

Building, generating javadoc and running the test apps requires JDK 1.8**.** It might work with later versions, but has not been tested.

First of all, make sure you have JDK installed by running (assuming Ubuntu Linux):

If this tells you that java is not installed, you need to run:

If you’re on windows, download the 1.8 JDK from https://www.java.com/

To build the library simply use the supplied gradle wrapper by going to the root directory of the repository in the command line and issue the following command:

The --info flag is so that you get detailed error information when tests fail, instead of just a short summary of which tests failed.

This will download gradle 5.1 and all dependencies, build all modules and run the unit tests.

If you get an error saying Could not determine java version from '[x]' that means that your locally installed Java version is newer than the gradle wrapper supports. You need to either upgrade the gradle wrapper or downgrade your Java version.

If you get an error saying Could not set unknown property '[x]' for the web or codeexamples projects, that means that gretty plugin has released a new version that is not compatible with your gradle version. You need to either upgrade the gradle wrapper or specify an exact gretty version in the build.gradle cofig files in the web and codeexamples projects.

You may run into some flaky tests. Some of the tests use helloworld.54proxy.com instead of a mock engine. This engine can become stale (no behavior data) and this might cause some tests to fail, especially the autoComplete tests. To fix this, you need to search a few times for phrases beginning with the strings that fail. For instance, if the “be” test fails, search a few times for “beef” to make sure there is data in the engine.

To generate the javadoc, run:

Run the test application in the web module by using the following command:

And the application will start and be hosted on http://localhost:8080/web.

Last updated

Was this helpful?