Permalink
Browse files

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

…ce()
  • Loading branch information...
vmassol committed Apr 6, 2012
1 parent 66b2a58 commit ea0554d77789e527b30f4191044edd50fc921e8d
Showing with 69 additions and 69 deletions.
  1. +1 −1 ...classloader-api/src/main/java/org/xwiki/classloader/internal/ExtendedURLStreamHandlerFactory.java
  2. +4 −4 ...mons-component-api/src/main/java/org/xwiki/component/internal/multi/DelegateComponentManager.java
  3. +5 −5 ...onent/xwiki-commons-component-api/src/main/java/org/xwiki/component/manager/ComponentManager.java
  4. +7 −7 ...commons-component-default/src/main/java/org/xwiki/component/embed/EmbeddableComponentManager.java
  5. +3 −3 ...nent/xwiki-commons-component-default/src/main/java/org/xwiki/component/embed/GenericProvider.java
  6. +3 −3 ...configuration-api/src/main/java/org/xwiki/configuration/internal/ConfigurationSourceProvider.java
  7. +1 −1 ...mons-environment-servlet/src/test/java/org/xwiki/environment/internal/ServletEnvironmentTest.java
  8. +1 −1 ...ns-environment/xwiki-commons-environment-standard/src/main/java/org/xwiki/environment/System.java
  9. +2 −2 ...nvironment/xwiki-commons-environment-standard/src/test/java/org/xwiki/environment/SystemTest.java
  10. +1 −1 ...ns-environment-standard/src/test/java/org/xwiki/environment/internal/StandardEnvironmentTest.java
  11. +1 −1 ...ension-api/src/main/java/org/xwiki/extension/handler/internal/DefaultExtensionHandlerManager.java
  12. +2 −2 ...mons-extension-api/src/main/java/org/xwiki/extension/internal/safe/DefaultScriptSafeProvider.java
  13. +1 −1 ...-api/src/main/java/org/xwiki/extension/repository/internal/DefaultExtensionRepositoryManager.java
  14. +1 −1 ...s-extension-api/src/main/java/org/xwiki/extension/repository/internal/local/ExtensionStorage.java
  15. +1 −1 ...-extension-api/src/test/java/org/xwiki/extension/internal/DefaultExtensionLicenseManagerTest.java
  16. +1 −1 ...sion-api/src/test/java/org/xwiki/extension/internal/DefaultExtensionManagerConfigurationTest.java
  17. +1 −1 ...on/xwiki-commons-extension-api/src/test/java/org/xwiki/extension/job/internal/InstallJobTest.java
  18. +1 −1 .../xwiki-commons-extension-api/src/test/java/org/xwiki/extension/job/internal/UninstallJobTest.java
  19. +1 −1 ...xtension-api/src/test/java/org/xwiki/extension/repository/DefaultCoreExtensionRepositoryTest.java
  20. +3 −3 ...ion-api/src/test/java/org/xwiki/extension/repository/DefaultInstalledExtensionRepositoryTest.java
  21. +1 −1 ...tension-api/src/test/java/org/xwiki/extension/repository/DefaultLocalExtensionRepositoryTest.java
  22. +1 −1 ...ension-api/src/test/java/org/xwiki/extension/repository/local/DefaultExtensionSerializerTest.java
  23. +3 −3 ...ki-commons-extension-api/src/test/java/org/xwiki/extension/test/AbstractExtensionHandlerTest.java
  24. +1 −1 ...n/xwiki-commons-extension-api/src/test/java/org/xwiki/extension/test/FileExtensionRepository.java
  25. +3 −3 ...-extension/xwiki-commons-extension-api/src/test/java/org/xwiki/extension/test/RepositoryUtil.java
  26. +1 −1 ...iki-commons-extension-api/src/test/java/org/xwiki/extension/test/ResourceExtensionRepository.java
  27. +1 −1 ...nsion-handler-jar/src/main/java/org/xwiki/extension/jar/internal/handler/JarExtensionHandler.java
  28. +10 −10 ...-commons-extension-handler-jar/src/test/java/org/xwiki/extension/jar/JarExtensionHandlerTest.java
  29. +2 −2 ...ether/src/main/java/org/xwiki/extension/repository/aether/internal/AetherExtensionRepository.java
  30. +2 −2 .../test/java/org/xwiki/extension/repository/aether/internal/AetherDefaultRepositoryManagerTest.java
  31. +1 −1 xwiki-commons-core/xwiki-commons-job/src/main/java/org/xwiki/job/internal/DefaultJobManager.java
  32. +1 −1 ...i-commons-core/xwiki-commons-job/src/test/java/org/xwiki/job/internal/DefaultJobProgressTest.java
  33. +1 −1 ...ommons-core/xwiki-commons-test/src/main/java/org/xwiki/test/AbstractMockingComponentTestCase.java
