1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.vfs.internal

File VfsAttachDriverRegistrationListener.java

 

Coverage histogram

../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
4
3
1
82
42
3
0.75
1.33
3
1

Classes

Class Line # Actions
VfsAttachDriverRegistrationListener 49 4 0% 3 0
1.0100%
 

Contributing tests

No tests hitting this source file were found.

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.vfs.internal;
21   
22    import java.util.Arrays;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
27    import javax.inject.Provider;
28    import javax.inject.Singleton;
29   
30    import org.xwiki.bridge.event.ApplicationReadyEvent;
31    import org.xwiki.component.annotation.Component;
32    import org.xwiki.component.manager.ComponentManager;
33    import org.xwiki.observation.EventListener;
34    import org.xwiki.observation.event.Event;
35    import org.xwiki.vfs.internal.attach.AttachDriver;
36   
37    import net.java.truevfs.access.TArchiveDetector;
38    import net.java.truevfs.access.TConfig;
39   
40    /**
41    * Register the XWiki custom "attach" VFS driver.
42    *
43    * @version $Id: ad3a5bb51e0d19bf711149a142d60c505dc23347 $
44    * @since 7.4.1
45    */
46    @Component
47    @Named("vfsAttachDriver")
48    @Singleton
 
49    public class VfsAttachDriverRegistrationListener implements EventListener
50    {
51    /**
52    * The name of the listener.
53    */
54    private static final String NAME = "vfsAttachDriver";
55   
56    @Inject
57    @Named("context")
58    private Provider<ComponentManager> componentManagerProvider;
59   
 
60  4 toggle @Override
61    public String getName()
62    {
63  4 return NAME;
64    }
65   
 
66  1 toggle @Override
67    public List<Event> getEvents()
68    {
69  1 return Arrays.<Event>asList(new ApplicationReadyEvent());
70    }
71   
 
72  1 toggle @Override
73    public void onEvent(Event event, Object source, Object data)
74    {
75    // Register our Attach VFS Driver and inject a Component Manager in it.
76  1 TConfig config = TConfig.current();
77    // Note: Make sure we add our own Archive Detector to the existing Detector so that all archive formats
78    // supported by TrueVFS are handled properly.
79  1 config.setArchiveDetector(new TArchiveDetector(config.getArchiveDetector(), "attach",
80    new AttachDriver(this.componentManagerProvider.get())));
81    }
82    }