[283690] [plug-in registry] Separate model from org.eclipse.pde.runtime to new independent plugin
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java
index 3950e4a..dd60f53 100644
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java
+++ b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java
@@ -22,7 +22,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.runtime.*;
import org.eclipse.pde.internal.runtime.registry.RegistryBrowserContentProvider.Folder;
-import org.eclipse.pde.internal.runtime.registry.model.*;
+import org.eclipse.pde.runtime.core.model.*;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.dnd.*;
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java
index 93703d9..5410be3 100644
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java
+++ b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserContentProvider.java
@@ -15,7 +15,7 @@
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.viewers.*;
-import org.eclipse.pde.internal.runtime.registry.model.*;
+import org.eclipse.pde.runtime.core.model.*;
public class RegistryBrowserContentProvider implements ITreeContentProvider {
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java
index bb94418..d0323b3 100644
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java
+++ b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserLabelProvider.java
@@ -17,7 +17,7 @@
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.runtime.*;
import org.eclipse.pde.internal.runtime.registry.RegistryBrowserContentProvider.Folder;
-import org.eclipse.pde.internal.runtime.registry.model.*;
+import org.eclipse.pde.runtime.core.model.*;
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Constants;
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java
index f30fdfd..2589109 100644
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java
+++ b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowserModelChangeListener.java
@@ -11,7 +11,7 @@
*******************************************************************************/
package org.eclipse.pde.internal.runtime.registry;
-import org.eclipse.pde.internal.runtime.registry.model.*;
+import org.eclipse.pde.runtime.core.model.*;
public class RegistryBrowserModelChangeListener implements ModelChangeListener {
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryModelFactory.java
similarity index 95%
rename from osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java
rename to osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryModelFactory.java
index c31b617..e680b72 100644
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryModelFactory.java
+++ b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryModelFactory.java
@@ -9,11 +9,12 @@
* IBM Corporation - initial API and implementation
* Wojciech Galanciak - bug 282672
*******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
+package org.eclipse.pde.internal.runtime.registry;
import java.net.URI;
import java.net.URISyntaxException;
import org.eclipse.core.runtime.*;
+import org.eclipse.pde.runtime.core.model.*;
/**
* Produces RegistryModels for URLs.
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Attribute.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Attribute.java
deleted file mode 100644
index 80cd06d..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Attribute.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class Attribute extends ModelObject {
-
- private static final long serialVersionUID = 1L;
- public static final String F_LOCATION = "Location"; //$NON-NLS-1$
-
- public static final String F_BUNDLE = "Bundle"; //$NON-NLS-1$
-
- private String name;
- private String value;
-
- public Attribute() {
- // empty
- }
-
- public Attribute(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BackendChangeListener.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BackendChangeListener.java
deleted file mode 100644
index 1344b6e..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BackendChangeListener.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-/**
- * Notifies on any changes coming from backend. Usually RegistryModel is only interested in receiving
- * news about that.
- *
- */
-public interface BackendChangeListener {
-
- void addBundle(Bundle adapter);
-
- void removeBundle(Bundle adapter);
-
- void updateBundle(Bundle adapter, int updated);
-
- void addService(ServiceRegistration adapter);
-
- void removeService(ServiceRegistration adapter);
-
- void updateService(ServiceRegistration adapter);
-
- void addExtensions(Extension[] extensions);
-
- void removeExtensions(Extension[] extensions);
-
- void addExtensionPoints(ExtensionPoint[] extensionPoints);
-
- void removeExtensionPoints(ExtensionPoint[] extensionPoints);
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java
deleted file mode 100644
index 8248502..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Bundle.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class Bundle extends ModelObject {
-
- private static final long serialVersionUID = 1L;
- public static final int ACTIVE = org.osgi.framework.Bundle.ACTIVE;
- public static final int UNINSTALLED = org.osgi.framework.Bundle.UNINSTALLED;
- public static final int INSTALLED = org.osgi.framework.Bundle.INSTALLED;
-
- private String symbolicName;
- private String location;
- private boolean isEnabled;
- private BundlePrerequisite[] imports = new BundlePrerequisite[0];
- private String version;
- private int state;
- private long id;
- private BundleLibrary[] libraries = new BundleLibrary[0];
- private BundlePrerequisite[] importedPackages = new BundlePrerequisite[0];
- private BundlePrerequisite[] exportedPackages = new BundlePrerequisite[0];
-
- private String fragmentHost;
- private String fragmentHostVersion;
-
- public void setFragmentHost(String fragmentHost) {
- this.fragmentHost = fragmentHost;
- }
-
- public String getFragmentHost() {
- return fragmentHost;
- }
-
- public String getFragmentHostVersion() {
- return fragmentHostVersion;
- }
-
- public void setFragmentHostVersion(String fragmentHostVersion) {
- this.fragmentHostVersion = fragmentHostVersion;
- }
-
- public void setSymbolicName(String symbolicName) {
- this.symbolicName = symbolicName;
- }
-
- public void setLocation(String location) {
- this.location = location;
- }
-
- public void setImports(BundlePrerequisite[] imports) {
- if (imports == null)
- throw new IllegalArgumentException();
-
- this.imports = imports;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public void setState(int state) {
- this.state = state;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public void setEnabled(boolean enabled) {
- isEnabled = enabled;
- }
-
- public void setLibraries(BundleLibrary[] libraries) {
- if (libraries == null)
- throw new IllegalArgumentException();
-
- this.libraries = libraries;
- }
-
- public String getSymbolicName() {
- return symbolicName;
- }
-
- public boolean isEnabled() {
- return isEnabled;
- }
-
- public BundlePrerequisite[] getImports() {
- return imports;
- }
-
- public BundleLibrary[] getLibraries() {
- return libraries;
- }
-
- public String getLocation() {
- return location;
- }
-
- public String getVersion() {
- return version;
- }
-
- public int getState() {
- return state;
- }
-
- public long getId() {
- return id;
- }
-
- public boolean equals(Object obj) {
- return (obj instanceof Bundle) && (id == ((Bundle) obj).id);
- }
-
- public int hashCode() {
- return (int) id;
- }
-
- public void setImportedPackages(BundlePrerequisite[] importedPackages) {
- this.importedPackages = importedPackages;
- }
-
- public BundlePrerequisite[] getImportedPackages() {
- return importedPackages;
- }
-
- public void setExportedPackages(BundlePrerequisite[] exportedPackages) {
- this.exportedPackages = exportedPackages;
- }
-
- public BundlePrerequisite[] getExportedPackages() {
- return exportedPackages;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BundleLibrary.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BundleLibrary.java
deleted file mode 100644
index 2413d80..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BundleLibrary.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class BundleLibrary extends ModelObject {
-
- private static final long serialVersionUID = 1L;
- private String library;
-
- public String getLibrary() {
- return library;
- }
-
- public void setLibrary(String name) {
- library = name;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BundlePrerequisite.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BundlePrerequisite.java
deleted file mode 100644
index 2ffc8c2..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/BundlePrerequisite.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class BundlePrerequisite extends ModelObject {
-
- private static final long serialVersionUID = 1L;
-
- private boolean isExported;
- private String name;
- private String version;
- private boolean isPackage;
-
- public void setPackage(boolean isPackage) {
- this.isPackage = isPackage;
- }
-
- public boolean isPackage() {
- return isPackage;
- }
-
- public void setExported(boolean isExported) {
- this.isExported = isExported;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public boolean isExported() {
- return isExported;
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- return version;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java
deleted file mode 100644
index e080c8e..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ConfigurationElement.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class ConfigurationElement extends Attribute {
-
- private static final long serialVersionUID = 1L;
-
- private Attribute[] elements = new Attribute[0];
-
- public void setElements(Attribute[] elements) {
- if (elements == null)
- throw new IllegalArgumentException();
-
- this.elements = elements;
- }
-
- public Attribute[] getElements() {
- return elements;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Extension.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Extension.java
deleted file mode 100644
index bf9fd95..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Extension.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class Extension extends ModelObject {
-
- private static final long serialVersionUID = 1L;
- private String namespaceIdentifier;
- private String label;
- private String extensionPointUniqueIdentifier;
- private ConfigurationElement[] configurationElements = new ConfigurationElement[0];
- private Long contributor;
-
- public void setNamespaceIdentifier(String namespaceIdentifier) {
- this.namespaceIdentifier = namespaceIdentifier;
- }
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public void setExtensionPointUniqueIdentifier(String extensionPointUniqueIdentifier) {
- this.extensionPointUniqueIdentifier = extensionPointUniqueIdentifier;
- }
-
- public void setConfigurationElements(ConfigurationElement[] configurationElements) {
- if (configurationElements == null)
- throw new IllegalArgumentException();
-
- this.configurationElements = configurationElements;
- }
-
- public void setContributor(Long contributor) {
- this.contributor = contributor;
- }
-
- public ConfigurationElement[] getConfigurationElements() {
- return configurationElements;
- }
-
- public String getExtensionPointUniqueIdentifier() {
- return extensionPointUniqueIdentifier;
- }
-
- public String getLabel() {
- return label;
- }
-
- public String getNamespaceIdentifier() {
- return namespaceIdentifier;
- }
-
- /**
- * @return contributor id or <code>null</code> if contributor not present
- */
- public Long getContributorId() {
- return contributor;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- Extension other = (Extension) obj;
- if (contributor == null) {
- if (other.contributor != null)
- return false;
- } else if (!contributor.equals(other.contributor))
- return false;
- if (extensionPointUniqueIdentifier == null) {
- if (other.extensionPointUniqueIdentifier != null)
- return false;
- } else if (!extensionPointUniqueIdentifier.equals(other.extensionPointUniqueIdentifier))
- return false;
- if (label == null) {
- if (other.label != null)
- return false;
- } else if (!label.equals(other.label))
- return false;
- if (namespaceIdentifier == null) {
- if (other.namespaceIdentifier != null)
- return false;
- } else if (!namespaceIdentifier.equals(other.namespaceIdentifier))
- return false;
- return true;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((contributor == null) ? 0 : contributor.hashCode());
- result = prime * result + ((extensionPointUniqueIdentifier == null) ? 0 : extensionPointUniqueIdentifier.hashCode());
- result = prime * result + ((label == null) ? 0 : label.hashCode());
- result = prime * result + ((namespaceIdentifier == null) ? 0 : namespaceIdentifier.hashCode());
- return result;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java
deleted file mode 100644
index 846d5ad..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ExtensionPoint.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-public class ExtensionPoint extends ModelObject {
-
- private static final long serialVersionUID = 1L;
-
- private String label;
- private String uniqueIdentifier;
- private String namespaceIdentifier;
- private Long contributor;
- private List extensions = new ArrayList();
-
- public void setLabel(String label) {
- this.label = label;
- }
-
- public void setUniqueIdentifier(String uniqueIdentifier) {
- this.uniqueIdentifier = uniqueIdentifier;
- }
-
- public void setNamespaceIdentifier(String namespaceIdentifier) {
- this.namespaceIdentifier = namespaceIdentifier;
- }
-
- public void setContributor(Long contributor) {
- this.contributor = contributor;
- }
-
- public void setExtensions(List extensions) {
- this.extensions = extensions;
- }
-
- public List getExtensions() {
- return extensions;
- }
-
- public String getLabel() {
- return label;
- }
-
- public String getUniqueIdentifier() {
- return uniqueIdentifier;
- }
-
- public String getNamespaceIdentifier() {
- return namespaceIdentifier;
- }
-
- /**
- * @return contributor id or <code>null</code> if contributor not present
- */
- public Long getContributorId() {
- return contributor;
- }
-
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((uniqueIdentifier == null) ? 0 : uniqueIdentifier.hashCode());
- return result;
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
- ExtensionPoint other = (ExtensionPoint) obj;
- if (uniqueIdentifier == null) {
- if (other.uniqueIdentifier != null)
- return false;
- } else if (!uniqueIdentifier.equals(other.uniqueIdentifier))
- return false;
- return true;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java
deleted file mode 100644
index a177424..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/LocalRegistryBackend.java
+++ /dev/null
@@ -1,514 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wolfgang Schell <ws@jetztgrad.net> - bug 259348
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import java.io.IOException;
-import java.net.URL;
-import java.util.Arrays;
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.service.resolver.*;
-import org.eclipse.osgi.util.ManifestElement;
-import org.eclipse.pde.internal.runtime.MessageHelper;
-import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-public class LocalRegistryBackend implements IRegistryEventListener, BundleListener, ServiceListener, RegistryBackend {
-
- private BackendChangeListener listener;
-
- public void setRegistryListener(BackendChangeListener listener) {
- this.listener = listener;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#connect()
- */
- public boolean connect(IProgressMonitor monitor) {
- if (monitor.isCanceled())
- return false;
-
- PDERuntimePlugin.getDefault().getBundleContext().addBundleListener(this);
- Platform.getExtensionRegistry().addListener(this);
- PDERuntimePlugin.getDefault().getBundleContext().addServiceListener(this);
-
- return true;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#disconnect()
- */
- public void disconnect() {
- Platform.getExtensionRegistry().removeListener(this);
- PDERuntimePlugin.getDefault().getBundleContext().removeBundleListener(this);
- PDERuntimePlugin.getDefault().getBundleContext().removeServiceListener(this);
- }
-
- protected static boolean isRegisteredService(org.osgi.framework.Bundle bundle, ServiceReference ref) {
- return bundle.equals(ref.getBundle());
- }
-
- protected static boolean isServiceInUse(org.osgi.framework.Bundle bundle, ServiceReference ref) {
- org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles();
- return (usingBundles != null && Arrays.asList(usingBundles).contains(bundle));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#start(org.osgi.framework.Bundle)
- */
- public void start(long id) {
- try {
- PDERuntimePlugin.getDefault().getBundleContext().getBundle(id).start();
- } catch (BundleException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#stop(org.osgi.framework.Bundle)
- */
- public void stop(long id) {
- try {
- PDERuntimePlugin.getDefault().getBundleContext().getBundle(id).stop();
- } catch (BundleException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.pde.internal.runtime.registry.model.local.RegistryBackend#diagnose(org.osgi.framework.Bundle)
- */
- public String[] diagnose(long id) {
- PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- State state = plaformAdmin.getState(false);
-
- BundleDescription desc = state.getBundle(id);
-
- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- VersionConstraint[] unsatisfied = platformAdmin.getStateHelper().getUnsatisfiedConstraints(desc);
- ResolverError[] resolverErrors = platformAdmin.getState(false).getResolverErrors(desc);
-
- String[] problems = new String[unsatisfied.length + resolverErrors.length];
-
- for (int i = 0; i < resolverErrors.length; i++) {
- problems[i] = resolverErrors[i].toString();
- }
- int j = 0;
- for (int i = resolverErrors.length; i < unsatisfied.length + resolverErrors.length; i++) {
- problems[i] = MessageHelper.getResolutionFailureMessage(unsatisfied[j]);
- j++;
- }
- return problems;
- }
-
- public void initializeBundles(IProgressMonitor monitor) {
- if (monitor.isCanceled())
- return;
-
- org.osgi.framework.Bundle[] newBundles = PDERuntimePlugin.getDefault().getBundleContext().getBundles();
- for (int i = 0; i < newBundles.length; i++) {
- if (monitor.isCanceled())
- return;
-
- Bundle ba = createBundleAdapter(newBundles[i]);
- listener.addBundle(ba);
- }
- }
-
- public void initializeExtensionPoints(IProgressMonitor monitor) {
- if (monitor.isCanceled())
- return;
-
- IExtensionPoint[] extPoints = Platform.getExtensionRegistry().getExtensionPoints();
- ExtensionPoint[] extPts = new ExtensionPoint[extPoints.length];
- for (int i = 0; i < extPoints.length; i++) {
- if (monitor.isCanceled())
- return;
-
- extPts[i] = createExtensionPointAdapter(extPoints[i]);
- }
- listener.addExtensionPoints(extPts);
- }
-
- public void initializeServices(IProgressMonitor monitor) {
- if (monitor.isCanceled())
- return;
-
- ServiceReference[] references = null;
- try {
- references = PDERuntimePlugin.getDefault().getBundleContext().getAllServiceReferences(null, null);
- } catch (InvalidSyntaxException e) { // nothing
- }
-
- if (references == null) {
- return;
- }
-
- for (int i = 0; i < references.length; i++) {
- if (monitor.isCanceled())
- return;
-
- ServiceRegistration service = createServiceReferenceAdapter(references[i]);
- listener.addService(service);
- }
- }
-
- private Bundle createBundleAdapter(org.osgi.framework.Bundle bundle) {
- Bundle adapter = new Bundle();
- adapter.setSymbolicName(bundle.getSymbolicName());
- adapter.setVersion((String) bundle.getHeaders().get(org.osgi.framework.Constants.BUNDLE_VERSION));
- adapter.setState(bundle.getState());
- adapter.setId(bundle.getBundleId());
- adapter.setEnabled(getIsEnabled(bundle));
- adapter.setLocation(createLocation(bundle));
-
- String fragmentHost = (String) bundle.getHeaders().get(Constants.FRAGMENT_HOST);
- if (fragmentHost != null) {
- ManifestElement[] header;
- try {
- header = ManifestElement.parseHeader(Constants.FRAGMENT_HOST, fragmentHost);
-
- if (header.length > 0) {
- ManifestElement host = header[0];
- adapter.setFragmentHost(host.getValue());
- String version = host.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE);
- if (version != null) {
- adapter.setFragmentHostVersion(version);
- }
- }
- } catch (BundleException e) {
- PDERuntimePlugin.log(e);
- }
- }
-
- BundlePrerequisite[] imports = (BundlePrerequisite[]) getManifestHeaderArray(bundle, Constants.REQUIRE_BUNDLE);
- if (imports != null)
- adapter.setImports(imports);
-
- BundleLibrary[] libraries = (BundleLibrary[]) getManifestHeaderArray(bundle, Constants.BUNDLE_CLASSPATH);
- if (libraries != null)
- adapter.setLibraries(libraries);
-
- BundlePrerequisite[] importPackages = (BundlePrerequisite[]) getManifestHeaderArray(bundle, Constants.IMPORT_PACKAGE);
- if (importPackages != null)
- adapter.setImportedPackages(importPackages);
-
- BundlePrerequisite[] exportPackages = (BundlePrerequisite[]) getManifestHeaderArray(bundle, Constants.EXPORT_PACKAGE);
- if (exportPackages != null)
- adapter.setExportedPackages(exportPackages);
-
- return adapter;
- }
-
- private Extension createExtensionAdapter(IExtension extension) {
- Extension adapter = new Extension();
- adapter.setNamespaceIdentifier(extension.getNamespaceIdentifier());
- adapter.setLabel(extension.getLabel());
- adapter.setExtensionPointUniqueIdentifier(extension.getExtensionPointUniqueIdentifier());
- adapter.setContributor(getBundleId(extension.getContributor().getName()));
-
- IConfigurationElement[] elements = extension.getConfigurationElements();
- if (elements.length > 0) {
- ConfigurationElement[] configurationElements = new ConfigurationElement[elements.length];
- for (int i = 0; i < elements.length; i++) {
- configurationElements[i] = createConfigurationElement(elements[i]);
- }
- adapter.setConfigurationElements(configurationElements);
- }
-
- return adapter;
- }
-
- private ConfigurationElement createConfigurationElement(IConfigurationElement config) {
- ConfigurationElement element = new ConfigurationElement();
- element.setName(createName(config));
- Attribute[] attributes = createConfigurationElementAttributes(config);
- if (attributes != null)
- element.setElements(attributes);
- return element;
- }
-
- private static Long getBundleId(String name) {
- BundleDescription descr = PDERuntimePlugin.getDefault().getPlatformAdmin().getState().getBundle(name, null);
- return descr == null ? null : new Long(descr.getBundleId());
- }
-
- private ExtensionPoint createExtensionPointAdapter(IExtensionPoint extensionPoint) {
- ExtensionPoint adapter = new ExtensionPoint();
- adapter.setLabel(extensionPoint.getLabel());
- adapter.setUniqueIdentifier(extensionPoint.getUniqueIdentifier());
- adapter.setNamespaceIdentifier(extensionPoint.getNamespaceIdentifier());
- adapter.setContributor(getBundleId(extensionPoint.getContributor().getName()));
-
- Extension[] extensions = createExtensionAdapters(extensionPoint.getExtensions());
- adapter.getExtensions().addAll(Arrays.asList(extensions));
- return adapter;
- }
-
- private ServiceRegistration createServiceReferenceAdapter(ServiceReference ref) {
- ServiceRegistration service = new ServiceRegistration();
- service.setId(((Long) ref.getProperty(org.osgi.framework.Constants.SERVICE_ID)).longValue());
- service.setBundle(ref.getBundle().getSymbolicName());
-
- org.osgi.framework.Bundle[] usingBundles = ref.getUsingBundles();
- long[] usingBundlesIds = null;
- if (usingBundles != null) {
- usingBundlesIds = new long[usingBundles.length];
- for (int i = 0; i < usingBundles.length; i++) {
- usingBundlesIds[i] = usingBundles[i].getBundleId();
- }
- }
- if (usingBundlesIds != null)
- service.setUsingBundles(usingBundlesIds);
-
- String[] classes = (String[]) ref.getProperty(org.osgi.framework.Constants.OBJECTCLASS);
- String[] propertyKeys = ref.getPropertyKeys();
- Property[] properties = null;
- if (propertyKeys != null) {
- properties = new Property[propertyKeys.length];
- for (int p = 0; p < propertyKeys.length; p++) {
- String key = propertyKeys[p];
- Object value = ref.getProperty(key);
- properties[p] = new Property(key, ServiceRegistration.toString(value));
- }
- }
-
- if (classes != null) {
- Arrays.sort(classes);
- service.setName(new ServiceName(classes));
- service.setProperties(properties);
- }
- return service;
- }
-
- private static boolean getIsEnabled(org.osgi.framework.Bundle bundle) {
- PlatformAdmin plaformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- State state = plaformAdmin.getState(false);
-
- BundleDescription description = state.getBundle(bundle.getBundleId());
- return (state.getDisabledInfos(description)).length == 0;
- }
-
- private static String createLocation(org.osgi.framework.Bundle bundle) {
- URL bundleEntry = null;
-
- try {
- bundleEntry = bundle.getEntry("/"); //$NON-NLS-1$
- } catch (IllegalStateException e) {
- return null;
- }
-
- if (bundleEntry == null)
- return null;
-
- try {
- bundleEntry = FileLocator.resolve(bundleEntry);
- } catch (IOException e) { // do nothing
- }
- IPath path = new Path(bundleEntry.getFile());
- String pathString = path.removeTrailingSeparator().toOSString();
- if (pathString.startsWith("file:")) //$NON-NLS-1$
- pathString = pathString.substring(5);
- if (pathString.endsWith("!")) //$NON-NLS-1$
- pathString = pathString.substring(0, pathString.length() - 1);
- return pathString;
- }
-
- private Object[] getManifestHeaderArray(org.osgi.framework.Bundle bundle, String headerKey) {
- String libraries = (String) bundle.getHeaders().get(headerKey);
- try {
- ManifestElement[] elements = ManifestElement.parseHeader(headerKey, libraries);
- if (elements == null)
- return null;
- if (headerKey.equals(Constants.BUNDLE_CLASSPATH)) {
- BundleLibrary[] array = new BundleLibrary[elements.length];
- for (int i = 0; i < elements.length; i++) {
- BundleLibrary library = new BundleLibrary();
- library.setLibrary(elements[i].getValue());
- array[i] = library;
- }
- return array;
- } else if (headerKey.equals(Constants.REQUIRE_BUNDLE) || headerKey.equals(Constants.IMPORT_PACKAGE) || headerKey.equals(Constants.EXPORT_PACKAGE)) {
- BundlePrerequisite[] array = new BundlePrerequisite[elements.length];
- for (int i = 0; i < elements.length; i++) {
- ManifestElement element = elements[i];
-
- BundlePrerequisite prereq = new BundlePrerequisite();
- prereq.setName(element.getValue());
- if (headerKey.equals(Constants.REQUIRE_BUNDLE)) {
- prereq.setVersion(element.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE));
- String visibility = element.getDirective(Constants.VISIBILITY_DIRECTIVE);
- prereq.setExported(Constants.VISIBILITY_REEXPORT.equals(visibility));
- } else {
- prereq.setVersion(element.getAttribute(Constants.VERSION_ATTRIBUTE));
- prereq.setPackage(true);
- }
-
- array[i] = prereq;
- }
- return array;
- }
- } catch (BundleException e) { // do nothing
- }
- return null;
- }
-
- private Attribute[] createConfigurationElementAttributes(IConfigurationElement config) {
- String[] atts = config.getAttributeNames();
-
- Attribute[] catts = new Attribute[atts.length];
- for (int i = 0; i < atts.length; i++)
- catts[i] = new Attribute(atts[i], config.getAttribute(atts[i]));
-
- IConfigurationElement[] children = config.getChildren();
- Attribute[] result = new Attribute[children.length + catts.length];
- for (int i = 0; i < children.length; i++) {
- IConfigurationElement child = children[i];
- result[i] = createConfigurationElement(child);
- }
- for (int i = 0; i < catts.length; i++) {
- result[children.length + i] = catts[i];
- }
- return result;
- }
-
- private static String createName(IConfigurationElement config) {
- String label = config.getAttribute("label"); //$NON-NLS-1$
- if (label == null)
- label = config.getName();
-
- if (label == null)
- label = config.getAttribute("name"); //$NON-NLS-1$
-
- if (label == null && config.getAttribute("id") != null) { //$NON-NLS-1$
- String[] labelSplit = config.getAttribute("id").split("\\."); //$NON-NLS-1$ //$NON-NLS-2$
- label = labelSplit.length == 0 ? null : labelSplit[labelSplit.length - 1];
- }
-
- return label;
- }
-
- private Extension[] createExtensionAdapters(IExtension[] extensions) {
- Extension[] extensionAdapters = new Extension[extensions.length];
- for (int i = 0; i < extensions.length; i++) {
- extensionAdapters[i] = createExtensionAdapter(extensions[i]);
- }
- return extensionAdapters;
- }
-
- public void bundleChanged(BundleEvent event) {
- Bundle adapter = createBundleAdapter(event.getBundle());
-
- switch (event.getType()) {
- case BundleEvent.INSTALLED :
- listener.addBundle(adapter);
- break;
- case BundleEvent.UNINSTALLED :
- listener.removeBundle(adapter);
- break;
- case BundleEvent.UPDATED :
- listener.updateBundle(adapter, ModelChangeDelta.UPDATED);
- break;
- case BundleEvent.RESOLVED :
- listener.updateBundle(adapter, ModelChangeDelta.RESOLVED);
- break;
- case BundleEvent.UNRESOLVED :
- listener.updateBundle(adapter, ModelChangeDelta.UNRESOLVED);
- break;
- case BundleEvent.STARTING :
- listener.updateBundle(adapter, ModelChangeDelta.STARTING);
- break;
- case BundleEvent.STARTED :
- listener.updateBundle(adapter, ModelChangeDelta.STARTED);
- break;
- case BundleEvent.STOPPING :
- listener.updateBundle(adapter, ModelChangeDelta.STOPPING);
- break;
- case BundleEvent.STOPPED :
- listener.updateBundle(adapter, ModelChangeDelta.STOPPED);
- break;
- default :
- listener.updateBundle(adapter, ModelChangeDelta.UPDATED);
- }
- }
-
- public void serviceChanged(ServiceEvent event) {
- ServiceReference ref = event.getServiceReference();
- ServiceRegistration adapter = createServiceReferenceAdapter(ref);
-
- switch (event.getType()) {
- case ServiceEvent.REGISTERED :
- listener.addService(adapter);
- break;
- case ServiceEvent.UNREGISTERING :
- listener.removeService(adapter);
- break;
- case ServiceEvent.MODIFIED :
- default :
- listener.updateService(adapter);
- break;
- }
- }
-
- private ExtensionPoint[] createExtensionPointAdapters(IExtensionPoint[] extensionPoints) {
- ExtensionPoint[] result = new ExtensionPoint[extensionPoints.length];
- for (int i = 0; i < extensionPoints.length; i++) {
- result[i] = createExtensionPointAdapter(extensionPoints[i]);
- }
- return result;
- }
-
- public void added(IExtension[] extensions) {
- listener.addExtensions(createExtensionAdapters(extensions));
- }
-
- public void removed(IExtension[] extensions) {
- listener.removeExtensions(createExtensionAdapters(extensions));
- }
-
- public void added(IExtensionPoint[] extensionPoints) {
- listener.addExtensionPoints(createExtensionPointAdapters(extensionPoints));
- }
-
- public void removed(IExtensionPoint[] extensionPoints) {
- listener.removeExtensionPoints(createExtensionPointAdapters(extensionPoints));
- }
-
- public void setEnabled(long id, boolean enabled) {
- State state = PDERuntimePlugin.getDefault().getState();
- BundleDescription desc = state.getBundle(id);
-
- if (enabled) {
- DisabledInfo[] infos = state.getDisabledInfos(desc);
- for (int i = 0; i < infos.length; i++) {
- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- platformAdmin.removeDisabledInfo(infos[i]);
- }
- } else {
- DisabledInfo info = new DisabledInfo("org.eclipse.pde.ui", "Disabled via PDE", desc); //$NON-NLS-1$ //$NON-NLS-2$
- PlatformAdmin platformAdmin = PDERuntimePlugin.getDefault().getPlatformAdmin();
- platformAdmin.addDisabledInfo(info);
- }
-
- org.osgi.framework.Bundle b = PDERuntimePlugin.getDefault().getBundleContext().getBundle(id);
- PackageAdmin packageAdmin = PDERuntimePlugin.getDefault().getPackageAdmin();
- packageAdmin.refreshPackages(new org.osgi.framework.Bundle[] {b});
- }
-
- public void setBackendChangeListener(BackendChangeListener listener) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java
deleted file mode 100644
index 1a140eb..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeDelta.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-/**
- * Delta model objects are of type IBundle, IService, IExtension, IExtensionPoint
- */
-public class ModelChangeDelta {
-
- public static final int ADDED = 0;
- public static final int UPDATED = 1;
- public static final int REMOVED = 2;
- public static final int STARTING = 3;
- public static final int STARTED = 4;
- public static final int STOPPING = 5;
- public static final int STOPPED = 6;
- public static final int RESOLVED = 7;
- public static final int UNRESOLVED = 8;
-
- // TODO SWITCH from HEAVY ModelChangeDelta carrying whole object, to LIGHT delta - name, type (Bundle/Service/Ext/ExtPt), id
- private ModelObject fObject;
- private int fFlag;
-
- public ModelChangeDelta() {
- // empty
- }
-
- public ModelChangeDelta(ModelObject object, int flag) {
- fObject = object;
- fFlag = flag;
- }
-
- public ModelObject getModelObject() {
- return fObject;
- }
-
- public int getFlag() {
- return fFlag;
- }
-
- public void setModelObject(ModelObject fObject) {
- this.fObject = fObject;
- }
-
- public void setFlag(int flag) {
- this.fFlag = flag;
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeListener.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeListener.java
deleted file mode 100644
index b02cf81..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelChangeListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-/**
- * Event provides a list of objects that have changed.
- * Possible objects on the list are IBundle, IService, IExtension, IExtensionPoint.
- *
- * This is temporary solution and is subject to future changes.
- */
-public interface ModelChangeListener {
-
- void modelChanged(ModelChangeDelta[] deltas);
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java
deleted file mode 100644
index e54d9ef..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ModelObject.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import java.io.Serializable;
-
-public abstract class ModelObject implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Property.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Property.java
deleted file mode 100644
index 1527f1e..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/Property.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wolfgang Schell <ws@jetztgrad.net> - bug 260055
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class Property extends ModelObject implements Comparable {
-
- private static final long serialVersionUID = 1L;
- public static final String PREFIX_SERVICE = "service."; //$NON-NLS-1$
- public static final String PREFIX_COMPONENT = "component."; //$NON-NLS-1$
-
- private String name;
- private String value;
-
- public Property() {
- // empty
- }
-
- // TODO should we merge this with Attribute somehow?
- public Property(String name, String value) {
- this.name = name;
- this.value = value;
- }
-
- public String getValue() {
- return value;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
-
- /**
- * Compare properties for order. Returns a negative integer, zero, or a positive
- * integer as the first argument is less than, equal to, or greater than the second.
- *
- * <p>
- * The {@link Property}s are compared according to the following rules:
- * <ul>
- * <li>objectClass is always less than everything else</li>
- * <li>properties with names starting with "service." are considered "less"
- * than other properties.</li>
- * <li>regular properties are considered "more" than other properties</li>
- * </ul>
- * </p>
- *
- * <p>
- * When sorting an array of properties with the following code:
- *
- * <pre>
- * Property[] properties = ...;
- * Arrays.sort(properties, PropertyComparator.INSTANCE);
- * </pre>
- *
- * the result is something like this:
- * <ul>
- * <li>objectClass</li>
- * <li>service.id</li>
- * <li>service.id</li>
- * </ul>
- * </p>
- *
- * @param obj other property to be compared against
- *
- * @return a negative integer, zero, or a positive integer as the first
- * argument is less than, equal to, or greater than the second.
- */
- public int compareTo(Object obj) {
- if (!(obj instanceof Property)) {
- return 0;
- }
-
- Property other = (Property) obj;
-
- String name0 = getName();
- String name1 = other.getName();
-
- if ("objectClass".equals(name0)) { //$NON-NLS-1$
- return -1;
- }
-
- if ("objectClass".equals(name1)) { //$NON-NLS-1$
- return 1;
- }
-
- if (name0.startsWith(PREFIX_COMPONENT) && name1.startsWith(PREFIX_COMPONENT)) {
- // both are service properties
- // simply compare them
- return name0.compareTo(name1);
- }
-
- if (name0.startsWith(PREFIX_COMPONENT)) {
- return -1;
- }
-
- if (name1.startsWith(PREFIX_COMPONENT)) {
- return 1;
- }
-
- if (name0.startsWith(PREFIX_SERVICE) && name1.startsWith(PREFIX_SERVICE)) {
- // both are service properties
- // simply compare them
- return name0.compareTo(name1);
- }
-
- if (name0.startsWith(PREFIX_SERVICE)) {
- return -1;
- }
-
- if (name1.startsWith(PREFIX_SERVICE)) {
- return 1;
- }
-
- // simply compare strings
- return name0.compareTo(name1);
- }
-
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryBackend.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryBackend.java
deleted file mode 100644
index 2c225d9..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryBackend.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public interface RegistryBackend {
-
- public boolean connect(IProgressMonitor monitor);
-
- public void disconnect();
-
- public void setEnabled(long id, boolean enabled);
-
- public void start(long id);
-
- public void stop(long id);
-
- public String[] diagnose(long id);
-
- public void initializeBundles(IProgressMonitor monitor);
-
- public void initializeExtensionPoints(IProgressMonitor monitor);
-
- public void setRegistryListener(BackendChangeListener listener);
-
- public void initializeServices(IProgressMonitor monitor);
-
-}
\ No newline at end of file
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java
deleted file mode 100644
index f68568b..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/RegistryModel.java
+++ /dev/null
@@ -1,464 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import java.util.*;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.osgi.service.resolver.VersionRange;
-import org.osgi.framework.Version;
-
-/**
- * Model entry point for Eclipse runtime. Provides information about runtime bundles, services and extension points.
- */
-public class RegistryModel {
-
- private BackendChangeListener backendListener = new BackendChangeListener() {
- public void addBundle(Bundle adapter) {
- ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.ADDED);
-
- bundles.put(new Long(adapter.getId()), adapter);
-
- if (adapter.getFragmentHost() != null) {
- addFragment(adapter);
-
- Bundle host = getBundle(adapter.getFragmentHost(), adapter.getFragmentHostVersion());
- if (host != null) {
- ModelChangeDelta d2 = new ModelChangeDelta(host, ModelChangeDelta.UPDATED);
- fireModelChangeEvent(new ModelChangeDelta[] {delta, d2});
- return;
- }
- }
-
- fireModelChangeEvent(new ModelChangeDelta[] {delta});
- }
-
- public void removeBundle(Bundle adapter) {
- ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.REMOVED);
-
- bundles.remove(new Long(adapter.getId()));
-
- if (adapter.getFragmentHost() != null) {
- removeFragment(adapter);
-
- Bundle host = getBundle(adapter.getFragmentHost(), adapter.getFragmentHostVersion());
- if (host != null) {
- ModelChangeDelta d2 = new ModelChangeDelta(host, ModelChangeDelta.UPDATED);
- fireModelChangeEvent(new ModelChangeDelta[] {delta, d2});
- return;
- }
- }
-
- fireModelChangeEvent(new ModelChangeDelta[] {delta});
- }
-
- public void updateBundle(Bundle adapter, int updated) {
- ModelChangeDelta delta = new ModelChangeDelta(adapter, updated);
-
- bundles.put(new Long(adapter.getId()), adapter); // replace old with new one
-
- if (adapter.getFragmentHost() != null) {
- addFragment(adapter);
- }
-
- fireModelChangeEvent(new ModelChangeDelta[] {delta});
- }
-
- public void addService(ServiceRegistration adapter) {
- ModelChangeDelta serviceNameDelta = null;
- if (!serviceNames.contains(adapter.getName())) {
- ServiceName name = adapter.getName();
-
- serviceNames.add(name);
-
- serviceNameDelta = new ModelChangeDelta(name, ModelChangeDelta.ADDED);
- }
-
- services.put(new Long(adapter.getId()), adapter);
-
- ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.ADDED);
-
- if (serviceNameDelta != null) {
- fireModelChangeEvent(new ModelChangeDelta[] {serviceNameDelta, delta});
- } else {
- fireModelChangeEvent(new ModelChangeDelta[] {delta});
- }
- }
-
- public void removeService(ServiceRegistration adapter) {
- ModelChangeDelta serviceNameDelta = null;
- if (getServices(adapter.getName().getClasses()).length == 0) {
- serviceNames.remove(adapter.getName());
- serviceNameDelta = new ModelChangeDelta(adapter.getName(), ModelChangeDelta.REMOVED);
- }
-
- services.remove(new Long(adapter.getId()));
-
- ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.REMOVED);
-
- if (serviceNameDelta != null) {
- fireModelChangeEvent(new ModelChangeDelta[] {serviceNameDelta, delta});
- } else {
- fireModelChangeEvent(new ModelChangeDelta[] {delta});
- }
- }
-
- public void updateService(ServiceRegistration adapter) {
- services.put(new Long(adapter.getId()), adapter);
-
- ModelChangeDelta delta = new ModelChangeDelta(adapter, ModelChangeDelta.UPDATED);
-
- fireModelChangeEvent(new ModelChangeDelta[] {delta});
- }
-
- public void addExtensions(Extension[] extensionAdapters) {
- for (int i = 0; i < extensionAdapters.length; i++) {
- String id = extensionAdapters[i].getExtensionPointUniqueIdentifier();
- ExtensionPoint extPoint = (ExtensionPoint) extensionPoints.get(id);
- extPoint.getExtensions().add(extensionAdapters[i]);
- }
-
- ModelChangeDelta[] delta = new ModelChangeDelta[extensionAdapters.length];
- for (int i = 0; i < delta.length; i++) {
- delta[i] = new ModelChangeDelta(extensionAdapters[i], ModelChangeDelta.ADDED);
- }
- fireModelChangeEvent(delta);
- }
-
- public void removeExtensions(Extension[] extensionAdapters) {
- for (int i = 0; i < extensionAdapters.length; i++) {
- String id = extensionAdapters[i].getExtensionPointUniqueIdentifier();
- ExtensionPoint extPoint = (ExtensionPoint) extensionPoints.get(id);
- extPoint.getExtensions().remove(extensionAdapters[i]);
- }
-
- ModelChangeDelta[] delta = new ModelChangeDelta[extensionAdapters.length];
- for (int i = 0; i < delta.length; i++) {
- delta[i] = new ModelChangeDelta(extensionAdapters[i], ModelChangeDelta.REMOVED);
- }
- fireModelChangeEvent(delta);
- }
-
- public void addExtensionPoints(ExtensionPoint[] extensionPointAdapters) {
- for (int i = 0; i < extensionPointAdapters.length; i++) {
- extensionPoints.put(extensionPointAdapters[i].getUniqueIdentifier(), extensionPointAdapters[i]);
- }
-
- ModelChangeDelta[] delta = new ModelChangeDelta[extensionPointAdapters.length];
- for (int i = 0; i < delta.length; i++) {
- delta[i] = new ModelChangeDelta(extensionPointAdapters[i], ModelChangeDelta.ADDED);
- }
- fireModelChangeEvent(delta);
- }
-
- public void removeExtensionPoints(ExtensionPoint[] extensionPointAdapters) {
- for (int i = 0; i < extensionPointAdapters.length; i++) {
- extensionPoints.remove(extensionPointAdapters[i].getUniqueIdentifier());
- }
-
- ModelChangeDelta[] delta = new ModelChangeDelta[extensionPointAdapters.length];
- for (int i = 0; i < delta.length; i++) {
- delta[i] = new ModelChangeDelta(extensionPointAdapters[i], ModelChangeDelta.REMOVED);
- }
- fireModelChangeEvent(delta);
- }
- };
-
- private List listeners = new ArrayList();
- private Map bundles;
- private Map services;
- private Map extensionPoints;
- private Set serviceNames;
- private Map fragments;
-
- protected RegistryBackend backend;
-
- public RegistryModel(RegistryBackend backend) {
- bundles = Collections.synchronizedMap(new HashMap());
- services = Collections.synchronizedMap(new HashMap());
- extensionPoints = Collections.synchronizedMap(new HashMap());
- serviceNames = Collections.synchronizedSet(new HashSet());
- fragments = Collections.synchronizedMap(new HashMap());
-
- this.backend = backend;
- backend.setRegistryListener(backendListener);
- }
-
- public BackendChangeListener getBackendChangeListener() {
- return this.backendListener;
- }
-
- protected void addFragment(Bundle fragment) {
- Set hostFragments = (Set) fragments.get(fragment.getFragmentHost());
- if (hostFragments == null) {
- hostFragments = Collections.synchronizedSet(new HashSet());
- fragments.put(fragment.getFragmentHost(), hostFragments);
- }
-
- if (!hostFragments.add(fragment)) {
- // not added if element already exists. So remove old and add it again.
- hostFragments.remove(fragment);
- hostFragments.add(fragment);
- }
- }
-
- protected void removeFragment(Bundle fragment) {
- Set hostFragments = (Set) fragments.get(fragment.getFragmentHost());
- if (hostFragments == null) {
- return;
- }
-
- hostFragments.remove(fragment);
- }
-
- public boolean connect(IProgressMonitor monitor, boolean forceInit) {
- if (!backend.connect(monitor))
- return false;
-
- if (forceInit) {
- initialize(monitor);
- }
-
- return true;
- }
-
- public void initialize(IProgressMonitor monitor) {
- backend.initializeBundles(monitor);
- backend.initializeServices(monitor);
- backend.initializeExtensionPoints(monitor);
- }
-
- public void disconnect() {
- backend.disconnect();
- }
-
- public Bundle[] getBundles() {
- return (Bundle[]) bundles.values().toArray(new Bundle[bundles.values().size()]);
- }
-
- public ExtensionPoint[] getExtensionPoints() {
- return (ExtensionPoint[]) extensionPoints.values().toArray(new ExtensionPoint[extensionPoints.values().size()]);
- }
-
- public ServiceRegistration[] getServices() {
- return (ServiceRegistration[]) services.values().toArray(new ServiceRegistration[services.values().size()]);
- }
-
- public ServiceName[] getServiceNames() {
- return (ServiceName[]) serviceNames.toArray(new ServiceName[serviceNames.size()]);
- }
-
- public ServiceRegistration[] getServices(String[] classes) {
- List result = new ArrayList();
-
- for (Iterator i = services.values().iterator(); i.hasNext();) {
- ServiceRegistration sr = (ServiceRegistration) i.next();
- if (Arrays.equals(classes, sr.getName().getClasses()))
- result.add(sr);
- }
-
- return (ServiceRegistration[]) result.toArray(new ServiceRegistration[result.size()]);
- }
-
- public void addModelChangeListener(ModelChangeListener listener) {
- listeners.add(listener);
- }
-
- public void removeModelChangeListener(ModelChangeListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * For received domain types: Bundle, IExtension, IExtensionPoint, ServiceReference,
- * generates delta with model types: IBundle, IExtensionAdapter, IExtensionPointAdapter, IService
- *
- * @param objects
- */
- synchronized protected void fireModelChangeEvent(ModelChangeDelta[] delta) {
- for (Iterator i = listeners.iterator(); i.hasNext();) {
- ModelChangeListener listener = (ModelChangeListener) i.next();
- listener.modelChanged(delta);
- }
- }
-
- public Bundle getBundle(Long id) {
- return (Bundle) bundles.get(id);
- }
-
- public Bundle getBundle(String symbolicName, String versionRange) {
- for (Iterator i = bundles.values().iterator(); i.hasNext();) {
- Bundle bundle = (Bundle) i.next();
-
- if (bundle.getSymbolicName().equals(symbolicName)) {
- if (versionMatches(bundle.getVersion(), versionRange))
- return bundle;
- }
- }
-
- return null;
- }
-
- public ExtensionPoint getExtensionPoint(String extensionPointUniqueIdentifier) {
- return (ExtensionPoint) extensionPoints.get(extensionPointUniqueIdentifier);
- }
-
- public Bundle[] getFragments(Bundle bundle) {
- Set set = (Set) fragments.get(bundle.getSymbolicName());
- if (set == null)
- return new Bundle[0];
-
- List result = new ArrayList(set.size());
- Version hostVersion = Version.parseVersion(bundle.getVersion());
- for (Iterator i = set.iterator(); i.hasNext();) {
- Bundle fragment = (Bundle) i.next();
- String fragmentVersionOrRange = fragment.getFragmentHostVersion();
-
- if (versionMatches(hostVersion, fragmentVersionOrRange))
- result.add(fragment);
- }
-
- return (Bundle[]) result.toArray(new Bundle[result.size()]);
- }
-
- private boolean versionMatches(String hostVersion, String versionOrRange) {
- try {
- Version version = Version.parseVersion(hostVersion);
- return versionMatches(version, versionOrRange);
-
- } catch (IllegalArgumentException e) {
- // ignore
- }
-
- return false;
- }
-
- /**
- * Check if hostVersion is greater or equal fragmentVersion, or is included in fragment version range
- * @param hostVersion Version
- * @param versionOrRange Version or VersionRange
- * @return true if matches, false otherwise
- */
- private boolean versionMatches(Version hostVersion, String versionOrRange) {
- if (versionOrRange == null) {
- return true;
- }
-
- try {
- Version version = Version.parseVersion(versionOrRange);
- if (hostVersion.compareTo(version) >= 0)
- return true;
-
- } catch (IllegalArgumentException e) {
- // wrong formatting, try VersionRange
- }
-
- try {
- VersionRange range = new VersionRange(versionOrRange);
- if (range.isIncluded(hostVersion))
- return true;
-
- } catch (IllegalArgumentException e2) {
- // wrong range formatting
- }
-
- return false;
- }
-
- public ExtensionPoint[] getExtensionPoints(Bundle adapter) {
- ExtensionPoint[] extPoints = getExtensionPoints();
- List result = new ArrayList();
-
- for (int i = 0; i < extPoints.length; i++) {
- if (extPoints[i].getContributorId().longValue() == adapter.getId())
- result.add(extPoints[i]);
- }
- return (ExtensionPoint[]) result.toArray(new ExtensionPoint[result.size()]);
- }
-
- public Extension[] getExtensions(Bundle adapter) {
- ExtensionPoint[] extPoints = getExtensionPoints();
- List result = new ArrayList();
-
- for (int i = 0; i < extPoints.length; i++) {
- for (Iterator it = extPoints[i].getExtensions().iterator(); it.hasNext();) {
- Extension a = (Extension) it.next();
- if (a.getContributorId().longValue() == adapter.getId())
- result.add(a);
- }
-
- }
- return (Extension[]) result.toArray(new Extension[result.size()]);
- }
-
- public ServiceRegistration[] getRegisteredServices(Bundle adapter) {
- ServiceRegistration[] services = getServices();
- List result = new ArrayList();
-
- String symbolicName = adapter.getSymbolicName();
-
- for (int i = 0; i < services.length; i++) {
- if (symbolicName.equals(services[i].getBundle()))
- result.add(services[i]);
- }
- return (ServiceRegistration[]) result.toArray(new ServiceRegistration[result.size()]);
- }
-
- public ServiceRegistration[] getServicesInUse(Bundle adapter) {
- ServiceRegistration[] services = getServices();
- List result = new ArrayList();
-
- long id = adapter.getId();
-
- for (int i = 0; i < services.length; i++) {
- long[] usingBundles = services[i].getUsingBundleIds();
- if (usingBundles != null) {
- for (int j = 0; j < usingBundles.length; j++)
- if (id == usingBundles[j])
- result.add(services[i]);
- }
- }
- return (ServiceRegistration[]) result.toArray(new ServiceRegistration[result.size()]);
- }
-
- public void start(Bundle adapter) {
- backend.start(adapter.getId());
- }
-
- public void stop(Bundle adapter) {
- backend.stop(adapter.getId());
- }
-
- public void enable(Bundle adapter) {
- backend.setEnabled(adapter.getId(), true);
- }
-
- public void disable(Bundle adapter) {
- backend.setEnabled(adapter.getId(), false);
- }
-
- public String[] diagnose(Bundle adapter) {
- return backend.diagnose(adapter.getId());
- }
-
- public Bundle[] getUsingBundles(ServiceRegistration reg) {
- long[] usingBundles = reg.getUsingBundleIds();
- if (usingBundles.length == 0)
- return new Bundle[0];
-
- Set bundles = new HashSet();
- for (int i = 0; i < usingBundles.length; i++) {
- Bundle bundle = getBundle(new Long(usingBundles[i]));
- if (bundle != null)
- bundles.add(bundle);
- }
- return (Bundle[]) bundles.toArray(new Bundle[bundles.size()]);
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceName.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceName.java
deleted file mode 100644
index 99de270..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceName.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wolfgang Schell <ws@jetztgrad.net> - bug 260055
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-import java.util.Arrays;
-
-public class ServiceName extends ModelObject implements Comparable {
-
- private static final long serialVersionUID = 1L;
-
- private String[] classes;
-
- public ServiceName(String[] classes) {
- this.classes = classes;
- }
-
- public String[] getClasses() {
- return classes;
- }
-
- private static int hashCode(Object[] array) {
- int prime = 31;
- if (array == null)
- return 0;
- int result = 1;
- for (int index = 0; index < array.length; index++) {
- result = prime * result + (array[index] == null ? 0 : array[index].hashCode());
- }
- return result;
- }
-
- public int hashCode() {
- final int prime = 31;
- return prime * ServiceName.hashCode(classes);
- }
-
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (getClass() != obj.getClass())
- return false;
- ServiceName other = (ServiceName) obj;
- return Arrays.equals(classes, other.classes);
- }
-
- public int compareTo(Object obj) {
- if (obj instanceof ServiceName) {
- // compare first class
- ServiceName other = (ServiceName) obj;
- String myClass = classes[0];
- String otherClass = other.getClasses()[0];
-
- return myClass.compareTo(otherClass);
- }
- return 0;
-
- }
-}
diff --git a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java b/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java
deleted file mode 100644
index bc64991..0000000
--- a/osgimonitoring/plugins/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/model/ServiceRegistration.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Wolfgang Schell <ws@jetztgrad.net> - bug 259348, 260055
- * Wojciech Galanciak <wojciech.galanciak@gmail.com> - bug 282804
- *******************************************************************************/
-package org.eclipse.pde.internal.runtime.registry.model;
-
-public class ServiceRegistration extends ModelObject implements Comparable {
-
- private static final long serialVersionUID = 1L;
-
- private long id;
- private String bundle;
- private long[] usingBundles = new long[0];
- private ServiceName name;
- private Property[] properties = new Property[0];
-
- public void setId(long id) {
- this.id = id;
- }
-
- public void setBundle(String bundle) {
- this.bundle = bundle;
- }
-
- public void setUsingBundles(long[] usingBundles) {
- if (usingBundles == null)
- throw new IllegalArgumentException();
-
- this.usingBundles = usingBundles;
- }
-
- public void setName(ServiceName name) {
- if (name == null)
- throw new IllegalArgumentException();
-
- this.name = name;
- }
-
- public void setProperties(Property[] properties) {
- if (properties == null)
- throw new IllegalArgumentException();
-
- this.properties = properties;
- }
-
- public long getId() {
- return id;
- }
-
- public ServiceName getName() {
- return name;
- }
-
- public String getBundle() {
- return bundle;
- }
-
- public long[] getUsingBundleIds() {
- return usingBundles;
- }
-
- public Property[] getProperties() {
- return properties;
- }
-
- public Property getProperty(String name) {
- for (int p = 0; p < properties.length; p++) {
- Property property = properties[p];
- if (name.equals(property.getName())) {
- return property;
- }
- }
- return null;
- }
-
- public static String toString(Object value) {
- if (value == null) {
- return ""; //$NON-NLS-1$
- } else if (value instanceof CharSequence) {
- CharSequence charSequence = (CharSequence) value;
- return charSequence.toString();
- } else if (value instanceof Object[]) {
- StringBuffer buff = new StringBuffer();
- appendString(buff, value);
-
- return buff.toString();
- } else {
- return value.toString();
- }
- }
-
- public static void appendString(StringBuffer buff, Object value) {
- if (value == null) {
- // ignore
- } else if (value instanceof Object[]) {
- Object[] objects = (Object[]) value;
- buff.append("["); //$NON-NLS-1$
- for (int o = 0; o < objects.length; o++) {
- Object object = objects[o];
- if (o > 0)
- buff.append(", "); //$NON-NLS-1$
- appendString(buff, object);
- }
- buff.append("]"); //$NON-NLS-1$
- } else {
- buff.append(value.toString());
- }
- }
-
- public boolean equals(Object obj) {
- return (obj instanceof ServiceRegistration) && (id == (((ServiceRegistration) obj).id));
- }
-
- public int hashCode() {
- return (int) id;
- }
-
- public int compareTo(Object obj) {
- if (obj instanceof ServiceRegistration) {
- ServiceRegistration other = (ServiceRegistration) obj;
- return name.compareTo(other.getName());
- }
- return 0;
- }
-}