コード例 #1
0
  @Initialize
  public void intialize() {
    String trimmedTemplateConfig = templateConfig.trim();

    // Only attempt to load as a template resource URI if the configured 'template'
    // value is all on one line.  If it has line breaks then we know it's not an
    // external resource...
    if (trimmedTemplateConfig.trim().indexOf('\n') == -1) {
      try {
        InputStream templateStream =
            appContext.getResourceLocator().getResource(trimmedTemplateConfig);
        if (templateStream != null) {
          templateConfig = StreamUtils.readStreamAsString(templateStream);
        }
      } catch (IOException e) {
        logger.debug(
            "'template' configuration value '"
                + trimmedTemplateConfig
                + "' does not resolve to an external FreeMarker template.  Using configured value as the actual template.");
      }
    }

    // Create the template instance...
    template = new FreeMarkerTemplate(templateConfig);
  }
コード例 #2
0
  /**
   * Set the resource configuration on the bean populator.
   *
   * @throws SmooksConfigurationException Incorrectly configured resource.
   */
  @Initialize
  public void initialize() throws SmooksConfigurationException {

    if (logger.isDebugEnabled()) {
      logger.debug("Initializing EntityLocatorParameterVisitor with name '" + name + "'");
    }

    beanWiring = wireBeanIdName != null;
    isAttribute = (valueAttributeName != null);

    beanIdStore = appContext.getBeanIdStore();

    if (parameterListType == ParameterListType.NAMED) {
      NamedParameterIndex parameterIndex =
          (NamedParameterIndex) ParameterManager.getParameterIndex(entityLocatorId, appContext);
      parameter = parameterIndex.register(name);
    } else {
      PositionalParameterIndex parameterIndex =
          (PositionalParameterIndex)
              ParameterManager.getParameterIndex(entityLocatorId, appContext);
      parameter = parameterIndex.register(index);
    }

    if (wireBeanIdName != null) {
      wireBeanId = beanIdStore.register(wireBeanIdName);
    }
  }