Mercurial > hg > release > thermostat-0.11
changeset 855:fac3b36775fc
Simplify client API and implementations by introducing generics to Filter and other related classes
review-thread: http://icedtea.classpath.org/pipermail/thermostat/2012-December/004712.html
reviewed-by: jerboaa, ebaron
line wrap: on
line diff
--- a/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/ServerHandler.java Thu Dec 13 12:12:19 2012 -0500 +++ b/agent/command/src/main/java/com/redhat/thermostat/agent/command/internal/ServerHandler.java Wed Dec 12 19:49:12 2012 -0500 @@ -54,7 +54,6 @@ import com.redhat.thermostat.agent.command.ReceiverRegistry; import com.redhat.thermostat.agent.command.RequestReceiver; import com.redhat.thermostat.common.command.Request; -import com.redhat.thermostat.common.command.Request.RequestType; import com.redhat.thermostat.common.command.Response; import com.redhat.thermostat.common.command.Response.ResponseType; import com.redhat.thermostat.common.utils.LoggingUtils; @@ -80,9 +79,9 @@ if (! authSucceeded) { response = new Response(ResponseType.AUTH_FAILED); } else { - logger.info("Request received: " + request.getType().toString()); - RequestReceiver receiver = receivers.getReceiver(request - .getReceiver()); + String receiverName = request.getReceiver(); + logger.info("Request received: " + request.getType().toString() + " for " + receiverName); + RequestReceiver receiver = receivers.getReceiver(receiverName); if (receiver != null) { response = receiver.receive(request); } else {
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/Filter.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/Filter.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,11 +36,12 @@ package com.redhat.thermostat.client.core; - /** * Marker interface for filters of information sources (VMs, Hosts, etc.) * */ -public interface Filter { +public interface Filter<T> { + + boolean matches(T toMatch); }
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/HostFilter.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.core; - -import com.redhat.thermostat.common.dao.HostRef; - -public interface HostFilter extends Filter { - - boolean matches(HostRef toMatch); - -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/HostInformationService.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.core; - -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; -import com.redhat.thermostat.common.dao.HostRef; - -public interface HostInformationService extends InformationService { - - public HostFilter getFilter(); - - public HostInformationServiceController getInformationServiceController(HostRef ref); -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/InformationService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/InformationService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,12 +36,15 @@ package com.redhat.thermostat.client.core; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; +import com.redhat.thermostat.common.dao.Ref; + /** * Marker interface for information services. * */ -public interface InformationService { +public interface InformationService<T extends Ref> { /** * Priority group for services that provide generic overview information @@ -91,6 +94,8 @@ */ public int getPriority(); - public Filter getFilter(); + public Filter<T> getFilter(); + + public InformationServiceController<T> getInformationServiceController(T ref); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/NameMatchingRefFilter.java Wed Dec 12 19:49:12 2012 -0500 @@ -0,0 +1,76 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.core; + +import java.util.Objects; + +import com.redhat.thermostat.common.dao.Ref; + +public class NameMatchingRefFilter<T extends Ref> implements Filter<T> { + + private String pattern; + + public NameMatchingRefFilter() { + this(null); + } + + public NameMatchingRefFilter(String pattern) { + setPattern(pattern); + } + + @Override + public boolean matches(T toMatch) { + if (pattern == null || pattern.isEmpty()) { + return true; + } else { + return matchesPattern(toMatch); + } + } + + public void setPattern(String pattern) { + this.pattern = pattern; + } + + public String getPattern() { + return pattern; + } + + protected boolean matchesPattern(Ref ref) { + Objects.requireNonNull(pattern); + return ref.getName().contains(pattern) || ref.getStringID().contains(pattern); + } +}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/VmFilter.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ -package com.redhat.thermostat.client.core; - -import com.redhat.thermostat.common.dao.VmRef; - -public interface VmFilter extends Filter { - - boolean matches(VmRef toMatch); - -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/VmInformationService.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.core; - -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.common.dao.VmRef; - -public interface VmInformationService extends InformationService { - - public VmFilter getFilter(); - - public VmInformationServiceController getInformationServiceController(VmRef ref); -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/controllers/HostInformationServiceController.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.core.controllers; - -/** - * Interface controller for controllers contributing controllers related to Hosts - * - */ -public interface HostInformationServiceController extends InformationServiceController { - -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/controllers/InformationServiceController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/controllers/InformationServiceController.java Wed Dec 12 19:49:12 2012 -0500 @@ -37,12 +37,13 @@ package com.redhat.thermostat.client.core.controllers; import com.redhat.thermostat.client.core.views.UIComponent; +import com.redhat.thermostat.common.dao.Ref; /** * Marker interface for service controllers (VMs, Hosts, etc.) * */ -public interface InformationServiceController { +public interface InformationServiceController<T extends Ref> { UIComponent getView(); String getLocalizedName();
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/controllers/VmInformationServiceController.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.core.controllers; - -/** - * Interface for contributing controllers related to VM-related views. - * - */ -public interface VmInformationServiceController extends InformationServiceController { -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/core/internal/InformationServiceComparator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/core/internal/InformationServiceComparator.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,6 +40,7 @@ import com.redhat.thermostat.client.core.InformationService; +@SuppressWarnings("rawtypes") public class InformationServiceComparator<T extends InformationService> implements Comparator<T> {
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/AlwaysMatchFilter.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.osgi.service; - -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.common.dao.VmRef; - -public class AlwaysMatchFilter implements VmFilter { - - @Override - public boolean matches(VmRef ref) { - return true; - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/DecoratorProvider.java Wed Dec 12 19:49:12 2012 -0500 @@ -0,0 +1,57 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.osgi.service; + +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.ui.Decorator; +import com.redhat.thermostat.common.dao.Ref; + +/** + * This interface allows plugins to install a custom {@link Decorator} into + * the Reference List view. + * + * <br /><br /> + * + * Active {@link Decorator}s are first queried against their filters + * and then installed into the view if the filter passes. + */ +public interface DecoratorProvider<T extends Ref> { + + Decorator getDecorator(); + Filter<T> getFilter(); + +}
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/HostDecorator.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.osgi.service; - -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.ui.Decorator; - -/** - * This interface allows plugins to install a custom {@link Decorator} into - * the Reference List view. - * - * <br /><br /> - * - * Active {@link HostDecorator}s are first queried against their filters - * and then installed into the view if the filter passes. - */ -public interface HostDecorator { - - Decorator getDecorator(); - HostFilter getFilter(); -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VMContextAction.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VMContextAction.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,7 +36,7 @@ package com.redhat.thermostat.client.osgi.service; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.dao.VmRef; /** @@ -46,5 +46,5 @@ void execute(VmRef referece); - VmFilter getFilter(); + Filter<VmRef> getFilter(); }
--- a/client/core/src/main/java/com/redhat/thermostat/client/osgi/service/VmDecorator.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.osgi.service; - -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.ui.Decorator; - -/** - * This interface allows plugins to install a custom {@link Decorator} into - * the Reference List view. - * - * <br /><br /> - * - * Active {@link VmDecorator}s are first queried against their filters - * and then installed into the view if the filter passes. - */ -public interface VmDecorator { - - Decorator getDecorator(); - VmFilter getFilter(); -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/HostInformationController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/HostInformationController.java Wed Dec 12 19:49:12 2012 -0500 @@ -39,8 +39,8 @@ import java.util.Collections; import java.util.List; -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.internal.InformationServiceComparator; import com.redhat.thermostat.client.core.views.BasicView; import com.redhat.thermostat.client.core.views.HostInformationView; @@ -54,11 +54,11 @@ public HostInformationController(UiFacadeFactory uiFacadeFactory, HostRef ref, HostInformationViewProvider provider) { view = provider.createView(); - List<HostInformationService> hostInfoServices = uiFacadeFactory.getHostInformationServices(); - Collections.sort(hostInfoServices, new InformationServiceComparator<HostInformationService>()); - for (HostInformationService hostInfoService : hostInfoServices) { + List<InformationService<HostRef>> hostInfoServices = uiFacadeFactory.getHostInformationServices(); + Collections.sort(hostInfoServices, new InformationServiceComparator<InformationService<HostRef>>()); + for (InformationService<HostRef> hostInfoService : hostInfoServices) { if (hostInfoService.getFilter().matches(ref)) { - HostInformationServiceController ctrl = hostInfoService.getInformationServiceController(ref); + InformationServiceController<HostRef> ctrl = hostInfoService.getInformationServiceController(ref); String name = ctrl.getLocalizedName(); view.addChildView(name, ctrl.getView()); }
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/HostVmFilter.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.ui; - -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.dao.Ref; -import com.redhat.thermostat.common.dao.VmRef; - -public class HostVmFilter implements HostFilter, VmFilter { - - private String filter; - - public HostVmFilter() { - } - - public void setFilter(String filter) { - this.filter = filter; - } - - @Override - public boolean matches(HostRef toMatch) { - return matchesRef(toMatch); - } - - @Override - public boolean matches(VmRef toMatch) { - return matchesRef(toMatch); - } - - public boolean matchesRef(Ref ref) { - if (filter == null || filter.isEmpty()) { - return true; - - } else { - return matchesRef(ref, filter); - } - } - - public boolean matchesRef(Ref ref, String filter) { - return ref.getName().contains(filter) || ref.getStringID().contains(filter); - } -}
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/UiFacadeFactory.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/UiFacadeFactory.java Wed Dec 12 19:49:12 2012 -0500 @@ -39,8 +39,7 @@ import java.util.Collection; import java.util.List; -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.client.osgi.service.VMContextAction; import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.common.dao.HostRef; @@ -59,19 +58,19 @@ public HostInformationController getHostController(HostRef ref); - List<HostInformationService> getHostInformationServices(); + List<InformationService<HostRef>> getHostInformationServices(); - void addHostInformationService(HostInformationService hostInfoService); + void addHostInformationService(InformationService<HostRef> hostInfoService); - void removeHostInformationService(HostInformationService hostInfoService); + void removeHostInformationService(InformationService<HostRef> hostInfoService); public VmInformationController getVmController(VmRef ref); - List<VmInformationService> getVmInformationServices(); + List<InformationService<VmRef>> getVmInformationServices(); - void addVmInformationService(VmInformationService vmInfoService); + void addVmInformationService(InformationService<VmRef> vmInfoService); - void removeVmInformationService(VmInformationService vmInfoService); + void removeVmInformationService(InformationService<VmRef> vmInfoService); Collection<VMContextAction> getVMContextActions(); void addVMContextAction(VMContextAction service);
--- a/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/main/java/com/redhat/thermostat/client/ui/VmInformationController.java Wed Dec 12 19:49:12 2012 -0500 @@ -39,8 +39,8 @@ import java.util.Collections; import java.util.List; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.internal.InformationServiceComparator; import com.redhat.thermostat.client.core.views.BasicView; import com.redhat.thermostat.client.core.views.VmInformationView; @@ -59,11 +59,11 @@ VmInformationController(OSGIUtils serviceProvider, UiFacadeFactory uiFacadeFactory, VmRef vmRef, VmInformationViewProvider provider) { view = provider.createView(); - List<VmInformationService> vmInfoServices = uiFacadeFactory.getVmInformationServices(); - Collections.sort(vmInfoServices, new InformationServiceComparator<VmInformationService>()); - for (VmInformationService vmInfoService : vmInfoServices) { + List<InformationService<VmRef>> vmInfoServices = uiFacadeFactory.getVmInformationServices(); + Collections.sort(vmInfoServices, new InformationServiceComparator<InformationService<VmRef>>()); + for (InformationService<VmRef> vmInfoService : vmInfoServices) { if (vmInfoService.getFilter().matches(vmRef)) { - VmInformationServiceController ctrl = vmInfoService.getInformationServiceController(vmRef); + InformationServiceController<VmRef> ctrl = vmInfoService.getInformationServiceController(vmRef); String name = ctrl.getLocalizedName(); view.addChildView(name, ctrl.getView()); }
--- a/client/core/src/test/java/com/redhat/thermostat/client/ui/HostInformationControllerTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/HostInformationControllerTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -47,22 +47,17 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.HostInformationView; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.common.dao.HostRef; public class HostInformationControllerTest { - private static final HostFilter FILTER = new HostFilter() { - - @Override - public boolean matches(HostRef toMatch) { - return true; - } - }; + private static final Filter<HostRef> FILTER = new NameMatchingRefFilter<>(); private UiFacadeFactory uiFacadeFactory; private HostRef ref; @@ -83,7 +78,7 @@ int[] priorities = { 45, 20, 0, 90, 53 }; // Mock services - List<HostInformationService> services = mockServices(priorities); + List<InformationService<HostRef>> services = mockServices(priorities); new HostInformationController(uiFacadeFactory, ref, provider); @@ -96,11 +91,11 @@ verifyService(services.get(3), order); } - private List<HostInformationService> mockServices(int[] priorities) { - List<HostInformationService> services = new ArrayList<>(); + private List<InformationService<HostRef>> mockServices(int[] priorities) { + List<InformationService<HostRef>> services = new ArrayList<>(); for (int priority : priorities) { - HostInformationService service = mock(HostInformationService.class); - HostInformationServiceController controller = mock(HostInformationServiceController.class); + InformationService<HostRef> service = mock(InformationService.class); + InformationServiceController<HostRef> controller = mock(InformationServiceController.class); when(service.getFilter()).thenReturn(FILTER); when(service.getInformationServiceController(ref)).thenReturn( controller); @@ -112,7 +107,7 @@ return services; } - private void verifyService(HostInformationService service, InOrder order) { + private void verifyService(InformationService<HostRef> service, InOrder order) { order.verify(service).getInformationServiceController(ref); }
--- a/client/core/src/test/java/com/redhat/thermostat/client/ui/HostVmFilterTest.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.ui; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.redhat.thermostat.client.ui.HostVmFilter; -import com.redhat.thermostat.common.dao.VmRef; - -public class HostVmFilterTest { - - private HostVmFilter filter; - - @Before - public void setUp() throws Exception { - filter = new HostVmFilter(); - } - - @After - public void tearDown() throws Exception { - filter = null; - } - - @Test - public void vmStringIDfilterMatches() { - VmRef ref = mock(VmRef.class); - when(ref.getStringID()).thenReturn("operation1"); - when(ref.getName()).thenReturn("noMatch"); - filter.setFilter("op"); - assertTrue(filter.matches(ref)); - } - - @Test - public void vmNamefilterMatches() { - VmRef ref = mock(VmRef.class); - when(ref.getName()).thenReturn("operation1"); - when(ref.getStringID()).thenReturn("noMatch"); - filter.setFilter("op"); - assertTrue(filter.matches(ref)); - } - - @Test - public void filterDoesntMatch() { - VmRef ref = mock(VmRef.class); - when(ref.getName()).thenReturn("test1"); - when(ref.getStringID()).thenReturn("test3"); - filter.setFilter("op"); - assertFalse(filter.matches(ref)); - } - - @Test - public void filterMatches() { - VmRef ref = mock(VmRef.class); - when(ref.getName()).thenReturn("test1"); - when(ref.getStringID()).thenReturn("test1"); - filter.setFilter("test1"); - assertTrue(filter.matches(ref)); - } - -}
--- a/client/core/src/test/java/com/redhat/thermostat/client/ui/VmInformationControllerTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/core/src/test/java/com/redhat/thermostat/client/ui/VmInformationControllerTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -47,22 +47,17 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.VmInformationView; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; import com.redhat.thermostat.common.dao.VmRef; public class VmInformationControllerTest { - private static final VmFilter FILTER = new VmFilter() { - - @Override - public boolean matches(VmRef toMatch) { - return true; - } - }; + private static final Filter<VmRef> FILTER = new NameMatchingRefFilter<>(); private UiFacadeFactory uiFacadeFactory; private VmRef ref; @@ -83,7 +78,7 @@ int[] priorities = { 45, 20, 0, 90, 53 }; // Mock services - List<VmInformationService> services = mockServices(priorities); + List<InformationService<VmRef>> services = mockServices(priorities); new VmInformationController(uiFacadeFactory, ref, provider); @@ -96,11 +91,11 @@ verifyService(services.get(3), order); } - private List<VmInformationService> mockServices(int[] priorities) { - List<VmInformationService> services = new ArrayList<>(); + private List<InformationService<VmRef>> mockServices(int[] priorities) { + List<InformationService<VmRef>> services = new ArrayList<>(); for (int priority : priorities) { - VmInformationService service = mock(VmInformationService.class); - VmInformationServiceController controller = mock(VmInformationServiceController.class); + InformationService<VmRef> service = mock(InformationService.class); + InformationServiceController<VmRef> controller = mock(InformationServiceController.class); when(service.getFilter()).thenReturn(FILTER); when(service.getInformationServiceController(ref)).thenReturn( controller); @@ -112,7 +107,7 @@ return services; } - private void verifyService(VmInformationService service, InOrder order) { + private void verifyService(InformationService<VmRef> service, InOrder order) { order.verify(service).getInformationServiceController(ref); }
--- a/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilter.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/LivingVMFilter.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,12 +36,12 @@ package com.redhat.thermostat.client.filter.vm.core; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.storage.model.VmInfo; -public class LivingVMFilter implements VmFilter { +public class LivingVMFilter implements Filter<VmRef> { volatile boolean filterActive = true;
--- a/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/living-vm-filter/core/src/main/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivator.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,6 +38,8 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -47,9 +49,11 @@ import org.osgi.framework.ServiceRegistration; import org.osgi.util.tracker.ServiceTracker; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.osgi.service.MenuAction; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.common.dao.VmRef; public class VMFilterActivator implements BundleActivator { @@ -74,7 +78,9 @@ registration = context.registerService(MenuAction.class.getName(), menu, null); registeredServices.add(registration); - registration = context.registerService(VmFilter.class.getName(), filter, null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + registration = context.registerService(Filter.class.getName(), filter, properties); registeredServices.add(registration); return super.addingService(reference);
--- a/client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/living-vm-filter/core/src/test/java/com/redhat/thermostat/client/filter/vm/core/VMFilterActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.test.StubBundleContext; @@ -62,7 +62,7 @@ activator.vmInfoDaoTracker.addingService(ref); assertTrue(ctx.isServiceRegistered(MenuAction.class.getName(), LivingVMFilterMenuAction.class)); - assertTrue(ctx.isServiceRegistered(VmFilter.class.getName(), LivingVMFilter.class)); + assertTrue(ctx.isServiceRegistered(Filter.class.getName(), LivingVMFilter.class)); } }
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/DeadVMDecorator.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,97 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.filter.vm.swing; - -import java.io.IOException; - -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.osgi.service.VmDecorator; -import com.redhat.thermostat.client.ui.Decorator; -import com.redhat.thermostat.client.ui.IconDescriptor; -import com.redhat.thermostat.common.dao.VmInfoDAO; -import com.redhat.thermostat.common.dao.VmRef; -import com.redhat.thermostat.storage.model.VmInfo; - -public class DeadVMDecorator implements VmDecorator { - - private class VMDecorator implements Decorator { - @Override - public IconDescriptor getIconDescriptor() { - try { - return IconDescriptor.createFromClassloader(getClass().getClassLoader(), "deadvm.png"); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - @Override - public String getLabel(String originalLabel) { - return "[not running] " + originalLabel; - } - - @Override - public Quadrant getQuadrant() { - return Quadrant.BOTTOM_LEFT; - } - } - - private VmFilter decoratorFilter; - private VMDecorator decorator; - - public DeadVMDecorator(final VmInfoDAO dao) { - decorator = new VMDecorator(); - decoratorFilter = new VmFilter() { - @Override - public boolean matches(VmRef vm) { - VmInfo vmInfo = dao.getVmInfo(vm); - - return !vmInfo.isAlive(); - } - }; - } - - @Override - public Decorator getDecorator() { - return decorator; - } - - @Override - public VmFilter getFilter() { - return decoratorFilter; - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/DeadVMDecoratorProvider.java Wed Dec 12 19:49:12 2012 -0500 @@ -0,0 +1,97 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.filter.vm.swing; + +import java.io.IOException; + +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; +import com.redhat.thermostat.client.ui.Decorator; +import com.redhat.thermostat.client.ui.IconDescriptor; +import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.storage.model.VmInfo; + +public class DeadVMDecoratorProvider implements DecoratorProvider<VmRef> { + + private class DeadVMDecorator implements Decorator { + @Override + public IconDescriptor getIconDescriptor() { + try { + return IconDescriptor.createFromClassloader(getClass().getClassLoader(), "deadvm.png"); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + @Override + public String getLabel(String originalLabel) { + return "[not running] " + originalLabel; + } + + @Override + public Quadrant getQuadrant() { + return Quadrant.BOTTOM_LEFT; + } + } + + private Filter<VmRef> decoratorFilter; + private DeadVMDecorator decorator; + + public DeadVMDecoratorProvider(final VmInfoDAO dao) { + decorator = new DeadVMDecorator(); + decoratorFilter = new Filter<VmRef>() { + @Override + public boolean matches(VmRef vm) { + VmInfo vmInfo = dao.getVmInfo(vm); + + return !vmInfo.isAlive(); + } + }; + } + + @Override + public Decorator getDecorator() { + return decorator; + } + + @Override + public Filter<VmRef> getFilter() { + return decoratorFilter; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/LivingVMDecoratorProvider.java Wed Dec 12 19:49:12 2012 -0500 @@ -0,0 +1,91 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.filter.vm.swing; + +import java.io.IOException; + +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.filter.vm.core.LivingVMFilter; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; +import com.redhat.thermostat.client.swing.IconResource; +import com.redhat.thermostat.client.ui.Decorator; +import com.redhat.thermostat.client.ui.IconDescriptor; +import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.common.dao.VmRef; + +public class LivingVMDecoratorProvider implements DecoratorProvider<VmRef> { + + private class LivingVMDecorator implements Decorator { + @Override + public IconDescriptor getIconDescriptor() { + try { + return IconDescriptor.createFromClassloader(IconResource.class.getClassLoader(), IconResource.JAVA_APPLICATION.getPath()); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + + @Override + public String getLabel(String originalLabel) { + return originalLabel; + } + + @Override + public Quadrant getQuadrant() { + return Quadrant.MAIN; + } + } + + private LivingVMFilter decoratorFilter; + private LivingVMDecorator decorator; + + public LivingVMDecoratorProvider(VmInfoDAO dao) { + decorator = new LivingVMDecorator(); + decoratorFilter = new LivingVMFilter(dao); + } + + @Override + public Decorator getDecorator() { + return decorator; + } + + @Override + public Filter<VmRef> getFilter() { + return decoratorFilter; + } +}
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMDecorator.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.filter.vm.swing; - -import java.io.IOException; - -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.filter.vm.core.LivingVMFilter; -import com.redhat.thermostat.client.osgi.service.VmDecorator; -import com.redhat.thermostat.client.swing.IconResource; -import com.redhat.thermostat.client.ui.Decorator; -import com.redhat.thermostat.client.ui.IconDescriptor; -import com.redhat.thermostat.common.dao.VmInfoDAO; - -public class VMDecorator implements VmDecorator { - - private class LivingVMDecorator implements Decorator { - @Override - public IconDescriptor getIconDescriptor() { - try { - return IconDescriptor.createFromClassloader(IconResource.class.getClassLoader(), IconResource.JAVA_APPLICATION.getPath()); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - @Override - public String getLabel(String originalLabel) { - return originalLabel; - } - - @Override - public Quadrant getQuadrant() { - return Quadrant.MAIN; - } - } - - private LivingVMFilter decoratorFilter; - private LivingVMDecorator decorator; - - public VMDecorator(VmInfoDAO dao) { - decorator = new LivingVMDecorator(); - decoratorFilter = new LivingVMFilter(dao); - } - - @Override - public Decorator getDecorator() { - return decorator; - } - - @Override - public VmFilter getFilter() { - return decoratorFilter; - } -}
--- a/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/living-vm-filter/swing/src/main/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivator.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,6 +38,8 @@ import java.util.ArrayList; import java.util.Collections; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Iterator; import java.util.List; @@ -47,8 +49,10 @@ import org.osgi.framework.ServiceRegistration; import org.osgi.util.tracker.ServiceTracker; -import com.redhat.thermostat.client.osgi.service.VmDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.common.dao.VmRef; public class VMFilterActivator implements BundleActivator { @@ -64,15 +68,18 @@ public Object addingService(ServiceReference reference) { VmInfoDAO dao = (VmInfoDAO) context.getService(reference); - VMDecorator decorator = new VMDecorator(dao); - DeadVMDecorator deadDecorator = new DeadVMDecorator(dao); + LivingVMDecoratorProvider decorator = new LivingVMDecoratorProvider(dao); + DeadVMDecoratorProvider deadDecorator = new DeadVMDecoratorProvider(dao); ServiceRegistration registration = null; + + Dictionary<String, String> decoratorProperties = new Hashtable<>(); + decoratorProperties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); - registration = context.registerService(VmDecorator.class.getName(), deadDecorator, null); + registration = context.registerService(DecoratorProvider.class.getName(), deadDecorator, decoratorProperties); registeredServices.add(registration); - registration = context.registerService(VmDecorator.class.getName(), decorator, null); + registration = context.registerService(DecoratorProvider.class.getName(), decorator, decoratorProperties); registeredServices.add(registration); return super.addingService(reference);
--- a/client/living-vm-filter/swing/src/test/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/living-vm-filter/swing/src/test/java/com/redhat/thermostat/client/filter/vm/swing/VMFilterActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -41,7 +41,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.osgi.service.VmDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.test.StubBundleContext; import com.redhat.thermostat.test.StubServiceReference; @@ -60,8 +60,8 @@ StubServiceReference ref = new StubServiceReference(reg.getInfo()); activator.vmInfoDaoTracker.addingService(ref); - assertTrue(ctx.isServiceRegistered(VmDecorator.class.getName(), VMDecorator.class)); - assertTrue(ctx.isServiceRegistered(VmDecorator.class.getName(), DeadVMDecorator.class)); + assertTrue(ctx.isServiceRegistered(DecoratorProvider.class.getName(), LivingVMDecoratorProvider.class)); + assertTrue(ctx.isServiceRegistered(DecoratorProvider.class.getName(), DeadVMDecoratorProvider.class)); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/MainWindow.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/MainWindow.java Wed Dec 12 19:49:12 2012 -0500 @@ -90,15 +90,13 @@ import sun.misc.Signal; -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.core.views.BasicView; import com.redhat.thermostat.client.core.views.SearchFieldView.SearchAction; import com.redhat.thermostat.client.locale.LocaleResources; -import com.redhat.thermostat.client.osgi.service.HostDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.client.osgi.service.VMContextAction; -import com.redhat.thermostat.client.osgi.service.VmDecorator; import com.redhat.thermostat.client.swing.components.EdtHelper; import com.redhat.thermostat.client.swing.components.HtmlTextBuilder; import com.redhat.thermostat.client.swing.components.StatusBar; @@ -134,16 +132,17 @@ private final DefaultTreeModel treeModel; private DefaultMutableTreeNode treeRoot; - private List<HostFilter> hostFilters; - private List<VmFilter> vmFilters; - private List<HostDecorator> hostDecorators; - private List<VmDecorator> vmDecorators; + private List<Filter<HostRef>> hostFilters; + private List<Filter<VmRef>> vmFilters; + private List<DecoratorProvider<HostRef>> hostDecorators; + private List<DecoratorProvider<VmRef>> vmDecorators; private HostsVMsLoader hostsVMsLoader; public BackgroundTreeModelWorker(DefaultTreeModel model, DefaultMutableTreeNode root, - List<HostFilter> hostFilters, List<VmFilter> vmFilters, - List<HostDecorator> hostDecorators, List<VmDecorator> vmDecorators, + List<Filter<HostRef>> hostFilters, List<Filter<VmRef>> vmFilters, + List<DecoratorProvider<HostRef>> hostDecorators, + List<DecoratorProvider<VmRef>> vmDecorators, HostsVMsLoader hostsVMsLoader, JTree tree) { this.hostFilters = hostFilters; @@ -178,7 +177,7 @@ shouldInsert = true; } else { shouldInsert = true; - for (HostFilter filter : hostFilters) { + for (Filter<HostRef> filter : hostFilters) { if (!filter.matches(inRemoteModel)) { shouldInsert = false; break; @@ -193,8 +192,8 @@ } if (shouldInsert) { - for (HostDecorator decorator : hostDecorators) { - HostFilter filter = decorator.getFilter(); + for (DecoratorProvider<HostRef> decorator : hostDecorators) { + Filter<HostRef> filter = decorator.getFilter(); if (filter != null && filter.matches(inRemoteModel)) { inTreeNode.addDecorator(decorator.getDecorator()); } @@ -219,7 +218,7 @@ shouldInsert = true; } else { shouldInsert = true; - for (VmFilter filter : vmFilters) { + for (Filter<VmRef> filter : vmFilters) { if (!filter.matches(inRemoteModel)) { shouldInsert = false; break; @@ -228,8 +227,8 @@ } if (shouldInsert) { - for (VmDecorator decorator : vmDecorators) { - VmFilter filter = decorator.getFilter(); + for (DecoratorProvider<VmRef> decorator : vmDecorators) { + Filter<VmRef> filter = decorator.getFilter(); if (filter != null && filter.matches(inRemoteModel)) { inTreeNode.addDecorator(decorator.getDecorator()); } @@ -700,8 +699,9 @@ } @Override - public void updateTree(List<HostFilter> hostFilters, List<VmFilter> vmFilters, - List<HostDecorator> hostDecorators, List<VmDecorator> vmDecorators, + public void updateTree(List<Filter<HostRef>> hostFilters, List<Filter<VmRef>> vmFilters, + List<DecoratorProvider<HostRef>> hostDecorators, + List<DecoratorProvider<VmRef>> vmDecorators, HostsVMsLoader hostsVMsLoader) { BackgroundTreeModelWorker worker =
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostFilterRegistry.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostFilterRegistry.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,14 +40,18 @@ import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; -import com.redhat.thermostat.client.core.HostFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.ThermostatExtensionRegistry; +import com.redhat.thermostat.common.dao.HostRef; -class HostFilterRegistry extends ThermostatExtensionRegistry<HostFilter> { +class HostFilterRegistry extends ThermostatExtensionRegistry<Filter> { - private static final String FILTER = "(" + Constants.OBJECTCLASS + "=" + HostFilter.class.getName() + ")"; + private static final String FILTER = "(&(" + Constants.OBJECTCLASS + "=" + + Filter.class.getName() + ")&(" + + com.redhat.thermostat.common.Constants.GENERIC_SERVICE_CLASSNAME + "=" + + HostRef.class.getName() + "))"; public HostFilterRegistry(BundleContext context) throws InvalidSyntaxException { - super(context, FILTER, HostFilter.class); + super(context, FILTER, Filter.class); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostIconDecorator.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.swing.internal; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; - -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.osgi.service.HostDecorator; -import com.redhat.thermostat.client.swing.IconResource; -import com.redhat.thermostat.client.ui.Decorator; -import com.redhat.thermostat.client.ui.IconDescriptor; -import com.redhat.thermostat.common.dao.HostRef; -import com.redhat.thermostat.common.utils.StreamUtils; - -public class HostIconDecorator implements HostDecorator { - - private final HostFilter anyHost = new AnyHostMatcher(); - - @Override - public Decorator getDecorator() { - return new IconDecorator(); - } - - @Override - public HostFilter getFilter() { - return anyHost; - } - - private static class IconDecorator implements Decorator { - - private final IconDescriptor icon; - - public IconDecorator() { - IconDescriptor icon = null; - try { - InputStream in = new FileInputStream(IconResource.HOST.getPath()); - icon = new IconDescriptor(ByteBuffer.wrap(StreamUtils.readAll(in))); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - this.icon = icon; - } - - @Override - public String getLabel(String originalLabel) { - return originalLabel; - } - - @Override - public IconDescriptor getIconDescriptor() { - return icon; - } - - @Override - public Quadrant getQuadrant() { - return Quadrant.MAIN; - } - - } - - private static class AnyHostMatcher implements HostFilter { - @Override - public boolean matches(HostRef toMatch) { - return true; - } - } - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProvider.java Wed Dec 12 19:49:12 2012 -0500 @@ -0,0 +1,99 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.swing.internal; + +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.ByteBuffer; + +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; +import com.redhat.thermostat.client.swing.IconResource; +import com.redhat.thermostat.client.ui.Decorator; +import com.redhat.thermostat.client.ui.IconDescriptor; +import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.common.utils.StreamUtils; + +public class HostIconDecoratorProvider implements DecoratorProvider<HostRef> { + + private final Filter<HostRef> anyHost = new NameMatchingRefFilter<HostRef>(); + + @Override + public Decorator getDecorator() { + return new IconDecorator(); + } + + @Override + public Filter<HostRef> getFilter() { + return anyHost; + } + + private static class IconDecorator implements Decorator { + + private final IconDescriptor icon; + + public IconDecorator() { + IconDescriptor icon = null; + try { + InputStream in = new FileInputStream(IconResource.HOST.getPath()); + icon = new IconDescriptor(ByteBuffer.wrap(StreamUtils.readAll(in))); + } catch (IOException ioe) { + ioe.printStackTrace(); + } + this.icon = icon; + } + + @Override + public String getLabel(String originalLabel) { + return originalLabel; + } + + @Override + public IconDescriptor getIconDescriptor() { + return icon; + } + + @Override + public Quadrant getQuadrant() { + return Quadrant.MAIN; + } + + } + +}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostTreeDecoratorRegistry.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/HostTreeDecoratorRegistry.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,14 +40,19 @@ import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; -import com.redhat.thermostat.client.osgi.service.HostDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.common.ThermostatExtensionRegistry; +import com.redhat.thermostat.common.dao.HostRef; -class HostTreeDecoratorRegistry extends ThermostatExtensionRegistry<HostDecorator> { +@SuppressWarnings("rawtypes") +class HostTreeDecoratorRegistry extends ThermostatExtensionRegistry<DecoratorProvider> { - private static final String FILTER = "(" + Constants.OBJECTCLASS + "=" + HostDecorator.class.getName() + ")"; + private static final String FILTER = "(&(" + Constants.OBJECTCLASS + "=" + + DecoratorProvider.class.getName() + ")&(" + + com.redhat.thermostat.common.Constants.GENERIC_SERVICE_CLASSNAME + "=" + + HostRef.class.getName() + "))"; public HostTreeDecoratorRegistry(BundleContext context) throws InvalidSyntaxException { - super(context, FILTER, HostDecorator.class); + super(context, FILTER, DecoratorProvider.class); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainView.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainView.java Wed Dec 12 19:49:12 2012 -0500 @@ -41,16 +41,16 @@ import javax.swing.JFrame; -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.core.views.BasicView; -import com.redhat.thermostat.client.osgi.service.HostDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.client.osgi.service.VMContextAction; -import com.redhat.thermostat.client.osgi.service.VmDecorator; import com.redhat.thermostat.common.ActionListener; import com.redhat.thermostat.common.HostsVMsLoader; +import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.Ref; +import com.redhat.thermostat.common.dao.VmRef; public interface MainView { @@ -70,8 +70,8 @@ void addActionListener(ActionListener<Action> capture); - void updateTree(List<HostFilter> hostFilters, List<VmFilter> vmFilters, - List<HostDecorator> hostDecorators, List<VmDecorator> vmDecorators, + void updateTree(List<Filter<HostRef>> hostFilters, List<Filter<VmRef>> vmFilters, + List<DecoratorProvider<HostRef>> hostDecorators, List<DecoratorProvider<VmRef>> vmDecorators, HostsVMsLoader any); String getHostVmTreeFilterText();
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImpl.java Wed Dec 12 19:49:12 2012 -0500 @@ -48,22 +48,20 @@ import org.osgi.framework.InvalidSyntaxException; -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.client.core.views.AgentInformationDisplayView; import com.redhat.thermostat.client.core.views.AgentInformationViewProvider; import com.redhat.thermostat.client.core.views.ClientConfigViewProvider; import com.redhat.thermostat.client.core.views.ClientConfigurationView; -import com.redhat.thermostat.client.osgi.service.HostDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.client.osgi.service.VMContextAction; -import com.redhat.thermostat.client.osgi.service.VmDecorator; import com.redhat.thermostat.client.swing.internal.MainView.Action; import com.redhat.thermostat.client.ui.AgentInformationDisplayController; import com.redhat.thermostat.client.ui.AgentInformationDisplayModel; import com.redhat.thermostat.client.ui.ClientConfigurationController; import com.redhat.thermostat.client.ui.HostInformationController; -import com.redhat.thermostat.client.ui.HostVmFilter; import com.redhat.thermostat.client.ui.MainWindowController; import com.redhat.thermostat.client.ui.SummaryController; import com.redhat.thermostat.client.ui.UiFacadeFactory; @@ -91,11 +89,11 @@ private static final Logger logger = LoggingUtils.getLogger(MainWindowControllerImpl.class); - private final CopyOnWriteArrayList<HostFilter> hostFilters = new CopyOnWriteArrayList<>(); - private final CopyOnWriteArrayList<VmFilter> vmFilters = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList<Filter<HostRef>> hostFilters = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList<Filter<VmRef>> vmFilters = new CopyOnWriteArrayList<>(); - private final CopyOnWriteArrayList<HostDecorator> hostTreeDecorators = new CopyOnWriteArrayList<>(); - private final CopyOnWriteArrayList<VmDecorator> vmTreeDecorators = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList<DecoratorProvider<HostRef>> hostTreeDecorators = new CopyOnWriteArrayList<>(); + private final CopyOnWriteArrayList<DecoratorProvider<VmRef>> vmTreeDecorators = new CopyOnWriteArrayList<>(); private ApplicationService appSvc; private Timer backgroundUpdater; @@ -135,18 +133,19 @@ } }; - private HostVmFilter searchFilter; + private NameMatchingRefFilter<HostRef> hostFilter; + private NameMatchingRefFilter<VmRef> vmFilter; private VmFilterRegistry vmFilterRegistry; private HostFilterRegistry hostFilterRegistry; - private ActionListener<ThermostatExtensionRegistry.Action> hostFilterListener = new UpdateListAndTree<>(HostFilter.class, hostFilters); - private ActionListener<ThermostatExtensionRegistry.Action> vmFilterListener = new UpdateListAndTree<>(VmFilter.class, vmFilters); + private ActionListener<ThermostatExtensionRegistry.Action> hostFilterListener = new FilterExtensionListener<HostRef>(hostFilters); + private ActionListener<ThermostatExtensionRegistry.Action> vmFilterListener = new FilterExtensionListener<VmRef>(vmFilters); private HostTreeDecoratorRegistry hostDecoratorRegistry; private VMTreeDecoratorRegistry vmDecoratorRegistry; - private ActionListener<ThermostatExtensionRegistry.Action> hostDecoratorListener = new UpdateListAndTree<>(HostDecorator.class, hostTreeDecorators); - private ActionListener<ThermostatExtensionRegistry.Action> vmDecoratorListener = new UpdateListAndTree<>(VmDecorator.class, vmTreeDecorators); + private ActionListener<ThermostatExtensionRegistry.Action> hostDecoratorListener = new DecoratorProviderExtensionListener<HostRef>(hostTreeDecorators); + private ActionListener<ThermostatExtensionRegistry.Action> vmDecoratorListener = new DecoratorProviderExtensionListener<VmRef>(vmTreeDecorators); private VMInformationRegistry vmInfoRegistry; private ActionListener<ThermostatExtensionRegistry.Action> vmInfoRegistryListener = @@ -178,9 +177,11 @@ throw new RuntimeException(e); } - searchFilter = new HostVmFilter(); - hostFilters.add(searchFilter); - vmFilters.add(searchFilter); + hostFilter = new NameMatchingRefFilter<>(); + vmFilter = new NameMatchingRefFilter<>(); + + hostFilters.add(hostFilter); + vmFilters.add(vmFilter); this.facadeFactory = facadeFactory; @@ -200,17 +201,23 @@ installListenersAndStartRegistries(); } - /** + /* * This method is for testing purposes only */ - HostVmFilter getSearchFilter() { - return searchFilter; + Filter<HostRef> getHostFilter() { + return hostFilter; + } + /* + * This also is for testing purposes. + */ + Filter<VmRef> getVmFilter() { + return vmFilter; } /** * This method is for testing purposes only */ - List<VmDecorator> getVmTreeDecorators() { + List<DecoratorProvider<VmRef>> getVmTreeDecorators() { return vmTreeDecorators; } @@ -245,7 +252,8 @@ @Override public void setHostVmTreeFilter(String filter) { - this.searchFilter.setFilter(filter); + this.hostFilter.setPattern(filter); + this.vmFilter.setPattern(filter); doUpdateTreeAsync(); } @@ -447,26 +455,28 @@ } } - private class UpdateListAndTree<T> implements ActionListener<ThermostatExtensionRegistry.Action> { + private class FilterExtensionListener<T> implements ActionListener<ThermostatExtensionRegistry.Action> { - private final Class<T> extensionClass; - private final CopyOnWriteArrayList<T> extensionList; + private final CopyOnWriteArrayList<Filter<T>> extensionList; - public UpdateListAndTree(Class<T> extensionClass, CopyOnWriteArrayList<T> addRemoveExtensionsFrom) { - this.extensionClass = extensionClass; + public FilterExtensionListener(CopyOnWriteArrayList<Filter<T>> addRemoveExtensionsFrom) { this.extensionList = addRemoveExtensionsFrom; } @SuppressWarnings("unchecked") @Override - public void actionPerformed(ActionEvent<com.redhat.thermostat.common.ThermostatExtensionRegistry.Action> actionEvent) { + public void actionPerformed(ActionEvent<ThermostatExtensionRegistry.Action> actionEvent) { Object payload = actionEvent.getPayload(); - if (!extensionClass.isInstance(payload)) { - throw new IllegalArgumentException("unexpected payload type. expected a " + extensionClass.getName() + " but got " + payload.getClass().getName()); + Filter<T> filter = null; + + try { + filter = (Filter<T>) payload; + } catch (ClassCastException cce) { + throw new IllegalArgumentException("unexpected payload type. " + + payload.getClass().getName() + " not allowed here.", cce); } - - T filter = (T) payload; + switch (actionEvent.getActionId()) { case SERVICE_ADDED: @@ -487,6 +497,47 @@ } } + private class DecoratorProviderExtensionListener<T extends Ref> implements ActionListener<ThermostatExtensionRegistry.Action> { + + private final CopyOnWriteArrayList<DecoratorProvider<T>> extensionList; + + public DecoratorProviderExtensionListener(CopyOnWriteArrayList<DecoratorProvider<T>> addRemoveExtensionsFrom) { + this.extensionList = addRemoveExtensionsFrom; + } + + @SuppressWarnings("unchecked") + @Override + public void actionPerformed(ActionEvent<com.redhat.thermostat.common.ThermostatExtensionRegistry.Action> actionEvent) { + + Object payload = actionEvent.getPayload(); + DecoratorProvider<T> decorator = null; + + try { + decorator = (DecoratorProvider<T>) payload; + } catch (ClassCastException cce) { + throw new IllegalArgumentException("unexpected payload type. " + payload.getClass().getName() + "not allowed here.", cce); + } + + + switch (actionEvent.getActionId()) { + case SERVICE_ADDED: + extensionList.add(decorator); + doUpdateTreeAsync(); + break; + + case SERVICE_REMOVED: + extensionList.remove(decorator); + doUpdateTreeAsync(); + break; + + default: + logger.log(Level.WARNING, "received unknown event from ExtensionRegistry: " + + actionEvent.getActionId()); + break; + } + } + } + private class VmInformationControllerProvider { private VmInformationController lastSelectedVM; private Map<VmRef, Integer> selectedForVM = new ConcurrentHashMap<>();
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/UiFacadeFactoryImpl.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,8 +43,7 @@ import org.osgi.framework.BundleContext; -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.client.core.views.SummaryViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; @@ -66,8 +65,8 @@ private CountDownLatch shutdown = new CountDownLatch(1); - private List<HostInformationService> hostInformationServices = new ArrayList<>(); - private List<VmInformationService> vmInformationServices = new ArrayList<>(); + private List<InformationService<HostRef>> hostInformationServices = new ArrayList<>(); + private List<InformationService<VmRef>> vmInformationServices = new ArrayList<>(); private Collection<VMContextAction> contextAction = new ArrayList<>(); private BundleContext context; @@ -123,17 +122,17 @@ } @Override - public List<VmInformationService> getVmInformationServices() { + public List<InformationService<VmRef>> getVmInformationServices() { return vmInformationServices; } @Override - public void addVmInformationService(VmInformationService vmInfoService) { + public void addVmInformationService(InformationService<VmRef> vmInfoService) { vmInformationServices.add(vmInfoService); } @Override - public void removeVmInformationService(VmInformationService vmInfoService) { + public void removeVmInformationService(InformationService<VmRef> vmInfoService) { vmInformationServices.remove(vmInfoService); } @@ -164,17 +163,17 @@ } @Override - public List<HostInformationService> getHostInformationServices() { + public List<InformationService<HostRef>> getHostInformationServices() { return hostInformationServices; } @Override - public void addHostInformationService(HostInformationService hostInfoService) { + public void addHostInformationService(InformationService<HostRef> hostInfoService) { hostInformationServices.add(hostInfoService); } @Override - public void removeHostInformationService(HostInformationService hostInfoService) { + public void removeHostInformationService(InformationService<HostRef> hostInfoService) { hostInformationServices.remove(hostInfoService); }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMInformationRegistry.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMInformationRegistry.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,14 +40,19 @@ import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ThermostatExtensionRegistry; +import com.redhat.thermostat.common.dao.VmRef; -class VMInformationRegistry extends ThermostatExtensionRegistry<VmInformationService> { +@SuppressWarnings("rawtypes") +class VMInformationRegistry extends ThermostatExtensionRegistry<InformationService> { - private static final String FILTER = "(&(" + Constants.OBJECTCLASS + "=" + VmInformationService.class.getName() + "))"; + private static final String FILTER = "(&(" + Constants.OBJECTCLASS + "=" + + InformationService.class.getName() + ")&(" + + com.redhat.thermostat.common.Constants.GENERIC_SERVICE_CLASSNAME + "=" + + VmRef.class.getName() + "))"; public VMInformationRegistry(BundleContext context) throws InvalidSyntaxException { - super(context, FILTER, VmInformationService.class); + super(context, FILTER, InformationService.class); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMTreeDecoratorRegistry.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VMTreeDecoratorRegistry.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,14 +40,19 @@ import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; -import com.redhat.thermostat.client.osgi.service.VmDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.common.ThermostatExtensionRegistry; +import com.redhat.thermostat.common.dao.VmRef; -class VMTreeDecoratorRegistry extends ThermostatExtensionRegistry<VmDecorator> { +@SuppressWarnings("rawtypes") +class VMTreeDecoratorRegistry extends ThermostatExtensionRegistry<DecoratorProvider> { - private static final String FILTER = "(" + Constants.OBJECTCLASS + "=" + VmDecorator.class.getName() + ")"; - + private static final String FILTER = "(&(" + Constants.OBJECTCLASS + "=" + + DecoratorProvider.class.getName() + ")&(" + + com.redhat.thermostat.common.Constants.GENERIC_SERVICE_CLASSNAME + "=" + + VmRef.class.getName() + "))"; + public VMTreeDecoratorRegistry(BundleContext context) throws InvalidSyntaxException { - super(context, FILTER, VmDecorator.class); + super(context, FILTER, DecoratorProvider.class); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VmFilterRegistry.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/VmFilterRegistry.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,14 +40,18 @@ import org.osgi.framework.Constants; import org.osgi.framework.InvalidSyntaxException; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.ThermostatExtensionRegistry; +import com.redhat.thermostat.common.dao.VmRef; -class VmFilterRegistry extends ThermostatExtensionRegistry<VmFilter> { +class VmFilterRegistry extends ThermostatExtensionRegistry<Filter> { - private static final String FILTER = "(" + Constants.OBJECTCLASS + "=" + VmFilter.class.getName() + ")"; + private static final String FILTER = "(&(" + Constants.OBJECTCLASS + "=" + + Filter.class.getName() + ")&(" + + com.redhat.thermostat.common.Constants.GENERIC_SERVICE_CLASSNAME + "=" + + VmRef.class.getName() + "))"; public VmFilterRegistry(BundleContext context) throws InvalidSyntaxException { - super(context, FILTER, VmFilter.class); + super(context, FILTER, Filter.class); } }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/HostInformationServiceTracker.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.swing.internal.osgi; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.ui.UiFacadeFactory; - -class HostInformationServiceTracker extends ServiceTracker { - - private UiFacadeFactory uiFacadeFactory; - - private BundleContext context; - - HostInformationServiceTracker(BundleContext context, UiFacadeFactory uiFacadeFactory) { - super(context, HostInformationService.class.getName(), null); - this.context = context; - this.uiFacadeFactory = uiFacadeFactory; - } - - @Override - public Object addingService(ServiceReference reference) { - HostInformationService service = (HostInformationService) super.addingService(reference); - uiFacadeFactory.addHostInformationService(service); - return service; - } - - @Override - public void removedService(ServiceReference reference, Object service) { - uiFacadeFactory.removeHostInformationService((HostInformationService)service); - super.removedService(reference, service); - } -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/InformationServiceTracker.java Wed Dec 12 19:49:12 2012 -0500 @@ -0,0 +1,94 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.swing.internal.osgi; + +import java.util.logging.Logger; + +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceReference; +import org.osgi.util.tracker.ServiceTracker; + +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.ui.UiFacadeFactory; +import com.redhat.thermostat.common.Constants; +import com.redhat.thermostat.common.dao.HostRef; +import com.redhat.thermostat.common.dao.VmRef; +import com.redhat.thermostat.common.utils.LoggingUtils; + +@SuppressWarnings("rawtypes") +public class InformationServiceTracker extends ServiceTracker { + + private UiFacadeFactory uiFacadeFactory; + private static final Logger logger = LoggingUtils.getLogger(InformationServiceTracker.class); + + @SuppressWarnings("unchecked") + public InformationServiceTracker(BundleContext context, UiFacadeFactory uiFacadeFactory) { + super(context, InformationService.class.getName(), null); + this.uiFacadeFactory = uiFacadeFactory; + } + + @Override + public Object addingService(ServiceReference reference) { + Object service = super.addingService(reference); + String genericType = (String) reference.getProperty(Constants.GENERIC_SERVICE_CLASSNAME); + if (genericType.equals(HostRef.class.getName())) { + uiFacadeFactory.addHostInformationService((InformationService<HostRef>) service); + } else if (genericType.equals(VmRef.class.getName())) { + uiFacadeFactory.addVmInformationService((InformationService<VmRef>) service); + } else { + logUnknownGenericServiceType(genericType); + } + return service; + } + + @Override + public void removedService(ServiceReference reference, Object service) { + String genericType = (String) reference.getProperty(Constants.GENERIC_SERVICE_CLASSNAME); + if (genericType.equals(HostRef.class.getName())) { + uiFacadeFactory.removeHostInformationService((InformationService<HostRef>) service); + } else if (genericType.equals(VmRef.class.getName())) { + uiFacadeFactory.removeVmInformationService((InformationService<VmRef>) service); + } else { + logUnknownGenericServiceType(genericType); + } + super.removedService(reference, service); + } + + private void logUnknownGenericServiceType(String genericType) { + logger.warning("InformationServiceTracker encountered an unknown generic type: " + genericType); + } +}
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivator.java Wed Dec 12 19:49:12 2012 -0500 @@ -37,6 +37,8 @@ package com.redhat.thermostat.client.swing.internal.osgi; import java.util.Arrays; +import java.util.Dictionary; +import java.util.Hashtable; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; @@ -48,9 +50,9 @@ import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.client.core.views.SummaryViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; -import com.redhat.thermostat.client.osgi.service.HostDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.client.swing.internal.GUIClientCommand; -import com.redhat.thermostat.client.swing.internal.HostIconDecorator; +import com.redhat.thermostat.client.swing.internal.HostIconDecoratorProvider; import com.redhat.thermostat.client.swing.internal.Main; import com.redhat.thermostat.client.swing.internal.UiFacadeFactoryImpl; import com.redhat.thermostat.client.swing.views.SwingAgentInformationViewProvider; @@ -59,14 +61,15 @@ import com.redhat.thermostat.client.swing.views.SwingSummaryViewProvider; import com.redhat.thermostat.client.swing.views.SwingVmInformationViewProvider; import com.redhat.thermostat.client.ui.UiFacadeFactory; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.cli.CommandRegistry; import com.redhat.thermostat.common.cli.CommandRegistryImpl; +import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.utils.keyring.Keyring; public class ThermostatActivator implements BundleActivator { - private HostInformationServiceTracker hostInfoServiceTracker; - private VmInformationServiceTracker vmInfoServiceTracker; + private InformationServiceTracker infoServiceTracker; private VMContextActionServiceTracker contextActionTracker; private CommandRegistry cmdReg; @@ -75,8 +78,10 @@ @Override public void start(final BundleContext context) throws Exception { - HostDecorator hostDecorator = new HostIconDecorator(); - context.registerService(HostDecorator.class.getName(), hostDecorator, null); + HostIconDecoratorProvider hostDecorator = new HostIconDecoratorProvider(); + Dictionary<String, String> decoratorProperties = new Hashtable<>(); + decoratorProperties.put(Constants.GENERIC_SERVICE_CLASSNAME, HostRef.class.getName()); + context.registerService(DecoratorProvider.class.getName(), hostDecorator, decoratorProperties); // Host views HostInformationViewProvider infoProvider = new SwingHostInformationViewProvider(); @@ -104,10 +109,9 @@ UiFacadeFactory uiFacadeFactory = new UiFacadeFactoryImpl(context); - hostInfoServiceTracker = new HostInformationServiceTracker(context, uiFacadeFactory); - hostInfoServiceTracker.open(); - vmInfoServiceTracker = new VmInformationServiceTracker(context, uiFacadeFactory); - vmInfoServiceTracker.open(); + uiFacadeFactory.getMainWindow(); + infoServiceTracker = new InformationServiceTracker(context, uiFacadeFactory); + infoServiceTracker.open(); contextActionTracker = new VMContextActionServiceTracker(context, uiFacadeFactory); contextActionTracker.open(); @@ -125,8 +129,7 @@ @Override public void stop(BundleContext context) throws Exception { - hostInfoServiceTracker.close(); - vmInfoServiceTracker.close(); //context.removeServiceListener(vmInfoServiceTracker); + infoServiceTracker.close(); contextActionTracker.close(); cmdReg.unregisterCommands(); }
--- a/client/swing/src/main/java/com/redhat/thermostat/client/swing/internal/osgi/VmInformationServiceTracker.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.swing.internal.osgi; - -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceReference; -import org.osgi.util.tracker.ServiceTracker; - -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.ui.UiFacadeFactory; - -class VmInformationServiceTracker extends ServiceTracker { - - private UiFacadeFactory uiFacadeFactory; - - private BundleContext context; - - VmInformationServiceTracker(BundleContext context, UiFacadeFactory uiFacadeFactory) { - super(context, VmInformationService.class.getName(), null); - this.context = context; - this.uiFacadeFactory = uiFacadeFactory; - } - - @Override - public Object addingService(ServiceReference 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/swing/src/test/java/com/redhat/thermostat/client/swing/MainWindowTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/MainWindowTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -72,9 +72,9 @@ import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; -import com.redhat.thermostat.client.core.HostFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.core.views.SearchFieldView; -import com.redhat.thermostat.client.osgi.service.HostDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.client.swing.internal.MainView; import com.redhat.thermostat.client.ui.Decorator; @@ -134,14 +134,16 @@ @Test public void testHostVmDecoratorsAdded() throws InterruptedException { - List<HostDecorator> decorators = new ArrayList<>(); - HostDecorator refDecorator = mock(HostDecorator.class); + List<DecoratorProvider<HostRef>> decorators = new ArrayList<>(); + @SuppressWarnings("unchecked") + DecoratorProvider<HostRef> refDecorator = mock(DecoratorProvider.class); final Decorator decorator = mock(Decorator.class); when(decorator.getLabel(anyString())).thenReturn("fluff"); when(refDecorator.getDecorator()).thenReturn(decorator); - HostFilter filter = mock(HostFilter.class); + @SuppressWarnings("unchecked") + Filter<HostRef> filter = mock(Filter.class); when(filter.matches(isA(HostRef.class))).thenReturn(false).thenReturn(true); when(refDecorator.getFilter()).thenReturn(filter);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorProviderTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -0,0 +1,89 @@ +/* + * Copyright 2012 Red Hat, Inc. + * + * This file is part of Thermostat. + * + * Thermostat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published + * by the Free Software Foundation; either version 2, or (at your + * option) any later version. + * + * Thermostat is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Thermostat; see the file COPYING. If not see + * <http://www.gnu.org/licenses/>. + * + * Linking this code with other modules is making a combined work + * based on this code. Thus, the terms and conditions of the GNU + * General Public License cover the whole combination. + * + * As a special exception, the copyright holders of this code give + * you permission to link this code with independent modules to + * produce an executable, regardless of the license terms of these + * independent modules, and to copy and distribute the resulting + * executable under terms of your choice, provided that you also + * meet, for each linked independent module, the terms and conditions + * of the license of that module. An independent module is a module + * which is not derived from or based on this code. If you modify + * this code, you may extend this exception to your version of the + * library, but you are not obligated to do so. If you do not wish + * to do so, delete this exception statement from your version. + */ + +package com.redhat.thermostat.client.swing.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; + +import javax.imageio.ImageIO; + +import org.junit.Test; + +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.ui.Decorator; +import com.redhat.thermostat.common.dao.HostRef; + +public class HostIconDecoratorProviderTest { + + @Test + public void verifyFilter() { + HostIconDecoratorProvider decorator = new HostIconDecoratorProvider(); + + Filter<HostRef> filter = decorator.getFilter(); + HostRef aHost = mock(HostRef.class); + + assertTrue(filter.matches(aHost)); + } + + @Test + public void verifyHostDecoratorDoesNotModifyLabel() { + HostIconDecoratorProvider iconDecorator = new HostIconDecoratorProvider(); + + Decorator decorator = iconDecorator.getDecorator(); + + String INPUT = "testfoobarbaz"; + + assertEquals(INPUT, decorator.getLabel(INPUT)); + } + + @Test + public void verifyHostDecoratorHasAnIcon() throws IOException { + HostIconDecoratorProvider iconDecorator = new HostIconDecoratorProvider(); + + Decorator decorator = iconDecorator.getDecorator(); + + BufferedImage icon = ImageIO.read(new ByteArrayInputStream(decorator.getIconDescriptor().getData().array())); + + assertNotNull(icon); + } +}
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/HostIconDecoratorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -/* - * Copyright 2012 Red Hat, Inc. - * - * This file is part of Thermostat. - * - * Thermostat is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published - * by the Free Software Foundation; either version 2, or (at your - * option) any later version. - * - * Thermostat is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Thermostat; see the file COPYING. If not see - * <http://www.gnu.org/licenses/>. - * - * Linking this code with other modules is making a combined work - * based on this code. Thus, the terms and conditions of the GNU - * General Public License cover the whole combination. - * - * As a special exception, the copyright holders of this code give - * you permission to link this code with independent modules to - * produce an executable, regardless of the license terms of these - * independent modules, and to copy and distribute the resulting - * executable under terms of your choice, provided that you also - * meet, for each linked independent module, the terms and conditions - * of the license of that module. An independent module is a module - * which is not derived from or based on this code. If you modify - * this code, you may extend this exception to your version of the - * library, but you are not obligated to do so. If you do not wish - * to do so, delete this exception statement from your version. - */ - -package com.redhat.thermostat.client.swing.internal; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.mock; - -import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.IOException; - -import javax.imageio.ImageIO; - -import org.junit.Test; - -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.ui.Decorator; -import com.redhat.thermostat.common.dao.HostRef; - -public class HostIconDecoratorTest { - - @Test - public void verifyFilter() { - HostIconDecorator decorator = new HostIconDecorator(); - - HostFilter filter = decorator.getFilter(); - HostRef aHost = mock(HostRef.class); - - assertTrue(filter.matches(aHost)); - } - - @Test - public void verifyHostDecoratorDoesNotModifyLabel() { - HostIconDecorator iconDecorator = new HostIconDecorator(); - - Decorator decorator = iconDecorator.getDecorator(); - - String INPUT = "testfoobarbaz"; - - assertEquals(INPUT, decorator.getLabel(INPUT)); - } - - @Test - public void verifyHostDecoratorHasAnIcon() throws IOException { - HostIconDecorator iconDecorator = new HostIconDecorator(); - - Decorator decorator = iconDecorator.getDecorator(); - - BufferedImage icon = ImageIO.read(new ByteArrayInputStream(decorator.getIconDescriptor().getData().array())); - - assertNotNull(icon); - } -}
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/MainWindowControllerImplTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -64,12 +64,11 @@ import org.mockito.ArgumentCaptor; import org.osgi.framework.BundleException; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.core.views.BasicView; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; import com.redhat.thermostat.client.osgi.service.MenuAction; import com.redhat.thermostat.client.osgi.service.VMContextAction; -import com.redhat.thermostat.client.osgi.service.VmDecorator; -import com.redhat.thermostat.client.ui.HostVmFilter; import com.redhat.thermostat.client.ui.SummaryController; import com.redhat.thermostat.client.ui.UiFacadeFactory; import com.redhat.thermostat.client.ui.VmInformationController; @@ -190,7 +189,7 @@ private void setUpVMContextActions() { action1 = mock(VMContextAction.class); - VmFilter action1Filter = mock(VmFilter.class); + Filter action1Filter = mock(Filter.class); when(action1Filter.matches(isA(VmRef.class))).thenReturn(true); when(action1.getName()).thenReturn("action1"); @@ -198,7 +197,7 @@ when(action1.getFilter()).thenReturn(action1Filter); action2 = mock(VMContextAction.class); - VmFilter action2Filter = mock(VmFilter.class); + Filter action2Filter = mock(Filter.class); when(action2Filter.matches(isA(VmRef.class))).thenReturn(false); when(action2.getName()).thenReturn("action2"); @@ -225,14 +224,14 @@ @Test public void verifyDecoratorsAdded() { - List<VmDecorator> currentDecoratros = controller.getVmTreeDecorators(); + List<DecoratorProvider<VmRef>> currentDecoratros = controller.getVmTreeDecorators(); assertEquals(0, currentDecoratros.size()); ActionEvent<ThermostatExtensionRegistry.Action> event = new ActionEvent<ThermostatExtensionRegistry.Action>(vmDecoratorRegistry, ThermostatExtensionRegistry.Action.SERVICE_ADDED); - VmDecorator payload = mock(VmDecorator.class); + DecoratorProvider<VmRef> payload = mock(DecoratorProvider.class); event.setPayload(payload); decoratorsListener.actionPerformed(event); @@ -372,7 +371,7 @@ controller.setHostVmTreeFilter("test1"); - HostVmFilter filter = controller.getSearchFilter(); + Filter<VmRef> filter = controller.getVmFilter(); assertTrue(filter.matches(ref1)); assertFalse(filter.matches(ref2)); }
--- a/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/client/swing/src/test/java/com/redhat/thermostat/client/swing/internal/osgi/ThermostatActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -46,8 +46,8 @@ import com.redhat.thermostat.client.core.views.HostInformationViewProvider; import com.redhat.thermostat.client.core.views.SummaryViewProvider; import com.redhat.thermostat.client.core.views.VmInformationViewProvider; -import com.redhat.thermostat.client.osgi.service.HostDecorator; -import com.redhat.thermostat.client.swing.internal.HostIconDecorator; +import com.redhat.thermostat.client.osgi.service.DecoratorProvider; +import com.redhat.thermostat.client.swing.internal.HostIconDecoratorProvider; import com.redhat.thermostat.client.swing.views.SwingAgentInformationViewProvider; import com.redhat.thermostat.client.swing.views.SwingClientConfigurationViewProvider; import com.redhat.thermostat.client.swing.views.SwingHostInformationViewProvider; @@ -65,7 +65,7 @@ activator.start(ctx); - assertTrue(ctx.isServiceRegistered(HostDecorator.class.getName(), HostIconDecorator.class)); + assertTrue(ctx.isServiceRegistered(DecoratorProvider.class.getName(), HostIconDecoratorProvider.class)); assertTrue(ctx.isServiceRegistered(SummaryViewProvider.class.getName(), SwingSummaryViewProvider.class)); assertTrue(ctx.isServiceRegistered(HostInformationViewProvider.class.getName(), SwingHostInformationViewProvider.class)); assertTrue(ctx.isServiceRegistered(VmInformationViewProvider.class.getName(), SwingVmInformationViewProvider.class));
--- a/common/core/src/main/java/com/redhat/thermostat/common/Constants.java Thu Dec 13 12:12:19 2012 -0500 +++ b/common/core/src/main/java/com/redhat/thermostat/common/Constants.java Wed Dec 12 19:49:12 2012 -0500 @@ -55,8 +55,6 @@ public static final long KILOBYTES_TO_BYTES = 1000; - public static final int HOST_INFO_NETWORK_IPV4_INDEX = 0; - public static final int HOST_INFO_NETWORK_IPV6_INDEX = 1; - + public static final String GENERIC_SERVICE_CLASSNAME = "GenericClassName"; }
--- a/common/core/src/main/java/com/redhat/thermostat/common/ThermostatExtensionRegistry.java Thu Dec 13 12:12:19 2012 -0500 +++ b/common/core/src/main/java/com/redhat/thermostat/common/ThermostatExtensionRegistry.java Wed Dec 12 19:49:12 2012 -0500 @@ -73,7 +73,7 @@ @Override public void removedService(ServiceReference reference, Object service) { if (!classType.isAssignableFrom(service.getClass())) { - throw new AssertionError("removing a non-Filter service"); + throw new AssertionError("removing a service of not matching type."); } actionNotifier.fireAction(Action.SERVICE_REMOVED, service);
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostCpuViewPart.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Composite; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; @@ -55,7 +55,7 @@ viewProvider.setParent(parent); HostCpuService service = OSGIUtils.getInstance().getService(HostCpuService.class); - HostInformationServiceController controller = service.getInformationServiceController(ref); + InformationServiceController<HostRef> controller = service.getInformationServiceController(ref); SWTComponent view = (SWTComponent) controller.getView(); return view; }
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/HostMemoryViewPart.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Composite; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; @@ -55,7 +55,7 @@ viewProvider.setParent(parent); HostMemoryService service = OSGIUtils.getInstance().getService(HostMemoryService.class); - HostInformationServiceController controller = service.getInformationServiceController(ref); + InformationServiceController<HostRef> controller = service.getInformationServiceController(ref); SWTComponent view = (SWTComponent) controller.getView(); return view; }
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmCpuViewPart.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Composite; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; @@ -55,7 +55,7 @@ viewProvider.setParent(parent); VmCpuService service = OSGIUtils.getInstance().getService(VmCpuService.class); - VmInformationServiceController controller = service.getInformationServiceController(ref); + InformationServiceController<VmRef> controller = service.getInformationServiceController(ref); SWTComponent view = (SWTComponent) controller.getView(); return view; }
--- a/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.common/src/com/redhat/thermostat/eclipse/chart/common/VmGcViewPart.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Composite; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; @@ -55,7 +55,7 @@ viewProvider.setParent(parent); VmGcService service = OSGIUtils.getInstance().getService(VmGcService.class); - VmInformationServiceController controller = service.getInformationServiceController(ref); + InformationServiceController<VmRef> controller = service.getInformationServiceController(ref); SWTComponent view = (SWTComponent) controller.getView(); return view; }
--- a/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.chart.vmclassstat/src/com/redhat/thermostat/eclipse/chart/vmclassstat/VmClassStatViewPart.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Composite; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; @@ -55,7 +55,7 @@ viewProvider.setParent(parent); VmClassStatService service = OSGIUtils.getInstance().getService(VmClassStatService.class); - VmInformationServiceController controller = service.getInformationServiceController(ref); + InformationServiceController<VmRef> controller = service.getInformationServiceController(ref); SWTComponent view = (SWTComponent) controller.getView(); return view; }
--- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostCpuViewPartTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostCpuViewPartTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -48,7 +48,7 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmRef; @@ -63,7 +63,7 @@ public class HostCpuViewPartTest extends AbstractRefViewPartTest<HostRef> { private SWTHostCpuViewProvider viewProvider; - private HostInformationServiceController controller; + private InformationServiceController<HostRef> controller; @Test public void testSetFocus() throws Exception { @@ -134,7 +134,7 @@ @Override protected void mockController() { HostCpuService service = mock(HostCpuService.class); - controller = mock(HostInformationServiceController.class); + controller = mock(InformationServiceController.class); thermoView = mock(SWTHostCpuView.class); when(osgi.getService(HostCpuService.class)).thenReturn(service);
--- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostMemoryViewPartTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostMemoryViewPartTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -46,7 +46,7 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.eclipse.ThermostatConstants; @@ -60,7 +60,7 @@ public class HostMemoryViewPartTest extends AbstractRefViewPartTest<HostRef> { private SWTHostMemoryViewProvider viewProvider; - private HostInformationServiceController controller; + private InformationServiceController<HostRef> controller; @Test public void testSelectionAfter() throws Exception { @@ -82,7 +82,7 @@ @Override protected void mockController() { HostMemoryService service = mock(HostMemoryService.class); - controller = mock(HostInformationServiceController.class); + controller = mock(InformationServiceController.class); thermoView = mock(SWTHostMemoryView.class); when(osgi.getService(HostMemoryService.class)).thenReturn(service);
--- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostOverviewViewPartTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/HostOverviewViewPartTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -46,7 +46,7 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.eclipse.ThermostatConstants; @@ -59,7 +59,7 @@ public class HostOverviewViewPartTest extends AbstractRefViewPartTest<HostRef> { - private HostInformationServiceController controller; + private InformationServiceController<HostRef> controller; private SWTHostOverviewViewProvider viewProvider; @Test @@ -82,7 +82,7 @@ @Override protected void mockController() { HostOverviewService service = mock(HostOverviewService.class); - controller = mock(HostInformationServiceController.class); + controller = mock(InformationServiceController.class); thermoView = mock(SWTHostOverviewView.class); when(osgi.getService(HostOverviewService.class)).thenReturn(service);
--- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmClassStatViewPartTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmClassStatViewPartTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -46,7 +46,7 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.chart.vmclassstat.Activator; @@ -60,7 +60,7 @@ public class VmClassStatViewPartTest extends AbstractRefViewPartTest<VmRef> { private SWTVmClassStatViewProvider viewProvider; - private VmInformationServiceController controller; + private InformationServiceController<VmRef> controller; @Test public void testSelectionAfter() throws Exception { @@ -83,7 +83,7 @@ @Override protected void mockController() { VmClassStatService service = mock(VmClassStatService.class); - controller = mock(VmInformationServiceController.class); + controller = mock(InformationServiceController.class); thermoView = mock(SWTVmClassStatView.class); when(osgi.getService(VmClassStatService.class)).thenReturn(service);
--- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmCpuViewPartTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmCpuViewPartTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -48,7 +48,7 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.ThermostatConstants; @@ -62,7 +62,7 @@ public class VmCpuViewPartTest extends AbstractRefViewPartTest<VmRef> { private SWTVmCpuViewProvider viewProvider; - private VmInformationServiceController controller; + private InformationServiceController<VmRef> controller; @Test public void testSelectionHostRef() throws Exception { @@ -111,7 +111,7 @@ @Override protected void mockController() { VmCpuService service = mock(VmCpuService.class); - controller = mock(VmInformationServiceController.class); + controller = mock(InformationServiceController.class); thermoView = mock(SWTVmCpuView.class); when(osgi.getService(VmCpuService.class)).thenReturn(service);
--- a/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse.test/src/com/redhat/thermostat/eclipse/test/views/VmGcViewPartTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -46,7 +46,7 @@ import org.junit.Test; import org.mockito.InOrder; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.eclipse.ThermostatConstants; @@ -60,7 +60,7 @@ public class VmGcViewPartTest extends AbstractRefViewPartTest<VmRef> { private SWTVmGcViewProvider viewProvider; - private VmInformationServiceController controller; + private InformationServiceController<VmRef> controller; @Test public void testSelectionAfter() throws Exception { @@ -83,7 +83,7 @@ @Override protected void mockController() { VmGcService service = mock(VmGcService.class); - controller = mock(VmInformationServiceController.class); + controller = mock(InformationServiceController.class); thermoView = mock(SWTVmGcView.class); when(osgi.getService(VmGcService.class)).thenReturn(service);
--- a/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java Thu Dec 13 12:12:19 2012 -0500 +++ b/eclipse/com.redhat.thermostat.eclipse/src/com/redhat/thermostat/eclipse/internal/views/HostOverviewViewPart.java Wed Dec 12 19:49:12 2012 -0500 @@ -38,7 +38,7 @@ import org.eclipse.swt.widgets.Composite; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.eclipse.SWTComponent; @@ -55,7 +55,7 @@ provider.setParent(top); HostOverviewService service = OSGIUtils.getInstance().getService(HostOverviewService.class); - HostInformationServiceController controller = service.getInformationServiceController(ref); + InformationServiceController<HostRef> controller = service.getInformationServiceController(ref); return (SWTComponent) controller.getView(); }
--- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/HostCpuService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,9 +36,10 @@ package com.redhat.thermostat.host.cpu.client.core; -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.CpuStatDAO; import com.redhat.thermostat.common.dao.HostInfoDAO; @@ -46,15 +47,10 @@ import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.host.cpu.client.core.internal.HostCpuController; -public class HostCpuService implements HostInformationService { +public class HostCpuService implements InformationService<HostRef> { private static final int PRIORITY = PRIORITY_CPU_GROUP; - private static final HostFilter FILTER = new HostFilter() { - @Override - public boolean matches(HostRef toMatch) { - return true; - } - }; + private static final Filter<HostRef> FILTER = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private HostInfoDAO hostInfoDAO; @@ -67,12 +63,12 @@ } @Override - public HostFilter getFilter() { + public Filter<HostRef> getFilter() { return FILTER; } @Override - public HostInformationServiceController getInformationServiceController( + public InformationServiceController<HostRef> getInformationServiceController( HostRef ref) { HostCpuViewProvider provider = OSGIUtils.getInstance().getService(HostCpuViewProvider.class); return new HostCpuController(appSvc, hostInfoDAO, cpuStatDAO, ref, provider);
--- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.host.cpu.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,12 +45,14 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.HostInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.CpuStatDAO; import com.redhat.thermostat.common.dao.HostInfoDAO; +import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.host.cpu.client.core.HostCpuService; public class Activator implements BundleActivator { @@ -75,7 +79,9 @@ ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); Objects.requireNonNull(appSvc); HostCpuService service = new HostCpuService(appSvc, hostInfoDAO, cpuStatDAO); - reg = context.registerService(HostInformationService.class.getName(), service, null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, HostRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service, properties); } @Override
--- a/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-cpu/client-core/src/main/java/com/redhat/thermostat/host/cpu/client/core/internal/HostCpuController.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,7 +40,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -60,7 +60,7 @@ import com.redhat.thermostat.storage.model.DiscreteTimeData; import com.redhat.thermostat.storage.model.HostInfo; -public class HostCpuController implements HostInformationServiceController { +public class HostCpuController implements InformationServiceController<HostRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
--- a/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-cpu/client-core/src/test/java/com/redhat/thermostat/host/cpu/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.HostInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.CpuStatDAO; import com.redhat.thermostat.common.dao.HostInfoDAO; @@ -81,7 +81,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(HostInformationService.class.getName(), HostCpuService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), HostCpuService.class)); activator.stop(context);
--- a/host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-cpu/client-swing/src/test/java/com/redhat/thermostat/host/cpu/client/swing/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -42,8 +42,6 @@ import org.junit.Test; import com.redhat.thermostat.host.cpu.client.core.HostCpuViewProvider; -import com.redhat.thermostat.host.cpu.client.swing.internal.Activator; -import com.redhat.thermostat.host.cpu.client.swing.internal.SwingHostCpuViewProvider; import com.redhat.thermostat.test.StubBundleContext; public class ActivatorTest {
--- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/HostMemoryService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,9 +36,10 @@ package com.redhat.thermostat.host.memory.client.core; -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.common.dao.HostRef; @@ -46,15 +47,10 @@ import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.host.memory.client.core.internal.HostMemoryController; -public class HostMemoryService implements HostInformationService { +public class HostMemoryService implements InformationService<HostRef> { private static final int PRIORITY = PRIORITY_MEMORY_GROUP; - private static final HostFilter FILTER = new HostFilter() { - @Override - public boolean matches(HostRef toMatch) { - return true; - } - }; + private static final Filter<HostRef> FILTER = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private HostInfoDAO hostInfoDAO; @@ -67,12 +63,12 @@ } @Override - public HostFilter getFilter() { + public Filter<HostRef> getFilter() { return FILTER; } @Override - public HostInformationServiceController getInformationServiceController( + public InformationServiceController<HostRef> getInformationServiceController( HostRef ref) { HostMemoryViewProvider provider = OSGIUtils.getInstance().getService(HostMemoryViewProvider.class); return new HostMemoryController(appSvc, hostInfoDAO, memoryStatDAO, ref, provider);
--- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.host.memory.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,11 +45,13 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.HostInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.HostInfoDAO; +import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.MemoryStatDAO; import com.redhat.thermostat.host.memory.client.core.HostMemoryService; @@ -75,7 +79,9 @@ ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); Objects.requireNonNull(appSvc); HostMemoryService service = new HostMemoryService(appSvc, hostInfoDAO, memoryStatDAO); - reg = context.registerService(HostInformationService.class.getName(), service, null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, HostRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service, properties); } @Override
--- a/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-memory/client-core/src/main/java/com/redhat/thermostat/host/memory/client/core/internal/HostMemoryController.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,7 +40,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -62,7 +62,7 @@ import com.redhat.thermostat.storage.model.MemoryStat; import com.redhat.thermostat.storage.model.MemoryType; -public class HostMemoryController implements HostInformationServiceController { +public class HostMemoryController implements InformationServiceController<HostRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
--- a/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-memory/client-core/src/test/java/com/redhat/thermostat/host/memory/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.HostInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.common.dao.MemoryStatDAO; @@ -83,7 +83,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(HostInformationService.class.getName(), HostMemoryService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), HostMemoryService.class)); activator.stop(context);
--- a/host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-memory/client-swing/src/test/java/com/redhat/thermostat/host/memory/client/swing/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -42,8 +42,6 @@ import org.junit.Test; import com.redhat.thermostat.host.memory.client.core.HostMemoryViewProvider; -import com.redhat.thermostat.host.memory.client.swing.internal.Activator; -import com.redhat.thermostat.host.memory.client.swing.internal.SwingHostMemoryViewProvider; import com.redhat.thermostat.test.StubBundleContext; public class ActivatorTest {
--- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/HostOverviewService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,9 +36,10 @@ package com.redhat.thermostat.host.overview.client.core; -import com.redhat.thermostat.client.core.HostFilter; -import com.redhat.thermostat.client.core.HostInformationService; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.common.dao.HostRef; @@ -46,15 +47,10 @@ import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.host.overview.client.core.internal.HostOverviewController; -public class HostOverviewService implements HostInformationService { +public class HostOverviewService implements InformationService<HostRef> { private static final int PRIORITY = PRIORITY_DEFAULT_GROUP; - private static final HostFilter FILTER = new HostFilter() { - @Override - public boolean matches(HostRef toMatch) { - return true; - } - }; + private static final Filter<HostRef> FILTER = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private HostInfoDAO hostInfoDAO; @@ -67,12 +63,12 @@ } @Override - public HostFilter getFilter() { + public Filter<HostRef> getFilter() { return FILTER; } @Override - public HostInformationServiceController getInformationServiceController( + public InformationServiceController<HostRef> getInformationServiceController( HostRef ref) { HostOverviewViewProvider provider = OSGIUtils.getInstance().getService(HostOverviewViewProvider.class); return new HostOverviewController(appSvc, hostInfoDAO, networkInfoDAO, ref, provider);
--- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.host.overview.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,11 +45,13 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.HostInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.HostInfoDAO; +import com.redhat.thermostat.common.dao.HostRef; import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; import com.redhat.thermostat.host.overview.client.core.HostOverviewService; @@ -76,7 +80,9 @@ ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); Objects.requireNonNull(appSvc); HostOverviewService service = new HostOverviewService(appSvc, hostInfoDAO, networkInfoDAO); - reg = context.registerService(HostInformationService.class.getName(), service, null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, HostRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service, properties); } @Override
--- a/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-overview/client-core/src/main/java/com/redhat/thermostat/host/overview/client/core/internal/HostOverviewController.java Wed Dec 12 19:49:12 2012 -0500 @@ -41,7 +41,7 @@ import java.util.Vector; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.HostInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -61,7 +61,7 @@ import com.redhat.thermostat.storage.model.HostInfo; import com.redhat.thermostat.storage.model.NetworkInterfaceInfo; -public class HostOverviewController implements HostInformationServiceController { +public class HostOverviewController implements InformationServiceController<HostRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
--- a/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-overview/client-core/src/test/java/com/redhat/thermostat/host/overview/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.HostInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.HostInfoDAO; import com.redhat.thermostat.common.dao.NetworkInterfaceInfoDAO; @@ -81,7 +81,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(HostInformationService.class.getName(), HostOverviewService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), HostOverviewService.class)); activator.stop(context);
--- a/host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/host-overview/client-swing/src/test/java/com/redhat/thermostat/host/overview/client/swing/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -42,8 +42,6 @@ import org.junit.Test; import com.redhat.thermostat.host.overview.client.core.HostOverviewViewProvider; -import com.redhat.thermostat.host.overview.client.swing.internal.Activator; -import com.redhat.thermostat.host.overview.client.swing.internal.SwingHostOverviewViewProvider; import com.redhat.thermostat.test.StubBundleContext; public class ActivatorTest {
--- a/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/KillVMAction.java Thu Dec 13 12:12:19 2012 -0500 +++ b/killvm/client-swing/src/main/java/com/redhat/thermostat/killvm/client/internal/KillVMAction.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,7 +40,7 @@ import java.util.Objects; import com.redhat.thermostat.client.command.RequestQueue; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.client.osgi.service.VMContextAction; import com.redhat.thermostat.common.command.Request; import com.redhat.thermostat.common.command.Request.RequestType; @@ -104,11 +104,11 @@ } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return new LocalAndAliveFilter(); } - private class LocalAndAliveFilter implements VmFilter { + private class LocalAndAliveFilter implements Filter<VmRef> { @Override public boolean matches(VmRef ref) {
--- a/killvm/client-swing/src/test/java/com/redhat/thermostat/killvm/client/internal/KillVMActionTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/killvm/client-swing/src/test/java/com/redhat/thermostat/killvm/client/internal/KillVMActionTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -54,7 +54,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import com.redhat.thermostat.client.command.RequestQueue; -import com.redhat.thermostat.client.core.VmFilter; +import com.redhat.thermostat.client.core.Filter; import com.redhat.thermostat.common.command.Request; import com.redhat.thermostat.common.command.RequestResponseListener; import com.redhat.thermostat.common.dao.AgentInfoDAO; @@ -84,7 +84,7 @@ KillVMAction action = new KillVMAction(agentDao, vmInfoDao, listener); - VmFilter filter = action.getFilter(); + Filter<VmRef> filter = action.getFilter(); when(vmInfo.isAlive()).thenReturn(true); assertTrue(filter.matches(matching));
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationController.java Wed Dec 12 19:49:12 2012 -0500 @@ -41,7 +41,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.common.ActionEvent; @@ -64,7 +64,7 @@ import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; import com.redhat.thermostat.thread.model.ThreadSummary; -public class ThreadInformationController implements VmInformationServiceController { +public class ThreadInformationController implements InformationServiceController<VmRef> { private static final Logger logger = LoggingUtils.getLogger(ThreadInformationController.class);
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/impl/ThreadInformationService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,20 +36,20 @@ package com.redhat.thermostat.thread.client.controller.impl; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; -public class ThreadInformationService implements VmInformationService { +public class ThreadInformationService implements InformationService<VmRef> { private static final int PRIORITY = PRIORITY_THREAD_GROUP; - private VmFilter filter = new AlwaysMatchFilter(); + private Filter<VmRef> filter = new NameMatchingRefFilter<>(); private ApplicationService service; private ThreadCollectorFactory collectorFactory; private ThreadViewProvider viewFactory; @@ -63,12 +63,12 @@ } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return filter; } @Override - public VmInformationServiceController getInformationServiceController(VmRef ref) { + public InformationServiceController<VmRef> getInformationServiceController(VmRef ref) { return new ThreadInformationController(ref, service, collectorFactory, viewFactory); }
--- a/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/thread/client-controllers/src/main/java/com/redhat/thermostat/thread/client/controller/osgi/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,16 +36,20 @@ package com.redhat.thermostat.thread.client.controller.osgi; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; +import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.thread.client.common.ThreadViewProvider; import com.redhat.thermostat.thread.client.common.collector.ThreadCollectorFactory; import com.redhat.thermostat.thread.client.controller.impl.ThreadInformationService; @@ -72,9 +76,12 @@ ApplicationService applicationService = (ApplicationService) services.get(ApplicationService.class.getName()); ThreadViewProvider viewFactory = (ThreadViewProvider) services.get(ThreadViewProvider.class.getName()); - VmInformationService vmInfoService = new ThreadInformationService(applicationService, collectorFactory, viewFactory); - registration = context.registerService(VmInformationService.class.getName(), vmInfoService, null); + InformationService<VmRef> vmInfoService = new ThreadInformationService(applicationService, collectorFactory, viewFactory); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + registration = context.registerService(InformationService.class.getName(), vmInfoService, properties); } + @Override public void dependenciesUnavailable() { registration.unregister();
--- a/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/VmClassStatService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/VmClassStatService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,20 +36,20 @@ package com.redhat.thermostat.vm.classstat.client.core; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmClassStatDAO; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.vm.classstat.client.core.internal.VmClassStatController; -public class VmClassStatService implements VmInformationService { +public class VmClassStatService implements InformationService<VmRef> { private static final int PRIORITY = PRIORITY_MEMORY_GROUP + 20; - private VmFilter filter = new AlwaysMatchFilter(); + private Filter<VmRef> filter = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private VmClassStatDAO vmClassStatDao; @@ -60,13 +60,13 @@ } @Override - public VmInformationServiceController getInformationServiceController(VmRef ref) { + public InformationServiceController<VmRef> getInformationServiceController(VmRef ref) { VmClassStatViewProvider viewProvider = OSGIUtils.getInstance().getService(VmClassStatViewProvider.class); return new VmClassStatController(appSvc, vmClassStatDao, ref, viewProvider); } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return filter; }
--- a/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.vm.classstat.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,11 +45,13 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.VmClassStatDAO; +import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.vm.classstat.client.core.VmClassStatService; public class Activator implements BundleActivator { @@ -71,7 +75,9 @@ ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); Objects.requireNonNull(appSvc); VmClassStatService service = new VmClassStatService(appSvc, dao); - reg = context.registerService(VmInformationService.class.getName(), service, null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service, properties); } @Override
--- a/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-classstat/client-core/src/main/java/com/redhat/thermostat/vm/classstat/client/core/internal/VmClassStatController.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,7 +40,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.common.ActionEvent; @@ -58,7 +58,7 @@ import com.redhat.thermostat.vm.classstat.client.core.VmClassStatViewProvider; import com.redhat.thermostat.vm.classstat.client.locale.LocaleResources; -public class VmClassStatController implements VmInformationServiceController { +public class VmClassStatController implements InformationServiceController<VmRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
--- a/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-classstat/client-core/src/test/java/com/redhat/thermostat/vm/classstat/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmClassStatDAO; import com.redhat.thermostat.test.StubBundleContext; @@ -80,7 +80,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), VmClassStatService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), VmClassStatService.class)); activator.stop(context);
--- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/VmCpuService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,20 +36,20 @@ package com.redhat.thermostat.vm.cpu.client.core; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmCpuStatDAO; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.vm.cpu.client.core.internal.VmCpuController; -public class VmCpuService implements VmInformationService { +public class VmCpuService implements InformationService<VmRef> { private static final int PRIORITY = PRIORITY_CPU_GROUP; - private static final VmFilter FILTER = new AlwaysMatchFilter(); + private static final Filter<VmRef> FILTER = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private VmCpuStatDAO vmCpuStatDAO; @@ -60,14 +60,14 @@ } @Override - public VmInformationServiceController getInformationServiceController( + public InformationServiceController<VmRef> getInformationServiceController( VmRef ref) { VmCpuViewProvider provider = OSGIUtils.getInstance().getService(VmCpuViewProvider.class); return new VmCpuController(appSvc, vmCpuStatDAO, ref, provider); } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return FILTER; }
--- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.vm.cpu.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,41 +45,45 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.VmCpuStatDAO; +import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.vm.cpu.client.core.VmCpuService; public class Activator implements BundleActivator { - + private MultipleServiceTracker tracker; private ServiceRegistration reg; @Override public void start(final BundleContext context) throws Exception { Class<?>[] deps = new Class<?>[] { - VmCpuStatDAO.class, - ApplicationService.class + VmCpuStatDAO.class, + ApplicationService.class }; - - tracker = new MultipleServiceTracker(context, deps , new Action() { - - @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmCpuStatDAO vmCpuStatDAO = (VmCpuStatDAO) services.get(VmCpuStatDAO.class.getName()); - Objects.requireNonNull(vmCpuStatDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmCpuService service = new VmCpuService(appSvc, vmCpuStatDAO); - reg = context.registerService(VmInformationService.class.getName(), service, null); - } + + tracker = new MultipleServiceTracker(context, deps , new Action() { - @Override - public void dependenciesUnavailable() { - reg.unregister(); - } + @Override + public void dependenciesAvailable(Map<String, Object> services) { + VmCpuStatDAO vmCpuStatDAO = (VmCpuStatDAO) services.get(VmCpuStatDAO.class.getName()); + Objects.requireNonNull(vmCpuStatDAO); + ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); + Objects.requireNonNull(appSvc); + VmCpuService service = new VmCpuService(appSvc, vmCpuStatDAO); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service, properties); + } + + @Override + public void dependenciesUnavailable() { + reg.unregister(); + } }); tracker.open(); } @@ -88,4 +94,3 @@ } } -
--- a/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-cpu/client-core/src/main/java/com/redhat/thermostat/vm/cpu/client/core/internal/VmCpuController.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,7 +40,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -58,7 +58,7 @@ import com.redhat.thermostat.vm.cpu.client.core.VmCpuViewProvider; import com.redhat.thermostat.vm.cpu.client.locale.LocaleResources; -public class VmCpuController implements VmInformationServiceController { +public class VmCpuController implements InformationServiceController<VmRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer(); private final VmRef ref;
--- a/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-cpu/client-core/src/test/java/com/redhat/thermostat/vm/cpu/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmCpuStatDAO; import com.redhat.thermostat.test.StubBundleContext; @@ -80,7 +80,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), VmCpuService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), VmCpuService.class)); activator.stop(context);
--- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/VmGcService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,10 +36,10 @@ package com.redhat.thermostat.vm.gc.client.core; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmGcStatDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; @@ -47,10 +47,10 @@ import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.vm.gc.client.core.internal.VmGcController; -public class VmGcService implements VmInformationService { +public class VmGcService implements InformationService<VmRef> { private static final int PRIORITY = PRIORITY_MEMORY_GROUP; - private static final VmFilter FILTER = new AlwaysMatchFilter(); + private static final Filter<VmRef> FILTER = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private VmMemoryStatDAO vmMemoryStatDAO; @@ -63,14 +63,14 @@ } @Override - public VmInformationServiceController getInformationServiceController( + public InformationServiceController<VmRef> getInformationServiceController( VmRef ref) { VmGcViewProvider provider = OSGIUtils.getInstance().getService(VmGcViewProvider.class); return new VmGcController(appSvc, vmMemoryStatDAO, vmGcStatDAO, ref, provider); } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return FILTER; }
--- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.vm.gc.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,12 +45,14 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.VmGcStatDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.vm.gc.client.core.VmGcService; public class Activator implements BundleActivator { @@ -75,7 +79,9 @@ ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); Objects.requireNonNull(appSvc); VmGcService service = new VmGcService(appSvc, vmMemoryStatDAO, vmGcStatDAO); - reg = context.registerService(VmInformationService.class.getName(), service, null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service, properties); } @Override
--- a/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-gc/client-core/src/main/java/com/redhat/thermostat/vm/gc/client/core/internal/VmGcController.java Wed Dec 12 19:49:12 2012 -0500 @@ -46,7 +46,7 @@ import java.util.TreeSet; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -68,7 +68,7 @@ import com.redhat.thermostat.vm.gc.client.core.VmGcViewProvider; import com.redhat.thermostat.vm.gc.client.locale.LocaleResources; -public class VmGcController implements VmInformationServiceController { +public class VmGcController implements InformationServiceController<VmRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
--- a/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-gc/client-core/src/test/java/com/redhat/thermostat/vm/gc/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmGcStatDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; @@ -83,7 +83,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), VmGcService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), VmGcService.class)); activator.stop(context);
--- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapDumperService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/HeapDumperService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,10 +36,10 @@ package com.redhat.thermostat.vm.heap.analysis.client.core; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; import com.redhat.thermostat.common.dao.VmRef; @@ -47,14 +47,14 @@ import com.redhat.thermostat.vm.heap.analysis.client.core.internal.HeapDumpController; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; -public class HeapDumperService implements VmInformationService { +public class HeapDumperService implements InformationService<VmRef> { private static final int PRIORITY = PRIORITY_MEMORY_GROUP + 60; private ApplicationService appService; private VmMemoryStatDAO vmMemoryStatDao; private HeapDAO heapDao; - private VmFilter filter = new AlwaysMatchFilter(); + private Filter<VmRef> filter = new NameMatchingRefFilter<>(); public HeapDumperService(ApplicationService appService, VmMemoryStatDAO vmMemoryStatDao, HeapDAO heapDao) { this.vmMemoryStatDao = vmMemoryStatDao; @@ -63,7 +63,7 @@ } @Override - public VmInformationServiceController getInformationServiceController(VmRef ref) { + public InformationServiceController<VmRef> getInformationServiceController(VmRef ref) { HeapViewProvider viewProvider = OSGIUtils.getInstance().getService(HeapViewProvider.class); HeapDumpDetailsViewProvider detailsViewProvider = OSGIUtils.getInstance().getService(HeapDumpDetailsViewProvider.class); HeapHistogramViewProvider histogramViewProvider = OSGIUtils.getInstance().getService(HeapHistogramViewProvider.class); @@ -73,7 +73,7 @@ } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return filter; }
--- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.vm.heap.analysis.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,11 +45,13 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.vm.heap.analysis.client.core.HeapDumperService; import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; @@ -76,7 +80,9 @@ Objects.requireNonNull(heapDao); HeapDumperService service = new HeapDumperService(appSvc, vmMemoryStatDao, heapDao); - reg = context.registerService(VmInformationService.class.getName(), service , null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service , properties); } @Override
--- a/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-heap-analysis/client-core/src/main/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/HeapDumpController.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -73,7 +73,7 @@ import com.redhat.thermostat.vm.heap.analysis.common.HeapDAO; import com.redhat.thermostat.vm.heap.analysis.common.HeapDump; -public class HeapDumpController implements VmInformationServiceController { +public class HeapDumpController implements InformationServiceController<VmRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
--- a/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-heap-analysis/client-core/src/test/java/com/redhat/thermostat/vm/heap/analysis/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; import com.redhat.thermostat.test.StubBundleContext; @@ -83,7 +83,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), HeapDumperService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), HeapDumperService.class)); activator.stop(context);
--- a/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/MemoryStatsService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/MemoryStatsService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,10 +36,10 @@ package com.redhat.thermostat.vm.memory.client.core; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.AgentInfoDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; @@ -48,10 +48,10 @@ import com.redhat.thermostat.gc.remote.common.GCRequest; import com.redhat.thermostat.vm.memory.client.core.internal.MemoryStatsController; -public class MemoryStatsService implements VmInformationService { +public class MemoryStatsService implements InformationService<VmRef> { private static final int PRIORITY = PRIORITY_MEMORY_GROUP + 40; - private VmFilter filter = new AlwaysMatchFilter(); + private Filter<VmRef> filter = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private VmMemoryStatDAO vmMemoryStatDao; @@ -66,13 +66,13 @@ } @Override - public VmInformationServiceController getInformationServiceController(VmRef ref) { + public InformationServiceController<VmRef> getInformationServiceController(VmRef ref) { MemoryStatsViewProvider viewProvider = OSGIUtils.getInstance().getService(MemoryStatsViewProvider.class); return new MemoryStatsController(appSvc, vmMemoryStatDao, ref, viewProvider, agentDAO, gcRequest); } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return filter; }
--- a/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,18 +36,22 @@ package com.redhat.thermostat.vm.memory.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.AgentInfoDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; +import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.gc.remote.common.GCRequest; import com.redhat.thermostat.vm.memory.client.core.MemoryStatsService; @@ -81,7 +85,9 @@ ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); MemoryStatsService impl = new MemoryStatsService(appSvc, memoryStatDao, agentDAO, gcRequest); - memoryStatRegistration = context.registerService(VmInformationService.class.getName(), impl , null); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + memoryStatRegistration = context.registerService(InformationService.class.getName(), impl , properties); } }); tracker.open();
--- a/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-memory/client-core/src/main/java/com/redhat/thermostat/vm/memory/client/core/internal/MemoryStatsController.java Wed Dec 12 19:49:12 2012 -0500 @@ -41,7 +41,7 @@ import java.util.Map; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -70,7 +70,7 @@ import com.redhat.thermostat.vm.memory.client.core.StatsModel; import com.redhat.thermostat.vm.memory.client.locale.LocaleResources; -public class MemoryStatsController implements VmInformationServiceController { +public class MemoryStatsController implements InformationServiceController<VmRef> { private static final Translate<LocaleResources> translate = LocaleResources.createLocalizer();
--- a/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-memory/client-core/src/test/java/com/redhat/thermostat/vm/memory/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.AgentInfoDAO; import com.redhat.thermostat.common.dao.VmMemoryStatDAO; @@ -86,7 +86,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), MemoryStatsService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), MemoryStatsService.class)); activator.stop(context);
--- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/VmOverviewService.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,20 +36,20 @@ package com.redhat.thermostat.vm.overview.client.core; -import com.redhat.thermostat.client.core.VmFilter; -import com.redhat.thermostat.client.core.VmInformationService; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; -import com.redhat.thermostat.client.osgi.service.AlwaysMatchFilter; +import com.redhat.thermostat.client.core.Filter; +import com.redhat.thermostat.client.core.InformationService; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; +import com.redhat.thermostat.client.core.NameMatchingRefFilter; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.common.utils.OSGIUtils; import com.redhat.thermostat.vm.overview.client.core.internal.VmOverviewController; -public class VmOverviewService implements VmInformationService { +public class VmOverviewService implements InformationService<VmRef> { private static final int PRIORITY = PRIORITY_DEFAULT_GROUP; - private static final VmFilter FILTER = new AlwaysMatchFilter(); + private static final Filter<VmRef> FILTER = new NameMatchingRefFilter<>(); private ApplicationService appSvc; private VmInfoDAO vmInfoDAO; @@ -60,14 +60,14 @@ } @Override - public VmInformationServiceController getInformationServiceController( + public InformationServiceController<VmRef> getInformationServiceController( VmRef ref) { VmOverviewViewProvider provider = OSGIUtils.getInstance().getService(VmOverviewViewProvider.class); return new VmOverviewController(appSvc, vmInfoDAO, ref, provider); } @Override - public VmFilter getFilter() { + public Filter<VmRef> getFilter() { return FILTER; }
--- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/Activator.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/Activator.java Wed Dec 12 19:49:12 2012 -0500 @@ -36,6 +36,8 @@ package com.redhat.thermostat.vm.overview.client.core.internal; +import java.util.Dictionary; +import java.util.Hashtable; import java.util.Map; import java.util.Objects; @@ -43,11 +45,13 @@ import org.osgi.framework.BundleContext; import org.osgi.framework.ServiceRegistration; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; +import com.redhat.thermostat.common.Constants; import com.redhat.thermostat.common.MultipleServiceTracker; import com.redhat.thermostat.common.MultipleServiceTracker.Action; import com.redhat.thermostat.common.dao.VmInfoDAO; +import com.redhat.thermostat.common.dao.VmRef; import com.redhat.thermostat.vm.overview.client.core.VmOverviewService; public class Activator implements BundleActivator { @@ -58,26 +62,28 @@ @Override public void start(final BundleContext context) throws Exception { Class<?>[] deps = new Class<?>[] { - VmInfoDAO.class, - ApplicationService.class + VmInfoDAO.class, + ApplicationService.class }; - - tracker = new MultipleServiceTracker(context, deps , new Action() { - - @Override - public void dependenciesAvailable(Map<String, Object> services) { - VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); - Objects.requireNonNull(vmInfoDAO); - ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); - Objects.requireNonNull(appSvc); - VmOverviewService service = new VmOverviewService(appSvc, vmInfoDAO); - reg = context.registerService(VmInformationService.class.getName(), service, null); - } + + tracker = new MultipleServiceTracker(context, deps , new Action() { - @Override - public void dependenciesUnavailable() { - reg.unregister(); - } + @Override + public void dependenciesAvailable(Map<String, Object> services) { + VmInfoDAO vmInfoDAO = (VmInfoDAO) services.get(VmInfoDAO.class.getName()); + Objects.requireNonNull(vmInfoDAO); + ApplicationService appSvc = (ApplicationService) services.get(ApplicationService.class.getName()); + Objects.requireNonNull(appSvc); + VmOverviewService service = new VmOverviewService(appSvc, vmInfoDAO); + Dictionary<String, String> properties = new Hashtable<>(); + properties.put(Constants.GENERIC_SERVICE_CLASSNAME, VmRef.class.getName()); + reg = context.registerService(InformationService.class.getName(), service, properties); + } + + @Override + public void dependenciesUnavailable() { + reg.unregister(); + } }); tracker.open(); }
--- a/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewController.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-overview/client-core/src/main/java/com/redhat/thermostat/vm/overview/client/core/internal/VmOverviewController.java Wed Dec 12 19:49:12 2012 -0500 @@ -40,7 +40,7 @@ import java.util.Date; import java.util.concurrent.TimeUnit; -import com.redhat.thermostat.client.core.controllers.VmInformationServiceController; +import com.redhat.thermostat.client.core.controllers.InformationServiceController; import com.redhat.thermostat.client.core.views.BasicView.Action; import com.redhat.thermostat.client.core.views.UIComponent; import com.redhat.thermostat.common.ActionEvent; @@ -57,7 +57,7 @@ import com.redhat.thermostat.vm.overview.client.core.VmOverviewViewProvider; import com.redhat.thermostat.vm.overview.client.locale.LocaleResources; -public class VmOverviewController implements VmInformationServiceController { +public class VmOverviewController implements InformationServiceController<VmRef> { private static final Translate<LocaleResources> translator = LocaleResources.createLocalizer();
--- a/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/ActivatorTest.java Thu Dec 13 12:12:19 2012 -0500 +++ b/vm-overview/client-core/src/test/java/com/redhat/thermostat/vm/overview/client/core/internal/ActivatorTest.java Wed Dec 12 19:49:12 2012 -0500 @@ -43,7 +43,7 @@ import org.junit.Test; -import com.redhat.thermostat.client.core.VmInformationService; +import com.redhat.thermostat.client.core.InformationService; import com.redhat.thermostat.common.ApplicationService; import com.redhat.thermostat.common.dao.VmInfoDAO; import com.redhat.thermostat.test.StubBundleContext; @@ -80,7 +80,7 @@ activator.start(context); - assertTrue(context.isServiceRegistered(VmInformationService.class.getName(), VmOverviewService.class)); + assertTrue(context.isServiceRegistered(InformationService.class.getName(), VmOverviewService.class)); activator.stop(context);