use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project cxf by apache.
the class BusWiringBeanFactoryPostProcessor method insertConstructorArg.
/**
* Insert the given value as the first constructor argument in the given set. To do this, we clear the
* argument set, then re-insert all its generic arguments, then re-insert all its indexed arguments with
* their indices incremented by 1, and finally set the first indexed argument (at index 0) to the given
* value.
*
* @param constructorArgs the argument definition to modify.
* @param valueToInsert the value to insert as the first argument.
*/
private void insertConstructorArg(ConstructorArgumentValues constructorArgs, Object valueToInsert) {
List<ValueHolder> genericArgs = new ArrayList<>(CastUtils.<ValueHolder>cast(constructorArgs.getGenericArgumentValues()));
Map<Integer, ValueHolder> indexedArgs = new HashMap<>(CastUtils.<Integer, ValueHolder>cast(constructorArgs.getIndexedArgumentValues()));
constructorArgs.clear();
for (ValueHolder genericValue : genericArgs) {
constructorArgs.addGenericArgumentValue(genericValue);
}
for (Map.Entry<Integer, ValueHolder> entry : indexedArgs.entrySet()) {
constructorArgs.addIndexedArgumentValue(entry.getKey() + 1, entry.getValue());
}
constructorArgs.addIndexedArgumentValue(0, valueToInsert);
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project cxf by apache.
the class UndertowHTTPServerEngineBeanDefinitionParser method doParse.
public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
String portStr = element.getAttribute("port");
bean.addPropertyValue("port", portStr);
String hostStr = element.getAttribute("host");
if (hostStr != null && !"".equals(hostStr.trim())) {
bean.addPropertyValue("host", hostStr);
}
String continuationsStr = element.getAttribute("continuationsEnabled");
if (continuationsStr != null && continuationsStr.length() > 0) {
bean.addPropertyValue("continuationsEnabled", continuationsStr);
}
String maxIdleTimeStr = element.getAttribute("maxIdleTime");
if (maxIdleTimeStr != null && !"".equals(maxIdleTimeStr.trim())) {
bean.addPropertyValue("maxIdleTime", maxIdleTimeStr);
}
ValueHolder busValue = ctx.getContainingBeanDefinition().getConstructorArgumentValues().getArgumentValue(0, Bus.class);
bean.addPropertyValue("bus", busValue.getValue());
try {
Element elem = DOMUtils.getFirstElement(element);
while (elem != null) {
String name = elem.getLocalName();
if ("tlsServerParameters".equals(name)) {
mapTLSServerParameters(elem, bean);
} else if ("threadingParameters".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "threadingParameters", ThreadingParametersType.class, UndertowHTTPServerEngineBeanDefinitionParser.class, "createThreadingParameters");
} else if ("tlsServerParametersRef".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "tlsServerParametersRef", TLSServerParametersIdentifiedType.class, UndertowHTTPServerEngineBeanDefinitionParser.class, "createTLSServerParametersConfigRef");
} else if ("threadingParametersRef".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "threadingParametersRef", ThreadingParametersIdentifiedType.class, UndertowHTTPServerEngineBeanDefinitionParser.class, "createThreadingParametersRef");
} else if ("handlers".equals(name)) {
List<?> handlers = ctx.getDelegate().parseListElement(elem, bean.getBeanDefinition());
bean.addPropertyValue("handlers", handlers);
}
elem = org.apache.cxf.helpers.DOMUtils.getNextElement(elem);
}
} catch (Exception e) {
throw new RuntimeException("Could not process configuration.", e);
}
bean.setLazyInit(false);
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project cxf by apache.
the class NettyHttpServerEngineBeanDefinitionParser method doParse.
public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
String portStr = element.getAttribute("port");
bean.addPropertyValue("port", portStr);
String hostStr = element.getAttribute("host");
if (hostStr != null && !"".equals(hostStr.trim())) {
bean.addPropertyValue("host", hostStr);
}
String readIdleTimeStr = element.getAttribute("readIdleTime");
if (readIdleTimeStr != null && !"".equals(readIdleTimeStr.trim())) {
bean.addPropertyValue("readIdleTime", readIdleTimeStr);
}
String writeIdleTimeStr = element.getAttribute("writeIdleTime");
if (writeIdleTimeStr != null && !"".equals(writeIdleTimeStr.trim())) {
bean.addPropertyValue("writeIdleTime", writeIdleTimeStr);
}
String maxChunkContentSizeStr = element.getAttribute("maxChunkContentSize");
if (maxChunkContentSizeStr != null && !"".equals(maxChunkContentSizeStr.trim())) {
bean.addPropertyValue("maxChunkContentSize", maxChunkContentSizeStr);
}
ValueHolder busValue = ctx.getContainingBeanDefinition().getConstructorArgumentValues().getArgumentValue(0, Bus.class);
bean.addPropertyValue("bus", busValue.getValue());
try {
Element elem = DOMUtils.getFirstElement(element);
while (elem != null) {
String name = elem.getLocalName();
if ("tlsServerParameters".equals(name)) {
mapTLSServerParameters(elem, bean);
} else if ("tlsServerParametersRef".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "tlsServerParametersRef", TLSServerParametersIdentifiedType.class, NettyHttpServerEngineBeanDefinitionParser.class, "createTLSServerParametersConfigRef");
} else if ("threadingParameters".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "threadingParameters", ThreadingParametersType.class, NettyHttpServerEngineBeanDefinitionParser.class, "createThreadingParameters");
} else if ("threadingParametersRef".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "threadingParametersRef", ThreadingParametersIdentifiedType.class, NettyHttpServerEngineBeanDefinitionParser.class, "createThreadingParametersRef");
} else if ("sessionSupport".equals(name) || "reuseAddress".equals(name)) {
String text = elem.getTextContent();
bean.addPropertyValue(name, text);
}
elem = org.apache.cxf.helpers.DOMUtils.getNextElement(elem);
}
} catch (Exception e) {
throw new RuntimeException("Could not process configuration.", e);
}
bean.setLazyInit(false);
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project cxf by apache.
the class JettyHTTPServerEngineBeanDefinitionParser method doParse.
public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
String portStr = element.getAttribute("port");
bean.addPropertyValue("port", portStr);
String hostStr = element.getAttribute("host");
if (hostStr != null && !"".equals(hostStr.trim())) {
bean.addPropertyValue("host", hostStr);
}
String continuationsStr = element.getAttribute("continuationsEnabled");
if (continuationsStr != null && continuationsStr.length() > 0) {
bean.addPropertyValue("continuationsEnabled", continuationsStr);
}
String maxIdleTimeStr = element.getAttribute("maxIdleTime");
if (maxIdleTimeStr != null && !"".equals(maxIdleTimeStr.trim())) {
bean.addPropertyValue("maxIdleTime", maxIdleTimeStr);
}
String sendServerVersionStr = element.getAttribute("sendServerVersion");
if (sendServerVersionStr != null && sendServerVersionStr.length() > 0) {
bean.addPropertyValue("sendServerVersion", sendServerVersionStr);
}
ValueHolder busValue = ctx.getContainingBeanDefinition().getConstructorArgumentValues().getArgumentValue(0, Bus.class);
bean.addPropertyValue("bus", busValue.getValue());
try {
Element elem = DOMUtils.getFirstElement(element);
while (elem != null) {
String name = elem.getLocalName();
if ("tlsServerParameters".equals(name)) {
mapTLSServerParameters(elem, bean);
} else if ("threadingParameters".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "threadingParameters", ThreadingParametersType.class, JettyHTTPServerEngineBeanDefinitionParser.class, "createThreadingParameters");
} else if ("tlsServerParametersRef".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "tlsServerParametersRef", TLSServerParametersIdentifiedType.class, JettyHTTPServerEngineBeanDefinitionParser.class, "createTLSServerParametersConfigRef");
} else if ("threadingParametersRef".equals(name)) {
mapElementToJaxbPropertyFactory(elem, bean, "threadingParametersRef", ThreadingParametersIdentifiedType.class, JettyHTTPServerEngineBeanDefinitionParser.class, "createThreadingParametersRef");
} else if ("connector".equals(name)) {
// only deal with the one connector here
List<?> list = ctx.getDelegate().parseListElement(elem, bean.getBeanDefinition());
bean.addPropertyValue("connector", list.get(0));
} else if ("handlers".equals(name)) {
List<?> handlers = ctx.getDelegate().parseListElement(elem, bean.getBeanDefinition());
bean.addPropertyValue("handlers", handlers);
} else if ("sessionTimeout".equals(name) || "sessionSupport".equals(name) || "reuseAddress".equals(name)) {
String text = elem.getTextContent();
bean.addPropertyValue(name, text);
}
elem = org.apache.cxf.helpers.DOMUtils.getNextElement(elem);
}
} catch (Exception e) {
throw new RuntimeException("Could not process configuration.", e);
}
bean.setLazyInit(false);
}
use of org.springframework.beans.factory.config.ConstructorArgumentValues.ValueHolder in project spring-boot by spring-projects.
the class ServletComponentScanRegistrar method updatePostProcessor.
private void updatePostProcessor(BeanDefinitionRegistry registry, Set<String> packagesToScan) {
BeanDefinition definition = registry.getBeanDefinition(BEAN_NAME);
ValueHolder constructorArguments = definition.getConstructorArgumentValues().getGenericArgumentValue(Set.class);
@SuppressWarnings("unchecked") Set<String> mergedPackages = (Set<String>) constructorArguments.getValue();
mergedPackages.addAll(packagesToScan);
constructorArguments.setValue(mergedPackages);
}
Aggregations