Пересмотрена структура проекта
Изменено название: ArcadexSystem -> ASys. Изменены корневые пакеты: eu.arcadex.system -> asys Проект полностью переходит на модульную структуру. Удаляется модуль Core.
This commit is contained in:
54
API/pom.xml
Normal file
54
API/pom.xml
Normal file
@@ -0,0 +1,54 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
<name>ASys API</name>
|
||||
|
||||
<developers>
|
||||
<developer>
|
||||
<name>DmitriyMX</name>
|
||||
<email>mail@dmiriymx.ru</email>
|
||||
</developer>
|
||||
</developers>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<groupId>asys</groupId>
|
||||
<artifactId>api</artifactId>
|
||||
<version>0.1</version>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<build>
|
||||
<finalName>${project.groupId}.${project.artifactId}-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-Name>${project.name}</Bundle-Name>
|
||||
<Bundle-SymbolicName>${project.groupId}.${project.artifactId}</Bundle-SymbolicName>
|
||||
<Export-Package>asys.api</Export-Package>
|
||||
<Import-Package>*</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,3 +1,3 @@
|
||||
# ArcadexSystem: Core
|
||||
# ASys
|
||||
|
||||
Ядро системы
|
||||
Модульная система управления серверами Minecraft. Основана на технологии [OSGi](https://www.osgi.org/).
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>build_files</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>filesystem</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,15 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>configuration</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
</project>
|
||||
39
core/pom.xml
39
core/pom.xml
@@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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>
|
||||
<name>Core</name>
|
||||
|
||||
<artifactId>core</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<packaging>bundle</packaging>
|
||||
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
<finalName>${groupId}.${artifactId}-${version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>2.3.5</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-Name>Arcadex System: ${name} ${version}</Bundle-Name>
|
||||
<Bundle-SymbolicName>${groupId}.${artifactId}</Bundle-SymbolicName>
|
||||
<Bundle-Activator>eu.arcadex.system.core.ASysCoreActivator</Bundle-Activator>
|
||||
<Export-Package>eu.arcadex.system.core.api</Export-Package>
|
||||
<Import-Package>*</Import-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -1,93 +0,0 @@
|
||||
package eu.arcadex.system.core;
|
||||
|
||||
import eu.arcadex.system.core.api.ICore;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.BundleException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author DmitriyMX <mail@dmitriymx.ru>
|
||||
* 2016
|
||||
*/
|
||||
class ASysCore implements ICore {
|
||||
private Logger logger = LoggerFactory.getLogger(ASysCore.class.getName());
|
||||
private BundleContext bundleContext;
|
||||
private List<Bundle> modules;
|
||||
|
||||
ASysCore(BundleContext bundleContext) {
|
||||
this.bundleContext = bundleContext;
|
||||
}
|
||||
|
||||
void init() {
|
||||
// Загрузка библиотек
|
||||
logger.trace("Load libraries");
|
||||
startBundles(loadJars("lib"));
|
||||
|
||||
// Загрузка модулей
|
||||
logger.trace("Load modules");
|
||||
modules = loadJars("modules");
|
||||
startBundles(modules);
|
||||
}
|
||||
|
||||
private List<Bundle> loadJars(String directory) {
|
||||
List<Bundle> bundlesList = new ArrayList<>();
|
||||
|
||||
File libsDir = new File(directory);
|
||||
String[] jarsList = libsDir.list();
|
||||
for (String jar : jarsList) {
|
||||
if (!jar.endsWith(".jar")) continue;
|
||||
try {
|
||||
logger.trace("Load jar \"{}/{}\"", directory, jar);
|
||||
Bundle bundle = bundleContext.installBundle(String.format("file:%s/%s", directory, jar));
|
||||
bundlesList.add(bundle);
|
||||
} catch (BundleException e) {
|
||||
logger.error(String.format("Error load jar \"%s/%s\"", directory, jar), e);
|
||||
}
|
||||
}
|
||||
|
||||
return bundlesList;
|
||||
}
|
||||
|
||||
private void startBundles(List<Bundle> bundleList) {
|
||||
for (Bundle bundle : bundleList) {
|
||||
try {
|
||||
logger.trace("Start module \"{}\"", bundle.getSymbolicName());
|
||||
bundle.start();
|
||||
} catch (BundleException e) {
|
||||
logger.error(String.format("Error start bundle \"%s\"", bundle.getSymbolicName()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void stopBundles(List<Bundle> bundleList) {
|
||||
for (Bundle bundle : bundleList) {
|
||||
try {
|
||||
bundle.stop();
|
||||
} catch (BundleException e) {
|
||||
logger.error(String.format("Error stop bundle \"%s\"", bundle.getSymbolicName()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadMoludes() {
|
||||
logger.trace("Reload modules - start");
|
||||
|
||||
// Остановка модулей
|
||||
stopBundles(modules);
|
||||
|
||||
// Загрузка модулей по-новой
|
||||
modules = loadJars("modules");
|
||||
|
||||
// Запуск модулей
|
||||
startBundles(modules);
|
||||
|
||||
logger.trace("Reload modules - end");
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package eu.arcadex.system.core;
|
||||
|
||||
import eu.arcadex.system.core.api.ICore;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceRegistration;
|
||||
|
||||
/**
|
||||
* @author DmitriyMX <mail@dmitriymx.ru>
|
||||
* 2016
|
||||
*/
|
||||
public class ASysCoreActivator implements BundleActivator {
|
||||
private ServiceRegistration<?> service;
|
||||
|
||||
@Override
|
||||
public void start(BundleContext bundleContext) throws Exception {
|
||||
ASysCore core = new ASysCore(bundleContext);
|
||||
|
||||
// Регистрация сервиса доступа к Ядру
|
||||
service = bundleContext.registerService(ICore.class.getName(), core, null);
|
||||
|
||||
// Инициализация Ядра
|
||||
core.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop(BundleContext bundleContext) throws Exception {
|
||||
service.unregister();
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package eu.arcadex.system.core.api;
|
||||
|
||||
/**
|
||||
* @author DmitriyMX <mail@dmitriymx.ru>
|
||||
* 2016
|
||||
*/
|
||||
public interface ICore {
|
||||
void reloadMoludes();
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>database</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>filesystem</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,145 +0,0 @@
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
/**
|
||||
* File System proxy lib
|
||||
* <p>
|
||||
* Created by daniil on 02.04.16.
|
||||
*/
|
||||
public class FileSystemLib {
|
||||
/**
|
||||
* Copy data from InputStream to OutputStream
|
||||
*
|
||||
* @param from Input Stream
|
||||
* @param to Output Stream
|
||||
* @return size of copied data
|
||||
* @throws IOException
|
||||
*/
|
||||
protected static long copy(InputStream from, OutputStream to) throws IOException {
|
||||
assert from != null;
|
||||
assert to != null;
|
||||
byte[] buf = new byte[4096];
|
||||
long total = 0L;
|
||||
|
||||
while (true) {
|
||||
int r = from.read(buf);
|
||||
if (r == -1) {
|
||||
return total;
|
||||
}
|
||||
|
||||
to.write(buf, 0, r);
|
||||
total += (long) r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy file or directory from one direction to another
|
||||
*
|
||||
* @param from File to copy
|
||||
* @param to Destination
|
||||
* @param replace replace the destination file if present?
|
||||
* @throws IOException
|
||||
*/
|
||||
public void copy(Path from, Path to, boolean replace) throws IOException {
|
||||
assert from != null;
|
||||
assert to != null;
|
||||
|
||||
if (!replace)
|
||||
Files.copy(from, to);
|
||||
else
|
||||
Files.copy(from, to, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete file
|
||||
*
|
||||
* @param file file to delete
|
||||
* @throws IOException, FileNotFoundException
|
||||
*/
|
||||
public void delete(File file) throws IOException {
|
||||
assert file != null;
|
||||
|
||||
if (!file.exists())
|
||||
throw new FileNotFoundException("Unable to delete nonexistent file");
|
||||
if (!file.delete())
|
||||
throw new IOException("Unable to delete this file");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a symlink
|
||||
*
|
||||
* @param linkFile Where symlink should be created
|
||||
* @param actualFile Where should it point to
|
||||
* @throws IOException
|
||||
*/
|
||||
public void createSymlink(Path linkFile, Path actualFile) throws IOException {
|
||||
assert linkFile != null;
|
||||
assert actualFile != null;
|
||||
|
||||
if (!actualFile.toFile().exists())
|
||||
throw new FileNotFoundException("Couldn't find symlink destination");
|
||||
|
||||
Files.createSymbolicLink(linkFile, actualFile);
|
||||
}
|
||||
|
||||
public void restoreFromResources(String resourceName, File destination, boolean replace) throws IOException {
|
||||
assert resourceName != null;
|
||||
assert destination != null;
|
||||
|
||||
if (destination.exists() && !replace)
|
||||
return;
|
||||
try {
|
||||
if (!destination.createNewFile())
|
||||
throw new IOException("Unable to create new file");
|
||||
|
||||
try (InputStream is = this.getClass().getClassLoader().getResourceAsStream(resourceName);
|
||||
OutputStream os = new FileOutputStream(destination)) {
|
||||
copy(is, os);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new IOException("Unable to restore file from resource");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get FileReader for the file
|
||||
* <p>
|
||||
* We need this to make the code testable
|
||||
*
|
||||
* @param file file to read
|
||||
* @return FileReader
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
public Reader getReader(File file) throws FileNotFoundException {
|
||||
assert file != null;
|
||||
|
||||
return new FileReader(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get FileWriter for the file
|
||||
* <p>
|
||||
* We need this to make the code testable
|
||||
*
|
||||
* @param file file to write to
|
||||
* @return FileWriter
|
||||
* @throws IOException
|
||||
*/
|
||||
public Writer getWriter(File file) throws IOException {
|
||||
return new FileWriter(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unzip archive to directory
|
||||
*
|
||||
* @param archive archive to extract
|
||||
* @param directory destination
|
||||
* @throws IOException
|
||||
*/
|
||||
public void unzip(String archive, String directory) throws IOException {
|
||||
UnzipUtility zip = new UnzipUtility();
|
||||
zip.unzip(archive, directory);
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
import java.io.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipInputStream;
|
||||
|
||||
/**
|
||||
* This utility extracts files and directories of a standard zip file to
|
||||
* a destination directory.
|
||||
*
|
||||
* @author www.codejava.net
|
||||
*/
|
||||
public class UnzipUtility {
|
||||
/**
|
||||
* Size of the buffer to read/write data
|
||||
*/
|
||||
private static final int BUFFER_SIZE = 4096;
|
||||
|
||||
/**
|
||||
* Extracts a zip file specified by the zipFilePath to a directory specified by
|
||||
* destDirectory (will be created if does not exists)
|
||||
*
|
||||
* @param zipFilePath path of the archive
|
||||
* @param destDirectory where to extract to
|
||||
* @throws IOException
|
||||
*/
|
||||
public void unzip(String zipFilePath, String destDirectory) throws IOException {
|
||||
File destDir = new File(destDirectory);
|
||||
if (!destDir.exists()) {
|
||||
if (!destDir.mkdir())
|
||||
throw new IOException("Unable to create a root directory to unzip the archive");
|
||||
}
|
||||
ZipInputStream zipIn = new ZipInputStream(new FileInputStream(zipFilePath));
|
||||
ZipEntry entry = zipIn.getNextEntry();
|
||||
// iterates over entries in the zip file
|
||||
while (entry != null) {
|
||||
String filePath = destDirectory + File.separator + entry.getName();
|
||||
if (!entry.isDirectory()) {
|
||||
// if the entry is a file, extracts it
|
||||
extractFile(zipIn, filePath);
|
||||
} else {
|
||||
// if the entry is a directory, make the directory
|
||||
File dir = new File(filePath);
|
||||
|
||||
if (!dir.mkdir()) {
|
||||
throw new IOException("Unable to create a directory to unzip the directory");
|
||||
}
|
||||
}
|
||||
zipIn.closeEntry();
|
||||
entry = zipIn.getNextEntry();
|
||||
}
|
||||
zipIn.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts a zip entry (file entry)
|
||||
*
|
||||
* @param zipIn ZipInputStream
|
||||
* @param filePath Where to extract to
|
||||
* @throws IOException
|
||||
*/
|
||||
private void extractFile(ZipInputStream zipIn, String filePath) throws IOException {
|
||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath));
|
||||
byte[] bytesIn = new byte[BUFFER_SIZE];
|
||||
int read;
|
||||
while ((read = zipIn.read(bytesIn)) != -1) {
|
||||
bos.write(bytesIn, 0, read);
|
||||
}
|
||||
bos.close();
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>netty_api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>database</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
63
pom.xml
63
pom.xml
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>
|
||||
<name>Arcadex System</name>
|
||||
|
||||
<properties>
|
||||
<global.version>0.1</global.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>${global.version}</version>
|
||||
|
||||
<modules>
|
||||
<module>core</module>
|
||||
<module>configuration</module>
|
||||
<module>database</module>
|
||||
<module>filesystem</module>
|
||||
<module>screen</module>
|
||||
<module>build_files</module>
|
||||
<module>netty_api</module>
|
||||
<module>web_api</module>
|
||||
<module>server_manager</module>
|
||||
</modules>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>SonatypeRepo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.osgi</groupId>
|
||||
<artifactId>org.osgi.core</artifactId>
|
||||
<version>6.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>screen</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,65 +0,0 @@
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Realization of class dedicated to the control
|
||||
* of GNU Screen sessions
|
||||
* <p>
|
||||
* Created by daniil on 02.04.16.
|
||||
*/
|
||||
public class ScreenLib {
|
||||
|
||||
/**
|
||||
* Start a screen with certain ID
|
||||
* and execute a command inside it
|
||||
*
|
||||
* @param screenName Screen ID
|
||||
* @param runPath Home path of started screen
|
||||
* @param command Command [+args] to execute inside the screen
|
||||
* @throws IOException
|
||||
*/
|
||||
public void startScreen(String screenName, Path runPath, String... command) throws IOException {
|
||||
assert screenName != null && screenName.length() != 0;
|
||||
assert runPath != null;
|
||||
|
||||
// Merge two arrays
|
||||
String[] commandBase = new String[command.length + 3];
|
||||
commandBase[0] = "screen";
|
||||
commandBase[1] = "-dmS";
|
||||
commandBase[2] = screenName;
|
||||
|
||||
System.arraycopy(command, 0, commandBase, 3, command.length);
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(commandBase);
|
||||
processBuilder.directory(runPath.toFile());
|
||||
processBuilder.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send command to specific screen
|
||||
*
|
||||
* @param screenName Screen ID
|
||||
* @param command Command to send
|
||||
* @throws IOException
|
||||
*/
|
||||
public void sendCommand(String screenName, String command) throws IOException {
|
||||
assert screenName != null;
|
||||
assert command != null;
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("screen", "-S", screenName, "-p", "0", "-X", "stuff", String.format(command + "%n"));
|
||||
processBuilder.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Force terminate a screen session
|
||||
*
|
||||
* @param screenName Screen ID
|
||||
* @throws IOException
|
||||
*/
|
||||
public void killScreen(String screenName) throws IOException {
|
||||
assert screenName != null;
|
||||
|
||||
ProcessBuilder processBuilder = new ProcessBuilder("screen", "-X", "-S", screenName, "quit");
|
||||
processBuilder.start();
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>server_manager</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>build_files</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>screen</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>netty_api</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,32 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>arcadexsystem</artifactId>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<version>${global.version}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>web_api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>database</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>configuration</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eu.arcadex.system</groupId>
|
||||
<artifactId>server_manager</artifactId>
|
||||
<version>${global.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
Reference in New Issue
Block a user