本文整理汇总了Java中org.springframework.core.Conventions类的典型用法代码示例。如果您正苦于以下问题:Java Conventions类的具体用法?Java Conventions怎么用?Java Conventions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Conventions类属于org.springframework.core包,在下文中一共展示了Conventions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseChildElements
import org.springframework.core.Conventions; //导入依赖的package包/类
private void parseChildElements(Element element, String parentId, String redissonRef, BeanDefinitionBuilder redissonDef, ParserContext parserContext) {
if (element.hasChildNodes()) {
CompositeComponentDefinition compositeDef
= new CompositeComponentDefinition(parentId,
parserContext.extractSource(element));
parserContext.pushContainingComponent(compositeDef);
List<Element> childElts = DomUtils.getChildElements(element);
for (Element elt : childElts) {
if(BeanDefinitionParserDelegate
.QUALIFIER_ELEMENT.equals(elt.getLocalName())) {
continue;//parsed elsewhere
}
String localName = parserContext.getDelegate().getLocalName(elt);
localName = Conventions.attributeNameToPropertyName(localName);
if (ConfigType.contains(localName)) {
parseConfigTypes(elt, localName, redissonDef, parserContext);
} else if (AddressType.contains(localName)) {
parseAddressTypes(elt, localName, redissonDef, parserContext);
} else if (helper.isRedissonNS(elt)) {
elt.setAttribute(REDISSON_REF, redissonRef);
parserContext.getDelegate().parseCustomElement(elt);
}
}
parserContext.popContainingComponent();
}
}
示例2: parseNested
import org.springframework.core.Conventions; //导入依赖的package包/类
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
bd.setFactoryBeanName(element.getAttribute(
RedissonNamespaceParserSupport.REDISSON_REF_ATTRIBUTE));
String typeName
= Conventions.attributeNameToPropertyName(element.getLocalName());
bd.setFactoryMethodName("get" + StringUtils.capitalize(typeName));
helper.addConstructorArgs(element, KEY_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, TOPIC_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, PATTERN_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, SERVICE_ATTRIBUTE,
String.class, builder);
helper.addConstructorArgs(element, CODEC_REF_ATTRIBUTE,
Codec.class, builder);
if (RDestroyable.class.isAssignableFrom(getBeanClass(element))) {
((AbstractBeanDefinition) bd).setDestroyMethodName("destroy");
}
}
示例3: invokeTimeUnitOptions
import org.springframework.core.Conventions; //导入依赖的package包/类
private void invokeTimeUnitOptions(Element element, String id, ParserContext parserContext, RedissonNamespaceParserSupport helper, String timeAttrubute, String timeUnitAttribute) {
if (helper.hasAttribute(element, timeUnitAttribute)) {
Assert.state(
helper.hasAttribute(element, timeAttrubute),
"Missing \"" + timeAttrubute + "\" attribute in \""
+ RedissonNamespaceParserSupport.LOCAL_CACHED_MAP_OPTIONS_ELEMENT
+ "\" element.");
helper.invoker(id,
Conventions.attributeNameToPropertyName(timeAttrubute),
new Object[]{
Integer.parseInt(
helper.getAttribute(element, timeAttrubute)),
helper.getAttribute(element, timeUnitAttribute)},
parserContext);
}
}
示例4: parseAttributes
import org.springframework.core.Conventions; //导入依赖的package包/类
public void parseAttributes(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
NamedNodeMap attributes = element.getAttributes();
for (int x = 0; x < attributes.getLength(); x++) {
Attr attribute = (Attr) attributes.item(x);
if (isEligibleAttribute(attribute)) {
String propertyName
= attribute.getLocalName().endsWith(REF_SUFFIX)
? attribute.getLocalName()
.substring(0, attribute.getLocalName()
.length() - REF_SUFFIX.length())
: attribute.getLocalName();
propertyName = Conventions
.attributeNameToPropertyName(propertyName);
Assert.state(StringUtils.hasText(propertyName),
"Illegal property name returned from"
+ " 'extractPropertyName(String)': cannot be"
+ " null or empty.");
if (attribute.getLocalName().endsWith(REF_SUFFIX)) {
builder.addPropertyReference(propertyName,
attribute.getValue());
} else {
builder.addPropertyValue(propertyName, attribute.getValue());
}
}
}
}
示例5: parseServiceProperties
import org.springframework.core.Conventions; //导入依赖的package包/类
public static boolean parseServiceProperties(Element parent, Element element, ParserContext parserContext,
BeanDefinitionBuilder builder) {
String name = element.getLocalName();
if (PROPS_ID.equals(name)) {
if (DomUtils.getChildElementsByTagName(element, BeanDefinitionParserDelegate.ENTRY_ELEMENT).size() > 0) {
Object props = parserContext.getDelegate().parseMapElement(element, builder.getRawBeanDefinition());
builder.addPropertyValue(Conventions.attributeNameToPropertyName(PROPS_ID), props);
}
else {
parserContext.getReaderContext().error("Invalid service property type", element);
}
return true;
}
return false;
}
示例6: resolveModelAttribute
import org.springframework.core.Conventions; //导入依赖的package包/类
private WebDataBinder resolveModelAttribute(String attrName, MethodParameter methodParam,
ExtendedModelMap implicitModel, NativeWebRequest webRequest, Object handler) throws Exception {
// Bind request parameter onto object...
String name = attrName;
if ("".equals(name)) {
name = Conventions.getVariableNameForParameter(methodParam);
}
Class<?> paramType = methodParam.getParameterType();
Object bindObject;
if (implicitModel.containsKey(name)) {
bindObject = implicitModel.get(name);
}
else if (this.methodResolver.isSessionAttribute(name, paramType)) {
bindObject = this.sessionAttributeStore.retrieveAttribute(webRequest, name);
if (bindObject == null) {
raiseSessionRequiredException("Session attribute '" + name + "' required - not found in session");
}
}
else {
bindObject = BeanUtils.instantiateClass(paramType);
}
WebDataBinder binder = createBinder(webRequest, bindObject, name);
initBinder(handler, name, binder, webRequest);
return binder;
}
示例7: decorate
import org.springframework.core.Conventions; //导入依赖的package包/类
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
if (node instanceof Attr) {
Attr attr = (Attr) node;
String propertyName = parserContext.getDelegate().getLocalName(attr);
String propertyValue = attr.getValue();
MutablePropertyValues pvs = definition.getBeanDefinition().getPropertyValues();
if (pvs.contains(propertyName)) {
parserContext.getReaderContext().error("Property '" + propertyName + "' is already defined using " +
"both <property> and inline syntax. Only one approach may be used per property.", attr);
}
if (propertyName.endsWith(REF_SUFFIX)) {
propertyName = propertyName.substring(0, propertyName.length() - REF_SUFFIX.length());
pvs.add(Conventions.attributeNameToPropertyName(propertyName), new RuntimeBeanReference(propertyValue));
}
else {
pvs.add(Conventions.attributeNameToPropertyName(propertyName), propertyValue);
}
}
return definition;
}
示例8: resolveArgument
import org.springframework.core.Conventions; //导入依赖的package包/类
/**
* Throws MethodArgumentNotValidException if validation fails.
* @throws HttpMessageNotReadableException if {@link RequestBody#required()}
* is {@code true} and there is no body content or if there is no suitable
* converter to read the content with.
*/
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
Object arg = readWithMessageConverters(webRequest, parameter, parameter.getGenericParameterType());
String name = Conventions.getVariableNameForParameter(parameter);
WebDataBinder binder = binderFactory.createBinder(webRequest, arg, name);
if (arg != null) {
validateIfApplicable(binder, parameter);
if (binder.getBindingResult().hasErrors() && isBindExceptionRequired(binder, parameter)) {
throw new MethodArgumentNotValidException(parameter, binder.getBindingResult());
}
}
mavContainer.addAttribute(BindingResult.MODEL_KEY_PREFIX + name, binder.getBindingResult());
return arg;
}
示例9: registerServletFilter
import org.springframework.core.Conventions; //导入依赖的package包/类
/**
* Add the given filter to the ServletContext and map it to the
* {@code DispatcherServlet} as follows:
* <ul>
* <li>a default filter name is chosen based on its concrete type
* <li>the {@code asyncSupported} flag is set depending on the
* return value of {@link #isAsyncSupported() asyncSupported}
* <li>a filter mapping is created with dispatcher types {@code REQUEST},
* {@code FORWARD}, {@code INCLUDE}, and conditionally {@code ASYNC} depending
* on the return value of {@link #isAsyncSupported() asyncSupported}
* </ul>
* <p>If the above defaults are not suitable or insufficient, override this
* method and register filters directly with the {@code ServletContext}.
* @param servletContext the servlet context to register filters with
* @param filter the filter to be registered
* @return the filter registration
*/
protected FilterRegistration.Dynamic registerServletFilter(ServletContext servletContext, Filter filter) {
String filterName = Conventions.getVariableName(filter);
Dynamic registration = servletContext.addFilter(filterName, filter);
if (registration == null) {
int counter = -1;
while (counter == -1 || registration == null) {
counter++;
registration = servletContext.addFilter(filterName + "#" + counter, filter);
Assert.isTrue(counter < 100,
"Failed to register filter '" + filter + "'." +
"Could the same Filter instance have been registered already?");
}
}
registration.setAsyncSupported(isAsyncSupported());
registration.addMappingForServletNames(getDispatcherTypes(), false, getServletName());
return registration;
}
示例10: resolveArgument
import org.springframework.core.Conventions; //导入依赖的package包/类
/**
* {@inheritDoc}
* @throws MethodArgumentNotValidException if validation fails
* @throws HttpMessageNotReadableException if {@link RequestBody#required()}
* is {@code true} and there is no body content or if there is no suitable
* converter to read the content with.
*/
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer,
NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
Object argument = readWithMessageConverters(webRequest, parameter, parameter.getGenericParameterType());
String name = Conventions.getVariableNameForParameter(parameter);
WebDataBinder binder = binderFactory.createBinder(webRequest, argument, name);
if (argument != null) {
validate(binder, parameter);
}
mavContainer.addAttribute(BindingResult.MODEL_KEY_PREFIX + name, binder.getBindingResult());
return argument;
}
示例11: decorate
import org.springframework.core.Conventions; //导入依赖的package包/类
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
if (node instanceof Attr) {
Attr attr = (Attr) node;
String propertyName = parserContext.getDelegate().getLocalName(attr);
String propertyValue = attr.getValue();
MutablePropertyValues pvs = definition.getBeanDefinition().getPropertyValues();
if (pvs.contains(propertyName)) {
parserContext.getReaderContext().error("Property '" + propertyName + "' is already defined using " +
"both <property> and inline syntax. Only one approach may be used per property.", attr);
}
if (propertyName.endsWith(REF_SUFFIX)) {
propertyName = propertyName.substring(0, propertyName.length() - REF_SUFFIX.length());
pvs.add(Conventions.attributeNameToPropertyName(propertyName), new RuntimeBeanReference(propertyValue));
}
else {
pvs.add(Conventions.attributeNameToPropertyName(propertyName), propertyValue);
}
}
return definition;
}
示例12: getBeanClassName
import org.springframework.core.Conventions; //导入依赖的package包/类
@Override
protected String getBeanClassName(Element element) {
String elementName
= Conventions.attributeNameToPropertyName(
element.getLocalName());
return RedissonNamespaceParserSupport.IMPL_CLASS_PATH_PREFIX
+ StringUtils.capitalize(elementName);
}
示例13: getBeanClass
import org.springframework.core.Conventions; //导入依赖的package包/类
@Override
protected Class<?> getBeanClass(Element element) {
String elementName
= Conventions.attributeNameToPropertyName(
element.getLocalName());
try {
return Class.forName(RedissonNamespaceParserSupport.API_CLASS_PATH_PREFIX
+ (StringUtils.capitalize(FAIL_LOCK.equals(elementName)
? "lock"
: elementName)));
} catch (ClassNotFoundException ex) {
throw new IllegalArgumentException(ex);
}
}
示例14: parseNested
import org.springframework.core.Conventions; //导入依赖的package包/类
@Override
protected void parseNested(Element element, ParserContext parserContext, BeanDefinitionBuilder builder, BeanDefinition bd) {
bd.setFactoryBeanName(element.getAttribute(
RedissonNamespaceParserSupport.READ_WRITE_LOCK_REF_ATTRIBUTE));
String typeName
= Conventions.attributeNameToPropertyName(element.getLocalName());
bd.setFactoryMethodName(typeName);
}
示例15: addReturnValueAsModelAttribute
import org.springframework.core.Conventions; //导入依赖的package包/类
protected final void addReturnValueAsModelAttribute(Method handlerMethod, Class<?> handlerType,
Object returnValue, ExtendedModelMap implicitModel) {
ModelAttribute attr = AnnotationUtils.findAnnotation(handlerMethod, ModelAttribute.class);
String attrName = (attr != null ? attr.value() : "");
if ("".equals(attrName)) {
Class<?> resolvedType = GenericTypeResolver.resolveReturnType(handlerMethod, handlerType);
attrName = Conventions.getVariableNameForReturnType(handlerMethod, resolvedType, returnValue);
}
implicitModel.addAttribute(attrName, returnValue);
}