本文整理汇总了Java中net.sourceforge.stripes.config.Configuration类的典型用法代码示例。如果您正苦于以下问题:Java Configuration类的具体用法?Java Configuration怎么用?Java Configuration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Configuration类属于net.sourceforge.stripes.config包,在下文中一共展示了Configuration类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Uses the BootstrapPropertyResolver attached to the Configuration in order to look for
* configured bundle names in the servlet init parameters etc. If those can't be found then
* the default bundle names are put in place.
*/
public void init(Configuration configuration) throws Exception {
setConfiguration(configuration);
this.errorBundleName = configuration.getBootstrapPropertyResolver().
getProperty(ERROR_MESSAGE_BUNDLE);
if (this.errorBundleName == null) {
this.errorBundleName = BUNDLE_NAME;
}
this.fieldBundleName = configuration.getBootstrapPropertyResolver().
getProperty(FIELD_NAME_BUNDLE);
if (this.fieldBundleName == null) {
this.fieldBundleName = BUNDLE_NAME;
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:DefaultLocalizationBundleFactory.java
示例2: getKeyMaterialFromConfig
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Attempts to load material from which to manufacture a secret key from the Stripes
* Configuration. If config is unavailable or there is no material configured null
* will be returned.
*
* @return a byte[] of key material, or null
*/
protected static byte[] getKeyMaterialFromConfig() {
try {
Configuration config = StripesFilter.getConfiguration();
if (config != null) {
String key = config.getBootstrapPropertyResolver().getProperty(CONFIG_ENCRYPTION_KEY);
if (key != null) {
return key.getBytes();
}
}
}
catch (Exception e) {
log.warn("Could not load key material from configuration.", e);
}
return null;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:CryptoUtil.java
示例3: getValidationMetadata
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Get a map of property names to {@link ValidationMetadata} for the {@link ActionBean} class
* bound to the URL being built. If the URL does not point to an ActionBean class or no
* validation metadata exists for the ActionBean class then an empty map will be returned.
*
* @return a map of ActionBean property names to their validation metadata
* @see ValidationMetadataProvider#getValidationMetadata(Class)
*/
protected Map<String, ValidationMetadata> getValidationMetadata() {
Map<String, ValidationMetadata> validations = null;
Configuration configuration = StripesFilter.getConfiguration();
if (configuration != null) {
Class<? extends ActionBean> beanType = null;
try {
beanType = configuration.getActionResolver().getActionBeanType(this.baseUrl);
}
catch (UrlBindingConflictException e) {
// This can be safely ignored
}
if (beanType != null) {
validations = configuration.getValidationMetadataProvider().getValidationMetadata(
beanType);
}
}
if (validations == null)
validations = Collections.emptyMap();
return validations;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:32,代码来源:UrlBuilder.java
示例4: filterInit
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void filterInit(Configuration configuration) {
this.configuration = configuration;
Set<Class<? extends ActionBean>> foundClasses = (Set<Class<? extends ActionBean>>) cache.get(CACHE_KEY);
if (foundClasses == null) {
// synchronized (getLock())
foundClasses = findClasses();
if (foundClasses != null) {
Set<Class<? extends ActionBean>> cachedFoundClasses = (Set<Class<? extends ActionBean>>) cache
.putIfAbsent(CACHE_KEY, foundClasses);
if (cachedFoundClasses != null)
foundClasses = cachedFoundClasses;
}
// Process each ActionBean
for (Class<? extends ActionBean> clazz : foundClasses) {
addActionBean(clazz);
}
}
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:25,代码来源:ApplicationContextActionResolver.java
示例5: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Places all the known convertible types and type converters into an instance level Map.
*/
public void init(final Configuration configuration) {
this.configuration = configuration;
this.cache = new TypeHandlerCache<Class<? extends TypeConverter<?>>>();
this.cache.setSearchHierarchy(false);
cache.add(Boolean.class, BooleanTypeConverter.class);
cache.add(Boolean.TYPE, BooleanTypeConverter.class);
cache.add(Byte.class, ByteTypeConverter.class);
cache.add(Byte.TYPE, ByteTypeConverter.class);
cache.add(Short.class, ShortTypeConverter.class);
cache.add(Short.TYPE, ShortTypeConverter.class);
cache.add(Integer.class, IntegerTypeConverter.class);
cache.add(Integer.TYPE, IntegerTypeConverter.class);
cache.add(Long.class, LongTypeConverter.class);
cache.add(Long.TYPE, LongTypeConverter.class);
cache.add(Float.class, FloatTypeConverter.class);
cache.add(Float.TYPE, FloatTypeConverter.class);
cache.add(Double.class, DoubleTypeConverter.class);
cache.add(Double.TYPE, DoubleTypeConverter.class);
cache.add(Date.class, DateTypeConverter.class);
cache.add(BigInteger.class, BigIntegerTypeConverter.class);
cache.add(BigDecimal.class, BigDecimalTypeConverter.class);
cache.add(Enum.class, EnumeratedTypeConverter.class);
// Now some less useful, but still helpful converters
cache.add(String.class, StringTypeConverter.class);
cache.add(Object.class, ObjectTypeConverter.class);
cache.add(Character.class, CharacterTypeConverter.class);
cache.add(Character.TYPE, CharacterTypeConverter.class);
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:34,代码来源:DefaultTypeConverterFactory.java
示例6: getErrorMessage
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Looks up the specified key in the error message resource bundle. If the
* bundle is missing or if the resource cannot be found, will return null
* instead of throwing an exception.
*
* @param locale the locale in which to lookup the resource
* @param key the exact resource key to lookup
* @return the resource String or null
*/
public static String getErrorMessage(Locale locale, String key) {
try {
Configuration config = StripesFilter.getConfiguration();
ResourceBundle bundle = config.getLocalizationBundleFactory().getErrorMessageBundle(locale);
return bundle.getString(key);
}
catch (MissingResourceException mre) {
return null;
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:20,代码来源:LocalizationUtility.java
示例7: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Looks up the name of the configured renderer class in the configuration and
* attempts to find the Class object for it. If one isn't provided then the default
* class is used. If the configured class cannot be found an exception will be
* thrown and the factory is deemed invalid.
*/
public void init(Configuration configuration) throws Exception {
setConfiguration(configuration);
this.rendererClass = configuration.getBootstrapPropertyResolver().
getClassProperty(RENDERER_CLASS_KEY, TagErrorRenderer.class);
if (this.rendererClass == null)
this.rendererClass = DefaultTagErrorRenderer.class;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:16,代码来源:DefaultTagErrorRendererFactory.java
示例8: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/** Stores the configuration, and looks up the ActionBeanContext class specified. */
public void init(Configuration configuration) throws Exception {
setConfiguration(configuration);
Class<? extends ActionBeanContext> clazz = configuration.getBootstrapPropertyResolver()
.getClassProperty(CONTEXT_CLASS_NAME, ActionBeanContext.class);
if (clazz == null) {
clazz = ActionBeanContext.class;
}
else {
log.info(DefaultActionBeanContextFactory.class.getSimpleName(), " will use ",
ActionBeanContext.class.getSimpleName(), " subclass ", clazz.getName());
}
this.contextClass = clazz;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:16,代码来源:DefaultActionBeanContextFactory.java
示例9: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Scans the classpath of the current classloader (not including parents) to find implementations
* of the ActionBean interface. Examines annotations on the classes found to determine what
* forms and events they map to, and stores this information in a pair of maps for fast
* access during request processing.
*/
public void init(Configuration configuration) throws Exception {
this.configuration = configuration;
// Process each ActionBean
for (Class<? extends ActionBean> clazz : findClasses()) {
addActionBean(clazz);
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:15,代码来源:AnnotatedClassActionResolver.java
示例10: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Performs the necessary initialization for the StripesFilter. Mainly this involves deciding
* what configuration class to use, and then instantiating and initializing the chosen
* Configuration.
*
* @throws ServletException thrown if a problem is encountered initializing Stripes
*/
public void init(FilterConfig filterConfig) throws ServletException {
this.configuration = createConfiguration(filterConfig);
StripesFilter.configurations.add(new WeakReference<Configuration>(this.configuration));
this.servletContext = filterConfig.getServletContext();
this.servletContext.setAttribute(StripesFilter.class.getName(), this);
log.info("Stripes Initialization Complete. Version: ");
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:17,代码来源:StripesFilter.java
示例11: createConfiguration
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Create and configure a new {@link Configuration} instance using the suppied
* {@link FilterConfig}.
*
* @param filterConfig The filter configuration supplied by the container.
* @return The new configuration instance.
* @throws ServletException If the configuration cannot be created.
*/
protected static Configuration createConfiguration(FilterConfig filterConfig)
throws ServletException {
BootstrapPropertyResolver bootstrap = new BootstrapPropertyResolver(filterConfig);
// Set up the Configuration - if one isn't found by the bootstrapper then
// we'll just use the default: RuntimeConfiguration
Class<? extends Configuration> clazz = bootstrap.getClassProperty(CONFIG_CLASS,
Configuration.class);
if (clazz == null)
clazz = RuntimeConfiguration.class;
try {
Configuration configuration = clazz.newInstance();
configuration.setBootstrapPropertyResolver(bootstrap);
configuration.init();
return configuration;
}
catch (Exception e) {
log.fatal(e,
"Could not instantiate specified Configuration. Class name specified was ",
"[", clazz.getName(), "].");
throw new StripesServletException("Could not instantiate specified Configuration. "
+ "Class name specified was [" + clazz.getName() + "].", e);
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:35,代码来源:StripesFilter.java
示例12: getConfiguration
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Returns the Configuration that is being used to process the current request.
*/
public static Configuration getConfiguration() {
Configuration configuration = StripesFilter.configurationStash.get();
// If the configuration wasn't available in thread local, check to see if we only
// know about one configuration in total, and if so use that one
if (configuration == null) {
synchronized (StripesFilter.configurations) {
// Remove any references from the set that have been cleared
Iterator<WeakReference<Configuration>> iterator = StripesFilter.configurations.iterator();
while (iterator.hasNext()) {
WeakReference<Configuration> ref = iterator.next();
if (ref.get() == null) iterator.remove();
}
// If there is one and only one Configuration active, take it
if (StripesFilter.configurations.size() == 1) {
configuration = StripesFilter.configurations.iterator().next().get();
}
}
}
if (configuration == null) {
StripesRuntimeException sre = new StripesRuntimeException(
"Something is trying to access the current Stripes configuration but the " +
"current request was never routed through the StripesFilter! As a result " +
"the appropriate Configuration object cannot be located. Please take a look " +
"at the exact URL in your browser's address bar and ensure that any " +
"requests to that URL will be filtered through the StripesFilter according " +
"to the filter mappings in your web.xml."
);
log.error(sre); // log through an exception so that users get a stracktrace
}
return configuration;
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:39,代码来源:StripesFilter.java
示例13: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Looks up the filters as defined in the Configuration and then invokes the
* {@link ResolverUtil} to find implementations of AutoExceptionHandler. Each
* implementation found is then examined and cached by calling
* {@link #addHandler(Class)}
*
* @param configuration the Configuration for this Stripes application
* @throws Exception thrown if any of the discovered handler types cannot be safely
* instantiated
*/
@Override
public void init(Configuration configuration) throws Exception {
super.init(configuration);
// Fetch the AutoExceptionHandler implementations and add them to the cache
Set<Class<? extends AutoExceptionHandler>> handlers = findClasses();
for (Class<? extends AutoExceptionHandler> handler : handlers) {
if (!Modifier.isAbstract(handler.getModifiers())) {
log.debug("Processing class ", handler, " looking for exception handling methods.");
addHandler(handler);
}
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:24,代码来源:DelegatingExceptionHandler.java
示例14: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/** Stores a reference to the configuration and configures the default formatters. */
public void init(Configuration configuration) throws Exception {
this.configuration = configuration;
this.cache = new TypeHandlerCache<Class<? extends Formatter<?>>>();
this.cache.setDefaultHandler(ObjectFormatter.class);
add(Date.class, DateFormatter.class);
add(Number.class, NumberFormatter.class);
add(Enum.class, EnumFormatter.class);
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:11,代码来源:DefaultFormatterFactory.java
示例15: encrypt
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Takes in a String, encrypts it and then base64 encodes the resulting byte[] so that it can be
* transmitted and stored as a String. Can be decrypted by a subsequent call to
* {@link #decrypt(String)}. Because, null and "" are equivalent to the Stripes binding engine,
* if {@code input} is null, then it will be encrypted as if it were "".
*
* @param input the String to encrypt and encode
* @return the encrypted, base64 encoded String
*/
public static String encrypt(String input) {
if (input == null)
input = "";
// encryption is disabled in debug mode
Configuration configuration = StripesFilter.getConfiguration();
if (configuration != null && configuration.isDebugMode())
return input;
try {
// First size the output
Cipher cipher = getCipher(Cipher.ENCRYPT_MODE);
byte[] inbytes = input.getBytes();
final int inputLength = inbytes.length;
int size = cipher.getOutputSize(DISCARD_BYTES + inputLength);
byte[] output = new byte[size];
// Then encrypt along with the nonce and the hash code
byte[] nonce = nextNonce();
byte[] hash = generateHashCode(nonce, inbytes);
int index = cipher.update(hash, 0, HASH_CODE_SIZE, output, 0);
index = cipher.update(nonce, 0, NONCE_SIZE, output, index);
if (inbytes.length == 0) {
cipher.doFinal(output, index);
}
else {
cipher.doFinal(inbytes, 0, inbytes.length, output, index);
}
// Then base64 encode the bytes
return Base64.encodeBytes(output, BASE64_OPTIONS);
}
catch (Exception e) {
throw new StripesRuntimeException("Could not encrypt value.", e);
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:46,代码来源:CryptoUtil.java
示例16: UrlBuilder
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Constructs a UrlBuilder that references an {@link ActionBean}. Parameters can be added later
* using addParameter(). If the link is to be used in a page then the ampersand character
* usually used to separate parameters will be escaped using the XML entity for ampersand.
*
* @param locale the locale to use when formatting parameters with a {@link Formatter}
* @param beanType {@link ActionBean} class for which the URL will be built
* @param isForPage true if the URL is to be embedded in a page (e.g. in an anchor of img tag),
* false if for some other purpose.
*/
public UrlBuilder(Locale locale, Class<? extends ActionBean> beanType, boolean isForPage) {
this(locale, isForPage);
Configuration configuration = StripesFilter.getConfiguration();
if (configuration != null) {
this.baseUrl = configuration.getActionResolver().getUrlBinding(beanType);
}
else {
throw new StripesRuntimeException("Unable to lookup URL binding for ActionBean class "
+ "because there is no Configuration object available.");
}
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:22,代码来源:UrlBuilder.java
示例17: getFormatter
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Tries to get a formatter for the given value using the {@link FormatterFactory}. Returns
* null if there is no {@link Configuration} or {@link FormatterFactory} available (e.g. in a
* test environment) or if there is no {@link Formatter} configured for the value's type.
*
* @param value the object to be formatted
* @return a formatter, if one can be found; null otherwise
*/
@SuppressWarnings("rawtypes")
protected Formatter getFormatter(Object value) {
Configuration configuration = StripesFilter.getConfiguration();
if (configuration == null)
return null;
FormatterFactory factory = configuration.getFormatterFactory();
if (factory == null)
return null;
return factory.getFormatter(value.getClass(), locale, null, null);
}
开发者ID:nkasvosve,项目名称:beyondj,代码行数:21,代码来源:UrlBuilder.java
示例18: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
/**
* Scans the classpath of the current classloader (not including parents) to
* find implementations of the ActionBean interface. Examines annotations on
* the classes found to determine what forms and events they map to, and
* stores this information in a pair of maps for fast access during request
* processing.
*/
public void init(Configuration configuration) throws Exception {
this.configuration = configuration;
// Process each ActionBean
for (Class<? extends ActionBean> clazz : findClasses()) {
addActionBean(clazz);
}
}
开发者ID:geetools,项目名称:geeCommerce-Java-Shop-Software-and-PIM,代码行数:16,代码来源:AnnotatedClassActionResolver.java
示例19: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
@Override
public void init(Configuration configuration) throws Exception {
super.init(configuration);
servletContext = configuration.getServletContext();
Field eventMappingsField = AnnotatedClassActionResolver.class.getDeclaredField("eventMappings");
eventMappingsField.setAccessible(true);
eventMappings = (Map<Class<? extends ActionBean>, Map<String, Method>>) eventMappingsField.get(this);
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:10,代码来源:ModelActionResolver.java
示例20: init
import net.sourceforge.stripes.config.Configuration; //导入依赖的package包/类
@Override
public void init(Configuration configuration) throws Exception {
super.init(configuration);
for(Locale locale : locales) {
//Set UTF-8 as the default encoding
if(!encodings.containsKey(locale)) {
encodings.put(locale, "UTF-8");
}
}
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:12,代码来源:LocalePicker.java
注:本文中的net.sourceforge.stripes.config.Configuration类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论