Created
December 20, 2012 20:15
-
-
Save jeremyheiler/4348185 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public ItemProcessor extends IterativeProcessor<String> implements Processor { | |
@Override | |
public List<String> getItems(Request req) { | |
return req.getParameters("items"); | |
} | |
@Override | |
public void processItem(Request req, String item) { | |
Database.saveItem(item); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract IterativeProcessor<T> implements Processor { | |
protected abstract List<T> getItems(Request req); | |
protected abstract void processItem(Request req, T item); | |
@Override | |
public final void process(Request req) { | |
for (T item : getItems(req)) { | |
processItem(req, item); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface Processor { | |
public void process(Request req); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment