View Javadoc

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.impl.providers;
17  
18  import java.util.Set;
19  
20  import net.sf.jguiraffe.di.BeanProvider;
21  import net.sf.jguiraffe.di.Dependency;
22  import net.sf.jguiraffe.di.DependencyProvider;
23  
24  /**
25   * <p>
26   * A base class for simple bean providers.</code>
27   * <p>
28   * A <em>simple</em> <code>BeanProvider</code> is a bean provider that only
29   * cares for creating new bean instances. It does not have further support for
30   * life-cycle features. Bean providers of this type are intended to collaborate
31   * with a life-cycle-aware bean provider. This provider uses the simple bean
32   * provider just for the creation and implements specific initialization
33   * functionality.
34   * </p>
35   * <p>
36   * This base class provides implementations for some of the methods defined in
37   * the <code>{@link BeanProvider}</code> interface. Especially dummy
38   * implementations for the locking methods are available, which are typically
39   * not needed by simple providers.
40   * </p>
41   *
42   * @author Oliver Heger
43   * @version $Id: SimpleBeanProvider.java 205 2012-01-29 18:29:57Z oheger $
44   */
45  public abstract class SimpleBeanProvider implements BeanProvider
46  {
47      /**
48       * Returns the dependencies for this bean provider. This implementation
49       * simply returns <b>null</b>. Simple providers often do not have any
50       * dependencies.
51       *
52       * @return a set with the dependencies of this bean provider
53       */
54      public Set<Dependency> getDependencies()
55      {
56          return null;
57      }
58  
59      /**
60       * Returns the lock ID of the current transaction. Simple bean providers do
61       * not require any lock handling. So this implementation always returns
62       * <b>null</b>.
63       *
64       * @return the lock ID of the current transaction
65       */
66      public Long getLockID()
67      {
68          return null;
69      }
70  
71      /**
72       * Sets the lock ID of the current transaction. This is just a dummy
73       * implementation; simple bean providers do not need any lock handling.
74       *
75       * @param lid the lock ID of the current transaction
76       */
77      public void setLockID(Long lid)
78      {
79      }
80  
81      /**
82       * Returns a flag whether the managed bean is available. For simple bean
83       * providers this is always the case, so this implementation always returns
84       * <b>true</b>.
85       *
86       * @return a flag whether the managed bean is available
87       */
88      public boolean isBeanAvailable()
89      {
90          return true;
91      }
92  
93      /**
94       * Shuts down this {@code BeanProvider}. This implementation is just an
95       * empty dummy; a simple bean provider does not need any special shutdown
96       * handling.
97       *
98       * @param depProvider the {@code DependencyProvider}
99       */
100     public void shutdown(DependencyProvider depProvider)
101     {
102     }
103 }