PageRenderTime 78ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/projects/maven-3.0.5/maven-compat/src/main/java/org/apache/maven/repository/legacy/resolver/conflict/DefaultConflictResolverFactory.java

https://gitlab.com/essere.lab.public/qualitas.class-corpus
Java | 80 lines | 33 code | 10 blank | 37 comment | 0 complexity | cb6201cdd8d279b0fefc879f67796a43 MD5 | raw file
  1. package org.apache.maven.repository.legacy.resolver.conflict;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.codehaus.plexus.PlexusConstants;
  21. import org.codehaus.plexus.PlexusContainer;
  22. import org.codehaus.plexus.component.annotations.Component;
  23. import org.codehaus.plexus.component.annotations.Requirement;
  24. import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
  25. import org.codehaus.plexus.context.Context;
  26. import org.codehaus.plexus.context.ContextException;
  27. import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
  28. /**
  29. * A conflict resolver factory that obtains instances from a plexus container.
  30. *
  31. * @author <a href="mailto:markhobson@gmail.com">Mark Hobson</a>
  32. * @todo you don't need the container in here with the active maps (jvz).
  33. * @since 3.0
  34. */
  35. @Component( role = ConflictResolverFactory.class )
  36. public class DefaultConflictResolverFactory
  37. implements ConflictResolverFactory, Contextualizable
  38. {
  39. // fields -----------------------------------------------------------------
  40. /**
  41. * The plexus container used to obtain instances from.
  42. */
  43. @Requirement
  44. private PlexusContainer container;
  45. // ConflictResolverFactory methods ----------------------------------------
  46. /*
  47. * @see org.apache.maven.artifact.resolver.conflict.ConflictResolverFactory#getConflictResolver(java.lang.String)
  48. */
  49. public ConflictResolver getConflictResolver( String type )
  50. throws ConflictResolverNotFoundException
  51. {
  52. try
  53. {
  54. return (ConflictResolver) container.lookup( ConflictResolver.ROLE, type );
  55. }
  56. catch ( ComponentLookupException exception )
  57. {
  58. throw new ConflictResolverNotFoundException( "Cannot find conflict resolver of type: " + type );
  59. }
  60. }
  61. // Contextualizable methods -----------------------------------------------
  62. /*
  63. * @see org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable#contextualize(org.codehaus.plexus.context.Context)
  64. */
  65. public void contextualize( Context context )
  66. throws ContextException
  67. {
  68. container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
  69. }
  70. }