Skip to content

Commit

Permalink
Make Operator more extensible #1039
Browse files Browse the repository at this point in the history
Rework domain registries to use OperatorWorkspace

Signed-off-by: Alexander Fedorov <[email protected]>
  • Loading branch information
ruspl-afed committed Feb 21, 2022
1 parent 9d520b3 commit 516e4e8
Show file tree
Hide file tree
Showing 32 changed files with 709 additions and 105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@
<provide interface="org.eclipse.passage.loc.internal.emf.EditingDomainRegistry"/>
</service>
<reference bind="bindEventAdmin" interface="org.osgi.service.event.EventAdmin" name="EventAdmin" unbind="unbindEventAdmin"/>
<reference bind="bindGear" interface="org.eclipse.passage.loc.internal.api.OperatorGearSupplier" name="Gear" unbind="unbindGear"/>
<implementation class="org.eclipse.passage.loc.internal.agreements.core.AgreementDomainRegistry"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 ArSysOp
* Copyright (c) 2021, 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
Expand All @@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.passage.loc.internal.agreements.core;

import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand All @@ -31,11 +29,15 @@
import org.eclipse.passage.lic.agreements.model.api.AgreementGroup;
import org.eclipse.passage.lic.agreements.model.meta.AgreementsPackage;
import org.eclipse.passage.lic.agreements.model.util.AgreementsResourceImpl;
import org.eclipse.passage.lic.equinox.io.InstallationPath;
import org.eclipse.passage.lic.internal.equinox.events.EquinoxEvent;
import org.eclipse.passage.loc.internal.agreements.AgreementRegistry;
import org.eclipse.passage.loc.internal.agreements.AgreementRegistryEvents;
import org.eclipse.passage.loc.internal.agreements.core.i18n.AgreementsCoreMessages;
import org.eclipse.passage.loc.internal.api.OperatorGearSupplier;
import org.eclipse.passage.loc.internal.api.workspace.Agreements;
import org.eclipse.passage.loc.internal.api.workspace.KnownResources;
import org.eclipse.passage.loc.internal.api.workspace.OperatorWorkspace;
import org.eclipse.passage.loc.internal.api.workspace.ResourceHandle;
import org.eclipse.passage.loc.internal.emf.BaseDomainRegistry;
import org.eclipse.passage.loc.internal.emf.DomainContentAdapter;
import org.eclipse.passage.loc.internal.emf.EditingDomainRegistry;
Expand Down Expand Up @@ -70,6 +72,17 @@ public void deactivate(Map<String, Object> properties) {
super.deactivate(properties);
}

@Override
@Reference
public void bindGear(OperatorGearSupplier supplier) {
super.bindGear(supplier);
}

@Override
public void unbindGear(OperatorGearSupplier supplier) {
super.unbindGear(supplier);
}

@Reference
public void bindEventAdmin(EventAdmin admin) {
this.events = admin;
Expand Down Expand Up @@ -197,15 +210,18 @@ public void unregisterContent(String identifier) {
}

@Override
protected Path getResourceSetPath() throws Exception {
Path passagePath = new InstallationPath().get();
Files.createDirectories(passagePath);
return passagePath.resolve(domainName);
protected final Resource createResource(URI uri) {
return new AgreementsResourceImpl(uri);
}

@Override
protected final Resource createResource(URI uri) {
return new AgreementsResourceImpl(uri);
protected boolean emfResource(ResourceHandle handle) {
return Agreements.xmi.equals(handle.type());
}

@Override
protected KnownResources knownResources(OperatorWorkspace workspace) {
return workspace.agreements();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 ArSysOp
* Copyright (c) 2021, 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
Expand All @@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.passage.loc.internal.api.workspace;

public interface Agreements {
public interface Agreements extends KnownResources {

/**
* Locate a handle for the given file under the common agreements residence
Expand All @@ -24,4 +24,20 @@ public interface Agreements {

boolean exists(String file);

ResourceType text = new ResourceType() {

@Override
public String id() {
return "agreements_text"; //$NON-NLS-1$
}
};

ResourceType xmi = new ResourceType() {

@Override
public String id() {
return "agreements_xmi"; //$NON-NLS-1$
}
};

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* 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.loc.internal.api.workspace;

public interface Features extends KnownResources {

ResourceType xmi = new ResourceType() {

@Override
public String id() {
return "features_xmi"; //$NON-NLS-1$
}
};

ResourceType xmi033 = new ResourceType() {

@Override
public String id() {
return "lic_features"; //$NON-NLS-1$
}
};

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 ArSysOp
* Copyright (c) 2021, 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
Expand All @@ -24,6 +24,22 @@ public interface Keys {

ResourceHandle locatedPub(String product, String version);

ResourceType xmi = new ResourceType() {

@Override
public String id() {
return "keys_xmi"; //$NON-NLS-1$
}
};

ResourceType pub = new ResourceType() {

@Override
public String id() {
return "pub"; //$NON-NLS-1$
}
};

public static final class Smart implements Keys {

private final Keys delegate;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*******************************************************************************
* 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.loc.internal.api.workspace;

import java.util.List;

public interface KnownResources {

List<ResourceHandle> all();

// FIXME: AF: temporary to not keep the functionality
void memento(List<String> locations);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* 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.loc.internal.api.workspace;

public interface Licenses extends KnownResources {

ResourceType xmi = new ResourceType() {

@Override
public String id() {
return "licenses_xmi"; //$NON-NLS-1$
}
};

ResourceType xmi033 = new ResourceType() {

@Override
public String id() {
return "lic_licenses"; //$NON-NLS-1$
}
};

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 ArSysOp
* Copyright (c) 2021, 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
Expand All @@ -14,8 +14,16 @@

public interface OperatorWorkspace {

Features features();

Products products();

Keys keys();

Agreements agreements();

Licenses licenses();

Users users();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* 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.loc.internal.api.workspace;

public interface Products extends KnownResources {

ResourceType xmi = new ResourceType() {

@Override
public String id() {
return "products_xmi"; //$NON-NLS-1$
}
};

ResourceType xmi033 = new ResourceType() {

@Override
public String id() {
return "lic_products"; //$NON-NLS-1$
}
};

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2021 ArSysOp
* Copyright (c) 2021, 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
Expand All @@ -19,8 +19,13 @@ public interface ResourceHandle {
*/
String info();

ResourceType type();

void write(byte[] content) throws Exception;

byte[] content() throws Exception;

// FIXME: AF: find better solution
String uri();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*******************************************************************************
* 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.loc.internal.api.workspace;

public interface ResourceType {

String id();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*******************************************************************************
* 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.loc.internal.api.workspace;

public interface Users extends KnownResources {

ResourceType xmi = new ResourceType() {

@Override
public String id() {
return "users_xmi"; //$NON-NLS-1$
}
};

ResourceType xmi033 = new ResourceType() {

@Override
public String id() {
return "lic_users"; //$NON-NLS-1$
}
};

}
Loading

0 comments on commit 516e4e8

Please sign in to comment.