private void setDynamicGBeanDataAttributes(GBeanData gbeanData, GerConfigPropertySettingType[] configProperties, Bundle bundle) throws DeploymentException { List<String> unknownNames = new ArrayList<String>(); for (GerConfigPropertySettingType configProperty : configProperties) { String name = configProperty.getName(); GAttributeInfo attributeInfo = gbeanData.getGBeanInfo().getAttribute(name); if (attributeInfo == null) { String originalName = name; name = switchCase(name); attributeInfo = gbeanData.getGBeanInfo().getAttribute(name); if (attributeInfo == null) { unknownNames.add(originalName); continue; } } String type = attributeInfo.getType(); gbeanData.setAttribute(name, getValue(type, configProperty.getStringValue().trim(), bundle)); } if (unknownNames.size() > 0) { StringBuilder buf = new StringBuilder("The plan is trying to set attributes: ").append(unknownNames).append("\n"); buf.append("Known attributes: \n"); for (GAttributeInfo attributeInfo : gbeanData.getGBeanInfo().getAttributes()) { buf.append(attributeInfo).append("\n"); } throw new DeploymentException(buf.toString()); } }
public void setXmlAttribute(String name, XmlObject xmlObject, XmlObject enclosing) throws DeploymentException { String namespace = xmlObject.getDomNode().getNamespaceURI(); XmlAttributeBuilder builder = (XmlAttributeBuilder) xmlAttributeBuilderMap.get(namespace); if (builder == null) { throw new DeploymentException("No attribute builder deployed for namespace: " + namespace); } GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name); if (attribute == null) { throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName()); } String type = attribute.getType(); Object value = builder.getValue(xmlObject, enclosing, type, bundle); gbean.setAttribute(name, value); }
private void setDynamicGBeanDataAttributes(GBeanData gbeanData, GerConfigPropertySettingType[] configProperties, ClassLoader cl) throws DeploymentException { List<String> unknownNames = new ArrayList<String>(); for (GerConfigPropertySettingType configProperty : configProperties) { String name = configProperty.getName(); GAttributeInfo attributeInfo = gbeanData.getGBeanInfo().getAttribute(name); if (attributeInfo == null) { String originalName = name; name = switchCase(name); attributeInfo = gbeanData.getGBeanInfo().getAttribute(name); if (attributeInfo == null) { unknownNames.add(originalName); continue; } } String type = attributeInfo.getType(); gbeanData.setAttribute(name, getValue(type, configProperty.getStringValue().trim(), cl)); } if (unknownNames.size() > 0) { StringBuffer buf = new StringBuffer("The plan is trying to set attributes: ").append(unknownNames).append("\n"); buf.append("Known attributes: \n"); for (GAttributeInfo attributeInfo: gbeanData.getGBeanInfo().getAttributes()) { buf.append(attributeInfo).append("\n"); } throw new DeploymentException(buf.toString()); } }
private GBeanData setUpDynamicGBeanWithProperties(String className, GBeanInfoBuilder infoBuilder, List<ConfigProperty> configProperties, Bundle bundle, Set<String> ignore) throws DeploymentException { setUpDynamicGBean(className, infoBuilder, ignore, bundle, false); GBeanInfo gbeanInfo = infoBuilder.getBeanInfo(); GBeanData gbeanData = new GBeanData(gbeanInfo); for (ConfigProperty configProperty : configProperties) { if (configProperty.getConfigPropertyValue() != null) { String name = configProperty.getConfigPropertyName(); if (gbeanInfo.getAttribute(name) == null) { String originalName = name; name = switchCase(name); if (gbeanInfo.getAttribute(name) == null) { log.warn("Unsupported config-property: " + originalName); continue; } } String type = configProperty.getConfigPropertyType(); String value = configProperty.getConfigPropertyValue(); gbeanData.setAttribute(name, getValue(type, value, bundle)); } } return gbeanData; }
GAttributeInfo attribute = gbeanData.getGBeanInfo().getAttribute("configurationBaseUrl"); if (attribute != null && attribute.getType().equals("java.net.URL")) { try {
public void setAttribute(String name, String type, String text) throws DeploymentException { if (text != null) { text = text.trim(); // avoid formatting errors due to extra whitespace in XML configuration file } try { // @todo we should not need all of common just for this if (type == null) { GAttributeInfo attribute = gbean.getGBeanInfo().getAttribute(name); if (attribute == null) { throw new DeploymentException("Unknown attribute " + name + " on " + gbean.getAbstractName()); } type = attribute.getType(); } PropertyEditor editor = PropertyEditors.findEditor(type, bundle); if (editor == null) { throw new DeploymentException("Unable to find PropertyEditor for " + type); } editor.setAsText(text); Object value = editor.getValue(); gbean.setAttribute(name, value); } catch (DeploymentException e) { throw e; } catch (ClassNotFoundException e) { throw new DeploymentException("Unable to find PropertyEditor for " + type, e); } catch (Exception e) { throw new DeploymentException("Unable to set attribute " + name + " to " + text, e); } }
private GBeanData setUpDynamicGBeanWithProperties(String className, GBeanInfoBuilder infoBuilder, ConfigPropertyType[] configProperties, ClassLoader cl, Set<String> ignore) throws DeploymentException { setUpDynamicGBean(className, infoBuilder, ignore, cl, false); GBeanInfo gbeanInfo = infoBuilder.getBeanInfo(); GBeanData gbeanData = new GBeanData(gbeanInfo); for (ConfigPropertyType configProperty : configProperties) { if (configProperty.isSetConfigPropertyValue()) { String name = configProperty.getConfigPropertyName().getStringValue(); if (gbeanInfo.getAttribute(name) == null) { String originalName = name; name = switchCase(name); if (gbeanInfo.getAttribute(name) == null) { log.warn("Unsupported config-property: " + originalName); continue; } } String type = configProperty.getConfigPropertyType().getStringValue(); String value = configProperty.getConfigPropertyValue().getStringValue(); gbeanData.setAttribute(name, getValue(type, value, cl)); } } return gbeanData; }