* @param history a message history
  * @param componentName the name of a component to scan for
  * @param startingIndex the index to start scanning
  * @return the properties provided by the named component or null if none available
 public static Properties locateComponentInHistory(
     MessageHistory history, String componentName, int startingIndex) {
   Assert.notNull(history, "'history' must not be null");
   Assert.isTrue(StringUtils.hasText(componentName), "'componentName' must be provided");
       startingIndex < history.size(), "'startingIndex' can not be greater then size of history");
   Properties component = null;
   for (int i = startingIndex; i < history.size(); i++) {
     Properties properties = history.get(i);
     if (componentName.equals(properties.get("name"))) {
       component = properties;
   return component;
 public void registerChannel(String channelName, MessageChannel channel) {
   if (channel instanceof NamedComponent
       && ((NamedComponent) channel).getComponentName() != null) {
     if (channelName == null) {
       channelName = ((NamedComponent) channel).getComponentName();
     } else {
           ((NamedComponent) channel).getComponentName().equals(channelName),
           "channel name has already been set with a conflicting value");
   registerBean(channelName, channel, this);
 private Schema loadSchema(Resource[] resources, String schemaLanguage)
     throws IOException, SAXException {
   Assert.notEmpty(resources, "No resources given");
   Assert.hasLength(schemaLanguage, "No schema language provided");
   Source[] schemaSources = new Source[resources.length];
   XMLReader xmlReader = XMLReaderFactory.createXMLReader();
   xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
   for (int i = 0; i < resources.length; i++) {
     Assert.notNull(resources[i], "Resource is null");
     Assert.isTrue(resources[i].exists(), "Resource " + resources[i] + " does not exist");
     InputSource inputSource = SaxResourceUtils.createInputSource(resources[i]);
     schemaSources[i] = new SAXSource(xmlReader, inputSource);
   SchemaFactory schemaFactory = SchemaFactory.newInstance(schemaLanguage);
   return schemaFactory.newSchema(schemaSources);
 public void cleanup() {
   Assert.isTrue(this.cache.isClosed(), "Cache did not close after close() call");
 public static void cleanUp() {
   Assert.isTrue(cache.isClosed(), "Cache did not close after close() call");