Skip to content

Commit

Permalink
Bug 564818 API revision | conditions | key keepers review
Browse files Browse the repository at this point in the history
 - extend Framework Contract test set with `StreamCodecs` and
`KeyKeeper`s supplement expectation checks

Signed-off-by: elena.parovyshnaya <elena.parovyshnaya@gmail.com>
  • Loading branch information
eparovyshnaya committed Jul 5, 2020
1 parent f850888 commit 4a418de
Show file tree
Hide file tree
Showing 16 changed files with 362 additions and 137 deletions.
Expand Up @@ -23,52 +23,59 @@
* @see ConditionMiner
* @see LicensingCondition
* @since 0.4.0
* @deprecated use internal (1.0) MinedConditionsRegistry
*/
@Deprecated
public interface ConditionMinerRegistry {

/**
* Returns all registered {@link ConditionMiner}s.
*
* @return {@link Iterable} aggregate of {@link ConditionMiner}s. Can be empty. Cannot be {@code null}
* @see #registerConditionMiner(ConditionMiner, Map)
* @since 0.4.0
*/
Iterable<ConditionMiner> getConditionMiners();
/**
* Returns all registered {@link ConditionMiner}s.
*
* @return {@link Iterable} aggregate of {@link ConditionMiner}s. Can be empty.
* Cannot be {@code null}
* @see #registerConditionMiner(ConditionMiner, Map)
* @since 0.4.0
*/
Iterable<ConditionMiner> getConditionMiners();

/**
* Registers the {@code conditionMiner} to make it available for a registry client.
*
* @param conditionMiner miner to be registered
* @param properties - reserved for metadata
* @since 0.4.0
*/
void registerConditionMiner(ConditionMiner conditionMiner, Map<String, Object> properties);
/**
* Registers the {@code conditionMiner} to make it available for a registry
* client.
*
* @param conditionMiner miner to be registered
* @param properties - reserved for metadata
* @since 0.4.0
*/
void registerConditionMiner(ConditionMiner conditionMiner, Map<String, Object> properties);

/**
* Removes the {@code conditionMiner} from the registry.
* After removal the {@code conditionMiner} will no longer present in {@link #getConditionMiners} results
*
* @param conditionMiner the miner to be forgotten
* @param properties reserved for metadata
* @see #getConditionMiners
* @since 0.4.0
*/
void unregisterConditionMiner(ConditionMiner conditionMiner, Map<String, Object> properties);
/**
* Removes the {@code conditionMiner} from the registry. After removal the
* {@code conditionMiner} will no longer present in {@link #getConditionMiners}
* results
*
* @param conditionMiner the miner to be forgotten
* @param properties reserved for metadata
* @see #getConditionMiners
* @since 0.4.0
*/
void unregisterConditionMiner(ConditionMiner conditionMiner, Map<String, Object> properties);

/**
* To be extracted to a separate service and deprecated here: #552752 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=552752)
*
* @since 0.4.0
*/
LicensingResult importConditions(String source, LicensingConfiguration configuration);
/**
* To be extracted to a separate service and deprecated here: #552752
* (https://bugs.eclipse.org/bugs/show_bug.cgi?id=552752)
*
* @since 0.4.0
*/
LicensingResult importConditions(String source, LicensingConfiguration configuration);

/**
* Physical source used by the miner to quarry conditions.
* <p>
* To be extracted from the interface and deprecated here: #552753 (https://bugs.eclipse.org/bugs/show_bug.cgi?id=552753)
*
* @param miner to be examined for a target
* @since 0.4.0
*/
String getConditionMinerTarget(ConditionMiner miner);
/**
* Physical source used by the miner to quarry conditions.
* <p>
* To be extracted from the interface and deprecated here: #552753
* (https://bugs.eclipse.org/bugs/show_bug.cgi?id=552753)
*
* @param miner to be examined for a target
* @since 0.4.0
*/
String getConditionMinerTarget(ConditionMiner miner);
}
Expand Up @@ -17,54 +17,62 @@
/**
* Contract for a registry of {@link ConditionTransport}s.
*
* <p>As {@link LicensingCondition} can be persisted in any form, a {@link ConditionTransport}
* is associated with a particular <i>content type</i>.
* <p>
* As {@link LicensingCondition} can be persisted in any form, a
* {@link ConditionTransport} is associated with a particular <i>content
* type</i>.
* </p>
*
* @see ConditionTransport
* @see LicensingCondition
* @see #getConditionTransportForContentType(String)
* @since 0.4.0
* @deprecated use internal (1.0) ConditionTransportRegistry
*/
@Deprecated
public interface ConditionTransportRegistry {

/**
* Returns an aggregate of all registered {@link ConditionTransport}s.
*
* @return all registered {@link ConditionTransport}s.
* @since 0.4.0
*/
/**
* Returns an aggregate of all registered {@link ConditionTransport}s.
*
* @return all registered {@link ConditionTransport}s.
* @since 0.4.0
*/
Iterable<ConditionTransport> getConditionTransports();

/**
* <p>
* Returns {@link ConditionTransport}, which is registered to handle (read and write)
* {@link LicensingCondition}s in the given {@code contentType}. The value is nullable.
* </p>
*
* @param contentType string representation of content type (like <i>application/json</i> or <i>application/xmk</i>)
* @return a {@link ConditionTransport} registered for the given {@code contentType}, if any, and {@code null} otherwise.
* @see #registerConditionTransport(ConditionTransport, Map)
* @since 0.4.0
*/
/**
* <p>
* Returns {@link ConditionTransport}, which is registered to handle (read and
* write) {@link LicensingCondition}s in the given {@code contentType}. The
* value is nullable.
* </p>
*
* @param contentType string representation of content type (like
* <i>application/json</i> or <i>application/xmk</i>)
* @return a {@link ConditionTransport} registered for the given
* {@code contentType}, if any, and {@code null} otherwise.
* @see #registerConditionTransport(ConditionTransport, Map)
* @since 0.4.0
*/
ConditionTransport getConditionTransportForContentType(String contentType);

/**
* Adds the {@code transport} to the <i>registry</i> with the given set of properties.
*
* @param transport a transport to be registered
* @param properties the transport properties, like {@link ConditionMiner}s
* @since 0.4.0
*/
/**
* Adds the {@code transport} to the <i>registry</i> with the given set of
* properties.
*
* @param transport a transport to be registered
* @param properties the transport properties, like {@link ConditionMiner}s
* @since 0.4.0
*/
void registerConditionTransport(ConditionTransport transport, Map<String, Object> properties);

/**
* Removes the {@code transport} from the <i>registry</i>.
*
* @param transport a transport to be unregistered
* @param properties the transport properties
* @since 0.4.0
*/
/**
* Removes the {@code transport} from the <i>registry</i>.
*
* @param transport a transport to be unregistered
* @param properties the transport properties
* @since 0.4.0
*/
void unregisterConditionTransport(ConditionTransport transport, Map<String, Object> properties);

}
Expand Up @@ -13,15 +13,21 @@
package org.eclipse.passage.lic.internal.api;

import org.eclipse.passage.lic.internal.api.conditions.mining.MinedConditionsRegistry;
import org.eclipse.passage.lic.internal.api.io.KeyKeeperRegistry;
import org.eclipse.passage.lic.internal.api.io.StreamCodecRegistry;
import org.eclipse.passage.lic.internal.api.requirements.ResolvedRequirementsRegistry;

/**
* Supplies all the service that runtime <i>access cycle</i> can count on.
*/
public interface AccessCycleConfiguration {

ResolvedRequirementsRegistry requirementsRegistry();
ResolvedRequirementsRegistry requirementResolvers();

MinedConditionsRegistry conditionsRegistry();
MinedConditionsRegistry conditionMiners();

StreamCodecRegistry codecs();

KeyKeeperRegistry keyKeepers();

}
Expand Up @@ -50,7 +50,8 @@ public interface StreamCodec extends Service<LicensedProduct> {

/**
* Encode {@code input} stream data with a private key retrieved form the given
* {@code key} stream. Fill {@code output} stream with the encoded data.
* {@code key} stream. Fill {@code output} stream with the encoded data. All the
* streams stay opened.
*
* @param input source of data to be encoded
* @param output target stream to place encoded data into
Expand All @@ -64,7 +65,8 @@ void encode(InputStream input, OutputStream output, InputStream key, String user

/**
* Decode the {@code input} stream with the <i>public key</i> and store decoded
* data to {@code output} stream.
* data to {@code output} stream. All the streams stay opened at the end of the
* call.
*
* @param input source stream with encoded data
* @param output target stream for decoded data
Expand Down
Expand Up @@ -31,7 +31,7 @@ public Access(Framework framework) {

public boolean canUse(String feature) {
Set<Requirement> requirements = new Requirements(
framework.accessCycleConfiguration().requirementsRegistry().get(), feature).get();
framework.accessCycleConfiguration().requirementResolvers().get(), feature).get();
if (requirements.isEmpty()) {
return true;
}
Expand Down
Expand Up @@ -55,7 +55,7 @@ final class SealedAccessCycleConfiguration implements AccessCycleConfiguration {
new ComponentRequirements() //
));
conditions = new ReadOnlyRegistry<>(Arrays.asList(//
new RemoteConditions(product, transports())//
new RemoteConditions(product, conditionTransports())//
));
transports = new ReadOnlyRegistry<>(Arrays.asList(//
new JsonConditionTransport()//
Expand All @@ -69,29 +69,29 @@ final class SealedAccessCycleConfiguration implements AccessCycleConfiguration {
}

@Override
public ResolvedRequirementsRegistry requirementsRegistry() {
public ResolvedRequirementsRegistry requirementResolvers() {
return () -> requirements;
}

@Override
public MinedConditionsRegistry conditionsRegistry() {
public MinedConditionsRegistry conditionMiners() {
return () -> conditions;
}

private ConditionTransportRegistry transports() {
return () -> transports;
}

@SuppressWarnings("unused") // Under development: required for condition mining
private StreamCodecRegistry codecs() {
@Override
public StreamCodecRegistry codecs() {
return () -> codecs;
}

@SuppressWarnings("unused") // Under development: required for condition mining
private KeyKeeperRegistry keys() {
@Override
public KeyKeeperRegistry keyKeepers() {
return () -> keys;
}

private ConditionTransportRegistry conditionTransports() {
return () -> transports;
}

private Bundle bundle() {
return FrameworkUtil.getBundle(getClass());
}
Expand Down

0 comments on commit 4a418de

Please sign in to comment.