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

File InstanceOutputFilterStreamFactory.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart6.png
69% of files have more coverage

Code metrics

2
22
3
1
113
73
6
0.27
7.33
3
2

Classes

Class Line # Actions
InstanceOutputFilterStreamFactory 55 22 0% 6 11
0.592592659.3%
 

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.filter.instance.internal.output;
21   
22    import java.util.Collection;
23    import java.util.HashSet;
24    import java.util.List;
25    import java.util.Set;
26   
27    import javax.inject.Inject;
28    import javax.inject.Named;
29    import javax.inject.Provider;
30    import javax.inject.Singleton;
31   
32    import org.xwiki.component.annotation.Component;
33    import org.xwiki.component.manager.ComponentLookupException;
34    import org.xwiki.component.manager.ComponentManager;
35    import org.xwiki.component.phase.InitializationException;
36    import org.xwiki.filter.FilterException;
37    import org.xwiki.filter.descriptor.CompositeFilterStreamDescriptor;
38    import org.xwiki.filter.descriptor.FilterStreamDescriptor;
39    import org.xwiki.filter.instance.internal.InstanceUtils;
40    import org.xwiki.filter.instance.output.InstanceOutputProperties;
41    import org.xwiki.filter.instance.output.OutputInstanceFilterStreamFactory;
42    import org.xwiki.filter.output.AbstractBeanOutputFilterStreamFactory;
43    import org.xwiki.filter.type.FilterStreamType;
44   
45    /**
46    * A generic xml output filter implementation. This class can be used as a test bench to validate various
47    * XMLInputStream wiki parsers.
48    *
49    * @version $Id: c9e24b41ae03164e5b5ec31c8157e2b28d6ab131 $
50    * @since 6.2M1
51    */
52    @Component
53    @Named(InstanceUtils.ROLEHINT)
54    @Singleton
 
55    public class InstanceOutputFilterStreamFactory extends
56    AbstractBeanOutputFilterStreamFactory<InstanceOutputProperties, Object>
57    {
58    @Inject
59    @Named("context")
60    private Provider<ComponentManager> componentManagerProvider;
61   
 
62  14 toggle public InstanceOutputFilterStreamFactory()
63    {
64  14 super(FilterStreamType.XWIKI_INSTANCE);
65   
66  14 setName("XWiki instance output stream");
67  14 setDescription("Setup XWiki instance from wiki events.");
68    }
69   
 
70  14 toggle @Override
71    public void initialize() throws InitializationException
72    {
73  14 super.initialize();
74   
75  14 List<OutputInstanceFilterStreamFactory> factories;
76  14 try {
77  14 factories = this.componentManagerProvider.get().getInstanceList(OutputInstanceFilterStreamFactory.class);
78    } catch (ComponentLookupException e) {
79  0 throw new InitializationException(
80    "Failed to get registered instance of OutputInstanceFilterStreamFactory components", e);
81    }
82   
83  14 FilterStreamDescriptor[] descriptors = new FilterStreamDescriptor[factories.size() + 1];
84   
85  14 descriptors[0] = this.descriptor;
86  40 for (int i = 0; i < factories.size(); ++i) {
87  26 descriptors[i + 1] = factories.get(i).getDescriptor();
88    }
89   
90  14 setDescriptor(new CompositeFilterStreamDescriptor(this.descriptor.getName(), this.descriptor.getDescription(),
91    descriptors));
92    }
93   
 
94  0 toggle @Override
95    public Collection<Class< ? >> getFilterInterfaces() throws FilterException
96    {
97  0 List<OutputInstanceFilterStreamFactory> factories;
98  0 try {
99  0 factories = this.componentManagerProvider.get().getInstanceList(OutputInstanceFilterStreamFactory.class);
100    } catch (ComponentLookupException e) {
101  0 throw new FilterException(
102    "Failed to get regsitered instance of OutputInstanceFilterStreamFactory components", e);
103    }
104   
105  0 Set<Class< ? >> filters = new HashSet<Class< ? >>();
106  0 filters.addAll(super.getFilterInterfaces());
107  0 for (OutputInstanceFilterStreamFactory factory : factories) {
108  0 filters.addAll(factory.getFilterInterfaces());
109    }
110   
111  0 return filters;
112    }
113    }