Skip to content

Commit

Permalink
Mvn-ize build and upgrade to log4j 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Bravo27 committed Dec 10, 2020
1 parent 4e06409 commit 1381cc9
Show file tree
Hide file tree
Showing 20 changed files with 142 additions and 114 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,25 @@ As example of a client using this adapter, you may refer to the [Multiplayer Dar
If you want to install a version of this 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; this should be preferred to using COMMUNITY edition, otherwise you would see a limit on the event rate) from [Lightstreamer Download page](http://www.lightstreamer.com/download.htm), and install it, as explained in the `GETTING_STARTED.TXT` file in the installation home directory.
* Get the `deploy.zip` file of the [latest release](https://github.com/Lightstreamer/BananaDarts-adapter-java/releases), unzip it and copy the just unzipped `BananaDarts` folder into the `adapters` folder of your Lightstreamer Server installation.
* Download [croftsoft](http://sourceforge.net/projects/croftsoft/files/) library and compile a `croftsoft-math.jar` version. Please make sure to include: applet, io, inlp, lang and math packages.
* Copy the just compiled `croftsoft-math.jar` file in the `BananaDarts/lib` folder.
* [Optional] Customize logging settings in log4j configuration file `BananaDarts/classes/log4j2.xml`.
* Launch Lightstreamer Server.
* Launch a client like the [Multiplayer Darts - HTML (LeapJS, Three.js) Client](https://github.com/Lightstreamer/BananaDarts-client-javascript).

## Build
To build your own version of `LS_darts_adapters.jar`, instead of using the one provided in the `deploy.zip` file from the [Install](https://github.com/Lightstreamer/BananaDarts-adapter-java#install) section above, follow these steps:
* Clone this project
* Get the `ls-adapter-interface.jar` file from the [Lightstreamer distribution](http://www.lightstreamer.com/download) and copy it into the `lib` folder.
* Get the `log4j-1.2.17.jar` file from [Apache log4j](https://logging.apache.org/log4j/1.2/) and copy it into the `lib` folder.
* Download [croftsoft](http://sourceforge.net/projects/croftsoft/files/) library and compile a `croftsoft-math.jar` version. Please make sure to include: applet, io, inlp, lang and math packages.
* Put the just compiled `croftsoft-math.jar` file in the `lib` folder.
* Build the java source files in the `src` folder into a `LS_darts_adapters.jar` file. Here is an example for that:
```sh
> mkdir classes
> javac -classpath ./lib/croftsoft-math.jar;./lib/ls-adapter-interface.jar;./lib/log4j-1.2.17.jar -d ./classes ./src/com/lightstreamer/adapters/Dart/*.java ./src/com/lightstreamer/adapters/Dart/engine3D/*.java ./src/com/lightstreamer/adapters/Dart/room/*.java
> jar cvf LS_darts_adapters.jar -C classes com
To build your own version of `example-MultiplayerDarts-adapter-java-0.0.1-SNAPSHOT.jar`, instead of using the one provided in the `deploy.zip` file from the [Install](https://github.com/Lightstreamer/BananaDarts-adapter-java#install) section above, you have two options:
either use [Maven](https://maven.apache.org/) (or other build tools) to take care of dependencies and building (recommended) or gather the necessary jars yourself and build it manually.
As a precondition for compiling you need to download [croftsoft](http://sourceforge.net/projects/croftsoft/files/) library and copy the sources of applet, io, jnlp, lang and math packages into `src\main\java\` folder of this project.
For the sake of simplicity only the Maven case is detailed here.

### Maven

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
```sh
mvn install dependency:copy-dependencies
```
* Copy the just compiled `LS_darts_adapters.jar` in the `adapters/Dart/lib` folder of your Lightstreamer Server installation.


## See Also

Expand All @@ -44,5 +44,6 @@ To build your own version of `LS_darts_adapters.jar`, instead of using the one p

## Lightstreamer Compatibility Notes

* Compatible with Lightstreamer SDK for Java In-Process Adapters since 6.0
- Compatible with Lightstreamer SDK for Java In-Process Adapters since 7.3.
- For a version of this example compatible with Lightstreamer SDK for Java Adapters version 6.0, please refer to [this tag](https://github.com/Lightstreamer/BananaDarts-adapter-java/tree/pre_mvn).
- For a version of this example compatible with Lightstreamer SDK for Java Adapters version 5.1, please refer to [this tag](https://github.com/Lightstreamer/BananaDarts-adapter-java/tree/for_Lightstreamer_5.1).
2 changes: 0 additions & 2 deletions deployment_LS/README.md

This file was deleted.

25 changes: 0 additions & 25 deletions deployment_LS/dart/adapters.xml

This file was deleted.

42 changes: 0 additions & 42 deletions deployment_LS/dart/adapters_log_conf.xml

This file was deleted.

4 changes: 0 additions & 4 deletions lib/README.md

This file was deleted.

90 changes: 90 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.lightstreamer</groupId>
<artifactId>example-MultiplayerDarts-adapter-java</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>example-MultiplayerDarts-adapter-java</name>
<url>http://maven.apache.org</url>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.lightstreamer.adapters.Dart.DartMetaDataAdapter</mainClass>
</configuration>
</plugin>

</plugins>
</build>

<repositories>
<repository>
<id>Twitter</id>
<name>Twitter repository</name>
<url>https://maven.twttr.com/</url>
</repository>
<repository>
<id>Anahata</id>
<name>Anahata Repository</name>
<url>http://repo.anahata.uno/artifactory/anahata-public/</url>
</repository>

</repositories>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.lightstreamer</groupId>
<artifactId>ls-adapter-inprocess</artifactId>
<version>7.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.13.3</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>3.6.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.jnlp/jnlp -->
<dependency>
<groupId>javax.jnlp</groupId>
<artifactId>jnlp</artifactId>
<version>7.0</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.lightstreamer.adapters.Dart.engine3D.Universe;
import com.lightstreamer.adapters.Dart.room.ChatRoom;
Expand All @@ -46,6 +46,7 @@ public class DartDataAdapter implements SmartDataProvider, ChatRoomListener {

@Override
public void init(Map params, File configDir) throws DataProviderException {
/*
String logConfig = (String) params.get("log_config");
if (logConfig != null) {
File logConfigFile = new File(configDir, logConfig);
Expand All @@ -56,8 +57,9 @@ public void init(Map params, File configDir) throws DataProviderException {
DOMConfigurator.configure(logConfigFile.getAbsolutePath());
}
} //else the bridge to logback is expected
*/

logger = Logger.getLogger(Constants.LOGGER_CAT);
logger = LogManager.getLogger(Constants.LOGGER_CAT);

logger.info("Adapter Logger start.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.log4j.Logger;
import org.apache.log4j.xml.DOMConfigurator;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.lightstreamer.adapters.Dart.engine3D.Universe;
import com.lightstreamer.adapters.Dart.room.ChatRoom;
Expand Down Expand Up @@ -53,6 +53,7 @@ public class DartMetaDataAdapter extends LiteralBasedProvider {

@Override
public void init(Map params, File configDir) throws MetadataProviderException {
/*
String logConfig = (String) params.get("log_config");
if (logConfig != null) {
File logConfigFile = new File(configDir, logConfig);
Expand All @@ -63,8 +64,9 @@ public void init(Map params, File configDir) throws MetadataProviderException {
DOMConfigurator.configure(logConfigFile.getAbsolutePath());
}
} //else the bridge to logback is expected
*/

logger = Logger.getLogger(Constants.LOGGER_CAT);
logger = LogManager.getLogger(Constants.LOGGER_CAT);

// Read the Adapter Set name, which is supplied by the Server as a parameter
this.adapterSetId = (String) params.get("adapters_conf.id");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@
import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import org.apache.commons.math3.complex.Quaternion;

import com.croftsoft.core.lang.EnumUnknownException;
import com.croftsoft.core.math.axis.AxisAngle;

import com.lightstreamer.adapters.Dart.room.User;
import com.lightstreamer.interfaces.metadata.CreditsException;

public class Dart implements IBody {

private Logger logger = Logger.getLogger(com.lightstreamer.adapters.Dart.Constants.WORLD_CAT);
private Logger logger = LogManager.getLogger(com.lightstreamer.adapters.Dart.Constants.WORLD_CAT);

private String id;

Expand Down Expand Up @@ -463,19 +466,19 @@ public void resetScore() {
//rotation is not handled -->

@Override
public AxisAngle getAxisAngle() {
public Quaternion getAxisAngle() {
// TODO Auto-generated method stub
return null;
}

@Override
public void setAxisAngle(AxisAngle axisAngle) {
public void setAxisAngle(Quaternion axisAngle) {
// TODO Auto-generated method stub

}

@Override
public void rotate(AxisAngle axisAngle) {
public void rotate(Quaternion axisAngle) {
// TODO Auto-generated method stub

}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
/*
Copyright (c) Lightstreamer Srl
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Expand Down Expand Up @@ -117,4 +114,4 @@ public static boolean isInBoard(double x, double y) {
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
limitations under the License.
*/
package com.lightstreamer.adapters.Dart.engine3D;
import com.croftsoft.core.math.axis.AxisAngle;

import org.apache.commons.math3.complex.Quaternion;

/***********************************************************************
* Mutator interface for a JoglCamera.
Expand Down Expand Up @@ -53,15 +54,15 @@ public enum Translation {
UP
}

AxisAngle getAxisAngle ( );
Quaternion getAxisAngle ( );

double getX ( );

double getY ( );

double getZ ( );

void setAxisAngle ( AxisAngle axisAngle );
void setAxisAngle ( Quaternion axisAngle );

void setX ( double x );

Expand All @@ -71,7 +72,7 @@ public enum Translation {

// relative mutator methods

void rotate (AxisAngle axisAngle);
void rotate (Quaternion axisAngle);

void rotate (Axis axis, double degrees);

Expand Down
Loading

0 comments on commit 1381cc9

Please sign in to comment.