1 /*
2 * Copyright 2006-2016 The JGUIraffe Team.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License")
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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 net.sf.jguiraffe.di;
17
18 /**
19 * <p>
20 * Definition of an interface for a <code>BeanStore</code> that can be
21 * manipulated.
22 * </p>
23 * <p>
24 * This interface inherits from the basic <code>BeanStore</code> interface and
25 * adds a set of methods to it that allow for changes of the store, i.e. adding/
26 * removing bean providers or cleaning the whole store.
27 * </p>
28 *
29 * @author Oliver Heger
30 * @version $Id: MutableBeanStore.java 205 2012-01-29 18:29:57Z oheger $
31 */
32 public interface MutableBeanStore extends BeanStore
33 {
34 /**
35 * Adds the specified <code>BeanProvider</code> to this bean store under
36 * the given name.
37 *
38 * @param name the name of the bean provider (must not be <b>null</b>)
39 * @param provider the <code>BeanProvider</code> to be registered
40 * @throws IllegalArgumentException if the name or the provider is <b>null</b>
41 */
42 void addBeanProvider(String name, BeanProvider provider);
43
44 /**
45 * Adds an <em>anonymous</em> <code>BeanProvider</code> to this
46 * <code>BeanStore</code>. It is possible to define beans in the context
47 * of a dependency tag (e.g. a <code><param></code> tag); then this
48 * bean is only visible in this narrow context and cannot be accessed from
49 * elsewhere. This makes sense for beans that are used only once and are not
50 * shared between different components; then defining the bean directly at
51 * the point where it is used is more readable. Such beans do not have a
52 * real name, but an internal name is generated by this method, which is
53 * treated specially. For instance, internal names won't be returned by the
54 * <code>providerNames()</code> methods. The passed in index parameter is
55 * used for generating a unique name for the provider. It is in the
56 * responsibility of the caller to pass in unique numbers.
57 *
58 * @param index the index of the <code>BeanProvider</code>
59 * @param provider the <code>BeanProvider</code> to be registered (must
60 * not be <b>null</b>)
61 * @return the generated name for this <code>BeanProvider</code>
62 * @throws IllegalArgumentException if the <code>BeanProvider</code> is
63 * <b>null</b>
64 */
65 String addAnonymousBeanProvider(int index, BeanProvider provider);
66
67 /**
68 * Removes the <code>BeanProvider</code> with the specified name from this
69 * bean store. If this provider cannot be found, this operation has no
70 * effect.
71 *
72 * @param name the name of the provider to remove
73 * @return a reference to the removed provider or <b>null</b> if it could
74 * not be found
75 */
76 BeanProvider removeBeanProvider(String name);
77
78 /**
79 * Removes all <code>BeanProvider</code>s from this bean store.
80 */
81 void clear();
82
83 /**
84 * Sets the name of this bean store.
85 *
86 * @param n the new name
87 */
88 void setName(String n);
89
90 /**
91 * Sets the parent for this bean store.
92 *
93 * @param p the parent
94 */
95 void setParent(BeanStore p);
96 }