diff options
author | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-08-12 12:05:29 +0200 |
---|---|---|
committer | Sébastien Lesaint <sebastien.lesaint@sonarsource.com> | 2015-08-24 14:00:30 +0200 |
commit | 14dd030371a3ce08aba488e9264fef25977bd3e7 (patch) | |
tree | 23b3943674ac79e61bf2694bcb298d2686b22cd7 /sonar-core | |
parent | 8d785cec0a5394bbd79be3beaf5ee54497ad30a7 (diff) | |
download | sonarqube-14dd030371a3ce08aba488e9264fef25977bd3e7.tar.gz sonarqube-14dd030371a3ce08aba488e9264fef25977bd3e7.zip |
add ContainerPopulator to be used by ComputeEngineContainer
by using a specific class to populate a container, one can reuse the ComputeEngineContainer without subclassing it
Diffstat (limited to 'sonar-core')
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java | 11 | ||||
-rw-r--r-- | sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java | 32 |
2 files changed, 37 insertions, 6 deletions
diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java index cbc738cc977..52ef24da32a 100644 --- a/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java +++ b/sonar-core/src/main/java/org/sonar/core/platform/ComponentContainer.java @@ -20,12 +20,8 @@ package org.sonar.core.platform; import com.google.common.collect.Iterables; - -import java.util.Collection; import java.util.List; - import javax.annotation.Nullable; - import org.picocontainer.Characteristics; import org.picocontainer.ComponentAdapter; import org.picocontainer.DefaultPicoContainer; @@ -41,7 +37,7 @@ import org.sonar.api.utils.log.Profiler; @BatchSide @ServerSide -public class ComponentContainer { +public class ComponentContainer implements ContainerPopulator.Container { // no need for multiple children ComponentContainer parent; @@ -147,6 +143,7 @@ public class ComponentContainer { /** * @since 3.5 */ + @Override public ComponentContainer add(Object... objects) { for (Object object : objects) { if (object instanceof ComponentAdapter) { @@ -166,7 +163,8 @@ public class ComponentContainer { } } - public ComponentContainer addSingletons(Collection components) { + @Override + public ComponentContainer addSingletons(Iterable<?> components) { for (Object component : components) { addSingleton(component); } @@ -223,6 +221,7 @@ public class ComponentContainer { return this; } + @Override public <T> T getComponentByType(Class<T> type) { return pico.getComponent(type); } diff --git a/sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java b/sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java new file mode 100644 index 00000000000..64d6f1c8d1a --- /dev/null +++ b/sonar-core/src/main/java/org/sonar/core/platform/ContainerPopulator.java @@ -0,0 +1,32 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2014 SonarSource + * mailto:contact AT sonarsource DOT com + * + * SonarQube is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * SonarQube 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonar.core.platform; + +public interface ContainerPopulator<T extends ContainerPopulator.Container> { + void populateContainer(T container); + + interface Container { + Container add(Object... objects); + + Container addSingletons(Iterable<?> components); + + <T> T getComponentByType(Class<T> type); + } +} |