@@ -51,7 +51,7 @@ public URLStreamHandler createURLStreamHandler(String protocol)
{
ExtendedURLStreamHandler result;
try {
- result = this.componentManager.lookupComponent(ExtendedURLStreamHandler.class, protocol);
+ result = this.componentManager.getInstance(ExtendedURLStreamHandler.class, protocol);
} catch (ComponentLookupException cle) {
// No special protocol handler found, return null since code using this factory
// should know how to deal when no protocol handler is found.
@@ -72,15 +72,15 @@ public boolean hasComponent(Type role, String hint)
}
@Override
- public <T> T lookupComponent(Type roleType) throws ComponentLookupException
+ public <T> T getInstance(Type roleType) throws ComponentLookupException
{
- return getComponentManager().lookupComponent(roleType);
+ return getComponentManager().getInstance(roleType);
}
@Override
- public <T> T lookupComponent(Type roleType, String roleHint) throws ComponentLookupException
+ public <T> T getInstance(Type roleType, String roleHint) throws ComponentLookupException
{
- return getComponentManager().lookupComponent(roleType, roleHint);
+ return getComponentManager().getInstance(roleType, roleHint);
}
@Override
@@ -58,9 +58,9 @@
* @param roleType the class (aka role) that the component implements
* @return the component instance
* @throws ComponentLookupException in case the component cannot be found
- * @since 4.0M1
+ * @since 4.0RC1
*/
- <T> T lookupComponent(Type roleType) throws ComponentLookupException;
+ <T> T getInstance(Type roleType) throws ComponentLookupException;
/**
* Find a component instance that implements that passed interface class. If the component has a singleton lifecycle
@@ -72,9 +72,9 @@
* registered with a hint; the "default" hint being the default)
* @return the component instance
* @throws ComponentLookupException in case the component cannot be found
- * @since 4.0M1
+ * @since 4.0RC1
*/
- <T> T lookupComponent(Type roleType, String roleHint) throws ComponentLookupException;
+ <T> T getInstance(Type roleType, String roleHint) throws ComponentLookupException;
/**
* Release the provided singleton instance but don't unregister the component descriptor. This means that next time
@@ -223,7 +223,7 @@
* @param role the class (aka role) that the component implements
* @return the component instance
* @throws ComponentLookupException in case the component cannot be found
- * @deprecated since 4.0M1 use {@link #lookupComponent(Type)} iinstead
+ * @deprecated since 4.0M1 use {@link #getInstance} iinstead
*/
@Deprecated
<T> T lookup(Class<T> role) throws ComponentLookupException;
@@ -138,13 +138,13 @@ public boolean hasComponent(Type role, String hint)
}
@Override
- public <T> T lookupComponent(Type roleType) throws ComponentLookupException
+ public <T> T getInstance(Type roleType) throws ComponentLookupException
{
return getComponentInstance(new RoleHint<T>(roleType));
}
@Override
- public <T> T lookupComponent(Type roleType, String roleHint) throws ComponentLookupException
+ public <T> T getInstance(Type roleType, String roleHint) throws ComponentLookupException
{
return getComponentInstance(new RoleHint<T>(roleType, roleHint));
}
@@ -284,15 +284,15 @@ public void setParent(ComponentManager parentComponentManager)
fieldValue = lookupMap(ReflectionUtils.getLastTypeGenericArgument(dependency.getRoleType()));
} else if (dependencyRoleClass.isAssignableFrom(Provider.class)) {
try {
- fieldValue = lookupComponent(dependency.getRoleType(), dependency.getRoleHint());
+ fieldValue = getInstance(dependency.getRoleType(), dependency.getRoleHint());
} catch (ComponentLookupException e) {
fieldValue =
new GenericProvider<Object>(this, new RoleHint<Object>(
ReflectionUtils.getLastTypeGenericArgument(dependency.getRoleType()),
dependency.getRoleHint()));
}
} else {
- fieldValue = lookupComponent(dependency.getRoleType(), dependency.getRoleHint());
+ fieldValue = getInstance(dependency.getRoleType(), dependency.getRoleHint());
}
// Set the field by introspection
@@ -333,7 +333,7 @@ protected Object createLogger(Class< ? > instanceClass)
}
} else {
if (getParent() != null) {
- instance = getParent().lookupComponent(roleHint.getRoleClass(), roleHint.getHint());
+ instance = getParent().getInstance(roleHint.getRoleClass(), roleHint.getHint());
} else {
throw new ComponentLookupException("Can't find descriptor for the component [" + roleHint + "]");
}
@@ -531,14 +531,14 @@ private void removeComponent(RoleHint< ? > roleHint) throws ComponentLifecycleEx
@Deprecated
public <T> T lookup(Class<T> role) throws ComponentLookupException
{
- return lookupComponent(role);
+ return getInstance(role);
}
@Override
@Deprecated
public <T> T lookup(Class<T> role, String hint) throws ComponentLookupException
{
- return lookupComponent(role, hint);
+ return getInstance(role, hint);
}
@Override
@@ -75,7 +75,7 @@ public T get()
if (roleClass.isAssignableFrom(Provider.class)) {
try {
component =
- this.componentManager.lookupComponent(this.roleHint.getRoleType(), this.roleHint.getHint());
+ this.componentManager.getInstance(this.roleHint.getRoleType(), this.roleHint.getHint());
} catch (ComponentLookupException e) {
// Inject a default Provider
component =
@@ -94,9 +94,9 @@ public T get()
} else if (ReflectionUtils.getDirectAnnotation(ComponentRole.class, roleClass) != null
&& ReflectionUtils.getDirectAnnotation(Role.class, roleClass) == null) {
// since 4.0M1, retro-compatibility (generic type used to not be taken into account)
- component = this.componentManager.lookupComponent(roleClass, this.roleHint.getHint());
+ component = this.componentManager.getInstance(roleClass, this.roleHint.getHint());
} else {
- component = this.componentManager.lookupComponent(this.roleHint.getRoleType(), this.roleHint.getHint());
+ component = this.componentManager.getInstance(this.roleHint.getRoleType(), this.roleHint.getHint());
}
} catch (Exception e) {
throw new RuntimeException("Failed to get [" + this.roleHint + "]", e);
@@ -50,10 +50,10 @@ public ConfigurationSource get()
ConfigurationSource configurationSource;
try {
- configurationSource = this.componentManager.lookupComponent(ConfigurationSource.class);
+ configurationSource = this.componentManager.getInstance(ConfigurationSource.class);
} catch (ComponentLookupException e) {
try {
- configurationSource = this.componentManager.lookupComponent(ConfigurationSource.class, "memory");
+ configurationSource = this.componentManager.getInstance(ConfigurationSource.class, "memory");
} catch (ComponentLookupException e1) {
configurationSource = getVoidConfigurationSource();
}
@@ -70,7 +70,7 @@ private ConfigurationSource getVoidConfigurationSource()
ConfigurationSource configurationSource;
try {
- configurationSource = this.componentManager.lookupComponent(ConfigurationSource.class, "void");
+ configurationSource = this.componentManager.getInstance(ConfigurationSource.class, "void");
} catch (ComponentLookupException e) {
configurationSource = new VoidConfigurationSource();
}
@@ -56,7 +56,7 @@ public void setUp() throws Exception
{
EmbeddableComponentManager ecm = new EmbeddableComponentManager();
ecm.initialize(getClass().getClassLoader());
- this.environment = (ServletEnvironment) ecm.lookupComponent(Environment.class);
+ this.environment = (ServletEnvironment) ecm.getInstance(Environment.class);
}
@Test
@@ -126,7 +126,7 @@ public static ComponentManager initialize(File permanentDirectory, File resource
// Step 2: Initialize Environment
StandardEnvironment environment;
try {
- environment = (StandardEnvironment) ecm.lookupComponent(Environment.class);
+ environment = (StandardEnvironment) ecm.getInstance(Environment.class);
} catch (ComponentLookupException e) {
throw new RuntimeException("Failed to find Standard Environment", e);
}
@@ -41,7 +41,7 @@ public void testInitializeWithNoParameter() throws Exception
ComponentManager componentManager = System.initialize();
Assert.assertNotNull(componentManager);
- Environment environment = componentManager.lookupComponent(Environment.class);
+ Environment environment = componentManager.getInstance(Environment.class);
// Capture logs so that they don't leak in the test console
ReflectionUtils.setFieldValue(environment, "logger", NOPLogger.NOP_LOGGER);
@@ -66,7 +66,7 @@ public void testInitializeWithAllDirectoriesSet() throws Exception
temporaryDirectory);
Assert.assertNotNull(componentManager);
- Environment environment = componentManager.lookupComponent(Environment.class);
+ Environment environment = componentManager.getInstance(Environment.class);
// Verify the temporary directory
Assert.assertEquals(temporaryDirectory, environment.getTemporaryDirectory());
@@ -55,7 +55,7 @@ public void setUp() throws Exception
{
EmbeddableComponentManager ecm = new EmbeddableComponentManager();
ecm.initialize(getClass().getClassLoader());
- this.environment = (StandardEnvironment) ecm.lookupComponent(Environment.class);
+ this.environment = (StandardEnvironment) ecm.getInstance(Environment.class);
}
@Test
@@ -63,7 +63,7 @@
*/
private ExtensionHandler getExtensionHandler(LocalExtension localExtension) throws ComponentLookupException
{
- return this.componentManager.lookupComponent(ExtensionHandler.class, localExtension.getType().toLowerCase());
+ return this.componentManager.getInstance(ExtensionHandler.class, localExtension.getType().toLowerCase());
}
@Override
@@ -101,15 +101,15 @@ private Object get(Object unsafe, Type type)
{
try {
ScriptSafeProvider<Object> provider =
- this.component.lookupComponent(new DefaultParameterizedType(null, ScriptSafeProvider.class, type));
+ this.component.getInstance(new DefaultParameterizedType(null, ScriptSafeProvider.class, type));
return provider.get(unsafe);
} catch (ComponentLookupException e) {
// Try with raw type
if (type instanceof ParameterizedType) {
try {
ScriptSafeProvider<Object> provider =
- this.component.lookupComponent(((ParameterizedType) type).getRawType());
+ this.component.getInstance(((ParameterizedType) type).getRawType());
return provider.get(unsafe);
} catch (ComponentLookupException e1) {
@@ -107,7 +107,7 @@ public ExtensionRepository addRepository(ExtensionRepositoryId repositoryId) thr
try {
ExtensionRepositoryFactory repositoryFactory =
- this.componentManager.lookupComponent(ExtensionRepositoryFactory.class, repositoryId.getType());
+ this.componentManager.getInstance(ExtensionRepositoryFactory.class, repositoryId.getType());
repository = repositoryFactory.createRepository(repositoryId);
@@ -93,7 +93,7 @@ public ExtensionStorage(DefaultLocalExtensionRepository repository, File rootFol
this.rootFolder = rootFolder;
this.componentManager = componentManager;
- this.extensionSerializer = this.componentManager.lookupComponent(ExtensionSerializer.class);
+ this.extensionSerializer = this.componentManager.getInstance(ExtensionSerializer.class);
}
/**
@@ -39,7 +39,7 @@ public void setUp() throws Exception
{
super.setUp();
- this.licenseManager = getComponentManager().lookupComponent(ExtensionLicenseManager.class);
+ this.licenseManager = getComponentManager().getInstance(ExtensionLicenseManager.class);
}
@Test
@@ -44,7 +44,7 @@ public void setUp() throws Exception
// Register a Mocked Environment since we need to provide one.
registerMockComponent(Environment.class);
- this.configuration = getComponentManager().lookupComponent(ExtensionManagerConfiguration.class);
+ this.configuration = getComponentManager().getInstance(ExtensionManagerConfiguration.class);
}
@Test
@@ -39,7 +39,7 @@ public void setUp() throws Exception
// lookup
- this.handler = (TestExtensionHandler) getComponentManager().lookupComponent(ExtensionHandler.class, "type");
+ this.handler = (TestExtensionHandler) getComponentManager().getInstance(ExtensionHandler.class, "type");
}
@Test
@@ -41,7 +41,7 @@ public void setUp() throws Exception
// lookup
- this.handler = (TestExtensionHandler) getComponentManager().lookupComponent(ExtensionHandler.class, "type");
+ this.handler = (TestExtensionHandler) getComponentManager().getInstance(ExtensionHandler.class, "type");
// resources
@@ -43,7 +43,7 @@ public void setUp() throws Exception
registerMockComponent(Environment.class);
this.coreExtensionRepository =
- (ConfigurableDefaultCoreExtensionRepository) getComponentManager().lookupComponent(
+ (ConfigurableDefaultCoreExtensionRepository) getComponentManager().getInstance(
CoreExtensionRepository.class);
}
@@ -66,9 +66,9 @@ public void setUp() throws Exception
// lookup
- this.installedExtensionRepository = getComponentManager().lookupComponent(InstalledExtensionRepository.class);
- this.localExtensionRepository = getComponentManager().lookupComponent(LocalExtensionRepository.class);
- this.repositoryManager = getComponentManager().lookupComponent(ExtensionRepositoryManager.class);
+ this.installedExtensionRepository = getComponentManager().getInstance(InstalledExtensionRepository.class);
+ this.localExtensionRepository = getComponentManager().getInstance(LocalExtensionRepository.class);
+ this.repositoryManager = getComponentManager().getInstance(ExtensionRepositoryManager.class);
// resources
@@ -48,7 +48,7 @@ public void setUp() throws Exception
// lookup
- this.localExtensionRepository = getComponentManager().lookupComponent(LocalExtensionRepository.class);
+ this.localExtensionRepository = getComponentManager().getInstance(LocalExtensionRepository.class);
}
@Override
@@ -51,7 +51,7 @@ public void setUp() throws Exception
{
super.setUp();
- this.serializer = getComponentManager().lookupComponent(ExtensionSerializer.class);
+ this.serializer = getComponentManager().getInstance(ExtensionSerializer.class);
}
private DefaultLocalExtension serializeAndUnserialize(DefaultLocalExtension extension)
@@ -61,9 +61,9 @@ public void setUp() throws Exception
// lookup
- this.jobManager = getComponentManager().lookupComponent(JobManager.class);
- this.localExtensionRepository = getComponentManager().lookupComponent(LocalExtensionRepository.class);
- this.installedExtensionRepository = getComponentManager().lookupComponent(InstalledExtensionRepository.class);
+ this.jobManager = getComponentManager().getInstance(JobManager.class);
+ this.localExtensionRepository = getComponentManager().getInstance(LocalExtensionRepository.class);
+ this.installedExtensionRepository = getComponentManager().getInstance(InstalledExtensionRepository.class);
}
protected void beforeRepositoryUtil() throws Exception
@@ -53,7 +53,7 @@ public FileExtensionRepository(File directory, ComponentManager componentManager
{
super(new ExtensionRepositoryId("test-file", "file", null));
- this.extensionSerializer = componentManager.lookupComponent(ExtensionSerializer.class);
+ this.extensionSerializer = componentManager.getInstance(ExtensionSerializer.class);
this.directory = directory;
}
@@ -145,7 +145,7 @@ public void setup(Mockery mockery) throws Exception
registerComponent(ConfigurableDefaultCoreExtensionRepository.class);
((ConfigurableDefaultCoreExtensionRepository) this.componentManager
- .lookupComponent(CoreExtensionRepository.class)).addExtensions("coreextension", new DefaultVersion(
+ .getInstance(CoreExtensionRepository.class)).addExtensions("coreextension", new DefaultVersion(
"version"));
// copy
@@ -155,7 +155,7 @@ public void setup(Mockery mockery) throws Exception
// remote repositories
ExtensionRepositoryManager repositoryManager =
- this.componentManager.lookupComponent(ExtensionRepositoryManager.class);
+ this.componentManager.getInstance(ExtensionRepositoryManager.class);
// light remote repository
@@ -177,7 +177,7 @@ public void setup(Mockery mockery) throws Exception
// init
- this.componentManager.<ExtensionInitializer> lookupComponent(ExtensionInitializer.class).initialize();
+ this.componentManager.<ExtensionInitializer>getInstance(ExtensionInitializer.class).initialize();
}
public ComponentAnnotationLoader getComponentLoader()
@@ -54,7 +54,7 @@ public ResourceExtensionRepository(ClassLoader classLoader, String baseResource,
{
super(new ExtensionRepositoryId("test-resources", "resources", null));
- this.extensionSerializer = componentManager.lookupComponent(ExtensionSerializer.class);
+ this.extensionSerializer = componentManager.getInstance(ExtensionSerializer.class);
this.classLoader = classLoader;
this.baseResource = baseResource;
@@ -150,7 +150,7 @@ private void loadComponents(LocalExtensionFile jarFile, NamespaceURLClassLoader
}
stackingComponentEventManager.setObservationManager(componentManager
- .<ObservationManager> lookupComponent(ObservationManager.class));
+ .<ObservationManager>getInstance(ObservationManager.class));
stackingComponentEventManager.shouldStack(false);
stackingComponentEventManager.flushEvents();
}
Oops, something went wrong.

0 comments on commit ea0554d

Please sign in to comment.