/** * Gets the child of the specified element having the * specified name. If the child with this name doesn't exist * then null is returned instead. * * @param element the parent element * @param tagName the name of the desired child * @return either the named child or null */ public static Element getOptionalChild(Element element, String tagName) { return getOptionalChild(element, tagName, null); }
notNull = (MetaData.getOptionalChild(element, "not-null") != null);
/** * Gets the child of the specified element having the * specified name. If the child with this name doesn't exist * then null is returned instead. * * @param element the parent element * @param tagName the name of the desired child * @return either the named child or null */ public static Element getOptionalChild(Element element, String tagName) { return getOptionalChild(element, tagName, null); }
if (MetaData.getOptionalChild(element, "relation-table-mapping") != null) if (MetaData.getOptionalChild(element, "foreign-key-mapping") != null)
private static Element getMappingElement(Element element) throws DeploymentException { // if defaults check for preferred-relation-mapping if ("defaults".equals(element.getTagName())) { return element; } // check for table mapping style Element tableMappingElement = MetaData.getOptionalChild(element, "relation-table-mapping"); if (tableMappingElement != null) { return tableMappingElement; } // check for foreign-key mapping style Element foreignKeyMappingElement = MetaData.getOptionalChild(element, "foreign-key-mapping"); if (foreignKeyMappingElement != null) { return foreignKeyMappingElement; } return null; }
public static boolean getOptionalChildBooleanContent(Element element, String name) { Element child = getOptionalChild(element, name); if (child != null) { String value = getElementContent(child).toLowerCase(); return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"); } return false; }
/** * Macro to get the content of an optional child element. * * @param element The parent element. * @param tagName The name of the desired child. * @return The element content or null. */ public static String getOptionalChildContent(Element element, String tagName) { return getElementContent(getOptionalChild(element, tagName)); }
/** * Macro to get the content of an optional child element. * * @param element The parent element. * @param tagName The name of the desired child. * @return The element content or null. */ public static String getOptionalChildContent(Element element, String tagName) { return getElementContent(getOptionalChild(element, tagName)); }
/** * Macro to get the content of an optional child element with default value. * * @param element The parent element. * @param tagName The name of the desired child. * @return The element content or null. */ public static String getOptionalChildContent(Element element, String tagName, String defaultValue) { return getElementContent(getOptionalChild(element, tagName), defaultValue); }
/** * Macro to get the content of an optional child element with default value. * * @param element The parent element. * @param tagName The name of the desired child. * @return The element content or null. */ public static String getOptionalChildContent(Element element, String tagName, String defaultValue) { return getElementContent(getOptionalChild(element, tagName), defaultValue); }
public static boolean getOptionalChildBooleanContent(Element element, String name) { Element child = getOptionalChild(element, name); if (child != null) { String value = getElementContent(child).toLowerCase(); return value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"); } return false; }
public static boolean getOptionalChildBooleanContent(Element element, String name, boolean defaultValue) { Element child = getOptionalChild(element, name); boolean flag = defaultValue; if (child != null) { String value = getElementContent(child).toLowerCase(); flag = value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"); } return flag; }
public void importXml(Element element) throws DeploymentException { String flushString = MetaData.getElementContent(MetaData.getOptionalChild(element, "flush-enabled")); flushEnabled = Boolean.valueOf(flushString).booleanValue(); }
public static boolean getOptionalChildBooleanContent(Element element, String name, boolean defaultValue) { Element child = getOptionalChild(element, name); boolean flag = defaultValue; if (child != null) { String value = getElementContent(child).toLowerCase(); flag = value.equalsIgnoreCase("true") || value.equalsIgnoreCase("yes"); } return flag; }
public void importXml(Element ielement) { try { Element element = MetaData.getOptionalChild(ielement, "retry-handlers"); if (element == null) return; ArrayList list = new ArrayList(); Iterator handlers = MetaData.getChildrenByTagName(element, "handler"); while (handlers.hasNext()) { Element handler = (Element)handlers.next(); String className = MetaData.getElementContent(handler).trim(); Class clazz = SecurityActions.getContextClassLoader().loadClass(className); list.add(clazz.newInstance()); } retryHandlers = (TxRetryExceptionHandler[])list.toArray(new TxRetryExceptionHandler[list.size()]); } catch (Exception ex) { log.warn("Unable to importXml for the TxInterceptorCMT", ex); } }
throws DeploymentException Element lazyLoadGroupsElement = MetaData.getOptionalChild(element, "lazy-load-groups");
public void startService() throws Exception { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); URL stdJDBCUrl = classLoader.getResource("standardjbosscmp-jdbc.xml"); if(stdJDBCUrl == null) { throw new DeploymentException("No standardjbosscmp-jdbc.xml found"); } boolean debug = log.isDebugEnabled(); if(debug) { log.debug("Loading standardjbosscmp-jdbc.xml : " + stdJDBCUrl.toString()); } Element stdJDBCElement = XmlFileLoader.getDocument(stdJDBCUrl, true).getDocumentElement(); Element typeMaps = MetaData.getOptionalChild(stdJDBCElement, "type-mappings"); if(typeMaps != null) { for(Iterator i = MetaData.getChildrenByTagName(typeMaps, "type-mapping"); i.hasNext();) { Element typeMappingElement = (Element)i.next(); JDBCTypeMappingMetaData typeMapping = new JDBCTypeMappingMetaData(typeMappingElement); typeMappings.put(typeMapping.getName(), typeMapping); log.debug("added type-mapping: " + typeMapping.getName()); } } }
/** * XmlLoadable implementation */ public void importXml(Element element) throws DeploymentException { String maximumSize = MetaData.getElementContent(MetaData.getUniqueChild(element, "MaximumSize")); try { this.maxSize = Integer.parseInt(maximumSize); } catch (NumberFormatException e) { throw new DeploymentException("Invalid MaximumSize value for instance pool configuration"); } // Get whether the pool will block when MaximumSize instances are active String strictValue = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictMaximumSize")); this.isStrict = Boolean.valueOf(strictValue); String delay = MetaData.getElementContent(MetaData.getOptionalChild(element, "strictTimeout")); try { if( delay != null ) this.strictTimeout = Long.parseLong(delay); } catch (NumberFormatException e) { throw new DeploymentException("Invalid strictTimeout value for instance pool configuration"); } }
String rp = MetaData.getElementContent(MetaData.getOptionalChild(element, "remover-period")); String ml = MetaData.getElementContent(MetaData.getOptionalChild(element, "max-bean-life")); try
public void importXml(Element element) throws DeploymentException { // This one is mandatory String p = MetaData.getElementContent(MetaData.getUniqueChild(element, "cache-policy")); try { Class cls = SecurityActions.getContextClassLoader().loadClass(p); Constructor ctor = cls.getConstructor(new Class[] {AbstractInstanceCache.class}); m_cache = (CachePolicy)ctor.newInstance(new Object[] {this}); } catch (Exception x) { throw new DeploymentException("Can't create cache policy", x); } Element policyConf = MetaData.getOptionalChild(element, "cache-policy-conf"); if (policyConf != null) { if (m_cache instanceof XmlLoadable) { try { ((XmlLoadable)m_cache).importXml(policyConf); } catch (Exception x) { throw new DeploymentException("Can't import policy configuration", x); } } } }