Mercurial > hg > release > thermostat-1.0
changeset 385:5383cde331c8
Only show the heap analysis tab for some vms
Reviewed-by: neugens
Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-June/001875.html
line wrap: on
line diff
--- a/client/core/src/main/java/com/redhat/thermostat/client/internal/UiFacadeFactory.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/core/src/main/java/com/redhat/thermostat/client/internal/UiFacadeFactory.java Mon Jun 18 18:37:00 2012 -0400 @@ -60,10 +60,13 @@ void addVmInformationService(VmInformationService vmInfoService); + void removeVmInformationService(VmInformationService vmInfoService); + Collection<VMContextAction> getVMContextActions(); void addVMContextAction(VMContextAction service); public void shutdown(); public void awaitShutdown() throws InterruptedException; + }
--- a/client/core/src/main/java/com/redhat/thermostat/client/internal/UiFacadeFactoryImpl.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/core/src/main/java/com/redhat/thermostat/client/internal/UiFacadeFactoryImpl.java Mon Jun 18 18:37:00 2012 -0400 @@ -100,6 +100,11 @@ } @Override + public void removeVmInformationService(VmInformationService vmInfoService) { + vmInformationServices.remove(vmInfoService); + } + + @Override public Collection<VMContextAction> getVMContextActions() { return contextAction; }
--- a/client/core/src/main/java/com/redhat/thermostat/client/internal/osgi/VmInformationServiceTracker.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/core/src/main/java/com/redhat/thermostat/client/internal/osgi/VmInformationServiceTracker.java Mon Jun 18 18:37:00 2012 -0400 @@ -58,8 +58,14 @@ @Override public Object addingService(ServiceReference reference) { - VmInformationService service = (VmInformationService) context.getService(reference); + VmInformationService service = (VmInformationService) super.addingService(reference); uiFacadeFactory.addVmInformationService(service); return service; } + + @Override + public void removedService(ServiceReference reference, Object service) { + uiFacadeFactory.removeVmInformationService((VmInformationService)service); + super.removedService(reference, service); + } }
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VmInformationService.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VmInformationService.java Mon Jun 18 18:37:00 2012 -0400 @@ -40,5 +40,7 @@ public interface VmInformationService { + boolean isApplicableFor(VmRef ref); + VmInformationServiceController getInformationServiceController(VmRef ref); }
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Mon Jun 18 18:37:00 2012 -0400 @@ -69,10 +69,12 @@ Collection<VmInformationService> vmInfoServices = uiFacadeFactory.getVmInformationServices(); for (VmInformationService vmInfoService : vmInfoServices) { - VmInformationServiceController ctrl = vmInfoService.getInformationServiceController(vmRef); - String name = ctrl.getLocalizedName(); - Component viewComp = ctrl.getComponent(); - view.addChildView(name, viewComp); + if (vmInfoService.isApplicableFor(vmRef)) { + VmInformationServiceController ctrl = vmInfoService.getInformationServiceController(vmRef); + String name = ctrl.getLocalizedName(); + Component viewComp = ctrl.getComponent(); + view.addChildView(name, viewComp); + } } }
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumpAction.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumpAction.java Mon Jun 18 18:37:00 2012 -0400 @@ -52,7 +52,7 @@ /** * Implements the {@link VMContextAction} entry point to provide a kill switch - * for the currently selected Virtual Machine. + * for the currently selected Virtual Machine. */ public class HeapDumpAction implements VMContextAction { @@ -79,7 +79,7 @@ @Override public void execute(VmRef reference) { ApplicationContext.getInstance().getViewFactory().setViewClass(HeapView.class, HeapSwingView.class); - context.registerService(VmInformationService.class.getName(), new HeapDumperService(), null); + context.registerService(VmInformationService.class.getName(), new HeapDumperService(reference), null); } @Override
--- a/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumperService.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/heapdumper/src/main/java/com/redhat/thermostat/client/heap/HeapDumperService.java Mon Jun 18 18:37:00 2012 -0400 @@ -42,8 +42,19 @@ public class HeapDumperService implements VmInformationService { + private VmRef vmRef; + + public HeapDumperService(VmRef reference) { + this.vmRef = reference; + } + @Override public VmInformationServiceController getInformationServiceController(VmRef ref) { return new HeapDumpController(ref); } + + @Override + public boolean isApplicableFor(VmRef ref) { + return vmRef.equals(ref); + } }
--- a/client/memory-stats-panel/src/main/java/com/redhat/thermostat/client/stats/memory/MemoryStatsService.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/memory-stats-panel/src/main/java/com/redhat/thermostat/client/stats/memory/MemoryStatsService.java Mon Jun 18 18:37:00 2012 -0400 @@ -46,4 +46,9 @@ public VmInformationServiceController getInformationServiceController(VmRef ref) { return new MemoryStatsController(ref); } + + @Override + public boolean isApplicableFor(VmRef ref) { + return true; + } }
--- a/client/vmclassstat/src/main/java/com/redhat/thermostat/client/vmclassstat/VmClassStatService.java Mon Jun 18 21:44:07 2012 +0200 +++ b/client/vmclassstat/src/main/java/com/redhat/thermostat/client/vmclassstat/VmClassStatService.java Mon Jun 18 18:37:00 2012 -0400 @@ -47,4 +47,9 @@ return new VmClassStatController(ref); } + @Override + public boolean isApplicableFor(VmRef ref) { + return true; + } + }