use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project cxf by apache.
the class JettyHTTPServerEngineFactoryBeanDefinitionParser method doParse.
@Override
public void doParse(Element element, ParserContext ctx, BeanDefinitionBuilder bean) {
// bean.setAbstract(true);
String bus = element.getAttribute("bus");
BeanDefinitionBuilder factbean = BeanDefinitionBuilder.rootBeanDefinition(JettySpringTypesFactory.class);
ctx.getRegistry().registerBeanDefinition(JettySpringTypesFactory.class.getName(), factbean.getBeanDefinition());
try {
if (StringUtils.isEmpty(bus)) {
addBusWiringAttribute(bean, BusWiringType.CONSTRUCTOR);
} else {
bean.addConstructorArgReference(bus);
}
bean.addConstructorArgValue(mapElementToJaxbBean(element, TLSServerParametersIdentifiedType.class, JettySpringTypesFactory.class, "createTLSServerParametersMap"));
bean.addConstructorArgValue(mapElementToJaxbBean(element, ThreadingParametersIdentifiedType.class, JettySpringTypesFactory.class, "createThreadingParametersMap"));
// parser the engine list
List<Object> list = getRequiredElementsList(element, ctx, new QName(HTTP_JETTY_NS, "engine"), bean);
if (!list.isEmpty()) {
bean.addPropertyValue("enginesList", list);
}
} catch (Exception e) {
throw new RuntimeException("Could not process configuration.", e);
}
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project cxf by apache.
the class UndertowHTTPServerEngineBeanDefinitionParser method mapTLSServerParameters.
private void mapTLSServerParameters(Element e, BeanDefinitionBuilder bean) {
BeanDefinitionBuilder paramsbean = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.TLSServerParametersTypeInternal.class);
// read the attributes
NamedNodeMap as = e.getAttributes();
for (int i = 0; i < as.getLength(); i++) {
Attr a = (Attr) as.item(i);
if (a.getNamespaceURI() == null) {
String aname = a.getLocalName();
if ("jsseProvider".equals(aname) || "secureSocketProtocol".equals(aname)) {
paramsbean.addPropertyValue(aname, a.getValue());
}
}
}
// read the child elements
Node n = e.getFirstChild();
while (n != null) {
if (Node.ELEMENT_NODE != n.getNodeType() || !SECURITY_NS.equals(n.getNamespaceURI())) {
n = n.getNextSibling();
continue;
}
String ename = n.getLocalName();
// Schema should require that no more than one each of these exist.
String ref = ((Element) n).getAttribute("ref");
if ("keyManagers".equals(ename)) {
if (ref != null && ref.length() > 0) {
paramsbean.addPropertyReference("keyManagersRef", ref);
} else {
mapElementToJaxbProperty((Element) n, paramsbean, ename, KeyManagersType.class);
}
} else if ("trustManagers".equals(ename)) {
if (ref != null && ref.length() > 0) {
paramsbean.addPropertyReference("trustManagersRef", ref);
} else {
mapElementToJaxbProperty((Element) n, paramsbean, ename, TrustManagersType.class);
}
} else if ("cipherSuites".equals(ename)) {
mapElementToJaxbProperty((Element) n, paramsbean, ename, CipherSuites.class);
} else if ("cipherSuitesFilter".equals(ename)) {
mapElementToJaxbProperty((Element) n, paramsbean, ename, FiltersType.class);
} else if ("excludeProtocols".equals(ename)) {
mapElementToJaxbProperty((Element) n, paramsbean, ename, ExcludeProtocols.class);
} else if ("includeProtocols".equals(ename)) {
mapElementToJaxbProperty((Element) n, paramsbean, ename, IncludeProtocols.class);
} else if ("secureRandomParameters".equals(ename)) {
mapElementToJaxbProperty((Element) n, paramsbean, ename, SecureRandomParameters.class);
} else if ("clientAuthentication".equals(ename)) {
mapElementToJaxbProperty((Element) n, paramsbean, ename, ClientAuthentication.class);
} else if ("certConstraints".equals(ename)) {
mapElementToJaxbProperty((Element) n, paramsbean, ename, CertificateConstraintsType.class);
} else if ("certAlias".equals(ename)) {
paramsbean.addPropertyValue(ename, n.getTextContent());
}
n = n.getNextSibling();
}
BeanDefinitionBuilder jaxbbean = BeanDefinitionBuilder.rootBeanDefinition(TLSServerParametersConfig.class);
jaxbbean.addConstructorArgValue(paramsbean.getBeanDefinition());
bean.addPropertyValue("tlsServerParameters", jaxbbean.getBeanDefinition());
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project pentaho-platform by pentaho.
the class BeanListParser method parseInternal.
@Override
protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(BeanListBuilder.class.getName());
builder.addPropertyValue("type", element.getAttribute("class"));
Map<String, String> propMap = new HashMap<String, String>();
Element objectproperties = DomUtils.getChildElementByTagName(element, Const.ATTRIBUTES);
if (objectproperties != null) {
List props = DomUtils.getChildElementsByTagName(objectproperties, Const.ATTR);
if (props != null) {
for (Object o : props) {
Element prop = (Element) o;
String key = prop.getAttribute(Const.KEY);
String value = prop.getAttribute(Const.VALUE);
propMap.put(key, value);
}
}
}
builder.addPropertyValue(Const.ATTRIBUTES, propMap);
AbstractBeanDefinition definition = builder.getRawBeanDefinition();
definition.setSource(parserContext.extractSource(element));
return definition;
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project spring-security-oauth by spring-projects.
the class ConfigUtils method createSecurityMetadataSource.
public static BeanDefinition createSecurityMetadataSource(Element element, ParserContext pc) {
List<Element> filterPatterns = DomUtils.getChildElementsByTagName(element, "url");
if (filterPatterns.isEmpty()) {
return null;
}
String patternType = element.getAttribute("path-type");
if (!StringUtils.hasText(patternType)) {
patternType = "ant";
}
MatcherType matcherType = MatcherType.valueOf(patternType);
ManagedMap<BeanDefinition, BeanDefinition> invocationDefinitionMap = new ManagedMap<BeanDefinition, BeanDefinition>();
for (Element filterPattern : filterPatterns) {
String path = filterPattern.getAttribute("pattern");
if (!StringUtils.hasText(path)) {
pc.getReaderContext().error("pattern attribute cannot be empty or null", filterPattern);
}
String method = filterPattern.getAttribute("httpMethod");
if (!StringUtils.hasText(method)) {
method = null;
}
String access = filterPattern.getAttribute("resources");
if (StringUtils.hasText(access)) {
BeanDefinition matcher;
if (createMatcherMethod4x != null) {
matcher = (BeanDefinition) ReflectionUtils.invokeMethod(createMatcherMethod4x, matcherType, pc, path, method);
} else {
matcher = (BeanDefinition) ReflectionUtils.invokeMethod(createMatcherMethod3x, matcherType, path, method);
}
if (access.equals("none")) {
invocationDefinitionMap.put(matcher, BeanDefinitionBuilder.rootBeanDefinition(Collections.class).setFactoryMethod("emptyList").getBeanDefinition());
} else {
BeanDefinitionBuilder attributeBuilder = BeanDefinitionBuilder.rootBeanDefinition(SecurityConfig.class);
attributeBuilder.addConstructorArgValue(access);
attributeBuilder.setFactoryMethod("createListFromCommaDelimitedString");
if (invocationDefinitionMap.containsKey(matcher)) {
pc.getReaderContext().warning("Duplicate URL defined: " + path + ". The original attribute values will be overwritten", pc.extractSource(filterPattern));
}
invocationDefinitionMap.put(matcher, attributeBuilder.getBeanDefinition());
}
}
}
BeanDefinitionBuilder fidsBuilder = BeanDefinitionBuilder.rootBeanDefinition(DefaultFilterInvocationSecurityMetadataSource.class);
fidsBuilder.addConstructorArgValue(invocationDefinitionMap);
fidsBuilder.getRawBeanDefinition().setSource(pc.extractSource(element));
return fidsBuilder.getBeanDefinition();
}
use of org.springframework.beans.factory.support.BeanDefinitionBuilder in project loc-framework by lord-of-code.
the class LocElasticJobAutoConfiguration method createSpringJobScheduler.
private void createSpringJobScheduler(String name, List<Object> argList) {
ConfigurableApplicationContext configurableApplicationContext = (ConfigurableApplicationContext) applicationContext;
BeanDefinitionRegistry beanDefinitionRegistry = (BeanDefinitionRegistry) configurableApplicationContext.getBeanFactory();
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(SpringJobScheduler.class);
builder.setInitMethodName("init");
for (Object arg : argList) {
builder.addConstructorArgValue(arg);
}
beanDefinitionRegistry.registerBeanDefinition(name, builder.getBeanDefinition());
log.info("spring bean name {} register success ", name);
}
Aggregations