Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

XCOMMONS-147: Rename Component.lookupComponent() methods to getInstan…

…ce()

* Rename the List and Map APIs.
  • Loading branch information...
commit bd276eb79c7b662ece98cb9d8d6860692f0205aa 1 parent ea0554d
Vincent Massol vmassol authored
8 ...iki-commons-component-api/src/main/java/org/xwiki/component/internal/multi/DelegateComponentManager.java
View
@@ -84,15 +84,15 @@ public boolean hasComponent(Type role, String hint)
}
@Override
- public <T> List<T> lookupList(Type role) throws ComponentLookupException
+ public <T> List<T> getInstanceList(Type role) throws ComponentLookupException
{
- return getComponentManager().lookupList(role);
+ return getComponentManager().getInstanceList(role);
}
@Override
- public <T> Map<String, T> lookupMap(Type role) throws ComponentLookupException
+ public <T> Map<String, T> getInstanceMap(Type role) throws ComponentLookupException
{
- return getComponentManager().lookupMap(role);
+ return getComponentManager().getInstanceMap(role);
}
@Override
10 ...ns-component/xwiki-commons-component-api/src/main/java/org/xwiki/component/manager/ComponentManager.java
View
@@ -93,9 +93,9 @@
* @return the components
* @param <T> the type of the components role
* @throws ComponentLookupException if any error happen during component search
- * @since 4.0M1
+ * @since 4.0RC1
*/
- <T> List<T> lookupList(Type role) throws ComponentLookupException;
+ <T> List<T> getInstanceList(Type role) throws ComponentLookupException;
/**
* Find all the components implementing the provided role and organize then in a {@link Map} with role hint as key.
@@ -106,7 +106,7 @@
* @throws ComponentLookupException if any error happen during component search
* @since 4.0M1
*/
- <T> Map<String, T> lookupMap(Type role) throws ComponentLookupException;
+ <T> Map<String, T> getInstanceMap(Type role) throws ComponentLookupException;
/**
* Add a component in the component repository dynamically.
@@ -249,7 +249,7 @@
* @return the components
* @param <T> the type of the components role
* @throws ComponentLookupException if any error happen during component search
- * @deprecated since 4.0M1 use {@link #lookupList(Type)} instead
+ * @deprecated since 4.0M1 use {@link #getInstanceList} instead
*/
@Deprecated
<T> List<T> lookupList(Class<T> role) throws ComponentLookupException;
@@ -261,7 +261,7 @@
* @return the components
* @param <T> the type of the components role
* @throws ComponentLookupException if any error happen during component search
- * @deprecated since 4.0M1 use {@link #lookupMap(Type)} instead
+ * @deprecated since 4.0M1 use {@link #getInstanceMap} instead
*/
@Deprecated
<T> Map<String, T> lookupMap(Class<T> role) throws ComponentLookupException;
18 .../xwiki-commons-component-default/src/main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
View
@@ -150,18 +150,18 @@ public boolean hasComponent(Type role, String hint)
}
@Override
- public <T> List<T> lookupList(Type role) throws ComponentLookupException
+ public <T> List<T> getInstanceList(Type role) throws ComponentLookupException
{
- // Reuse lookupMap to make sure to not return components from parent Component Manager overridden by this
+ // Reuse getInstanceMap to make sure to not return components from parent Component Manager overridden by this
// Component Manager
- Map<String, T> objects = lookupMap(role);
+ Map<String, T> objects = getInstanceMap(role);
return objects.isEmpty() ? Collections.<T> emptyList() : new ArrayList<T>(objects.values());
}
@Override
@SuppressWarnings("unchecked")
- public <T> Map<String, T> lookupMap(Type role) throws ComponentLookupException
+ public <T> Map<String, T> getInstanceMap(Type role) throws ComponentLookupException
{
Map<String, T> objects = new HashMap<String, T>();
@@ -180,7 +180,7 @@ public boolean hasComponent(Type role, String hint)
// Add parent's list of components
if (getParent() != null) {
// If the hint already exists in the children Component Manager then don't add the one from the parent.
- for (Map.Entry<String, T> entry : getParent().<T> lookupMap(role).entrySet()) {
+ for (Map.Entry<String, T> entry : getParent().<T>getInstanceMap(role).entrySet()) {
if (!objects.containsKey(entry.getKey())) {
objects.put(entry.getKey(), entry.getValue());
}
@@ -279,9 +279,9 @@ public void setParent(ComponentManager parentComponentManager)
if (dependencyRoleClass.isAssignableFrom(Logger.class)) {
fieldValue = createLogger(instance.getClass());
} else if (dependencyRoleClass.isAssignableFrom(List.class)) {
- fieldValue = lookupList(ReflectionUtils.getLastTypeGenericArgument(dependency.getRoleType()));
+ fieldValue = getInstanceList(ReflectionUtils.getLastTypeGenericArgument(dependency.getRoleType()));
} else if (dependencyRoleClass.isAssignableFrom(Map.class)) {
- fieldValue = lookupMap(ReflectionUtils.getLastTypeGenericArgument(dependency.getRoleType()));
+ fieldValue = getInstanceMap(ReflectionUtils.getLastTypeGenericArgument(dependency.getRoleType()));
} else if (dependencyRoleClass.isAssignableFrom(Provider.class)) {
try {
fieldValue = getInstance(dependency.getRoleType(), dependency.getRoleHint());
@@ -545,14 +545,14 @@ private void removeComponent(RoleHint< ? > roleHint) throws ComponentLifecycleEx
@Deprecated
public <T> List<T> lookupList(Class<T> role) throws ComponentLookupException
{
- return lookupList((Type) role);
+ return getInstanceList((Type) role);
}
@Override
@Deprecated
public <T> Map<String, T> lookupMap(Class<T> role) throws ComponentLookupException
{
- return lookupMap((Type) role);
+ return getInstanceMap((Type) role);
}
@Override
4 ...s-component/xwiki-commons-component-default/src/main/java/org/xwiki/component/embed/GenericProvider.java
View
@@ -85,11 +85,11 @@ public T get()
}
} else if (roleClass.isAssignableFrom(List.class)) {
component =
- (T) this.componentManager.lookupList(ReflectionUtils.getLastTypeGenericArgument(this.roleHint
+ (T) this.componentManager.getInstanceList(ReflectionUtils.getLastTypeGenericArgument(this.roleHint
.getRoleType()));
} else if (roleClass.isAssignableFrom(Map.class)) {
component =
- (T) this.componentManager.lookupMap(ReflectionUtils.getLastTypeGenericArgument(this.roleHint
+ (T) this.componentManager.getInstanceMap(ReflectionUtils.getLastTypeGenericArgument(this.roleHint
.getRoleType()));
} else if (ReflectionUtils.getDirectAnnotation(ComponentRole.class, roleClass) != null
&& ReflectionUtils.getDirectAnnotation(Role.class, roleClass) == null) {
Please sign in to comment.
Something went wrong with that request. Please try again.