View Javadoc

1   package com.atlassian.plugin.web;
2   
3   import com.atlassian.plugin.Plugin;
4   import com.atlassian.plugin.web.conditions.ConditionLoadingException;
5   
6   import java.util.List;
7   import java.util.Map;
8   
9   /**
10   * Provides application specific methods to build/render web fragments
11   */
12  public interface WebFragmentHelper
13  {
14      /**
15       * Creates a condition instance.  The following process should be used:<ol>
16       * <li>Load the class via the plugin instance</li>
17       * <li>Instantiate the class using the plugin if it implements {@link com.atlassian.plugin.AutowireCapablePlugin}
18       * <li>If not, instantiate the class with the host container
19       *
20       * @param className the condition class name
21       * @param plugin the plugin from which the condition came
22       * @return the condition instance
23       * @throws ConditionLoadingException If the condition was unable to be created
24       */
25      Condition loadCondition(String className, Plugin plugin) throws ConditionLoadingException;
26  
27      /**
28       * Creates a context provider instance.  The following process should be used:<ol>
29       * <li>Load the class via the plugin instance</li>
30       * <li>Instantiate the class using the plugin if it implements {@link com.atlassian.plugin.AutowireCapablePlugin}
31       * <li>If not, instantiate the class with the host container
32       *
33       * @param className the context provider class name
34       * @param plugin the plugin from which the context provider came
35       * @return the context provider instance
36       * @throws ConditionLoadingException If the context provider was unable to be created
37       */
38      ContextProvider loadContextProvider(String className, Plugin plugin) throws ConditionLoadingException;
39  
40      /**
41       * Look up a message key in the application
42       *
43       * @param key The message key
44       * @param arguments The arguments to use to replace tokens with any expressions already processed
45       * @param context The context (optional)
46       * @return The text message
47       */
48      String getI18nValue(String key, List<?> arguments, Map<String,Object> context);
49  
50      /**
51       * Renders the string fragment as a Velocity template
52       *
53       * @param fragment The string fragment to render
54       * @param context The context to use as the base of the Velocity context
55       * @return The rendered string
56       */
57      String renderVelocityFragment(String fragment, Map<String,Object> context);
58  }