4545import org .eclipse .osgi .util .NLS ;
4646
4747import org .eclipse .m2e .core .internal .Messages ;
48- import org .eclipse .m2e .core .ui .internal .M2EUIPluginActivator ;
4948import org .eclipse .m2e .core .ui .internal .archetype .ArchetypeCatalogFactory .LocalCatalogFactory ;
5049import org .eclipse .m2e .core .ui .internal .archetype .ArchetypeCatalogFactory .RemoteCatalogFactory ;
5150
@@ -78,13 +77,13 @@ public class ArchetypeCatalogsWriter {
7877
7978 public static final String ATT_CATALOG_ENABLED = "enabled" ;
8079
81- public Collection <ArchetypeCatalogFactory > readArchetypeCatalogs (InputStream is ,
82- Map <String , ArchetypeCatalogFactory > existingCatalogs ) throws IOException {
80+ Collection <ArchetypeCatalogFactory > readArchetypeCatalogs (InputStream is ,
81+ Map <String , ArchetypeCatalogFactory > existingCatalogs , ArchetypePlugin plugin ) throws IOException {
8382 Collection <ArchetypeCatalogFactory > catalogs = new ArrayList <>();
8483 try {
8584 SAXParserFactory parserFactory = SAXParserFactory .newInstance ();
8685 SAXParser parser = parserFactory .newSAXParser ();
87- parser .parse (is , new ArchetypeCatalogsContentHandler (catalogs , existingCatalogs ));
86+ parser .parse (is , new ArchetypeCatalogsContentHandler (catalogs , existingCatalogs , plugin ));
8887 } catch (SAXException ex ) {
8988 String msg = Messages .ArchetypeCatalogsWriter_error_parse ;
9089 log .error (msg , ex );
@@ -159,9 +158,12 @@ static class ArchetypeCatalogsContentHandler extends DefaultHandler {
159158
160159 private final Map <String , ArchetypeCatalogFactory > existingCatalogs ;
161160
161+ private ArchetypePlugin plugin ;
162+
162163 public ArchetypeCatalogsContentHandler (Collection <ArchetypeCatalogFactory > catalogs ,
163- Map <String , ArchetypeCatalogFactory > existingCatalogs ) {
164+ Map <String , ArchetypeCatalogFactory > existingCatalogs , ArchetypePlugin plugin ) {
164165 this .catalogs = catalogs ;
166+ this .plugin = plugin ;
165167 this .existingCatalogs = existingCatalogs == null ? Collections .emptyMap () : existingCatalogs ;
166168 }
167169
@@ -175,14 +177,14 @@ public void startElement(String uri, String localName, String qName, Attributes
175177 String path = attributes .getValue (ATT_CATALOG_LOCATION );
176178 if (path != null ) {
177179 String description = attributes .getValue (ATT_CATALOG_DESCRIPTION );
178- catalogs .add (M2EUIPluginActivator . getDefault (). getArchetypePlugin () .newLocalCatalogFactory (path ,
180+ catalogs .add (plugin .newLocalCatalogFactory (path ,
179181 description , true , enabled ));
180182 }
181183 } else if (TYPE_REMOTE .equals (type )) {
182184 String url = attributes .getValue (ATT_CATALOG_LOCATION );
183185 if (url != null ) {
184186 String description = attributes .getValue (ATT_CATALOG_DESCRIPTION );
185- catalogs .add (M2EUIPluginActivator . getDefault (). getArchetypePlugin () .newRemoteCatalogFactory (url ,
187+ catalogs .add (plugin .newRemoteCatalogFactory (url ,
186188 description , true , enabled ));
187189 }
188190 } else {
0 commit comments