1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package com.xpn.xwiki.plugin.activitystream.plugin

File ActivityStreamPlugin.java

 

Coverage histogram

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

Code metrics

0
13
8
1
120
55
9
0.69
1.62
8
1.12

Classes

Class Line # Actions
ActivityStreamPlugin 35 13 0% 9 2
0.904761990.5%
 

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 com.xpn.xwiki.plugin.activitystream.plugin;
21   
22    import com.xpn.xwiki.XWikiContext;
23    import com.xpn.xwiki.api.Api;
24    import com.xpn.xwiki.plugin.XWikiDefaultPlugin;
25    import com.xpn.xwiki.plugin.XWikiPluginInterface;
26    import com.xpn.xwiki.plugin.activitystream.api.ActivityStream;
27    import com.xpn.xwiki.plugin.activitystream.impl.ActivityStreamImpl;
28   
29    /**
30    * Plug-in for for managing streams of activity events.
31    *
32    * @see ActivityStream
33    * @version $Id: 4bb22d59d5bcf5abfc7cb577a376ffbca2d1f28d $
34    */
 
35    public class ActivityStreamPlugin extends XWikiDefaultPlugin
36    {
37    /**
38    * Name of the plugin.
39    */
40    public static final String PLUGIN_NAME = "activitystream";
41   
42    /**
43    * We should user inversion of control instead.
44    */
45    private ActivityStream activityStream;
46   
47    /**
48    * Constructor.
49    *
50    * @see XWikiDefaultPlugin#XWikiDefaultPlugin(String,String,com.xpn.xwiki.XWikiContext)
51    * @param name name of the plugin
52    * @param className class name of the plugin
53    * @param context the XWiki context
54    */
 
55  1 toggle public ActivityStreamPlugin(String name, String className, XWikiContext context)
56    {
57  1 super(name, className, context);
58  1 setActivityStream(new ActivityStreamImpl());
59    }
60   
 
61  2 toggle @Override
62    public String getName()
63    {
64  2 return PLUGIN_NAME;
65    }
66   
 
67  110 toggle @Override
68    public Api getPluginApi(XWikiPluginInterface plugin, XWikiContext context)
69    {
70  110 return new ActivityStreamPluginApi((ActivityStreamPlugin) plugin, context);
71    }
72   
73    /**
74    * @return The {@link ActivityStream} component used in behind by this plug-in instance
75    */
 
76  111 toggle public ActivityStream getActivityStream()
77    {
78  111 return this.activityStream;
79    }
80   
81    /**
82    * @param activityStream The {@link ActivityStream} component to be used
83    */
 
84  1 toggle public void setActivityStream(ActivityStream activityStream)
85    {
86  1 this.activityStream = activityStream;
87    }
88   
89    /**
90    * Get a preference for the activitystream from the XWiki configuration.
91    *
92    * @param preference Name of the preference to get the value from
93    * @param defaultValue Default value if the preference is not found in the configuration
94    * @param context the XWiki context
95    * @return value for the given preference
96    */
 
97  1 toggle public String getActivityStreamPreference(String preference, String defaultValue, XWikiContext context)
98    {
99  1 String preferencePrefix = "xwiki.plugin.activitystream.";
100  1 String prefName = preferencePrefix + preference;
101  1 return context.getWiki().getXWikiPreference(prefName, prefName, defaultValue, context);
102    }
103   
 
104  1 toggle @Override
105    public void init(XWikiContext context)
106    {
107  1 super.init(context);
108  1 try {
109  1 this.activityStream.init(context);
110    } catch (Exception e) {
111    // Do nothing.
112    }
113    }
114   
 
115  0 toggle @Override
116    public void virtualInit(XWikiContext context)
117    {
118  0 super.virtualInit(context);
119    }
120    }