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 <cs@schulte.it>, 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 5061 2015-05-31 13:20:40Z 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.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
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>
71       * <b>Note:</b><br/>
72       * Implementations must use the class loader associated with the given class as returned by method
73       * {@link Class#getClassLoader() specification.getClassLoader()} for loading classes. Only if that method returns
74       * {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap class
75       * loader is recommended.
76       * </p>
77       *
78       * @param <T> The type of the instance.
79       * @param specification The specification class to return an implementation instance of.
80       *
81       * @return An instance of an implementation of the specification class {@code specification} or {@code null}, if no
82       * such instance is available.
83       *
84       * @throws NullPointerException if {@code specification} is {@code null}.
85       * @throws ObjectManagementException if getting the object fails.
86       */
87      <T> T getObject( Class<T> specification )
88          throws NullPointerException, ObjectManagementException;
89  
90      /**
91       * Gets an instance of an implementation of a specification.
92       * <p>
93       * <b>Note:</b><br/>
94       * Implementations must use the class loader associated with the given class as returned by method
95       * {@link Class#getClassLoader() specification.getClassLoader()} for loading classes. Only if that method returns
96       * {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap class
97       * loader is recommended.
98       * </p>
99       *
100      * @param <T> The type of the instance.
101      * @param specification The specification class to return an implementation instance of.
102      * @param implementationName The name of the implementation to return an instance of.
103      *
104      * @return An instance of the implementation named {@code implementationName} of the specification class
105      * {@code specification} or {@code null}, if no such instance is available.
106      *
107      * @throws NullPointerException if {@code specification} or {@code implementationName} is {@code null}.
108      * @throws ObjectManagementException if getting the object fails.
109      */
110     <T> T getObject( Class<T> specification, String implementationName )
111         throws NullPointerException, ObjectManagementException;
112 
113     /**
114      * Gets an instance of a dependency of an object.
115      * <p>
116      * <b>Note:</b><br/>
117      * Implementations must use the class loader associated with the class of the given object as returned by method
118      * {@link Class#getClassLoader() object.getClass().getClassLoader()} for loading classes. Only if that method
119      * returns {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap
120      * class loader is recommended.
121      * </p>
122      *
123      * @param object The object to return a dependency instance of.
124      * @param dependencyName The name of the dependency of {@code object} to return an instance of.
125      *
126      * @return An instance of the dependency named {@code dependencyName} of {@code object} or {@code null}, if no such
127      * instance is available.
128      *
129      * @throws NullPointerException if {@code object} or {@code dependencyName} is {@code null}.
130      * @throws ObjectManagementException if getting the dependency instance fails.
131      */
132     Object getDependency( Object object, String dependencyName )
133         throws NullPointerException, ObjectManagementException;
134 
135     /**
136      * Gets an instance of a property of an object.
137      * <p>
138      * <b>Note:</b><br/>
139      * Implementations must use the class loader associated with the class of the given object as returned by method
140      * {@link Class#getClassLoader() object.getClass().getClassLoader()} for loading classes. Only if that method
141      * returns {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap
142      * class loader is recommended.
143      * </p>
144      *
145      * @param object The object to return a property instance of.
146      * @param propertyName The name of the property of {@code object} to return an instance of.
147      *
148      * @return An instance of the property named {@code propertyName} of {@code object} or {@code null}, if no such
149      * instance is available.
150      *
151      * @throws NullPointerException if {@code object} or {@code propertyName} is {@code null}.
152      * @throws ObjectManagementException if getting the property instance fails.
153      */
154     Object getProperty( Object object, String propertyName )
155         throws NullPointerException, ObjectManagementException;
156 
157     /**
158      * Gets an instance of a message of an object.
159      * <p>
160      * <b>Note:</b><br/>
161      * Implementations must use the class loader associated with the class of the given object as returned by method
162      * {@link Class#getClassLoader() object.getClass().getClassLoader()} for loading classes. Only if that method
163      * returns {@code null}, indicating the class has been loaded by the bootstrap class loader, use of the bootstrap
164      * class loader is recommended.
165      * </p>
166      *
167      * @param object The object to return a message instance of.
168      * @param messageName The name of the message of {@code object} to return an instance of.
169      * @param locale The locale of the message instance to return.
170      * @param arguments Arguments to format the message instance with.
171      *
172      * @return An instance of the message named {@code messageName} of {@code object} formatted with {@code arguments}
173      * for {@code locale} or {@code null}, if no such instance is available.
174      *
175      * @throws NullPointerException if {@code object}, {@code messageName} or {@code locale} is {@code null}.
176      * @throws ObjectManagementException if getting the message instance fails.
177      */
178     String getMessage( Object object, String messageName, Locale locale, Object... arguments )
179         throws NullPointerException, ObjectManagementException;
180 
181     // SECTION-END
182 }