Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-03-10 10:56:22 -0500
committerGlyn Normington2011-03-10 10:56:22 -0500
commitf11456935bd0874b42ab91e8eac040715f99c67b (patch)
tree407332e0f635eb2a7e7a65c69e7335099a5199bf /org.eclipse.virgo.kernel.shell
parent07466eeb91a5164bfd9a91a3e8701201fb857f03 (diff)
downloadorg.eclipse.virgo.kernel-f11456935bd0874b42ab91e8eac040715f99c67b.tar.gz
org.eclipse.virgo.kernel-f11456935bd0874b42ab91e8eac040715f99c67b.tar.xz
org.eclipse.virgo.kernel-f11456935bd0874b42ab91e8eac040715f99c67b.zip
bug 337211 - improve workarounds
Diffstat (limited to 'org.eclipse.virgo.kernel.shell')
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java25
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/KernelRegionFauxQuasiLiveBundle.java194
-rw-r--r--org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardQuasiLiveBundle.java6
-rw-r--r--org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelperTests.java6
4 files changed, 19 insertions, 212 deletions
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java
index 827d3cda..b85a819f 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelper.java
@@ -176,23 +176,23 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
*/
public ArtifactAccessor getArtifact(String type, String name, String version) {
- //TODO work around until 337211 is done
- if("org.eclipse.virgo.kernel".equals(name)){
- Map<String, Object> attributes = new TreeMap<String, Object>();
- attributes.put(TYPE_ATTRIBUTE, "Region");
- attributes.put(NAME_ATTRIBUTE, name);
- attributes.put(VERSION_ATTRIBUTE, version);
- attributes.put(STATE_ATTRIBUTE, "-");
- attributes.put("atomic", false);
- attributes.put("scoped", false);
- return new StandardArtifactAccessor(attributes, new HashMap<String, String>(), new HashSet<ArtifactAccessorPointer>());
- }
-
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
try {
ObjectName objectName = new ObjectName(String.format(ARTIFACT_MBEAN_QUERY, type, name, version));
ArtifactAccessorPointer pointer = buildArtifactAccessorPointer(objectName);
+ //TODO work around until 337211 is done
+ if ("-".equals(pointer.getState())) {
+ Map<String, Object> attributes = new TreeMap<String, Object>();
+ attributes.put(TYPE_ATTRIBUTE, "Region");
+ attributes.put(NAME_ATTRIBUTE, name);
+ attributes.put(VERSION_ATTRIBUTE, version);
+ attributes.put(STATE_ATTRIBUTE, "-");
+ attributes.put("atomic", false);
+ attributes.put("scoped", false);
+ return new StandardArtifactAccessor(attributes, new HashMap<String, String>(), new HashSet<ArtifactAccessorPointer>());
+ }
+
if(pointer != null) {
Map<String, Object> attributes = new TreeMap<String, Object>();
attributes.put(TYPE_ATTRIBUTE, pointer.getType());
@@ -250,6 +250,7 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
try {
state = dependantArtifact.getState();
} catch (Exception e) {
+ e.printStackTrace();
state = "-";
}
} else {
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/KernelRegionFauxQuasiLiveBundle.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/KernelRegionFauxQuasiLiveBundle.java
deleted file mode 100644
index b753cbae..00000000
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/KernelRegionFauxQuasiLiveBundle.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 VMware Inc.
- * 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:
- * VMware Inc. - initial contribution
- *******************************************************************************/
-
-package org.eclipse.virgo.kernel.shell.state.internal;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.security.cert.X509Certificate;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.framework.Version;
-
-/**
- * <p>
- * KernelRegionFauxQuasiLiveBundle is a fake bundle that represents bundles not in the user region.
- * </p>
- *
- */
-public class KernelRegionFauxQuasiLiveBundle implements Bundle{
-
- private final long bundleId;
- private final Version version;
- private final String symbolicName;
-
- public KernelRegionFauxQuasiLiveBundle(long bundleId, Version version, String symbolicName) {
- this.bundleId = bundleId;
- this.version = version;
- this.symbolicName = symbolicName;
- }
-
- @Override
- public int compareTo(Bundle o) {
- return 0;
- }
-
- @Override
- public int getState() {
- return 0x00000020;
- }
-
- @Override
- public void start(int options) throws BundleException {
- // no-op
- }
-
- @Override
- public void start() throws BundleException {
- // no-op
- }
-
- @Override
- public void stop(int options) throws BundleException {
- // no-op
- }
-
- @Override
- public void stop() throws BundleException {
- // no-op
- }
-
- @Override
- public void update(InputStream input) throws BundleException {
- // no-op
- }
-
- @Override
- public void update() throws BundleException {
- // no-op
- }
-
- @Override
- public void uninstall() throws BundleException {
- // no-op
- }
-
- @Override
- public Dictionary<String, String> getHeaders() {
- return new Hashtable<String, String>();
- }
-
- @Override
- public long getBundleId() {
- return this.bundleId;
- }
-
- @Override
- public String getLocation() {
- return "Kernel Region";
- }
-
- @Override
- public ServiceReference<?>[] getRegisteredServices() {
- return new ServiceReference[0];
- }
-
- @Override
- public ServiceReference<?>[] getServicesInUse() {
- return new ServiceReference[0];
- }
-
- @Override
- public boolean hasPermission(Object permission) {
- return false;
- }
-
- @Override
- public URL getResource(String name) {
- return null;
- }
-
- @Override
- public Dictionary<String, String> getHeaders(String locale) {
- return new Hashtable<String, String>();
- }
-
- @Override
- public String getSymbolicName() {
- return this.symbolicName;
- }
-
- @Override
- public Class<?> loadClass(String name) throws ClassNotFoundException {
- throw new ClassNotFoundException("Kernel Region Bundle");
- }
-
- @Override
- public Enumeration<URL> getResources(String name) throws IOException {
- return null;
- }
-
- @Override
- public Enumeration<String> getEntryPaths(String path) {
- return null;
- }
-
- @Override
- public URL getEntry(String path) {
- return null;
- }
-
- @Override
- public long getLastModified() {
- return 0;
- }
-
- @Override
- public Enumeration<URL> findEntries(String path, String filePattern, boolean recurse) {
- return null;
- }
-
- @Override
- public BundleContext getBundleContext() {
- return null;
- }
-
- @Override
- public Map<X509Certificate, List<X509Certificate>> getSignerCertificates(int signersType) {
- return null;
- }
-
- @Override
- public Version getVersion() {
- return this.version;
- }
-
- @Override
- public <A> A adapt(Class<A> type) {
- return null;
- }
-
- @Override
- public File getDataFile(String filename) {
- return null;
- }
-
-}
diff --git a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardQuasiLiveBundle.java b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardQuasiLiveBundle.java
index 9a8b038a..c7bf5916 100644
--- a/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardQuasiLiveBundle.java
+++ b/org.eclipse.virgo.kernel.shell/src/main/java/org/eclipse/virgo/kernel/shell/state/internal/StandardQuasiLiveBundle.java
@@ -51,11 +51,7 @@ final class StandardQuasiLiveBundle implements QuasiLiveBundle {
public StandardQuasiLiveBundle(QuasiFramework quasiFramework, QuasiBundle quasiBundle, Bundle osgiBundle) {
this.quasiFramework = quasiFramework;
this.quasiBundle = quasiBundle;
- if(osgiBundle != null){
- this.osgiBundle = osgiBundle;
- } else {
- this.osgiBundle = new KernelRegionFauxQuasiLiveBundle(quasiBundle.getBundleId(), quasiBundle.getVersion(), quasiBundle.getSymbolicName());
- }
+ this.osgiBundle = osgiBundle;
}
/**
diff --git a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelperTests.java b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelperTests.java
index c9a19a21..8d76e533 100644
--- a/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelperTests.java
+++ b/org.eclipse.virgo.kernel.shell/src/test/java/org/eclipse/virgo/kernel/shell/model/helper/StandardRamAccessorHelperTests.java
@@ -194,7 +194,11 @@ public class StandardRamAccessorHelperTests {
@Test
public void testGetArtifactNotExist() {
ArtifactAccessor artifact = this.ramAccessorHelper.getArtifact(TYPE, NAME, VERSION);
- assertNull(artifact);
+ assertNotNull(artifact);
+ // This accommodates the workaround to bug 337211.
+ assertEquals("Region", artifact.getType());
+ assertEquals(NAME, artifact.getName());
+ assertEquals(VERSION, artifact.getVersion());
}
}

Back to the top