01: package org.osbl.client.feeder;
02:
03: import org.conform.format.ResourceProvider;
04: import org.conform.BeanMetaProvider;
05: import org.osbl.client.ClientServiceProvider;
06:
07: import javax.servlet.http.HttpServlet;
08: import javax.servlet.ServletConfig;
09: import javax.servlet.ServletException;
10: import java.util.*;
11:
12: public abstract class Feed extends HttpServlet {
13: private static List<FeedInitializer> initializers = new LinkedList<FeedInitializer>();
14:
15: public static void addInitializer(FeedInitializer feedInitializer) {
16: initializers.add(feedInitializer);
17: }
18:
19: protected String channelURL;
20: protected String itemURL;
21:
22: private BeanMetaProvider beanMetaProvider;
23: private ClientServiceProvider serviceProvider;
24: private ResourceProvider resourceProvider;
25:
26: public final void init(ServletConfig servletConfig)
27: throws ServletException {
28: super .init(servletConfig);
29:
30: ClientServiceProvider serviceProvider = (ClientServiceProvider) servletConfig
31: .getServletContext().getAttribute("serviceProvider");
32: ClientServiceProvider.setInstance(serviceProvider);
33:
34: for (Iterator<FeedInitializer> iterator = initializers
35: .iterator(); iterator.hasNext();) {
36: FeedInitializer feedInitializer = iterator.next();
37: feedInitializer.preInitialization(this );
38: }
39:
40: initialize();
41:
42: for (Iterator<FeedInitializer> iterator = initializers
43: .iterator(); iterator.hasNext();) {
44: FeedInitializer feedInitializer = iterator.next();
45: feedInitializer.postInitialization(this );
46: }
47: }
48:
49: public String getChannelURL() {
50: return channelURL;
51: }
52:
53: public void setChannelURL(String channelURL) {
54: this .channelURL = channelURL;
55: }
56:
57: public String getItemURL() {
58: return itemURL;
59: }
60:
61: public void setItemURL(String itemURL) {
62: this .itemURL = itemURL;
63: }
64:
65: public BeanMetaProvider getBeanMetaProvider() {
66: return beanMetaProvider;
67: }
68:
69: public void setBeanMetaProvider(BeanMetaProvider beanMetaProvider) {
70: this .beanMetaProvider = beanMetaProvider;
71: }
72:
73: public ClientServiceProvider getServiceProvider() {
74: return serviceProvider;
75: }
76:
77: public void setServiceProvider(ClientServiceProvider serviceProvider) {
78: this .serviceProvider = serviceProvider;
79: }
80:
81: public ResourceProvider getResourceProvider() {
82: return resourceProvider;
83: }
84:
85: public void setResourceProvider(ResourceProvider resourceProvider) {
86: this .resourceProvider = resourceProvider;
87: }
88:
89: protected abstract void initialize();
90:
91: public String getServletName() {
92: return getClass().getSimpleName();
93: }
94: }
|