Skip to content
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

Bug 571147 extend 'lic.net' with common facilities #651

Merged
merged 1 commit into from
Feb 14, 2021
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package org.eclipse.passage.lac.internal.jetty;

import org.eclipse.core.runtime.Platform;
import org.eclipse.passage.internal.lac.base.BaseLicensingRequestHandled;
import org.eclipse.passage.internal.lac.base.AgentRequestHandled;
import org.eclipse.passage.lic.internal.jetty.JettyHandler;
import org.eclipse.passage.lic.internal.jetty.JettyServer;
import org.eclipse.passage.lic.internal.net.connect.Port;
Expand All @@ -39,7 +39,7 @@ public void stop(BundleContext context) throws Exception {
}

private JettyHandler handler() {
return new JettyHandler(request -> new BaseLicensingRequestHandled(request).get());
return new JettyHandler(request -> new AgentRequestHandled(request).get());
}

}
19 changes: 6 additions & 13 deletions bundles/org.eclipse.passage.lac/.settings/.api_filters
Original file line number Diff line number Diff line change
@@ -1,24 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.passage.lac" version="2">
<resource path="src/org/eclipse/passage/internal/lac/base/BaseLicensingRequestHandled.java" type="org.eclipse.passage.internal.lac.base.BaseLicensingRequestHandled">
<filter id="576725006">
<resource path="src/org/eclipse/passage/internal/lac/base/AgentRequestHandled.java" type="org.eclipse.passage.internal.lac.base.AgentRequestHandled">
<filter id="576720909">
<message_arguments>
<message_argument value="NetRequestHandled"/>
<message_argument value="BaseLicensingRequestHandled"/>
</message_arguments>
</filter>
<filter id="643842064">
<message_arguments>
<message_argument value="NetResponse"/>
<message_argument value="BaseLicensingRequestHandled"/>
<message_argument value="get()"/>
<message_argument value="RequestHandledByServices&lt;R&gt;"/>
<message_argument value="AgentRequestHandled"/>
</message_arguments>
</filter>
<filter id="643850349">
<message_arguments>
<message_argument value="NetRequest"/>
<message_argument value="BaseLicensingRequestHandled"/>
<message_argument value="BaseLicensingRequestHandled(NetRequest)"/>
<message_argument value="AgentRequestHandled"/>
<message_argument value="AgentRequestHandled(NetRequest)"/>
</message_arguments>
</filter>
</resource>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*******************************************************************************
* Copyright (c) 2021 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.internal.lac.base;

import java.util.Map;
import java.util.function.Function;

import org.eclipse.passage.lic.internal.api.PassageAction;
import org.eclipse.passage.lic.internal.net.handle.Chore;
import org.eclipse.passage.lic.internal.net.handle.NetRequest;
import org.eclipse.passage.lic.internal.net.handle.NetServices;

public final class AgentCycle extends NetServices<NetRequest> {

@Override
protected void defineChores(Map<PassageAction, Function<NetRequest, Chore>> services) {
// TODO Auto-generated method stub

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,12 @@
package org.eclipse.passage.internal.lac.base;

import org.eclipse.passage.lic.internal.net.handle.NetRequest;
import org.eclipse.passage.lic.internal.net.handle.NetRequestHandled;
import org.eclipse.passage.lic.internal.net.handle.NetResponse;
import org.eclipse.passage.lic.internal.net.handle.RequestHandledByServices;

public final class BaseLicensingRequestHandled implements NetRequestHandled {
public final class AgentRequestHandled extends RequestHandledByServices<NetRequest> {

public BaseLicensingRequestHandled(NetRequest origin) {
// TODO Auto-generated constructor stub
}

@Override
public NetResponse get() {
return null;
public AgentRequestHandled(NetRequest request) {
super(request, new AgentCycle());
}

}
40 changes: 40 additions & 0 deletions bundles/org.eclipse.passage.lbc.base/.settings/.api_filters
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.passage.lbc.base" version="2">
<resource path="src/org/eclipse/passage/lbc/internal/base/api/Grants.java" type="org.eclipse.passage.lbc.internal.base.api.Grants">
<filter id="643846161">
<message_arguments>
<message_argument value="GrantAcqisition"/>
<message_argument value="Grants"/>
<message_argument value="release(LicensedProduct, GrantAcqisition)"/>
</message_arguments>
</filter>
<filter id="643846161">
<message_arguments>
<message_argument value="LicensedProduct"/>
<message_argument value="Grants"/>
<message_argument value="acquire(LicensedProduct, String, String)"/>
</message_arguments>
</filter>
<filter id="643846161">
<message_arguments>
<message_argument value="LicensedProduct"/>
<message_argument value="Grants"/>
<message_argument value="release(LicensedProduct, GrantAcqisition)"/>
</message_arguments>
</filter>
</resource>
<resource path="src/org/eclipse/passage/lbc/internal/base/api/RawRequest.java" type="org.eclipse.passage.lbc.internal.base.api.RawRequest">
<filter id="576725006">
<message_arguments>
<message_argument value="NetRequest"/>
<message_argument value="RawRequest"/>
</message_arguments>
</filter>
<filter id="576725006">
<message_arguments>
<message_argument value="WithState&lt;S&gt;"/>
<message_argument value="RawRequest"/>
</message_arguments>
</filter>
</resource>
</component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* Copyright (c) 2020, 2021 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.lbc.internal.base;

import org.eclipse.passage.lbc.internal.base.api.RawRequest;
import org.eclipse.passage.lic.internal.net.handle.RequestHandledByServices;

public final class FlotingRequestHandled extends RequestHandledByServices<RawRequest> {

public FlotingRequestHandled(RawRequest request) {
super(request, new FloatingCycle());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
package org.eclipse.passage.lbc.internal.jetty;

import org.eclipse.core.runtime.Platform;
import org.eclipse.passage.lbc.internal.base.BaseFlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.FlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.EagerFloatingState;
import org.eclipse.passage.lbc.internal.base.api.FloatingState;
import org.eclipse.passage.lic.internal.jetty.JettyHandler;
Expand Down Expand Up @@ -42,7 +42,7 @@ public void stop(BundleContext context) throws Exception {
}

private JettyHandler handler() {
return new JettyHandler(request -> new BaseFlotingRequestHandled(new StatedRequest(request, state)).get());
return new JettyHandler(request -> new FlotingRequestHandled(new StatedRequest(request, state)).get());
}

}
3 changes: 2 additions & 1 deletion bundles/org.eclipse.passage.lic.api/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ Export-Package: org.eclipse.passage.lic.internal.api;
org.eclipse.passage.lic.e4.ui,
org.eclipse.passage.lic.json,
org.eclipse.passage.lic.oshi,
org.eclipse.passage.loc.products.core",
org.eclipse.passage.loc.products.core,
org.eclipse.passage.lac",
org.eclipse.passage.lic.internal.api.access;
x-friends:="org.eclipse.passage.lic.base,
org.eclipse.passage.lic.e4.ui,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,24 @@
* Contributors:
* ArSysOp - initial API and implementation
*******************************************************************************/
package org.eclipse.passage.lbc.internal.base;
package org.eclipse.passage.lic.internal.net.handle;

import java.util.Objects;

import org.eclipse.passage.lbc.internal.base.api.RawRequest;
import org.eclipse.passage.lic.internal.net.handle.Chores;
import org.eclipse.passage.lic.internal.net.handle.NetRequestHandled;
import org.eclipse.passage.lic.internal.net.handle.NetResponse;
public abstract class RequestHandledByServices<R extends NetRequest> implements NetRequestHandled {

public final class BaseFlotingRequestHandled implements NetRequestHandled {
private final R request;
private final Chores<R> chores;

private final RawRequest request;
private final Chores<RawRequest> chores;

public BaseFlotingRequestHandled(RawRequest request, Chores<RawRequest> chores) {
protected RequestHandledByServices(R request, Chores<R> chores) {
Objects.requireNonNull(request, "BaseFlotingRequestHandled:request");//$NON-NLS-1$
Objects.requireNonNull(chores, "BaseFlotingRequestHandled:chores");//$NON-NLS-1$
this.request = request;
this.chores = chores;
}

public BaseFlotingRequestHandled(RawRequest request) {
this(request, new FloatingCycle());
}

@Override
public NetResponse get() {
public final NetResponse get() {
return chores.workOut(request);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;

import org.eclipse.passage.lbc.internal.base.BaseFlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.FlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.api.RawRequest;
import org.eclipse.passage.lic.internal.api.PassageAction;
import org.eclipse.passage.lic.internal.net.handle.Failure;
Expand All @@ -42,19 +42,19 @@ public void handleRelease() {

@Test
public void doNotHandleNull() {
assertActionIsNotSupported(new BaseFlotingRequestHandled(new RequestConstructed().get()).get());
assertActionIsNotSupported(new FlotingRequestHandled(new RequestConstructed().get()).get());
}

@Test
public void doNotHandleForeignAction() {
assertActionIsNotSupported(//
new BaseFlotingRequestHandled(//
new FlotingRequestHandled(//
requestOfAction(new PassageAction.Of("strange")) //$NON-NLS-1$
).get());
}

private void testActionSupported(PassageAction action) {
assertActionIsSupported(new BaseFlotingRequestHandled(requestOfAction(action)).get());
assertActionIsSupported(new FlotingRequestHandled(requestOfAction(action)).get());
}

private void assertActionIsSupported(NetResponse response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.util.Optional;

import org.eclipse.emf.ecore.EObject;
import org.eclipse.passage.lbc.internal.base.BaseFlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.FlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.acquire.NoGrantsAvailable;
import org.eclipse.passage.lbc.internal.base.acquire.NotReleased;
import org.eclipse.passage.lbc.internal.base.api.RawRequest;
Expand All @@ -42,22 +42,22 @@ public final class FloatingCycleActionsDryRunTest {

@Test
public void mineNothing() throws LicensingException, IOException {
NetResponse response = new BaseFlotingRequestHandled(request(new PassageAction.Mine())).get();
NetResponse response = new FlotingRequestHandled(request(new PassageAction.Mine())).get();
assertFalse(response.failed());
assertTrue(new License(response).get().getLicenseGrants().isEmpty());
}

@Test
public void acquireNothing() throws LicensingException, IOException {
NetResponse response = new BaseFlotingRequestHandled(request(new PassageAction.Acquire())).get();
NetResponse response = new FlotingRequestHandled(request(new PassageAction.Acquire())).get();
assertTrue(response.failed());
assertEquals(new NoGrantsAvailable(product, feature).error().code(), response.error().code());
}

@Test
public void releaseInVain() throws LicensingException, IOException {
GrantAcqisition acqisition = acquisition();
NetResponse response = new BaseFlotingRequestHandled(//
NetResponse response = new FlotingRequestHandled(//
request(new PassageAction.Release(), Optional.of(acqisition))).get();
assertTrue(response.failed());
assertEquals(new NotReleased(product, acqisition).error().code(), response.error().code());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import java.util.Arrays;

import org.eclipse.passage.lbc.internal.base.BaseFlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.FlotingRequestHandled;
import org.eclipse.passage.lic.floating.model.net.ServerAuthenticationExpression;
import org.eclipse.passage.lic.floating.model.net.ServerAuthenticationType;
import org.eclipse.passage.lic.internal.api.EvaluationType;
Expand All @@ -43,7 +43,7 @@ public void demandsProductVersion() {

@Test
public void demandsUser() {
NetResponse response = new BaseFlotingRequestHandled(//
NetResponse response = new FlotingRequestHandled(//
new RequestConstructed()//
.withAction(new PassageAction.Mine())//
.withParameters(Arrays.asList(//
Expand All @@ -57,7 +57,7 @@ public void demandsUser() {
}

private void testDemandProductInformation(StringNamedData half) {
NetResponse response = new BaseFlotingRequestHandled(//
NetResponse response = new FlotingRequestHandled(//
new RequestConstructed()//
.withAction(new PassageAction.Mine())//
.withParameters(Arrays.asList(////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

import org.eclipse.passage.lbc.internal.base.BaseFlotingRequestHandled;
import org.eclipse.passage.lbc.internal.base.FlotingRequestHandled;
import org.eclipse.passage.lic.floating.model.net.ServerAuthenticationExpression;
import org.eclipse.passage.lic.floating.model.net.ServerAuthenticationType;
import org.eclipse.passage.lic.internal.api.EvaluationType;
Expand All @@ -38,7 +38,7 @@ public void demandsServerAuthExpression() {
}

private void testDemandServerAuthInformation(StringNamedData half) {
NetResponse response = new BaseFlotingRequestHandled(//
NetResponse response = new FlotingRequestHandled(//
new RequestConstructed()//
.withAction(new PassageAction.Mine())//
.withParameter(half).get()//
Expand Down