(window.webpackJsonp=window.webpackJsonp||[]).push([[138],{561:function(e,t,n){"use strict";n.r(t);var a=n(56),r=Object(a.a)({},(function(){var e=this,t=e.$createElement,n=e._self._c||t;return n("ContentSlotsDistributor",{attrs:{"slot-key":e.$parent.slotKey}},[n("h1",{attrs:{id:"resource-support"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#resource-support"}},[e._v("#")]),e._v(" Resource Support")]),e._v(" "),n("h2",{attrs:{id:"resource-support-2"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#resource-support-2"}},[e._v("#")]),e._v(" Resource Support")]),e._v(" "),n("p",[e._v("The resource inbound channel adapter builds upon Spring’s "),n("code",[e._v("Resource")]),e._v(" abstraction to support greater flexibility across a variety of actual types of underlying resources, such as a file, a URL, or a class path resource.\nTherefore, it is similar to but more generic than the file inbound channel adapter.")]),e._v(" "),n("h3",{attrs:{id:"resource-inbound-channel-adapter"}},[n("a",{staticClass:"header-anchor",attrs:{href:"#resource-inbound-channel-adapter"}},[e._v("#")]),e._v(" Resource Inbound Channel Adapter")]),e._v(" "),n("p",[e._v("The resource inbound channel adapter is a polling adapter that creates a "),n("code",[e._v("Message")]),e._v(" whose payload is a collection of "),n("code",[e._v("Resource")]),e._v(" objects.")]),e._v(" "),n("p",[n("code",[e._v("Resource")]),e._v(" objects are resolved based on the pattern specified by the "),n("code",[e._v("pattern")]),e._v(" attribute.\nThe collection of resolved "),n("code",[e._v("Resource")]),e._v(" objects is then sent as a payload within a "),n("code",[e._v("Message")]),e._v(" to the adapter’s channel.\nThat is one major difference between resource inbound channel adapter and file inbound channel adapter: The latter buffers "),n("code",[e._v("File")]),e._v(" objects and sends a single "),n("code",[e._v("File")]),e._v(" object per "),n("code",[e._v("Message")]),e._v(".")]),e._v(" "),n("p",[e._v("The following example shows a simple configuration that finds all files that end with the 'properties' extension in the "),n("code",[e._v("things.thing1")]),e._v(" package available on the classpath and sends them as the payload of a "),n("code",[e._v("Message")]),e._v(" to the channel named ‘resultChannel’:")]),e._v(" "),n("div",{staticClass:"language- extra-class"},[n("pre",{pre:!0,attrs:{class:"language-text"}},[n("code",[e._v('\n \n\n')])])]),n("p",[e._v("The resource inbound channel adapter relies on the "),n("code",[e._v("org.springframework.core.io.support.ResourcePatternResolver")]),e._v(" strategy interface to resolve the provided pattern.\nIt defaults to an instance of the current "),n("code",[e._v("ApplicationContext")]),e._v(".\nHowever, you can provide a reference to an instance of your own implementation of "),n("code",[e._v("ResourcePatternResolver")]),e._v(" by setting the "),n("code",[e._v("pattern-resolver")]),e._v(" attribute, as the following example shows:")]),e._v(" "),n("div",{staticClass:"language- extra-class"},[n("pre",{pre:!0,attrs:{class:"language-text"}},[n("code",[e._v('\n \n\n\n\n')])])]),n("p",[e._v("You may have a use case where you need to further filter the collection of resources resolved by the "),n("code",[e._v("ResourcePatternResolver")]),e._v(".\nFor example, you may want to prevent resources that were already resolved from appearing in a collection of resolved resources ever again.\nOn the other hand, your resources might be updated rather often and you "),n("em",[e._v("do")]),e._v(" want them to be picked up again.\nIn other words, both defining an additional filter and disabling filtering altogether are valid use cases.\nYou can provide your own implementation of the "),n("code",[e._v("org.springframework.integration.util.CollectionFilter")]),e._v(" strategy interface, as the following example shows:")]),e._v(" "),n("div",{staticClass:"language- extra-class"},[n("pre",{pre:!0,attrs:{class:"language-text"}},[n("code",[e._v("public interface CollectionFilter {\n\n Collection filter(Collection unfilteredElements);\n\n}\n")])])]),n("p",[e._v("The "),n("code",[e._v("CollectionFilter")]),e._v(" receives a collection of un-filtered elements (which are "),n("code",[e._v("Resource")]),e._v(" objects in the preceding example), and it returns a collection of filtered elements of that same type.")]),e._v(" "),n("p",[e._v("If you define the adapter with XML but you do not specify a filter reference, the resource inbound channel adapter uses a default implementation of "),n("code",[e._v("CollectionFilter")]),e._v(".\nThe implementation class of that default filter is "),n("code",[e._v("org.springframework.integration.util.AcceptOnceCollectionFilter")]),e._v(".\nIt remembers the elements passed in the previous invocation in order to avoid returning those elements more than once.")]),e._v(" "),n("p",[e._v("To inject your own implementation of "),n("code",[e._v("CollectionFilter")]),e._v(" instead, use the "),n("code",[e._v("filter")]),e._v(" attribute, as the following example shows:")]),e._v(" "),n("div",{staticClass:"language- extra-class"},[n("pre",{pre:!0,attrs:{class:"language-text"}},[n("code",[e._v('\n \n\n\n\n')])])]),n("p",[e._v("If you do not need any filtering and want to disable even the default "),n("code",[e._v("CollectionFilter")]),e._v(" strategy, provide an empty value for the filter attribute (for example, "),n("code",[e._v('filter=""')]),e._v(")")])])}),[],!1,null,null,null);t.default=r.exports}}]);