Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlyn Normington2011-04-03 14:01:05 -0400
committerGlyn Normington2011-04-03 14:01:05 -0400
commitc88237bf0136d59fe45f0d9cb83abf9bb5de5d25 (patch)
treeda80dd4f526f85917bd5de72fc8ac73affe43ba5 /org.eclipse.virgo.kernel.shell
parent7e6e9e51dc50671f5b6a47c1ee9b85b1e66c1055 (diff)
downloadorg.eclipse.virgo.kernel-c88237bf0136d59fe45f0d9cb83abf9bb5de5d25.tar.gz
org.eclipse.virgo.kernel-c88237bf0136d59fe45f0d9cb83abf9bb5de5d25.tar.xz
org.eclipse.virgo.kernel-c88237bf0136d59fe45f0d9cb83abf9bb5de5d25.zip
bug 337211: remove workaround
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.java93
1 files changed, 36 insertions, 57 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 b85a819f..e3cd2f17 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
@@ -13,7 +13,6 @@ package org.eclipse.virgo.kernel.shell.model.helper;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -29,11 +28,10 @@ import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
import javax.management.ReflectionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.eclipse.virgo.kernel.model.management.ManageableArtifact;
import org.eclipse.virgo.kernel.model.management.ManageableCompositeArtifact;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* <p>
@@ -57,7 +55,7 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
private static final String VERSION_ATTRIBUTE = "Version";
private static final String STATE_ATTRIBUTE = "state";
-
+
private static final String USER_INSTALLED = "user.installed";
private static final String OPERATION_SUCSESS = "%s operation returned successful";
@@ -68,29 +66,29 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
public StandardRamAccessorHelper() {
}
-
- /**
+
+ /**
* {@inheritDoc}
*/
public String start(String type, String name, String version) {
return performOperation(type, name, version, "start");
}
- /**
+ /**
* {@inheritDoc}
*/
public String stop(String type, String name, String version) {
return performOperation(type, name, version, "stop");
}
- /**
+ /**
* {@inheritDoc}
*/
public String uninstall(String type, String name, String version) {
return performOperation(type, name, version, "uninstall");
}
- /**
+ /**
* {@inheritDoc}
*/
public String refresh(String type, String name, String version) {
@@ -110,7 +108,7 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
}
}
- /**
+ /**
* {@inheritDoc}
*/
public List<String> getTypes() {
@@ -120,8 +118,8 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
Set<ObjectName> objectNames = mBeanServer.queryNames(new ObjectName("org.eclipse.virgo.kernel:type=Model,*"), null);
for (ObjectName objectName : objectNames) {
String type = objectName.getKeyProperty("artifact-type");
- if (!(type == null || types.contains(type))) {
- ManageableArtifact artifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
+ if (!(type == null || types.contains(type))) {
+ ManageableArtifact artifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
if (Boolean.valueOf(artifact.getProperties().get(USER_INSTALLED))) {
types.add(type);
}
@@ -133,14 +131,14 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
return types;
}
- /**
+ /**
* {@inheritDoc}
*/
public List<ArtifactAccessorPointer> getArtifactsOfType(String type) {
return getArtifactsOfType(type, true);
}
- /**
+ /**
* {@inheritDoc}
*/
public List<ArtifactAccessorPointer> getAllArtifactsOfType(String type) {
@@ -156,12 +154,12 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
for (ObjectName objectName : objectNames) {
ArtifactAccessorPointer pointer = buildArtifactAccessorPointer(objectName);
if (pointer != null) {
- ManageableArtifact artifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
- if(onlyUserInstalled) {
- if (!Boolean.valueOf(artifact.getProperties().get(USER_INSTALLED)) ) {
+ ManageableArtifact artifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
+ if (onlyUserInstalled) {
+ if (!Boolean.valueOf(artifact.getProperties().get(USER_INSTALLED))) {
continue;
- }
- }
+ }
+ }
artifacts.add(pointer);
}
}
@@ -171,36 +169,23 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
return artifacts;
}
- /**
+ /**
* {@inheritDoc}
*/
public ArtifactAccessor getArtifact(String type, String name, String version) {
-
+
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) {
+
+ if (pointer != null) {
Map<String, Object> attributes = new TreeMap<String, Object>();
attributes.put(TYPE_ATTRIBUTE, pointer.getType());
attributes.put(NAME_ATTRIBUTE, pointer.getName());
attributes.put(VERSION_ATTRIBUTE, pointer.getVersion());
- attributes.put(STATE_ATTRIBUTE, pointer.getState());
-
-
+ attributes.put(STATE_ATTRIBUTE, pointer.getState());
+
boolean scoped = false, atomic = false;
MBeanInfo info = mBeanServer.getMBeanInfo(objectName);
if (info.getDescriptor().getFieldValue("interfaceClassName").equals(ManageableCompositeArtifact.class.getName())) {
@@ -208,16 +193,16 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
scoped = compositeArtifact.isScoped();
atomic = compositeArtifact.isAtomic();
}
-
- attributes.put("atomic", atomic);
- attributes.put("scoped", scoped);
-
- ManageableArtifact artifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
-
- Set<ArtifactAccessorPointer> dependents = new HashSet<ArtifactAccessorPointer>();
+
+ attributes.put("atomic", atomic);
+ attributes.put("scoped", scoped);
+
+ ManageableArtifact artifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
+
+ Set<ArtifactAccessorPointer> dependents = new HashSet<ArtifactAccessorPointer>();
for (ObjectName dependentObjectName : artifact.getDependents()) {
ArtifactAccessorPointer dependentPointer = buildArtifactAccessorPointer(dependentObjectName);
- if(dependentPointer != null) {
+ if (dependentPointer != null) {
dependents.add(dependentPointer);
}
}
@@ -231,10 +216,10 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
LOGGER.warn("Unexpected error while trying to read the Runtime Artifact Model MBeans", e);
} catch (ReflectionException e) {
LOGGER.warn("Unexpected error while trying to read the Runtime Artifact Model MBeans", e);
- }
+ }
return null;
}
-
+
private ArtifactAccessorPointer buildArtifactAccessorPointer(ObjectName objectName) {
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ArtifactAccessorPointer result = null;
@@ -245,14 +230,8 @@ final public class StandardRamAccessorHelper implements RamAccessorHelper {
ManageableArtifact dependantArtifact = JMX.newMXBeanProxy(mBeanServer, objectName, ManageableArtifact.class);
String state;
- if(dependantArtifact != null){
- //TODO work around until 337211 is done
- try {
- state = dependantArtifact.getState();
- } catch (Exception e) {
- e.printStackTrace();
- state = "-";
- }
+ if (dependantArtifact != null) {
+ state = dependantArtifact.getState();
} else {
state = "-";
}

Back to the top