]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
4030da17e0720601d0c2df4eec115948db68d76c
[tmp/jakarta-migration.git] /
1 /*
2  * (C) Copyright 2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the GNU Lesser General Public License
6  * (LGPL) version 2.1 which accompanies this distribution, and is available at
7  * http://www.gnu.org/licenses/lgpl.html
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * Contributors:
15  *     Nuxeo - initial API and implementation
16  *
17  * $Id$
18  */
19
20 package org.collectionspace.ecm.platform.quote.service;
21
22 import org.apache.commons.logging.Log;
23 import org.apache.commons.logging.LogFactory;
24 import org.nuxeo.runtime.model.ComponentInstance;
25 import org.nuxeo.runtime.model.DefaultComponent;
26
27 import org.collectionspace.ecm.platform.quote.api.QuoteManager;
28 import org.collectionspace.ecm.platform.quote.impl.QuoteManagerImpl;
29
30 /**
31  * @author <a href="mailto:glefter@nuxeo.com">George Lefter</a>
32  *
33  */
34 public class QuoteService extends DefaultComponent {
35
36     public static final String ID = "org.collectionspace.ecm.platform.quote.service.QuoteService";
37
38     public static final String VERSIONING_EXTENSION_POINT_RULES = "rules";
39
40     private static final Log log = LogFactory.getLog(QuoteService.class);
41
42     private QuoteManager quoteManager;
43
44     private QuoteServiceConfig config;
45
46     @Override
47     public void registerContribution(Object contribution,
48             String extensionPoint, ComponentInstance contributor) {
49         if ("config".equals(extensionPoint)) {
50             config = (QuoteServiceConfig) contribution;
51             log.debug("registered service config: " + config);
52         } else {
53             log.warn("unknown extension point: " + extensionPoint);
54         }
55     }
56
57     @Override
58     public void unregisterContribution(Object contribution,
59             String extensionPoint, ComponentInstance contributor) {
60         // do nothing
61     }
62
63     public QuoteManager getQuoteManager() {
64         log.debug("getQuoteManager");
65         if (quoteManager == null) {
66             quoteManager = new QuoteManagerImpl(config);
67         }
68         return quoteManager;
69     }
70
71     public QuoteServiceConfig getConfig() {
72         return config;
73     }
74
75     @Override
76     public <T> T getAdapter(Class<T> adapter) {
77         if (adapter == QuoteManager.class) {
78             return adapter.cast(getQuoteManager());
79         }
80         return null;
81     }
82
83 }