public RemoteRefDConfigBean(DDBean ddBean, XmlObject ref, String namePath) { super(ddBean, ref); this.ref = ref; assert ddBean.getChildBean(namePath)[0].getText().equals(getRefName()); }
public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException { if (XPATHS[0].equals(bean.getXpath())) { return webAppBean; } return null; }
public ConnectorDCB(DDBean connectorDDBean, final GerConnectorType connector) { super(connectorDDBean, connector); DDBean[] list = connectorDDBean.getChildBean("resourceadapter"); if(list.length > 0) { resourceAdapterDDBean = list[0]; } //todo: do something if resourceAdapterDDBean is null loadExistingData(connector); // Make sure we're told if /connector/resourceadapter is replaced! connectorDDBean.addXpathListener("resourceadapter", new XpathListener() { public void fireXpathEvent(XpathEvent event) { if(event.isRemoveEvent()) { resourceAdapterDDBean = null; //todo: all our info was just invalidated } else if(event.isAddEvent()) { resourceAdapterDDBean = event.getBean(); //todo: reload defaults from DDBean } else { System.out.println("Detected change to J2EE DD /connector/resourceadapter property "+event.getChangeEvent().getPropertyName()); } } }); }
public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException { String xpath = bean.getXpath(); String[] xpaths = getXpaths(); if (xpath.equals(xpaths[0])) { //resource adapter config property String configPropertyName = bean.getText("config-property-name")[0]; ConfigPropertySettingDConfigBean configPropertySetting = (ConfigPropertySettingDConfigBean) configPropertiesMap.get(configPropertyName); assert configPropertySetting != null; return configPropertySetting; } if (xpath.equals(xpaths[1])) { //connection definition String connectionFactoryInterface = bean.getText("connectionfactory-interface")[0]; ConnectionDefinitionDConfigBean connectionDefinition = (ConnectionDefinitionDConfigBean) connectionDefinitionsMap.get(connectionFactoryInterface); assert connectionDefinition != null; return connectionDefinition; } if (xpath.equals(xpaths[2])) { //admin objects String adminObjectInterface = bean.getText("adminobject-interface")[0]; String adminObjectClass = bean.getText("adminobject-class")[0]; AdminObjectDConfigBean adminObject = (AdminObjectDConfigBean) adminObjectsMap.get(new Key(adminObjectInterface, adminObjectClass)); assert adminObject != null; return adminObject; } return null; }
private void replaceResourceAdapterDConfigBean(GerResourceadapterType resourceAdapter) { DDBean ddBean = getDDBean(); String path = getXpaths()[0]; System.out.println("********** Searching XPath "+path+" -- "+ddBean.getChildBean(path)); DDBean childDDBean = ddBean.getChildBean(path)[0]; resourceAdapterDConfigBean = new ResourceAdapterDConfigBean(childDDBean, resourceAdapter); }
public String[] getText(String xpath) { DDBean[] beans = getChildBean(xpath); if (beans == null) { return null; } String[] text = new String[beans.length]; for (int i = 0; i < beans.length; i++) { text[i] = beans[i].getText(); } return text; }
public DDBean[] getChildBean(String xpath) { if (xpath.startsWith("/")) { xpath = xpath.substring(1); } int index = xpath.indexOf('/'); String childName = (index == -1) ? xpath : xpath.substring(0, index); if (("/" + childName).equals(docBean.getXpath())) { if (index == -1) { return new DDBean[]{new DDBeanImpl((DDBeanImpl) docBean, xpath)}; } else { DDBean[] newDDBeans = docBean.getChildBean(xpath.substring(index + 1)); if (newDDBeans != null) { for (int i = 0; i < newDDBeans.length; i++) { newDDBeans[i] = new DDBeanImpl((DDBeanImpl) newDDBeans[i], xpath); } } return newDDBeans; } } else { return null; } }
protected void configure(DDBean ddBean, XmlObject xml) { ConfigPropertySetting[] old = null; if(this.ddBean != null) { this.ddBean.removeXpathListener("config-property", xpathListener); old = settings; DDBean[] all = ddBean == null ? new DDBean[0] : ddBean.getChildBean("config-property"); if(all == null) { all = new DDBean[0]; for (int i = 0; i < all.length; i++) { DDBean item = all[i]; byName.put(item.getText("config-property-name")[0], item); ddBean.addXpathListener("config-property", xpathListener);
public static XpathListener initialize(DDBean parentDDBean, final ConfigPropertiesHelper.ConfigPropertiesSource configPropertiesSource, String configPropertyXPath, String configPropertyNameXPath) { DDBean[] beans = parentDDBean.getChildBean(configPropertyXPath); ConfigPropertySettings[] configs = new ConfigPropertySettings[beans.length]; Set xmlBeans = new HashSet(Arrays.asList(configPropertiesSource.getConfigPropertySettingArray())); for (int i = 0; i < beans.length; i++) { DDBean bean = beans[i]; String[] names = bean.getText(configPropertyNameXPath); String name = names.length == 1 ? names[0] : ""; GerConfigPropertySettingType target = null; parentDDBean.addXpathListener(configPropertyXPath, configListener); return configListener;
public void removeDConfigBean(DConfigBeanRoot bean) throws BeanNotFoundException { String key = bean.getDDBean().getRoot().getFilename(); if (configBeans.containsKey(key)) { System.out.println("its here... not anymore"); configBeans.remove(key); } else { throw new BeanNotFoundException("BNF"); } }
void dispose() { if (ddBean != null) { ddBean.removeXpathListener("config-property-type", typeListener); ddBean.removeXpathListener("config-property-name", nameListener); } nameListener = null; typeListener = null; ddBean = null; }
public DConfigBean getDConfigBean(DDBean bean) throws ConfigurationException { String xpath = bean.getXpath(); String[] xpaths = getXpaths(); if (xpath.equals(xpaths[0])) { //resource adapter config property String configPropertyName = bean.getText("config-property-name")[0]; ConfigPropertySettingDConfigBean configPropertySetting = (ConfigPropertySettingDConfigBean) configPropertiesMap.get(configPropertyName); assert configPropertySetting != null; return configPropertySetting; } if (xpath.equals(xpaths[1])) { //connection definition String connectionFactoryInterface = bean.getText("connectionfactory-interface")[0]; ConnectionDefinitionDConfigBean connectionDefinition = (ConnectionDefinitionDConfigBean) connectionDefinitionsMap.get(connectionFactoryInterface); assert connectionDefinition != null; return connectionDefinition; } if (xpath.equals(xpaths[2])) { //admin objects String adminObjectInterface = bean.getText("adminobject-interface")[0]; String adminObjectClass = bean.getText("adminobject-class")[0]; AdminObjectDConfigBean adminObject = (AdminObjectDConfigBean) adminObjectsMap.get(new Key(adminObjectInterface, adminObjectClass)); assert adminObject != null; return adminObject; } return null; }
private void replaceWebAppDConfigBean(GerWebAppType webApp) { DDBean ddBean = getDDBean(); webAppBean = new WebAppDConfigBean(ddBean.getChildBean(XPATHS[0])[0], webApp); }
public String[] getText(String xpath) { DDBean[] beans = getChildBean(xpath); if (beans == null) { return null; } String[] text = new String[beans.length]; for (int i = 0; i < beans.length; i++) { text[i] = beans[i].getText(); } return text; }
public static void traverse(DConfigBean config, DDBean dd, int indent) throws ConfigurationException { indent += 3; indentPrint(indent, "starting \"" + dd.getXpath() + "\", config of type " + trimClass(config.getClass())); String[] pathsToFollow = config.getXpaths(); if (pathsToFollow.length > 0) indentPrint(indent, "- There are " + pathsToFollow.length + " xpaths returned."); indent += 4; for (int i = 0; i < pathsToFollow.length; i++) { String s = "path " + i + ": " + pathsToFollow[i]; DDBean[] lesserBeans = dd.getChildBean(pathsToFollow[i]); indentPrint(indent, s + " , " + lesserBeans.length + " found."); for (int j = 0; j < lesserBeans.length; j++) { DConfigBean cb = config.getDConfigBean(lesserBeans[j]); traverse(cb, lesserBeans[j], indent); } } }
protected void configure(DDBean ddBean, XmlObject xml) { ConfigPropertySetting[] old = null; if(this.ddBean != null) { this.ddBean.removeXpathListener("config-property", xpathListener); old = settings; DDBean[] all = ddBean == null ? new DDBean[0] : ddBean.getChildBean("config-property"); if(all == null) { all = new DDBean[0]; for (int i = 0; i < all.length; i++) { DDBean item = all[i]; byName.put(item.getText("config-property-name")[0], item); ddBean.addXpathListener("config-property", xpathListener);
public static XpathListener initialize(DDBean parentDDBean, final ConfigPropertiesHelper.ConfigPropertiesSource configPropertiesSource, String configPropertyXPath, String configPropertyNameXPath) { DDBean[] beans = parentDDBean.getChildBean(configPropertyXPath); ConfigPropertySettings[] configs = new ConfigPropertySettings[beans.length]; Set xmlBeans = new HashSet(Arrays.asList(configPropertiesSource.getConfigPropertySettingArray())); for (int i = 0; i < beans.length; i++) { DDBean bean = beans[i]; String[] names = bean.getText(configPropertyNameXPath); String name = names.length == 1 ? names[0] : ""; GerConfigPropertySettingType target = null; parentDDBean.addXpathListener(configPropertyXPath, configListener); return configListener;
public ConnectorDCB(DDBean connectorDDBean, final GerConnectorType connector) { super(connectorDDBean, connector); DDBean[] list = connectorDDBean.getChildBean("resourceadapter"); if(list.length > 0) { resourceAdapterDDBean = list[0]; } //todo: do something if resourceAdapterDDBean is null loadExistingData(connector); // Make sure we're told if /connector/resourceadapter is replaced! connectorDDBean.addXpathListener("resourceadapter", new XpathListener() { public void fireXpathEvent(XpathEvent event) { if(event.isRemoveEvent()) { resourceAdapterDDBean = null; //todo: all our info was just invalidated } else if(event.isAddEvent()) { resourceAdapterDDBean = event.getBean(); //todo: reload defaults from DDBean } else { System.out.println("Detected change to J2EE DD /connector/resourceadapter property "+event.getChangeEvent().getPropertyName()); } } }); }
protected String[] getXPathsFromNamespace(String uri, String[][] xpathSegments) { String[] attributeNames = ddBean.getRoot().getAttributeNames(); for (int i = 0; i < attributeNames.length; i++) { String attributeName = attributeNames[i]; if (attributeName.startsWith("xmlns")) { if (ddBean.getRoot().getAttributeValue(attributeName).equals(uri)) { if (attributeName.equals("xmlns")) { return getXPathsWithPrefix(null , xpathSegments); } return getXPathsWithPrefix(attributeName.substring(6), xpathSegments); } } } //we can't determine the namespace from looking at attributes, since the namespace is not an attribute. //try assuming that the ddbeans strip namespaces from their xpath handing. return getXPathsWithPrefix(null , xpathSegments); }