Skip to content

Working in ability to enable and disable units #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.github.thjomnx</groupId>
<artifactId>java-systemd</artifactId>
<version>2.2.0-SNAPSHOT</version>
<version>2.2.0-eks</version>
<packaging>jar</packaging>

<name>${project.artifactId}</name>
Expand Down Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>com.github.hypfvieh</groupId>
<artifactId>dbus-java</artifactId>
<version>3.3.0</version>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
Expand All @@ -57,29 +57,29 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.30</version>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.4.0</version>
<version>7.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-inline</artifactId>
<version>3.8.0</version>
<version>4.3.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.0.3</version>
<version>4.2.0</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
23 changes: 12 additions & 11 deletions src/main/java/de/thjom/java/systemd/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@

package de.thjom.java.systemd;

import java.math.BigInteger;
import java.util.List;

import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.interfaces.Introspectable;

import de.thjom.java.systemd.Unit.Mode;
import de.thjom.java.systemd.Unit.Who;
import de.thjom.java.systemd.interfaces.ManagerInterface;
import de.thjom.java.systemd.types.DynamicUser;
import de.thjom.java.systemd.types.Pair;
import de.thjom.java.systemd.types.StructForUnitEnableAndDisable;
import de.thjom.java.systemd.types.UnitFileChange;
import de.thjom.java.systemd.types.UnitFileInstallChange;
import de.thjom.java.systemd.types.UnitFileType;
import de.thjom.java.systemd.types.UnitProcessType;
import de.thjom.java.systemd.types.UnitType;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.connections.impl.DBusConnection;
import org.freedesktop.dbus.exceptions.DBusException;
import org.freedesktop.dbus.interfaces.Introspectable;

import java.math.BigInteger;
import java.util.List;

public class Manager extends InterfaceAdapter {

Expand Down Expand Up @@ -195,15 +196,15 @@ public void clearJobs() {
getInterface().clearJobs();
}

public List<UnitFileChange> disableUnitFiles(final List<String> names, final boolean runtime) {
public List<StructForUnitEnableAndDisable> disableUnitFiles(final List<String> names, final boolean runtime) {
return getInterface().disableUnitFiles(names, runtime);
}

public String dump() {
return getInterface().dump();
}

public List<UnitFileChange> enableUnitFiles(final List<String> names, final boolean runtime, final boolean force) {
public Pair<Boolean, List<StructForUnitEnableAndDisable>> enableUnitFiles(final List<String> names, final boolean runtime, final boolean force) {
return getInterface().enableUnitFiles(names, runtime, force);
}

Expand Down Expand Up @@ -355,7 +356,7 @@ public DBusPath restartUnit(final String name, final String mode) {
return getInterface().restartUnit(name, mode);
}

public List<UnitFileChange> revertUnitFiles(final List<String> names){
public List<UnitFileChange> revertUnitFiles(final List<String> names) {
return getInterface().revertUnitFiles(names);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

package de.thjom.java.systemd.interfaces;

import de.thjom.java.systemd.types.Pair;
import de.thjom.java.systemd.Signal;
import de.thjom.java.systemd.types.StructForUnitEnableAndDisable;
import de.thjom.java.systemd.types.*;
import org.freedesktop.dbus.DBusPath;
import org.freedesktop.dbus.annotations.DBusInterfaceName;
Expand All @@ -37,13 +39,13 @@ public interface ManagerInterface extends DBusInterface {
void clearJobs();

@DBusMemberName(value = "DisableUnitFiles")
List<UnitFileChange> disableUnitFiles(List<String> names, boolean runtime);
List<StructForUnitEnableAndDisable> disableUnitFiles(List<String> names, boolean runtime);

@DBusMemberName(value = "Dump")
String dump();

@DBusMemberName(value = "EnableUnitFiles")
List<UnitFileChange> enableUnitFiles(List<String> names, boolean runtime, boolean force);
Pair<Boolean, List<StructForUnitEnableAndDisable>> enableUnitFiles(List<String> names, boolean runtime, boolean force);

@DBusMemberName(value = "Exit")
void exit();
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/de/thjom/java/systemd/types/Pair.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Java-systemd implementation
* Copyright (c) 2016 Markus Enax
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of either the GNU Lesser General Public License Version 2 or the
* Academic Free Licence Version 3.0.
*
* Full licence texts are included in the COPYING file with this program.
*/

package de.thjom.java.systemd.types;

import org.freedesktop.dbus.Tuple;
import org.freedesktop.dbus.annotations.Position;

public final class Pair<A, B> extends Tuple {

@Position(0)
public final A a;
@Position(1)
public final B b;

public Pair(A a, B b) {
this.a = a;
this.b = b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Java-systemd implementation
* Copyright (c) 2016 Markus Enax
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of either the GNU Lesser General Public License Version 2 or the
* Academic Free Licence Version 3.0.
*
* Full licence texts are included in the COPYING file with this program.
*/

package de.thjom.java.systemd.types;

import org.freedesktop.dbus.Struct;
import org.freedesktop.dbus.annotations.Position;

public final class StructForUnitEnableAndDisable extends Struct {
@Position(0)
public final String a;
@Position(1)
public final String b;
@Position(2)
public final String c;

public StructForUnitEnableAndDisable(String a, String b, String c) {
this.a = a;
this.b = b;
this.c = c;
}
}