/** * 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 a unique child element. * * @param element The parent element. * @param tagName The name of the desired child. * @return The element content or null. */ public static String getUniqueChildContent(Element element, String tagName) { return getElementContent(getUniqueChild(element, tagName)); }
public void setClientInterceptors(Element config) throws Exception { this.interceptorConfig = config; Iterator interceptorElements = MetaData.getChildrenByTagName(interceptorConfig, "interceptor"); ClassLoader loader = Thread.currentThread().getContextClassLoader(); interceptorClasses.clear(); while( interceptorElements != null && interceptorElements.hasNext() ) { Element ielement = (Element) interceptorElements.next(); String className = null; className = MetaData.getElementContent(ielement); Class clazz = loader.loadClass(className); interceptorClasses.add(clazz); log.debug("added interceptor type: "+clazz); } }
propertyName = MetaData.getUniqueChildContent(element, "property-name"); MetaData.getOptionalChildContent(element, "column-name"); if(columnStr != null) { columnName = columnStr; String jdbcStr = MetaData.getOptionalChildContent(element, "jdbc-type"); if(jdbcStr != null) { jdbcType = JDBCMappingMetaData.getJdbcTypeFromName(jdbcStr); sqlType = MetaData.getUniqueChildContent(element, "sql-type"); } else { jdbcType = Integer.MIN_VALUE; notNull = (MetaData.getOptionalChild(element, "not-null") != null);
String strategyStr = MetaData.getUniqueChildContent(element, "strategy"); strategy = (byte)STRATEGIES.indexOf(strategyStr); if(strategy < 0) String pageSizeStr = MetaData.getOptionalChildContent(element, "page-size"); if(pageSizeStr != null) Element eagerLoadGroupElement = MetaData.getOptionalChild(element, "eager-load-group"); if(eagerLoadGroupElement != null) eagerLoadGroup = MetaData.getElementContent(eagerLoadGroupElement); Iterator iter = MetaData.getChildrenByTagName(element, "left-join"); leftJoinList = JDBCLeftJoinMetaData.readLeftJoinList(iter);
/** * 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"); } }
Element activationConfig = MetaData.getOptionalChild(proxyConfig, "activation-config"); if (activationConfig != null) Iterator<Element> iterator = MetaData.getChildrenByTagName(activationConfig, "activation-config-property"); while (iterator.hasNext()) org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData md = new org.jboss.metadata.ejb.spec.ActivationConfigPropertyMetaData(); ActivationConfigPropertyMetaData metaData = new ActivationConfigPropertyMetaData(md); String name = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-name")); String value = MetaData.getElementContent(MetaData.getUniqueChild(xml, "activation-config-property-value")); if (name == null || name.trim().length() == 0) throw new DeploymentException("activation-config-property doesn't have a name");
private Method[] getQueryMethods(Element queryElement) throws DeploymentException { // query-method sub-element Element queryMethod = MetaData.getUniqueChild(queryElement, "query-method"); // method name String methodName = MetaData.getUniqueChildContent(queryMethod, "method-name"); // method params ArrayList methodParams = new ArrayList(); Element methodParamsElement = MetaData.getUniqueChild(queryMethod, "method-params"); Iterator iterator = MetaData.getChildrenByTagName(methodParamsElement, "method-param"); while(iterator.hasNext()) { methodParams.add(MetaData.getElementContent((Element) iterator.next())); } try { Class[] parameters = Classes.convertToJavaClasses(methodParams.iterator(), entity.getClassLoader()); return getQueryMethods(methodName, parameters); } catch(ClassNotFoundException cnfe) { throw new DeploymentException(cnfe.getMessage()); } }
checkActivationConfig("password", metaData.getPasswd()); Element proxyConfig = invokerMetaData.getProxyFactoryConfig(); checkActivationConfig("maxMessages", MetaData.getOptionalChildContent(proxyConfig, "MaxMessages")); checkActivationConfig("minSession", MetaData.getOptionalChildContent(proxyConfig, "MinimumSize")); checkActivationConfig("maxSession", MetaData.getOptionalChildContent(proxyConfig, "MaximumSize")); checkActivationConfig("keepAlive", MetaData.getOptionalChildContent(proxyConfig, "KeepAliveMillis")); Element mdbConfig = MetaData.getOptionalChild(proxyConfig, "MDBConfig"); if (mdbConfig != null) if ("false".equalsIgnoreCase(MetaData.getElementContent(MetaData.getUniqueChild(mdbConfig, "DeliveryActive")))) checkActivationConfig("reconnectInterval", MetaData.getOptionalChildContent(proxyConfig, "ReconnectIntervalSec")); checkActivationConfig("deliveryActive", MetaData.getOptionalChildContent(proxyConfig, "DeliveryActive")); checkActivationConfig("providerAdapterJNDI", MetaData.getOptionalChildContent(proxyConfig, "JMSProviderAdapterJNDI")); Element dlqEl = MetaData.getOptionalChild(mdbConfig, "DLQConfig"); if (dlqEl != null) checkActivationConfig("DLQJNDIName", MetaData.getElementContent(MetaData.getUniqueChild(dlqEl, "DestinationQueue"))); try checkActivationConfig("DLQMaxResent", MetaData.getElementContent(MetaData.getUniqueChild(dlqEl, "MaxTimesRedelivered"))); checkActivationConfig("DLQUser", MetaData.getElementContent(MetaData.getOptionalChild(dlqEl, "DLQUser"))); checkActivationConfig("DLQPassword", MetaData.getElementContent(MetaData.getOptionalChild(dlqEl, "DLQPassword")));
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 Exception Iterator interceptorElements = MetaData.getChildrenByTagName(interceptors, "interceptor"); ClassLoader loader = container.getClassLoader(); while(interceptorElements != null && interceptorElements.hasNext()) className = MetaData.getElementContent(ielement); String byValueAttr = MetaData.getElementAttribute(ielement, "call-by-value"); if(byValueAttr != null)
if((strategyEl = MetaData.getOptionalChild(element, "group-name")) != null) groupName = MetaData.getElementContent(strategyEl); lockingField = null; keyGeneratorFactory = null; else if((strategyEl = MetaData.getOptionalChild(element, "modified-strategy")) != null) else if((strategyEl = MetaData.getOptionalChild(element, "read-strategy")) != null) else if((strategyEl = MetaData.getOptionalChild(element, "version-column")) != null) String fieldType = MetaData.getOptionalChildContent(element, "field-type"); if(fieldType != null) throw new DeploymentException( else if((strategyEl = MetaData.getOptionalChild(element, "timestamp-column")) != null) String fieldType = MetaData.getOptionalChildContent(element, "field-type"); if(fieldType != null) throw new DeploymentException( MetaData.getOptionalChildContent(element, "key-generator-factory")) != null)
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()); } } }
Element clientInterceptors = MetaData.getOptionalChild( proxyConfig, "client-interceptors", null if(clientInterceptors != null) String value = MetaData.getElementAttribute(clientInterceptors, "exposeContainer"); this.includeIClientIface = Boolean.valueOf(value).booleanValue(); NodeList children = clientInterceptors.getChildNodes();
/** * Get the content of the given element. * * @param element The element to get the content for. * @return The content of the element or null. */ public static String getElementContent(final Element element) { return getElementContent(element, 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); }
String perferredRelationMapping = MetaData.getOptionalChildContent(element, "preferred-relation-mapping"); if (MetaData.getOptionalChild(element, "relation-table-mapping") != null) if (MetaData.getOptionalChild(element, "foreign-key-mapping") != null)
Iterator interceptorElements = MetaData.getChildrenByTagName(element, "interceptor"); String transTypeString = stringTransactionValue(transType); ClassLoader loader = container.getClassLoader(); try className = MetaData.getFirstElementContent(ielement, null); Class clazz = loader.loadClass(className); Interceptor interceptor = (Interceptor) clazz.newInstance();
/** * Gets the child of the specified element having the * specified name. If the child with this name doesn't exist * then the supplied default element is returned instead. * * @param element the parent element * @param tagName the name of the desired child * @param defaultElement the element to return if the child * doesn't exist * @return either the named child or the supplied default */ public static Element getOptionalChild(Element element, String tagName, Element defaultElement) { Iterator goodChildren = getChildrenByTagName(element, tagName); if (goodChildren != null && goodChildren.hasNext()) { Element child = (Element)goodChildren.next(); if (goodChildren.hasNext()) { throw new IllegalStateException("expected only one " + tagName + " tag"); } return child; } else { return defaultElement; } }
name = MetaData.getUniqueChildContent(element, "name"); String rowLockingSQL = MetaData.getUniqueChildContent(element, "row-locking-template"); if(rowLockingSQL != null && !rowLockingSQL.trim().equals("")) String pkConstraintSQL = MetaData.getUniqueChildContent(element, "pk-constraint-template"); if(pkConstraintSQL != null && !pkConstraintSQL.trim().equals("")) String fkConstraintSQL = MetaData.getUniqueChildContent(element, "fk-constraint-template"); if(fkConstraintSQL != null && !fkConstraintSQL.trim().equals("")) String alterColumnSQL = MetaData.getOptionalChildContent(element, "add-column-template"); if(alterColumnSQL != null && !alterColumnSQL.trim().equals("")) alterColumnSQL = MetaData.getOptionalChildContent(element, "alter-column-template"); if(alterColumnSQL != null && !alterColumnSQL.trim().equals("")) alterColumnSQL = MetaData.getOptionalChildContent(element, "drop-column-template"); if(alterColumnSQL != null && !alterColumnSQL.trim().equals("")) String autoIncrementSQL = MetaData.getOptionalChildContent(element, "auto-increment-template"); if(autoIncrementSQL != null && !autoIncrementSQL.trim().equals("")) Iterator iterator = MetaData.getChildrenByTagName(element, "mapping"); while(iterator.hasNext()) Iterator functions = MetaData.getChildrenByTagName(element, "function-mapping"); while(functions.hasNext())