Skip to content

Commit

Permalink
Issue #644 - Refactor Activator to DS components
Browse files Browse the repository at this point in the history
  • Loading branch information
laeubi authored and mickaelistria committed Apr 19, 2022
1 parent fee4e7a commit 25d6833
Show file tree
Hide file tree
Showing 43 changed files with 451 additions and 382 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "m2e-core-tests"]
path = m2e-core-tests
url = https://github.com/tesla/m2e-core-tests.git
branch = master
url = https://github.com/laeubi/m2e-core-tests.git
branch = Issue_644_adjust
17 changes: 16 additions & 1 deletion org.eclipse.m2e.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,19 @@ Import-Package: javax.inject;version="1.0.0",
org.osgi.service.component.annotations;version="1.3.0",
org.slf4j;version="1.6.2"
Automatic-Module-Name: org.eclipse.m2e.core
Service-Component: OSGI-INF/org.eclipse.m2e.core.internal.project.registry.ProjectFacadeAdapterFactory.xml
Service-Component: OSGI-INF/org.eclipse.m2e.core.embedder.MavenModelManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.embedder.MavenImpl.xml,
OSGI-INF/org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl.xml,
OSGI-INF/org.eclipse.m2e.core.internal.markers.MavenMarkerManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.ProjectConfigurationManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.WorkspaceClassifierResolverManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.WorkspaceStateWriter.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.conversion.ProjectConversionManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.registry.MavenProjectManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.registry.ProjectFacadeAdapterFactory.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.registry.ProjectRegistryReader.xml,
OSGI-INF/org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob.xml,
OSGI-INF/org.eclipse.m2e.core.internal.repository.RepositoryRegistry.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.m2e.core.embedder.MavenModelManager">
<service>
<provide interface="org.eclipse.m2e.core.embedder.MavenModelManager"/>
</service>
<reference cardinality="1..1" field="maven" interface="org.eclipse.m2e.core.embedder.IMaven" name="maven"/>
<reference cardinality="1..1" field="projectManager" interface="org.eclipse.m2e.core.project.IMavenProjectRegistry" name="projectManager"/>
<implementation class="org.eclipse.m2e.core.embedder.MavenModelManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" deactivate="disposeContainer" name="org.eclipse.m2e.core.internal.embedder.MavenImpl">
<service>
<provide interface="org.eclipse.m2e.core.embedder.IMaven"/>
<provide interface="org.eclipse.m2e.core.embedder.IMavenConfigurationChangeListener"/>
</service>
<reference cardinality="1..1" field="mavenConfiguration" interface="org.eclipse.m2e.core.embedder.IMavenConfiguration" name="mavenConfiguration"/>
<implementation class="org.eclipse.m2e.core.internal.embedder.MavenImpl"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager">
<service>
<provide interface="org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager"/>
</service>
<implementation class="org.eclipse.m2e.core.internal.index.filter.ArtifactFilterManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl">
<service>
<provide interface="org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl"/>
</service>
<reference cardinality="1..1" field="preferenceStore" interface="org.eclipse.core.runtime.preferences.IPreferencesService" name="preferenceStore"/>
<implementation class="org.eclipse.m2e.core.internal.launch.MavenRuntimeManagerImpl"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.m2e.core.internal.markers.MavenMarkerManager">
<service>
<provide interface="org.eclipse.m2e.core.internal.markers.IMavenMarkerManager"/>
</service>
<reference cardinality="1..1" field="mavenConfiguration" interface="org.eclipse.m2e.core.embedder.IMavenConfiguration" name="mavenConfiguration"/>
<implementation class="org.eclipse.m2e.core.internal.markers.MavenMarkerManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" activate="init" name="org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl">
<service>
<provide interface="org.eclipse.m2e.core.embedder.IMavenConfiguration"/>
</service>
<reference bind="addConfigurationChangeListener" cardinality="0..n" interface="org.eclipse.m2e.core.embedder.IMavenConfigurationChangeListener" name="ConfigurationChangeListener" policy="dynamic" unbind="removeConfigurationChangeListener"/>
<reference cardinality="1..1" field="preferenceStore" interface="org.eclipse.core.runtime.preferences.IPreferencesService" name="preferenceStore"/>
<implementation class="org.eclipse.m2e.core.internal.preferences.MavenConfigurationImpl"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.m2e.core.internal.project.ProjectConfigurationManager">
<property name="event.mask" type="Integer" value="4"/>
<service>
<provide interface="org.eclipse.m2e.core.project.IProjectConfigurationManager"/>
<provide interface="org.eclipse.m2e.core.project.IMavenProjectChangedListener"/>
<provide interface="org.eclipse.core.resources.IResourceChangeListener"/>
</service>
<reference cardinality="1..1" field="maven" interface="org.eclipse.m2e.core.embedder.IMaven" name="maven"/>
<reference cardinality="1..1" field="mavenConfiguration" interface="org.eclipse.m2e.core.embedder.IMavenConfiguration" name="mavenConfiguration"/>
<reference cardinality="1..1" field="mavenMarkerManager" interface="org.eclipse.m2e.core.internal.markers.IMavenMarkerManager" name="mavenMarkerManager"/>
<reference cardinality="1..1" field="mavenModelManager" interface="org.eclipse.m2e.core.embedder.MavenModelManager" name="mavenModelManager"/>
<reference cardinality="1..1" field="projectManager" interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager" name="projectManager"/>
<implementation class="org.eclipse.m2e.core.internal.project.ProjectConfigurationManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.m2e.core.internal.project.WorkspaceClassifierResolverManager">
<service>
<provide interface="org.eclipse.m2e.core.project.IWorkspaceClassifierResolverManager"/>
</service>
<implementation class="org.eclipse.m2e.core.internal.project.WorkspaceClassifierResolverManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" name="org.eclipse.m2e.core.internal.project.WorkspaceStateWriter">
<service>
<provide interface="org.eclipse.m2e.core.project.IMavenProjectChangedListener"/>
</service>
<reference cardinality="1..1" field="projectManager" interface="org.eclipse.m2e.core.internal.project.registry.MavenProjectManager" name="projectManager"/>
<reference cardinality="1..1" field="workspace" interface="org.eclipse.core.resources.IWorkspace" name="workspace"/>
<implementation class="org.eclipse.m2e.core.internal.project.WorkspaceStateWriter"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.eclipse.m2e.core.internal.project.conversion.ProjectConversionManager">
<service>
<provide interface="org.eclipse.m2e.core.project.conversion.IProjectConversionManager"/>
</service>
<implementation class="org.eclipse.m2e.core.internal.project.conversion.ProjectConversionManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" activate="init" name="org.eclipse.m2e.core.internal.project.registry.MavenProjectManager">
<service>
<provide interface="org.eclipse.m2e.core.project.IMavenProjectRegistry"/>
</service>
<reference bind="addMavenProjectChangedListener" cardinality="0..n" interface="org.eclipse.m2e.core.project.IMavenProjectChangedListener" name="MavenProjectChangedListener" policy="dynamic" unbind="removeMavenProjectChangedListener"/>
<reference cardinality="1..1" field="configuration" interface="org.eclipse.m2e.core.embedder.IMavenConfiguration" name="configuration"/>
<reference cardinality="1..1" field="manager" interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager" name="manager"/>
<reference cardinality="1..1" field="mavenBackgroundJob" interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob" name="mavenBackgroundJob"/>
<reference cardinality="1..1" field="workspace" interface="org.eclipse.core.resources.IWorkspace" name="workspace"/>
<implementation class="org.eclipse.m2e.core.internal.project.registry.MavenProjectManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" activate="init" name="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager">
<service>
<provide interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager"/>
</service>
<reference bind="addMavenProjectChangedListener" cardinality="0..n" interface="org.eclipse.m2e.core.project.IMavenProjectChangedListener" name="MavenProjectChangedListener" policy="dynamic" unbind="removeMavenProjectChangedListener"/>
<reference bind="setWorkspace" cardinality="0..1" interface="org.eclipse.core.resources.IWorkspace" name="Workspace" policy="dynamic" unbind="unsetWorkspace"/>
<reference cardinality="1..1" field="configuration" interface="org.eclipse.m2e.core.embedder.IMavenConfiguration" name="configuration"/>
<reference cardinality="1..1" field="markerManager" interface="org.eclipse.m2e.core.internal.markers.IMavenMarkerManager" name="markerManager"/>
<reference cardinality="1..1" field="maven" interface="org.eclipse.m2e.core.embedder.IMaven" name="maven"/>
<reference cardinality="1..1" field="stateReader" interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryReader" name="stateReader"/>
<implementation class="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="init" name="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryReader">
<service>
<provide interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryReader"/>
</service>
<implementation class="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryReader"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" deactivate="shutdown" name="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob">
<property name="event.mask" type="Integer" value="7"/>
<service>
<provide interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob"/>
<provide interface="org.eclipse.core.resources.IResourceChangeListener"/>
</service>
<reference cardinality="1..1" field="manager" interface="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager" name="manager"/>
<reference cardinality="1..1" field="mavenConfiguration" interface="org.eclipse.m2e.core.embedder.IMavenConfiguration" name="mavenConfiguration"/>
<implementation class="org.eclipse.m2e.core.internal.project.registry.ProjectRegistryRefreshJob"/>
</scr:component>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.3.0" activate="updateRegistry" name="org.eclipse.m2e.core.internal.repository.RepositoryRegistry">
<service>
<provide interface="org.eclipse.m2e.core.repository.IRepositoryRegistry"/>
<provide interface="org.eclipse.m2e.core.project.IMavenProjectChangedListener"/>
<provide interface="org.eclipse.m2e.core.embedder.ISettingsChangeListener"/>
</service>
<reference cardinality="1..1" field="maven" interface="org.eclipse.m2e.core.embedder.IMaven" name="maven"/>
<reference cardinality="1..1" field="projectManager" interface="org.eclipse.m2e.core.project.IMavenProjectRegistry" name="projectManager"/>
<implementation class="org.eclipse.m2e.core.internal.repository.RepositoryRegistry"/>
</scr:component>
Original file line number Diff line number Diff line change
Expand Up @@ -377,4 +377,11 @@ <V> V execute(boolean offline, boolean forceDependencyUpdate, ICallable<V> calla
* @since 1.10
*/
<T> T lookup(Class<T> clazz) throws CoreException;

/**
* @param <T>
* @param clazz
* @return
*/
<T> T lookupComponent(Class<T> clazz);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -81,17 +83,15 @@
*
* @author Eugene Kuleshov XXX fix circular dependency
*/
@Component(service = {MavenModelManager.class})
public class MavenModelManager {
private static final Logger log = LoggerFactory.getLogger(MavenModelManager.class);

private final IMavenProjectRegistry projectManager;
@Reference
private IMavenProjectRegistry projectManager;

private final IMaven maven;

public MavenModelManager(IMaven maven, IMavenProjectRegistry projectManager) {
this.maven = maven;
this.projectManager = projectManager;
}
@Reference
private IMaven maven;

public org.apache.maven.model.Model readMavenModel(InputStream reader) throws CoreException {
return maven.readModel(reader);
Expand Down
Loading

0 comments on commit 25d6833

Please sign in to comment.