Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2008-03-06 13:21:18 -0500
committerSimon Kaegi2008-03-06 13:21:18 -0500
commit9bf569becb58cf77b6591b2d9554e417e9434cd2 (patch)
treeabb2818fe8bee0af76ffd65792c2849f01fd0523 /bundles/org.eclipse.equinox.p2.directorywatcher
parent42a80e6cf6596fd83969a988642c99763ad9f607 (diff)
downloadrt.equinox.p2-9bf569becb58cf77b6591b2d9554e417e9434cd2.tar.gz
rt.equinox.p2-9bf569becb58cf77b6591b2d9554e417e9434cd2.tar.xz
rt.equinox.p2-9bf569becb58cf77b6591b2d9554e417e9434cd2.zip
synching to HEAD a change from the extensionlocationUI branch
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.directorywatcher')
-rw-r--r--bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java50
1 files changed, 40 insertions, 10 deletions
diff --git a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
index 5a75d6ce2..fbbe6605f 100644
--- a/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
+++ b/bundles/org.eclipse.equinox.p2.directorywatcher/src/org/eclipse/equinox/internal/provisional/p2/directorywatcher/RepositoryListener.java
@@ -37,14 +37,30 @@ public class RepositoryListener extends DirectoryChangeListener {
private final BundleDescriptionFactory bundleDescriptionFactory;
private final Map currentFiles = new HashMap();
private final String repositoryName;
+ private final boolean hidden;
private long lastModifed;
- public RepositoryListener(BundleContext context, String repositoryName) {
+ /**
+ * Create a repository listener that watches the specified folder and generates repositories
+ * for its content.
+ * @param context the bundle context
+ * @param repositoryName the repository name to use for the repository
+ * @param repositoryFolder the target folder for the repository, or <code>null</code> if a folder based on the
+ * bundle's data location should be used.
+ * @param hidden <code>true</code> if the repository should be hidden, <code>false</code> if not.
+ */
+ public RepositoryListener(BundleContext context, String repositoryName, File repositoryFolder, boolean hidden) {
this.repositoryName = repositoryName;
- String stateDirName = "listener_" + repositoryName;
- File stateDir = context.getDataFile(stateDirName);
- stateDir.mkdirs();
+ this.hidden = hidden;
+ File stateDir;
+ if (repositoryFolder == null) {
+ String stateDirName = "listener_" + repositoryName;
+ stateDir = context.getDataFile(stateDirName);
+ stateDir.mkdirs();
+ } else {
+ stateDir = repositoryFolder;
+ }
URL stateDirURL;
try {
@@ -58,6 +74,10 @@ public class RepositoryListener extends DirectoryChangeListener {
bundleDescriptionFactory = initializeBundleDescriptionFactory(context);
}
+ public RepositoryListener(BundleContext context, String string) {
+ this(context, string, null, false);
+ }
+
private BundleDescriptionFactory initializeBundleDescriptionFactory(BundleContext context) {
ServiceReference reference = context.getServiceReference(PlatformAdmin.class.getName());
@@ -90,12 +110,17 @@ public class RepositoryListener extends DirectoryChangeListener {
//fall through and create a new repository
}
try {
- IArtifactRepository repository = manager.createRepository(stateDirURL, "artifact listener " + repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY);
- repository.setProperty(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
+ IArtifactRepository repository;
+ if (hidden) {
+ repository = manager.createRepository(stateDirURL, "artifact listener " + repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY);
+ repository.setProperty(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
+ } else {
+ repository = manager.createRepository(stateDirURL, repositoryName, IArtifactRepositoryManager.TYPE_SIMPLE_REPOSITORY);
+ }
return repository;
} catch (ProvisionException e) {
LogHelper.log(e);
- throw new IllegalStateException("Couldn't create listener artifact repository for: " + stateDirURL);
+ throw new IllegalStateException("Couldn't create artifact repository for: " + stateDirURL);
}
} finally {
context.ungetService(reference);
@@ -116,12 +141,17 @@ public class RepositoryListener extends DirectoryChangeListener {
} catch (ProvisionException e) {
//fall through and create new repository
}
- IMetadataRepository repository = manager.createRepository(stateDirURL, "Metadata listener " + repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY);
- repository.setProperty(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
+ IMetadataRepository repository;
+ if (hidden) {
+ repository = manager.createRepository(stateDirURL, "Metadata listener " + repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY);
+ repository.setProperty(IRepository.PROP_SYSTEM, Boolean.TRUE.toString());
+ } else {
+ repository = manager.createRepository(stateDirURL, repositoryName, IMetadataRepositoryManager.TYPE_SIMPLE_REPOSITORY);
+ }
return repository;
} catch (ProvisionException e) {
LogHelper.log(e);
- throw new IllegalStateException("Couldn't create listener metadata repository for: " + stateDirURL);
+ throw new IllegalStateException("Couldn't create metadata repository for: " + stateDirURL);
} finally {
context.ungetService(reference);
}

Back to the top