Skip to content

Commit bfb9237

Browse files
committed
SLING-5618 - Make the ResourceChangeCommandFactory independent from Eclipse
- Introduce abstractions in the API module which support working with the ResourceChangeCommandFactory outside of Eclipse. - Implement needed abstractions in the eclipse-core module and stop using the ResourceChangeCommandFactory internally - The ResourceChangeCommandFactory is now left only as a deprecated stub until the tests are ported to use the DefaultCommandFactoryImpl.
1 parent 4f6c81d commit bfb9237

29 files changed

Lines changed: 1573 additions & 535 deletions

eclipse/eclipse-core/META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Import-Package: org.apache.commons.httpclient;version="3.1.0",
2424
org.apache.sling.ide.log,
2525
org.apache.sling.ide.osgi,
2626
org.apache.sling.ide.serialization,
27+
org.apache.sling.ide.sync.content,
2728
org.apache.sling.ide.transport,
2829
org.apache.sling.ide.util,
2930
org.eclipse.core.commands,
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.sling.ide.eclipse.core;
18+
19+
import java.util.Set;
20+
21+
import org.apache.sling.ide.eclipse.core.internal.Activator;
22+
import org.apache.sling.ide.eclipse.core.internal.sync.content.EclipseWorkspaceDirectory;
23+
import org.apache.sling.ide.eclipse.core.internal.sync.content.EclipseWorkspaceFile;
24+
import org.apache.sling.ide.eclipse.core.internal.sync.content.EclipseWorkspaceProject;
25+
import org.apache.sling.ide.sync.content.WorkspaceResource;
26+
import org.eclipse.core.resources.IFile;
27+
import org.eclipse.core.resources.IFolder;
28+
import org.eclipse.core.resources.IProject;
29+
import org.eclipse.core.resources.IResource;
30+
31+
public abstract class EclipseResources {
32+
33+
public static WorkspaceResource create(IResource resource) {
34+
35+
Set<String> ignoredFileNames = Activator.getDefault().getPreferences().getIgnoredFileNamesForSync();
36+
37+
switch ( resource.getType() ) {
38+
case IResource.FILE:
39+
return new EclipseWorkspaceFile((IFile) resource, ignoredFileNames);
40+
case IResource.FOLDER:
41+
return new EclipseWorkspaceDirectory((IFolder) resource, ignoredFileNames);
42+
case IResource.PROJECT:
43+
return new EclipseWorkspaceProject((IProject) resource, ignoredFileNames);
44+
default:
45+
throw new IllegalArgumentException("Unable to create a local resource for Eclipse IResource.getType() = " + resource.getType() );
46+
}
47+
}
48+
49+
private EclipseResources() {
50+
51+
}
52+
}

eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/ResourceUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.sling.ide.eclipse.core;
1818

1919
import org.apache.sling.ide.eclipse.core.internal.Activator;
20+
import org.apache.sling.ide.sync.content.SyncCommandFactory;
2021
import org.eclipse.core.resources.IResource;
2122
import org.eclipse.core.runtime.QualifiedName;
2223

@@ -36,7 +37,7 @@ public abstract class ResourceUtil {
3637
* </p>
3738
*/
3839
public static final QualifiedName QN_IMPORT_MODIFICATION_TIMESTAMP = new QualifiedName(Activator.PLUGIN_ID,
39-
"importModificationTimestamp");
40+
SyncCommandFactory.PN_IMPORT_MODIFICATION_TIMESTAMP);
4041

4142
private ResourceUtil() {
4243

eclipse/eclipse-core/src/org/apache/sling/ide/eclipse/core/internal/Activator.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.apache.sling.ide.log.Logger;
2929
import org.apache.sling.ide.osgi.OsgiClientFactory;
3030
import org.apache.sling.ide.serialization.SerializationManager;
31+
import org.apache.sling.ide.sync.content.SyncCommandFactory;
3132
import org.apache.sling.ide.transport.BatcherFactory;
3233
import org.apache.sling.ide.transport.CommandExecutionProperties;
3334
import org.apache.sling.ide.transport.RepositoryFactory;
@@ -63,6 +64,7 @@ public class Activator extends Plugin {
6364
private ServiceTracker<Logger, Logger> tracer;
6465
private ServiceTracker<BatcherFactory, BatcherFactory> batcherFactoryLocator;
6566
private ServiceTracker<SourceReferenceResolver, Object> sourceReferenceLocator;
67+
private ServiceTracker<SyncCommandFactory, SyncCommandFactory> commandFactory;
6668

6769
private ServiceRegistration<Logger> tracerRegistration;
6870

@@ -107,6 +109,9 @@ public void start(BundleContext context) throws Exception {
107109

108110
sourceReferenceLocator = new ServiceTracker<>(context, SourceReferenceResolver.class, null);
109111
sourceReferenceLocator.open();
112+
113+
commandFactory = new ServiceTracker<>(context, SyncCommandFactory.class, null);
114+
commandFactory.open();
110115
}
111116

112117
/*
@@ -128,6 +133,7 @@ public void stop(BundleContext context) throws Exception {
128133
tracer.close();
129134
batcherFactoryLocator.close();
130135
sourceReferenceLocator.close();
136+
commandFactory.close();
131137

132138
plugin = null;
133139
super.stop(context);
@@ -172,6 +178,10 @@ public BatcherFactory getBatcherFactory() {
172178
return (BatcherFactory) ServiceUtil.getNotNull(batcherFactoryLocator);
173179
}
174180

181+
public SyncCommandFactory getCommandFactory() {
182+
return ServiceUtil.getNotNull(commandFactory);
183+
}
184+
175185
/**
176186
* @deprecated This should not be used directly to communicate with the client . There is no direct replacement
177187
*/

0 commit comments

Comments
 (0)