private boolean isMagicAttribute(GAttributeInfo attributeInfo) { String name = attributeInfo.getName(); String type = attributeInfo.getType(); return ("kernel".equals(name) && Kernel.class.getName().equals(type)) || ("classLoader".equals(name) && ClassLoader.class.getName().equals(type)) || ("abstractName".equals(name) && AbstractName.class.getName().equals(type)) || ("objectName".equals(name) && String.class.getName().equals(type)); }
} else if (attributes.containsKey(argumentName)) { GAttributeInfo attribute = (GAttributeInfo) attributes.get(argumentName); argumentTypes[i] = attribute.getType(); isReference[i] = false;
public void setManageableAttributes(String[] manageableAttributes) { for (int i = 0; i < manageableAttributes.length; i++) { String attributeName = manageableAttributes[i]; GAttributeInfo attribute = (GAttributeInfo) attributes.get(attributeName); if (attribute != null) { attributes.put(attributeName, new GAttributeInfo(attributeName, attribute.getType(), attribute.isPersistent(), true, attribute.getGetterName(), attribute.getSetterName())); } } }
map.put("getterName", attribInfo.getGetterName()); map.put("setterName", attribInfo.getSetterName()); map.put("type", attribInfo.getType()); map.put("manageable", String.valueOf(attribInfo.isManageable())); map.put("persistent", String.valueOf(attribInfo.isPersistent()));
null)); } else { if (!attributeType.equals(attribute.getType())) { throw new IllegalArgumentException("Getter and setter type do not match: " + attributeName + " for gbeanType: " + gbeanType.getName()); method.getName())); } else { if (!attributeType.equals(attribute.getType())) { throw new IllegalArgumentException("Getter and setter type do not match: " + attributeName + " for gbeanType: " + gbeanType.getName());
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()); } }
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()); } }
public void setPersistentAttributes(String[] persistentAttributes) { for (int i = 0; i < persistentAttributes.length; i++) { String attributeName = persistentAttributes[i]; GAttributeInfo attribute = (GAttributeInfo) attributes.get(attributeName); if (attribute != null && !references.containsKey(attributeName)) { if (isMagicAttribute(attribute)) { // magic attributes can't be persistent continue; } attributes.put(attributeName, new GAttributeInfo(attributeName, attribute.getType(), true, attribute.isManageable(), attribute.getGetterName(), attribute.getSetterName())); } else { if (attributeName.equals("kernel")) { addAttribute("kernel", Kernel.class, false); } else if (attributeName.equals("classLoader")) { addAttribute("classLoader", ClassLoader.class, false); } else if (attributeName.equals("abstractName")) { addAttribute("abstractName", AbstractName.class, false); } else if (attributeName.equals("objectName")) { addAttribute("obectName", String.class, false); } } } }
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); }
if (attribute != null && attribute.getType().equals("java.net.URL")) { try { Set set = configuration.getConfigurationResolver().resolve("");
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); } }
public static LinkedHashSet<String> getImports(List<GBeanData> gbeans) { LinkedHashSet<String> imports = new LinkedHashSet<String>(); for (GBeanData data: gbeans) { GBeanInfo info = data.getGBeanInfo(); addImport(imports, info.getClassName()); for (GAttributeInfo attInfo: info.getAttributes()) { addImport(imports, attInfo.getType()); } for (GReferenceInfo refInfo: info.getReferences()) { addImport(imports, refInfo.getReferenceType()); } for (GOperationInfo opInfo: info.getOperations()) { addImport(imports, opInfo.getReturnType()); for (String paramType : opInfo.getParameterList()) { addImport(imports, paramType); } } } return imports; }