01: /**
02: * EasyBeans
03: * Copyright (C) 2007 Bull S.A.S.
04: * Contact: easybeans@objectweb.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: BindingManager.java 2010 2007-10-26 13:19:08Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.proxy.binding;
25:
26: import java.util.ArrayList;
27: import java.util.List;
28:
29: import org.ow2.easybeans.api.binding.EZBBindingFactory;
30:
31: /**
32: * Manager of the binding factories.
33: * @author Florent BENOIT
34: */
35: public final class BindingManager {
36:
37: /**
38: * List of binding factories.
39: */
40: private List<EZBBindingFactory> bindingFactories = null;
41:
42: /**
43: * Unique instance of this manager.
44: */
45: private static BindingManager unique = null;
46:
47: /**
48: * Hide constructor, should use getInstance() method.
49: */
50: private BindingManager() {
51: this .bindingFactories = new ArrayList<EZBBindingFactory>();
52:
53: // Add the default factory
54: this .bindingFactories.add(new JNDIBindingFactory());
55: }
56:
57: /**
58: * Register a factory.
59: * @param factory the binding factory to add.
60: */
61: public void registerFactory(final EZBBindingFactory factory) {
62: bindingFactories.add(factory);
63: }
64:
65: /**
66: * Unregister a factory.
67: * @param factory the binding factory to remove.
68: */
69: public void unregisterFactory(final EZBBindingFactory factory) {
70: bindingFactories.remove(factory);
71: }
72:
73: /**
74: * Gets the instance.
75: * @return the unique instance.
76: */
77: public static BindingManager getInstance() {
78: if (unique == null) {
79: unique = new BindingManager();
80: }
81: return unique;
82: }
83:
84: /**
85: * @return list of factories
86: */
87: public List<EZBBindingFactory> getFactories() {
88: return bindingFactories;
89: }
90: }
|