Exemplo n.º 1
0
 /**
  * @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");
   Assert.isTrue(
       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;
       break;
     }
   }
   return component;
 }
Exemplo n.º 2
0
 public void registerChannel(String channelName, MessageChannel channel) {
   if (channel instanceof NamedComponent
       && ((NamedComponent) channel).getComponentName() != null) {
     if (channelName == null) {
       channelName = ((NamedComponent) channel).getComponentName();
     } else {
       Assert.isTrue(
           ((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);
 }
 @After
 public void cleanup() {
   this.cache.close();
   Assert.isTrue(this.cache.isClosed(), "Cache did not close after close() call");
 }
 @AfterClass
 public static void cleanUp() {
   cache.close();
   Assert.isTrue(cache.isClosed(), "Cache did not close after close() call");
 }