View Javadoc

1   // SECTION-START[License Header]
2   // <editor-fold defaultstate="collapsed" desc=" Generated License ">
3   /*
4    *   Java Object Management and Configuration
5    *   Copyright (C) Christian Schulte, 2005-206
6    *   All rights reserved.
7    *
8    *   Redistribution and use in source and binary forms, with or without
9    *   modification, are permitted provided that the following conditions
10   *   are met:
11   *
12   *     o Redistributions of source code must retain the above copyright
13   *       notice, this list of conditions and the following disclaimer.
14   *
15   *     o Redistributions in binary form must reproduce the above copyright
16   *       notice, this list of conditions and the following disclaimer in
17   *       the documentation and/or other materials provided with the
18   *       distribution.
19   *
20   *   THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21   *   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22   *   AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
23   *   THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
24   *   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25   *   NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26   *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27   *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28   *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29   *   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30   *
31   *   $JOMC: ObjectManager.java 4712 2013-01-02 13:56:12Z schulte $
32   *
33   */
34  // </editor-fold>
35  // SECTION-END
36  package org.jomc;
37  
38  import java.util.Locale;
39  
40  // SECTION-START[Documentation]
41  // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
42  /**
43   * Manages objects.
44   *
45   * <dl>
46   *   <dt><b>Identifier:</b></dt><dd>org.jomc.ObjectManager</dd>
47   *   <dt><b>Multiplicity:</b></dt><dd>One</dd>
48   *   <dt><b>Scope:</b></dt><dd>Singleton</dd>
49   * </dl>
50   *
51   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a> 1.0
52   * @version 1.0
53   * @see org.jomc.ObjectManager#getObject(java.lang.Class) getObject(ObjectManager.class)
54   * @see org.jomc.ObjectManager#getObject(java.lang.Class,java.lang.String) getObject(ObjectManager.class, "<i>implementation name</i>")
55   * @see org.jomc.ObjectManagerFactory
56   */
57  // </editor-fold>
58  // SECTION-END
59  // SECTION-START[Annotations]
60  // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
61  @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.4", comments = "See http://www.jomc.org/jomc/1.4/jomc-tools-1.4" )
62  // </editor-fold>
63  // SECTION-END
64  public interface ObjectManager
65  {
66      // SECTION-START[ObjectManager]
67  
68      /**
69       * Gets an instance of an implementation of a specification.
70       * <p><b>Note:</b><br/>
71       * Implementations must use the class loader associated with the given class as returned by method
72       * {@link Class#getClassLoader() specification.getClassLoader()} for loading classes. Only if that method returns
73       * {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap class
74       * loader is recommended.</p>
75       *
76       * @param <T> The type of the instance.
77       * @param specification The specification class to return an implementation instance of.
78       *
79       * @return An instance of an implementation of the specification class {@code specification} or {@code null}, if no
80       * such instance is available.
81       *
82       * @throws NullPointerException if {@code specification} is {@code null}.
83       * @throws ObjectManagementException if getting the object fails.
84       */
85      <T> T getObject( Class<T> specification )
86          throws NullPointerException, ObjectManagementException;
87  
88      /**
89       * Gets an instance of an implementation of a specification.
90       * <p><b>Note:</b><br/>
91       * Implementations must use the class loader associated with the given class as returned by method
92       * {@link Class#getClassLoader() specification.getClassLoader()} for loading classes. Only if that method returns
93       * {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap class
94       * loader is recommended.</p>
95       *
96       * @param <T> The type of the instance.
97       * @param specification The specification class to return an implementation instance of.
98       * @param implementationName The name of the implementation to return an instance of.
99       *
100      * @return An instance of the implementation named {@code implementationName} of the specification class
101      * {@code specification} or {@code null}, if no such instance is available.
102      *
103      * @throws NullPointerException if {@code specification} or {@code implementationName} is {@code null}.
104      * @throws ObjectManagementException if getting the object fails.
105      */
106     <T> T getObject( Class<T> specification, String implementationName )
107         throws NullPointerException, ObjectManagementException;
108 
109     /**
110      * Gets an instance of a dependency of an object.
111      * <p><b>Note:</b><br/>
112      * Implementations must use the class loader associated with the class of the given object as returned by method
113      * {@link Class#getClassLoader() object.getClass().getClassLoader()} for loading classes. Only if that method
114      * returns {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap
115      * class loader is recommended.</p>
116      *
117      * @param object The object to return a dependency instance of.
118      * @param dependencyName The name of the dependency of {@code object} to return an instance of.
119      *
120      * @return An instance of the dependency named {@code dependencyName} of {@code object} or {@code null}, if no such
121      * instance is available.
122      *
123      * @throws NullPointerException if {@code object} or {@code dependencyName} is {@code null}.
124      * @throws ObjectManagementException if getting the dependency instance fails.
125      */
126     Object getDependency( Object object, String dependencyName )
127         throws NullPointerException, ObjectManagementException;
128 
129     /**
130      * Gets an instance of a property of an object.
131      * <p><b>Note:</b><br/>
132      * Implementations must use the class loader associated with the class of the given object as returned by method
133      * {@link Class#getClassLoader() object.getClass().getClassLoader()} for loading classes. Only if that method
134      * returns {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap
135      * class loader is recommended.</p>
136      *
137      * @param object The object to return a property instance of.
138      * @param propertyName The name of the property of {@code object} to return an instance of.
139      *
140      * @return An instance of the property named {@code propertyName} of {@code object} or {@code null}, if no such
141      * instance is available.
142      *
143      * @throws NullPointerException if {@code object} or {@code propertyName} is {@code null}.
144      * @throws ObjectManagementException if getting the property instance fails.
145      */
146     Object getProperty( Object object, String propertyName )
147         throws NullPointerException, ObjectManagementException;
148 
149     /**
150      * Gets an instance of a message of an object.
151      * <p><b>Note:</b><br/>
152      * Implementations must use the class loader associated with the class of the given object as returned by method
153      * {@link Class#getClassLoader() object.getClass().getClassLoader()} for loading classes. Only if that method
154      * returns {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap
155      * class loader is recommended.</p>
156      *
157      * @param object The object to return a message instance of.
158      * @param messageName The name of the message of {@code object} to return an instance of.
159      * @param locale The locale of the message instance to return.
160      * @param arguments Arguments to format the message instance with.
161      *
162      * @return An instance of the message named {@code messageName} of {@code object} formatted with {@code arguments}
163      * for {@code locale} or {@code null}, if no such instance is available.
164      *
165      * @throws NullPointerException if {@code object}, {@code messageName} or {@code locale} is {@code null}.
166      * @throws ObjectManagementException if getting the message instance fails.
167      */
168     String getMessage( Object object, String messageName, Locale locale, Object... arguments )
169         throws NullPointerException, ObjectManagementException;
170 
171     // SECTION-END
172 }