-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1055 from eclipse-passage/1054
#1054 LIC: library-licensed-separately: support license import
- Loading branch information
Showing
14 changed files
with
338 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,4 +16,5 @@ output.. = bin/ | |
bin.includes = META-INF/,\ | ||
.,\ | ||
OSGI-INF/,\ | ||
about.html | ||
about.html,\ | ||
plugin.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<?eclipse version="3.4"?> | ||
<!-- | ||
Copyright (c) 2022 ArSysOp and others | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
ArSysOp - initial API and implementation | ||
--> | ||
<plugin> | ||
<extension-point id="library" name="%extension-point.name" schema="schema/library.exsd"/> | ||
|
||
</plugin> |
114 changes: 114 additions & 0 deletions
114
bundles/org.eclipse.passage.lic.base/schema/library.exsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- | ||
Copyright (c) 2022 ArSysOp and others | ||
This program and the accompanying materials are made available under the | ||
terms of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
SPDX-License-Identifier: EPL-2.0 | ||
Contributors: | ||
ArSysOp - initial API and implementation | ||
--> | ||
<!-- Schema file written by PDE --> | ||
<schema targetNamespace="org.eclipse.passage.lic.base" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appinfo> | ||
<meta.schema plugin="org.eclipse.passage.lic.base" id="library" name="External Library licensing service"/> | ||
</appinfo> | ||
<documentation> | ||
A library or component, developed separately, should use the extension to participate in licensing process of an outer project. | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appinfo> | ||
<meta.element /> | ||
</appinfo> | ||
</annotation> | ||
<complexType> | ||
<sequence minOccurs="1" maxOccurs="unbounded"> | ||
<element ref="licensingService" minOccurs="1" maxOccurs="unbounded"/> | ||
</sequence> | ||
<attribute name="point" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="id" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="name" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appinfo> | ||
<meta.attribute translatable="true"/> | ||
</appinfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<element name="licensingService"> | ||
<complexType> | ||
<attribute name="class" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appinfo> | ||
<meta.attribute kind="java" basedOn=":org.eclipse.passage.lic.internal.base.access.DelegatedLicensingService"/> | ||
</appinfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="since"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter the first release in which this extension point appears.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="examples"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter extension point usage example here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="apiinfo"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter API information here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appinfo> | ||
<meta.section type="implementation"/> | ||
</appinfo> | ||
<documentation> | ||
[Enter information about supplied implementation of this extension point.] | ||
</documentation> | ||
</annotation> | ||
|
||
|
||
</schema> |
40 changes: 40 additions & 0 deletions
40
....lic.base/src/org/eclipse/passage/lic/internal/base/access/DelegatedLicensingService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.base.access; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Path; | ||
import java.util.Collection; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.passage.lic.api.LicensedProduct; | ||
import org.eclipse.passage.lic.api.PassageLicenseCoverage; | ||
import org.eclipse.passage.lic.api.ServiceInvocationResult; | ||
import org.eclipse.passage.lic.api.agreements.AgreementAcceptanceService; | ||
import org.eclipse.passage.lic.api.conditions.Condition; | ||
import org.eclipse.passage.lic.api.restrictions.ExaminationCertificate; | ||
|
||
public interface DelegatedLicensingService extends PassageLicenseCoverage { | ||
|
||
LicensedProduct product(); | ||
|
||
@Override | ||
ServiceInvocationResult<ExaminationCertificate> assess(); | ||
|
||
Optional<AgreementAcceptanceService> agreementsService(); | ||
|
||
Collection<Condition> conditions(Path license); | ||
|
||
void installLicense(Path license) throws IOException; | ||
|
||
} |
57 changes: 57 additions & 0 deletions
57
...sage.lic.base/src/org/eclipse/passage/lic/internal/requirements/FilteredRequirements.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.requirements; | ||
|
||
import java.util.Collection; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
||
import org.eclipse.passage.lic.api.ServiceInvocationResult; | ||
import org.eclipse.passage.lic.api.registry.StringServiceId; | ||
import org.eclipse.passage.lic.api.requirements.Requirement; | ||
import org.eclipse.passage.lic.api.requirements.ResolvedRequirements; | ||
import org.eclipse.passage.lic.base.BaseServiceInvocationResult; | ||
|
||
public final class FilteredRequirements implements ResolvedRequirements { | ||
|
||
private final ResolvedRequirements delegate; | ||
private final Predicate<Requirement> condition; | ||
|
||
public FilteredRequirements(ResolvedRequirements delegate, Predicate<Requirement> condition) { | ||
Objects.requireNonNull(delegate, "FilteredRequirements::delegate"); //$NON-NLS-1$ | ||
Objects.requireNonNull(condition, "FilteredRequirements::condition"); //$NON-NLS-1$ | ||
this.delegate = delegate; | ||
this.condition = condition; | ||
} | ||
|
||
@Override | ||
public StringServiceId id() { | ||
return new StringServiceId("filtered-" + delegate.id().toString()); //$NON-NLS-1$ | ||
} | ||
|
||
@Override | ||
public ServiceInvocationResult<Collection<Requirement>> all() { | ||
ServiceInvocationResult<Collection<Requirement>> all = delegate.all(); | ||
Optional<Collection<Requirement>> some = all.data().map(this::filtered); | ||
return new BaseServiceInvocationResult<>(all.diagnostic(), some); | ||
} | ||
|
||
private Collection<Requirement> filtered(Collection<Requirement> all) { | ||
return all.stream()// | ||
.filter(condition)// | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...e.passage.lic.equinox/src/org/eclipse/passage/lic/internal/equinox/ServiceExtensions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2022 ArSysOp | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0/. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* ArSysOp - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.passage.lic.internal.equinox; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.function.Supplier; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.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; | ||
|
||
/** | ||
* <p> | ||
* Reads and instantiates executables for the most common service-supplying | ||
* extensions of sequence<service<class>> structure. | ||
* </p> | ||
* <p> | ||
* In case there is a trouble with any single library, logs details and proceeds | ||
* with the rest of them. | ||
* </p> | ||
*/ | ||
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()); | ||
|
||
public ServiceExtensions(String namespace, String point, Class<S> service) { | ||
Objects.requireNonNull(namespace, "ServiceExtensions::namespace"); //$NON-NLS-1$ | ||
Objects.requireNonNull(point, "ServiceExtensions::point"); //$NON-NLS-1$ | ||
Objects.requireNonNull(service, "ServiceExtensions::service"); //$NON-NLS-1$ | ||
this.namespace = namespace; | ||
this.point = point; | ||
this.service = service; | ||
} | ||
|
||
@Override | ||
public List<S> get() { | ||
return Arrays.stream(extensions())// | ||
.map(IExtension::getConfigurationElements)// | ||
.flatMap(Arrays::stream)// | ||
.map(this::oneService)// | ||
.filter(Optional::isPresent) // | ||
.map(Optional::get) // | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
private IExtension[] extensions() { | ||
return Platform.getExtensionRegistry().getExtensionPoint(namespace, point).getExtensions(); | ||
} | ||
|
||
private Optional<S> oneService(IConfigurationElement config) { | ||
try { | ||
Object executable = config.createExecutableExtension("class"); //$NON-NLS-1$ | ||
return Optional.of(service.cast(executable)); | ||
} catch (CoreException e) { | ||
log.error("failed to instanciate a service ", e); //$NON-NLS-1$ | ||
return Optional.empty(); | ||
} | ||
} | ||
} |
Oops, something went wrong.