1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.extension.repository.aether.internal.components

File PlexusContainerProvider.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart9.png
38% of files have more coverage

Code metrics

0
8
2
1
77
40
3
0.38
4
2
1.5

Classes

Class Line # Actions
PlexusContainerProvider 45 8 0% 3 1
0.990%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.extension.repository.aether.internal.components;
21   
22    import javax.inject.Inject;
23    import javax.inject.Provider;
24    import javax.inject.Singleton;
25   
26    import org.codehaus.plexus.ContainerConfiguration;
27    import org.codehaus.plexus.DefaultContainerConfiguration;
28    import org.codehaus.plexus.DefaultPlexusContainer;
29    import org.codehaus.plexus.PlexusConstants;
30    import org.codehaus.plexus.PlexusContainer;
31    import org.codehaus.plexus.PlexusContainerException;
32    import org.slf4j.Logger;
33    import org.xwiki.component.annotation.Component;
34    import org.xwiki.component.phase.Initializable;
35    import org.xwiki.component.phase.InitializationException;
36   
37    /**
38    * Provide easy access to singleton {@link PlexusContainer}.
39    *
40    * @version $Id: e7db152dcb2b445271d525390eeb1c2cc4e82bd3 $
41    * @since 5.2M1
42    */
43    @Component
44    @Singleton
 
45    public class PlexusContainerProvider implements Provider<PlexusContainer>, Initializable
46    {
47    /**
48    * The logger to log.
49    */
50    @Inject
51    private Logger logger;
52   
53    /**
54    * In-process maven runtime.
55    */
56    private DefaultPlexusContainer plexusContainer;
57   
 
58  25 toggle @Override
59    public void initialize() throws InitializationException
60    {
61  25 try {
62  25 ContainerConfiguration config = new DefaultContainerConfiguration();
63  25 config.setAutoWiring(true);
64  25 config.setClassPathScanning(PlexusConstants.SCANNING_INDEX);
65  25 this.plexusContainer = new DefaultPlexusContainer(config);
66  25 this.plexusContainer.setLoggerManager(new XWikiLoggerManager(this.logger));
67    } catch (PlexusContainerException e) {
68  0 throw new InitializationException("Failed to initialize Maven", e);
69    }
70    }
71   
 
72  71 toggle @Override
73    public PlexusContainer get()
74    {
75  71 return this.plexusContainer;
76    }
77    }