01: /*
02: * Copyright 2004 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.outerj.daisy.emailnotifier.serverimpl;
17:
18: import org.outerj.daisy.httpconnector.spi.RequestHandler;
19: import org.outerj.daisy.emailnotifier.serverimpl.httphandlers.*;
20: import org.outerj.daisy.plugin.PluginRegistry;
21:
22: import javax.annotation.PreDestroy;
23: import java.util.List;
24: import java.util.ArrayList;
25:
26: public class SubscriptionManagerHttpConnector {
27: private PluginRegistry pluginRegistry;
28: private List<RequestHandler> handlers;
29:
30: public SubscriptionManagerHttpConnector(
31: PluginRegistry pluginRegistry) throws Exception {
32: this .pluginRegistry = pluginRegistry;
33: initialize();
34: }
35:
36: @PreDestroy
37: public void destroy() {
38: dispose();
39: }
40:
41: private void initialize() throws Exception {
42: handlers = new ArrayList<RequestHandler>();
43: handlers.add(new SubscriptionHandler());
44: handlers.add(new SubscriptionsHandler());
45: handlers.add(new EventSubscribersHandler());
46: handlers.add(new DocumentSubscriptionHandler());
47: handlers.add(new DocumentSubscriptionForUserHandler());
48: handlers.add(new CollectionSubscriptionsHandler());
49:
50: for (RequestHandler handler : handlers) {
51: pluginRegistry.addPlugin(RequestHandler.class, handler
52: .getNamespace()
53: + handler.getPathPattern(), handler);
54: }
55: }
56:
57: private void dispose() {
58: for (RequestHandler handler : handlers) {
59: pluginRegistry.removePlugin(RequestHandler.class, handler
60: .getNamespace()
61: + handler.getPathPattern(), handler);
62: }
63: }
64: }
|