public void afterPropertiesSet() throws Exception {
    if (pluginCacheMillis == Long.MIN_VALUE) {
      pluginCacheMillis = cacheMillis;
    }

    if (pluginManager == null || localResourceLoader == null) {
      return;
    }

    for (GrailsPlugin plugin : pluginManager.getAllPlugins()) {
      for (Resource pluginBundle : getPluginBundles(plugin)) {
        // If the plugin is an inline plugin, use the abosolute path to the plugin's i18n files.
        // Otherwise, use the relative path to the plugin from the application's perspective.
        String basePath;
        if (isInlinePlugin(plugin)) {
          basePath = getInlinePluginPath(plugin);
        } else {
          basePath = WEB_INF_PLUGINS_PATH.substring(1) + plugin.getFileSystemName();
        }

        final String baseName =
            GrailsStringUtils.substringBefore(
                GrailsStringUtils.getFileBasename(pluginBundle.getFilename()), "_");
        String pathToAdd = basePath + GRAILS_APP_I18N_PATH_COMPONENT + baseName;
        if (!pluginBaseNames.contains(pathToAdd)) {
          pluginBaseNames.add(pathToAdd);
        }
      }
    }
  }
コード例 #2
0
 protected Resource findResourceInBinaryPlugins(PluginResourceInfo info) {
   if (pluginManager != null) {
     String fullPluginName = info.pluginName;
     for (GrailsPlugin plugin : pluginManager.getAllPlugins()) {
       if (plugin.getFileSystemName().equals(fullPluginName)
           && (plugin instanceof BinaryGrailsPlugin)) {
         return ((BinaryGrailsPlugin) plugin).getResource(info.uri);
       }
     }
   }
   return null;
 }
 protected void mergeBinaryPluginProperties(final Locale locale, Properties mergedProps) {
   final GrailsPlugin[] allPlugins = pluginManager.getAllPlugins();
   for (GrailsPlugin plugin : allPlugins) {
     if (plugin instanceof BinaryGrailsPlugin) {
       BinaryGrailsPlugin binaryPlugin = (BinaryGrailsPlugin) plugin;
       final Properties binaryPluginProperties = binaryPlugin.getProperties(locale);
       if (binaryPluginProperties != null) {
         mergedProps.putAll(binaryPluginProperties);
       }
     }
   }
 }