Skip to content

Instantly share code, notes, and snippets.

@sevennineteen
Created September 22, 2011 17:14
Show Gist options
  • Save sevennineteen/1235375 to your computer and use it in GitHub Desktop.
Save sevennineteen/1235375 to your computer and use it in GitHub Desktop.
Boilerplate to extend Day CQ's HTTP Polling Importer
package com.my.company.customimporter;
import java.io.IOException;
import java.io.InputStream;
import org.apache.sling.api.resource.Resource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.day.cq.polling.importer.HttpImporter;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Property;
/* These annotations are used by the SCR plugin
* to generate XML under OSGI-INF needed to deploy
* the component as a Declarative Service.
*/
@Component(label="My Custom Poller", metatype=true) // metatype makes service Felix-configurable
@Service
@Property(name="importer.scheme", label="Import Scheme", value="myscheme") // register the import scheme
/* extend the HttpImporter class */
public class MyCustomPoller extends HttpImporter {
private static final Logger log = LoggerFactory.getLogger(MyCustomPoller.class);
/* Implement the importData() method.
* This will typically be logic for persisting
* the response data relative to the target node.
*/
@Override
protected void importData(String scheme, InputStream data, String characterEncoding, Resource target) throws IOException {
log.info("Now we're cooking with gas...");
}
}
@Radha-Gangwar
Copy link

Hello,

How are importing the data in AEM using this code? I tried to replicate the same but not able to import the data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment