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

File InstanceOutputFilterStream.java

 

Coverage histogram

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

Code metrics

0
11
3
1
90
55
4
0.36
3.67
3
1.33

Classes

Class Line # Actions
InstanceOutputFilterStream 48 11 0% 4 1
0.928571492.9%
 

Contributing tests

This file is covered by 12 tests. .

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.io.IOException;
23    import java.util.List;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
27    import javax.inject.Provider;
28   
29    import org.xwiki.component.annotation.Component;
30    import org.xwiki.component.annotation.InstantiationStrategy;
31    import org.xwiki.component.descriptor.ComponentInstantiationStrategy;
32    import org.xwiki.component.manager.ComponentLookupException;
33    import org.xwiki.component.manager.ComponentManager;
34    import org.xwiki.filter.FilterDescriptorManager;
35    import org.xwiki.filter.FilterException;
36    import org.xwiki.filter.instance.internal.InstanceUtils;
37    import org.xwiki.filter.instance.output.InstanceOutputProperties;
38    import org.xwiki.filter.instance.output.OutputInstanceFilterStreamFactory;
39    import org.xwiki.filter.output.AbstractBeanOutputFilterStream;
40   
41    /**
42    * @version $Id: a9af1ee6f3075718551bd6b73d309667ae070cfe $
43    * @since 6.2M1
44    */
45    @Component
46    @Named(InstanceUtils.ROLEHINT)
47    @InstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP)
 
48    public class InstanceOutputFilterStream extends AbstractBeanOutputFilterStream<InstanceOutputProperties>
49    {
50    @Inject
51    private FilterDescriptorManager filterManager;
52   
53    @Inject
54    @Named("context")
55    private Provider<ComponentManager> componentManager;
56   
 
57  16 toggle @Override
58    public void setProperties(InstanceOutputProperties properties) throws FilterException
59    {
60  16 super.setProperties(properties);
61   
62  16 List<OutputInstanceFilterStreamFactory> factories;
63  16 try {
64  16 factories = this.componentManager.get().getInstanceList(OutputInstanceFilterStreamFactory.class);
65    } catch (ComponentLookupException e) {
66  0 throw new FilterException(
67    "Failed to get regsitered instance of OutputInstanceFilterStreamFactory components", e);
68    }
69   
70  16 Object[] filters = new Object[factories.size()];
71  16 int i = 0;
72  16 for (OutputInstanceFilterStreamFactory factory : factories) {
73  30 filters[i++] = factory.createOutputFilterStream(properties).getFilter();
74    }
75   
76  16 this.filter = this.filterManager.createCompositeFilter(filters);
77    }
78   
 
79  16 toggle @Override
80    public Object getFilter() throws FilterException
81    {
82  16 return this.filter;
83    }
84   
 
85  16 toggle @Override
86    public void close() throws IOException
87    {
88    // Nothing to close
89    }
90    }