/** * * @param compositeRuleName The composite rule name in the form ruleProvider.ruleName. * @return {@code String} The rule provider name part of the composite rule name. */ public static String parseRuleProviderName(final String compositeRuleName) { final int lastIndexOfDot = compositeRuleName.indexOf('.'); if (lastIndexOfDot == -1) { throwInvalidCompositeRuleName(compositeRuleName); } return compositeRuleName.substring(0, lastIndexOfDot); }
@ConfigParam (name="name") public void setCompositRuleName(final String compositRuleName) { this.compositRuleName = compositRuleName; this.ruleProviderName = RuleProviderAccessor.parseRuleProviderName(compositRuleName); this.ruleName = RuleProviderAccessor.parseRuleName(compositRuleName); }
/** * Adds the passed-in provider to the Smooks {@link ApplicationContext}. * * @param context The Smooks {@link ApplicationContext}. * @param provider The {@link RuleProvider} that is to be added. */ public static final void add(final ApplicationContext context, final RuleProvider provider) { AssertArgument.isNotNull(context, "context"); AssertArgument.isNotNull(provider, "provider"); Map<String, RuleProvider> providers = getRuleProviders(context); if (providers == null) { providers = new HashMap<String, RuleProvider>(); context.setAttribute(RuleProvider.class, providers); } providers.put(provider.getName(), provider); }
/** * Creates and installs the configured rule provider. * * @throws SmooksConfigurationException */ @Initialize public void installRuleProvider() throws SmooksConfigurationException { logger.debug(this); if(RuleProvider.class.isAssignableFrom(provider)) { final RuleProvider providerImpl = createProvider(provider); providerImpl.setName(name); providerImpl.setSrc(src); RuleProviderAccessor.add(applicationContext, providerImpl); } else { throw new SmooksConfigurationException("Invalid rule provider configuration :'" + this + "'"); } }
private synchronized void setRuleProvider(ExecutionContext executionContext) { if(ruleProvider != null) { return; } ruleProvider = RuleProviderAccessor.get(appContext, ruleProviderName); if(ruleProvider == null) { throw new SmooksException("Unknown rule provider '" + ruleProviderName + "'."); } // Configure the base bundle name for validation failure messages... setMessageBundleBaseName(); // Configure the maxFails per ValidationResult instance... String maxFailsConfig = executionContext.getConfigParameter(OnFailResult.MAX_FAILS); if(maxFailsConfig != null) { try { maxFails = Integer.parseInt(maxFailsConfig.trim()); } catch(NumberFormatException e) { throw new SmooksConfigurationException("Invalid config value '" + maxFailsConfig.trim() + "' for global parameter '" + OnFailResult.MAX_FAILS + "'. Must be a valid Integer value."); } } else { maxFails = Integer.MAX_VALUE; } }
/** * Adds the passed-in provider to the Smooks {@link ApplicationContext}. * * @param context The Smooks {@link ApplicationContext}. * @param provider The {@link RuleProvider} that is to be added. */ public static final void add(final ApplicationContext context, final RuleProvider provider) { AssertArgument.isNotNull(context, "context"); AssertArgument.isNotNull(provider, "provider"); Map<String, RuleProvider> providers = getRuleProviders(context); if (providers == null) { providers = new HashMap<String, RuleProvider>(); context.setAttribute(RuleProvider.class, providers); } providers.put(provider.getName(), provider); }
/** * Creates and installs the configured rule provider. * * @throws SmooksConfigurationException smooks configuration error */ @Initialize public void installRuleProvider() throws SmooksConfigurationException { logger.debug(this); if(RuleProvider.class.isAssignableFrom(provider)) { final RuleProvider providerImpl = createProvider(provider); providerImpl.setName(name); providerImpl.setSrc(src); RuleProviderAccessor.add(applicationContext, providerImpl); } else { throw new SmooksConfigurationException("Invalid rule provider configuration :'" + this + "'"); } }
private synchronized void setRuleProvider(ExecutionContext executionContext) { if(ruleProvider != null) { return; } ruleProvider = RuleProviderAccessor.get(appContext, ruleProviderName); if(ruleProvider == null) { throw new SmooksException("Unknown rule provider '" + ruleProviderName + "'."); } // Configure the base bundle name for validation failure messages... setMessageBundleBaseName(); // Configure the maxFails per ValidationResult instance... String maxFailsConfig = executionContext.getConfigParameter(OnFailResult.MAX_FAILS); if(maxFailsConfig != null) { try { maxFails = Integer.parseInt(maxFailsConfig.trim()); } catch(NumberFormatException e) { throw new SmooksConfigurationException("Invalid config value '" + maxFailsConfig.trim() + "' for global parameter '" + OnFailResult.MAX_FAILS + "'. Must be a valid Integer value."); } } else { maxFails = Integer.MAX_VALUE; } }
/** * Parse the rule name from the passed in composite rule name. * * @param compositeRuleName The composite rule name in the form ruleProvider.ruleName. * @return {@code String} The rule name part of the composite rule name. */ public static String parseRuleName(final String compositeRuleName) { final int lastIndexOfDot = compositeRuleName.lastIndexOf('.'); if (lastIndexOfDot == -1) { throwInvalidCompositeRuleName(compositeRuleName); } return compositeRuleName.substring(lastIndexOfDot + 1); }
/** * Gets a {@link RuleProvider} matching the passed in ruleProviderName. * * @param context The Smooks {@link ApplicationContext}. * @param ruleProviderName The name of the rule provider to lookup. * @return {@link RuleProvider} The {@link RuleProvider} matching the passed in ruleProviderName. * * @throws SmooksException * If no providers have been previously set in the {@link ApplicationContext}, or if * the specified ruleProviderName cannot be found. */ public static final RuleProvider get(final ApplicationContext context, final String ruleProviderName) { AssertArgument.isNotNull(context, "context"); Map<String, RuleProvider> providers = getRuleProviders(context); if ( providers == null || providers.isEmpty()) { throw new SmooksException("No RuleProviders were found. Have you configured a rules section in your Smooks configuration?"); } final RuleProvider provider = providers.get(ruleProviderName); if (provider == null) { throw new SmooksException("Not provider with name '" + ruleProviderName + "' was found in the execution context. Have you configured the rules section properly?"); } return provider; }
@ConfigParam (name="name") public void setCompositRuleName(final String compositRuleName) { this.compositRuleName = compositRuleName; this.ruleProviderName = RuleProviderAccessor.parseRuleProviderName(compositRuleName); this.ruleName = RuleProviderAccessor.parseRuleName(compositRuleName); }
/** * Creates and installs the configured rule provider. * * @throws SmooksConfigurationException */ @Initialize public void installRuleProvider() throws SmooksConfigurationException { logger.debug(this); if(RuleProvider.class.isAssignableFrom(provider)) { final RuleProvider providerImpl = createProvider(provider); providerImpl.setName(name); providerImpl.setSrc(src); RuleProviderAccessor.add(applicationContext, providerImpl); } else { throw new SmooksConfigurationException("Invalid rule provider configuration :'" + this + "'"); } }
/** * * @param compositeRuleName The composite rule name in the form ruleProvider.ruleName. * @return {@code String} The rule provider name part of the composite rule name. */ public static String parseRuleProviderName(final String compositeRuleName) { final int lastIndexOfDot = compositeRuleName.indexOf('.'); if (lastIndexOfDot == -1) { throwInvalidCompositeRuleName(compositeRuleName); } return compositeRuleName.substring(0, lastIndexOfDot); }
/** * Gets a {@link RuleProvider} matching the passed in ruleProviderName. * * @param context The Smooks {@link ApplicationContext}. * @param ruleProviderName The name of the rule provider to lookup. * @return {@link RuleProvider} The {@link RuleProvider} matching the passed in ruleProviderName. * * @throws SmooksException * If no providers have been previously set in the {@link ApplicationContext}, or if * the specified ruleProviderName cannot be found. */ public static final RuleProvider get(final ApplicationContext context, final String ruleProviderName) { AssertArgument.isNotNull(context, "context"); Map<String, RuleProvider> providers = getRuleProviders(context); if ( providers == null || providers.isEmpty()) { throw new SmooksException("No RuleProviders were found. Have you configured a rules section in your Smooks configuration?"); } final RuleProvider provider = providers.get(ruleProviderName); if (provider == null) { throw new SmooksException("Not provider with name '" + ruleProviderName + "' was found in the execution context. Have you configured the rules section properly?"); } return provider; }
/** * * @param compositeRuleName The composite rule name in the form ruleProvider.ruleName. * @return {@code String} The rule provider name part of the composite rule name. */ public static String parseRuleProviderName(final String compositeRuleName) { final int lastIndexOfDot = compositeRuleName.indexOf('.'); if (lastIndexOfDot == -1) { throwInvalidCompositeRuleName(compositeRuleName); } return compositeRuleName.substring(0, lastIndexOfDot); }
/** * Gets a {@link RuleProvider} matching the passed in ruleProviderName. * * @param context The Smooks {@link ApplicationContext}. * @param ruleProviderName The name of the rule provider to lookup. * @return {@link RuleProvider} The {@link RuleProvider} matching the passed in ruleProviderName. * * @throws SmooksException * If no providers have been previously set in the {@link ApplicationContext}, or if * the specified ruleProviderName cannot be found. */ public static final RuleProvider get(final ApplicationContext context, final String ruleProviderName) { AssertArgument.isNotNull(context, "context"); Map<String, RuleProvider> providers = getRuleProviders(context); if ( providers == null || providers.isEmpty()) { throw new SmooksException("No RuleProviders were found. Have you configured a rules section in your Smooks configuration?"); } final RuleProvider provider = providers.get(ruleProviderName); if (provider == null) { throw new SmooksException("Not provider with name '" + ruleProviderName + "' was found in the execution context. Have you configured the rules section properly?"); } return provider; }
/** * Parse the rule name from the passed in composite rule name. * * @param compositeRuleName The composite rule name in the form ruleProvider.ruleName. * @return {@code String} The rule name part of the composite rule name. */ public static String parseRuleName(final String compositeRuleName) { final int lastIndexOfDot = compositeRuleName.lastIndexOf('.'); if (lastIndexOfDot == -1) { throwInvalidCompositeRuleName(compositeRuleName); } return compositeRuleName.substring(lastIndexOfDot + 1); }
/** * Adds the passed-in provider to the Smooks {@link ApplicationContext}. * * @param context The Smooks {@link ApplicationContext}. * @param provider The {@link RuleProvider} that is to be added. */ public static final void add(final ApplicationContext context, final RuleProvider provider) { AssertArgument.isNotNull(context, "context"); AssertArgument.isNotNull(provider, "provider"); Map<String, RuleProvider> providers = getRuleProviders(context); if (providers == null) { providers = new HashMap<String, RuleProvider>(); context.setAttribute(RuleProvider.class, providers); } providers.put(provider.getName(), provider); }
/** * Parse the rule name from the passed in composite rule name. * * @param compositeRuleName The composite rule name in the form ruleProvider.ruleName. * @return {@code String} The rule name part of the composite rule name. */ public static String parseRuleName(final String compositeRuleName) { final int lastIndexOfDot = compositeRuleName.lastIndexOf('.'); if (lastIndexOfDot == -1) { throwInvalidCompositeRuleName(compositeRuleName); } return compositeRuleName.substring(lastIndexOfDot + 1); }