1    /*
2     * Copyright 2007 :torweg free software group
3     * 
4     * This program is free software: you can redistribute it and/or modify
5     * it under the terms of the GNU General Public License as published by
6     * the Free Software Foundation, either version 3 of the License, or
7     * (at your option) any later version.
8     * 
9     * This program 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
12    * GNU General Public License for more details.
13    * 
14    * You should have received a copy of the GNU General Public License
15    * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16    *
17    */
18   package org.torweg.pulse.bundle;
19   
20   import org.torweg.pulse.configuration.ConfigBean;
21   import org.torweg.pulse.configuration.Configuration;
22   import org.torweg.pulse.configuration.PoorMansCache;
23   
24   /**
25    * @author Christian Schatt
26    * @version $Revision: 1383 $
27    */
28   public abstract class AbstractConfigurableJoblet extends AbstractJoblet {
29   
30       /**
31        * Returns the {@code Joblet}'s configuration registered for the given
32        * {@code Bundle} or the global configuration if none is registered for
33        * the given {@code Bundle} or {@code null} if no configuration
34        * could be found at all.
35        * 
36        * @param b
37        *            the {@code Bundle} the {@code Joblet}'s
38        *            configuration is registered for
39        * 
40        * @return the {@code Joblet}'s configuration or {@code null}
41        */
42       @Deprecated
43       public final ConfigBean getConfig(final Bundle b) {
44           ConfigBean config = PoorMansCache.getBundleConfig(getClass(), b);
45           if (config == null) {
46               config = PoorMansCache.getConfig(getClass());
47           }
48           return config;
49       }
50   
51       /**
52        * Returns the {@code Joblet}'s configuration registered for the given
53        * {@code Bundle} or the global configuration if none is registered for
54        * the given {@code Bundle} or {@code null} if no configuration
55        * could be found at all.
56        * 
57        * @param b
58        *            the {@code Bundle} the {@code Joblet}'s
59        *            configuration is registered for
60        * 
61        * @return the {@code Joblet}'s configuration or {@code null}
62        */
63       public final Configuration getConfiguration(final Bundle b) {
64           Configuration config = PoorMansCache.getBundleConfiguration(getClass(),
65                   b);
66           if (config == null) {
67               config = PoorMansCache.getConfiguration(getClass());
68           }
69           return config;
70       }
71   
72   }
73