Skip to content

Commit

Permalink
Eliminate apache log4j dependency #1186
Browse files Browse the repository at this point in the history
Switch to slf4j interfaces

Signed-off-by: Alexander Fedorov <alexander.fedorov@arsysop.ru>
  • Loading branch information
ruspl-afed committed Dec 15, 2022
1 parent c938f1e commit 2e9faa7
Show file tree
Hide file tree
Showing 40 changed files with 102 additions and 106 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.passage.lbc.base/META-INF/MANIFEST.MF
Expand Up @@ -19,7 +19,7 @@ Export-Package: org.eclipse.passage.lbc.internal.base;x-friends:="org.eclipse.pa
org.eclipse.passage.lbc.internal.base.api;x-internal:=true,
org.eclipse.passage.lbc.internal.base.interaction;x-friends:="org.eclipse.passage.lbc.jetty",
org.eclipse.passage.lbc.internal.base.mine;x-friends:="org.eclipse.passage.lbc.base.tests,org.eclipse.passage.lic.hc.tests"
Import-Package: org.apache.log4j;version="1.2.19"
Import-Package: org.slf4j;version="1.7.36"
Bundle-ActivationPolicy: lazy
Provide-Capability: licensing.feature;licensing.feature="org.eclipse.passage.lbc.acquire.concurrent";version="2.6.1";name="FLS: Concurrent access to a feature grant for several users";level="info";provider="Eclipse Passage",
licensing.feature;licensing.feature="org.eclipse.passage.lbc.acquire.concurrent.full";version="2.6.1";name="FLS: Concurrent access to a feature grant for any amount of users";level="error";provider="Eclipse Passage"
Expand Up @@ -16,8 +16,6 @@
import java.util.Objects;
import java.util.Optional;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.passage.lbc.internal.base.DecodedRequest;
import org.eclipse.passage.lbc.internal.base.EncodedResponse;
Expand All @@ -31,11 +29,13 @@
import org.eclipse.passage.lic.internal.net.handle.PlainSuceess;
import org.eclipse.passage.lic.internal.net.handle.ProductUserRequest;
import org.eclipse.passage.lic.licenses.model.api.GrantAcqisition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class Acquisition {

private final ProductUserRequest<RawRequest> data;
private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

public Acquisition(ProductUserRequest<RawRequest> data) {
Objects.requireNonNull(data, "Acquisition::data"); //$NON-NLS-1$
Expand Down
Expand Up @@ -21,12 +21,12 @@
import java.util.UUID;
import java.util.function.Consumer;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.licenses.model.api.FeatureGrant;
import org.eclipse.passage.lic.licenses.model.api.GrantAcqisition;
import org.eclipse.passage.lic.licenses.model.meta.LicensesFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public abstract class DefaultGrantsStorage implements GrantsStorage {

Expand All @@ -43,7 +43,7 @@ public abstract class DefaultGrantsStorage implements GrantsStorage {
* </p>
*/
protected final Map<LicensedProduct, Map<String, Collection<GrantAcqisition>>> locks = new HashMap<>();
protected final Logger log = LogManager.getLogger(getClass());
protected final Logger log = LoggerFactory.getLogger(getClass());

@Override
public final Optional<GrantAcqisition> acquire(LicensedProduct product, String user, FeatureGrant grant) {
Expand Down
Expand Up @@ -19,22 +19,22 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lbc.internal.base.api.FlsGear;
import org.eclipse.passage.lbc.internal.base.api.FlsGearAwre;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.api.LicensingException;
import org.eclipse.passage.lic.licenses.model.api.FeatureGrant;
import org.eclipse.passage.lic.licenses.model.api.FloatingLicensePack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

final class FeatureGrants {

private final LicensedProduct product;
private final String user;
private final String feature;
private final Supplier<Path> base;
private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

FeatureGrants(LicensedProduct product, String user, String feature, Supplier<Path> base) {
this.product = product;
Expand Down Expand Up @@ -88,7 +88,7 @@ private Collection<FeatureGrant> get(FlsGear gear) {
.map(Optional::get) //
.collect(Collectors.toList());
} catch (LicensingException e) {
log.error(e);
log.error("Failed to get feature grants", e); //$NON-NLS-1$
return Collections.emptyList();
}
}
Expand Down
Expand Up @@ -19,8 +19,6 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.api.LicensingException;
import org.eclipse.passage.lic.api.io.KeyKeeper;
Expand All @@ -33,14 +31,16 @@
import org.eclipse.passage.lic.licenses.model.api.FloatingLicensePack;
import org.eclipse.passage.lic.licenses.model.meta.LicensesPackage;
import org.eclipse.passage.lic.licenses.model.util.LicensesResourceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

final class LicensePacks {

private final LicensedProduct product;
private final KeyKeeper key;
private final StreamCodec codec;
private final Supplier<Path> base;
private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

public LicensePacks(KeyKeeper key, StreamCodec codec, LicensedProduct product, Supplier<Path> base) {
this.product = product;
Expand Down
Expand Up @@ -14,14 +14,14 @@

import java.util.function.Supplier;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lic.equinox.EquinoxPassage;
import org.eclipse.passage.lic.licenses.model.api.FeatureGrant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

final class ProtectedGrantCapacity implements Supplier<Integer> {

private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());
private final String feature = "org.eclipse.passage.lbc.acquire.concurrent.full"; //$NON-NLS-1$
private final FeatureGrant grant;
private final int unlicensed = 4;
Expand Down
Expand Up @@ -16,8 +16,6 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.passage.lbc.internal.base.EncodedResponse;
import org.eclipse.passage.lbc.internal.base.api.RawRequest;
Expand All @@ -30,11 +28,13 @@
import org.eclipse.passage.lic.internal.net.handle.Failure;
import org.eclipse.passage.lic.internal.net.handle.ProductUserRequest;
import org.eclipse.passage.lic.licenses.model.api.PersonalLicensePack;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class Conditions implements Supplier<NetResponse> {

private final ProductUserRequest<RawRequest> data;
private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

public Conditions(ProductUserRequest<RawRequest> data) {
this.data = data;
Expand Down
Expand Up @@ -18,8 +18,6 @@
import java.util.Collections;
import java.util.List;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lbc.internal.base.i18n.BaseMessages;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.api.LicensingException;
Expand All @@ -44,13 +42,15 @@
import org.eclipse.passage.lic.licenses.model.api.ProductRef;
import org.eclipse.passage.lic.licenses.model.meta.LicensesPackage;
import org.eclipse.passage.lic.licenses.model.util.LicensesResourceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@SuppressWarnings("restriction")
final class ReassemblingMiningTool extends ArmedMiningTool {

private final String user;
private final LicensedProduct product;
private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

ReassemblingMiningTool(KeyKeeper key, StreamCodec codec, ConditionTransport transport, LicensedProduct product,
String user, ConditionMiningTarget miner) {
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.passage.lic.base/META-INF/MANIFEST.MF
Expand Up @@ -30,4 +30,4 @@ Export-Package: org.eclipse.passage.lic.base,
org.eclipse.passage.lic.internal.base.observatory;x-internal:=true,
org.eclipse.passage.lic.internal.base.requirements;x-internal:=true,
org.eclipse.passage.lic.internal.base.time;x-friends:="org.eclipse.passage.lic.base.tests"
Import-Package: org.apache.log4j;version="1.2.19"
Import-Package: org.slf4j;version="1.7.36"
Expand Up @@ -24,14 +24,14 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lic.api.acquire.GrantAcquisition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

final class Residence {

private final Path file;
private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

Residence(Supplier<Path> srotage) {
this.file = srotage.get().resolve("forsaken-grants.bin"); //$NON-NLS-1$
Expand Down
6 changes: 3 additions & 3 deletions bundles/org.eclipse.passage.lic.equinox/META-INF/MANIFEST.MF
Expand Up @@ -24,10 +24,10 @@ Export-Package: org.eclipse.passage.lic.equinox,
org.eclipse.passage.loc.licenses.core,
org.eclipse.passage.loc.users.core",
org.eclipse.passage.lic.internal.equinox.i18n;x-internal:=true
Import-Package: org.apache.log4j;version="1.2.19",
org.osgi.service.component.runtime;version="1.0.0",
Import-Package: org.osgi.service.component.runtime;version="1.0.0",
org.osgi.service.component.runtime.dto;version="1.0.0",
org.osgi.service.event;version="1.0.0"
org.osgi.service.event;version="1.0.0",
org.slf4j;version="1.7.36"
Bundle-ActivationPolicy: lazy
Provide-Capability: licensing.management;licensing.management="equinox";version="1.0.0"

Expand Up @@ -16,30 +16,30 @@
import java.util.Collections;
import java.util.Optional;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lic.api.Gear;
import org.eclipse.passage.lic.api.GearSupplier;
import org.eclipse.passage.lic.api.LicensingException;
import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @since 2.1
*/
public abstract class GearAware<G extends Gear, S extends GearSupplier<G>> {

private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

public final <T> Optional<T> withGear(Unsafe<G, T> with) throws LicensingException {
BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
Collection<ServiceReference<S>> references = Collections.emptyList();
try {
references = context.getServiceReferences(supplier(), null);
} catch (InvalidSyntaxException e) {
log.error(e);
log.error("Failed to resolve service references", e); //$NON-NLS-1$
return Optional.empty();
}
if (references.isEmpty()) {
Expand Down
Expand Up @@ -15,17 +15,17 @@
import java.util.Optional;
import java.util.function.Supplier;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.api.ServiceInvocationResult;
import org.eclipse.passage.lic.api.access.GrantLockAttempt;
import org.eclipse.passage.lic.base.diagnostic.DiagnosticExplained;
import org.eclipse.passage.lic.equinox.EquinoxPassage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class LicenseProtection {

private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());
private Optional<GrantLockAttempt> lock = Optional.empty();
private final Supplier<Interaction> interaction;

Expand Down
Expand Up @@ -19,12 +19,12 @@
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.Platform;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* <p>
Expand All @@ -41,7 +41,7 @@ public final class ServiceExtensions<S> implements Supplier<List<S>> {
private final String namespace;
private final String point;
private final Class<S> service;
private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());

public ServiceExtensions(String namespace, String point, Class<S> service) {
Objects.requireNonNull(namespace, "ServiceExtensions::namespace"); //$NON-NLS-1$
Expand Down
Expand Up @@ -18,4 +18,4 @@ Require-Bundle: org.eclipse.passage.lic.api;bundle-version="0.0.0",
org.eclipse.passage.lic.oshi;bundle-version="0.0.0"
Export-Package: org.eclipse.passage.lic.execute,
org.eclipse.passage.lic.internal.execute;x-internal:=true
Import-Package: org.apache.log4j;version="1.2.19"
Import-Package: org.slf4j;version="1.7.36"
Expand Up @@ -15,8 +15,6 @@
import java.io.InputStream;
import java.util.function.Supplier;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.passage.lic.api.AccessCycleConfiguration;
import org.eclipse.passage.lic.api.LicensedProduct;
import org.eclipse.passage.lic.api.LicensingException;
Expand All @@ -27,6 +25,8 @@
import org.eclipse.passage.lic.internal.execute.Logging;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class DefaultFramework extends BaseFramework {

Expand All @@ -35,7 +35,7 @@ public final class DefaultFramework extends BaseFramework {

public DefaultFramework(Supplier<Bundle> bundle) {
configureLogging();
this.log = LogManager.getLogger(getClass());
this.log = LoggerFactory.getLogger(getClass());
logConfiguration();
this.configuration = new FocusedAccessCycleConfiguration.Wide(this::product, bundle);
}
Expand Down
Expand Up @@ -14,8 +14,6 @@

import java.io.InputStream;

import org.apache.log4j.PropertyConfigurator;

public final class Logging {

private final ConfigSupplier config;
Expand All @@ -27,7 +25,7 @@ public Logging(ConfigSupplier config) {
@SuppressWarnings("resource")
public void configure() {
try (InputStream configuration = config.get()) {
PropertyConfigurator.configure(config.get());
// should be done by end-product framework
} catch (Exception e) {
System.err.println("Failed to configure logging"); //$NON-NLS-1$
e.printStackTrace();
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.passage.lic.jetty/META-INF/MANIFEST.MF
Expand Up @@ -17,5 +17,5 @@ Export-Package: org.eclipse.passage.lic.internal.jetty;x-friends:="org.eclipse.p
org.eclipse.passage.lic.internal.jetty.interaction;x-friends:="org.eclipse.passage.lbc.jetty"
Import-Package: javax.servlet,
javax.servlet.http,
org.apache.log4j;version="1.2.19"
org.slf4j;version="1.7.36"
Bundle-ActivationPolicy: lazy
Expand Up @@ -17,16 +17,16 @@
import java.util.Optional;
import java.util.function.Supplier;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.eclipse.jetty.server.Server;
import org.eclipse.passage.lic.internal.jetty.i18n.Messages;
import org.eclipse.passage.lic.internal.net.connect.BindAddress;
import org.eclipse.passage.lic.internal.net.connect.Port;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class JettyServer {

private final Logger log = LogManager.getLogger(getClass());
private final Logger log = LoggerFactory.getLogger(getClass());
private final Supplier<JettyHandler> handler;
private Optional<Server> server = Optional.empty();

Expand Down

0 comments on commit 2e9faa7

Please sign in to comment.