View Javadoc

1   /**
2    * Project MI+
3    *
4    * Copyright (c) 2013, Syed Muhammad Humayun - smhumayun@gmail.com
5    *
6    * This project includes software developed by Syed Muhammad Humayun - smhumayun@gmail.com
7    * http://www.smhumayun.com
8    *
9    * Licensed under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License. You may obtain a copy of the License at:
12   *
13   * http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on
17   * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied. See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21   */
22  package com.smhumayun.mi_plus;
23  
24  import java.util.LinkedHashMap;
25  
26  /**
27   * MI Object Cache used by {@link MIFactory}
28   *
29   * @author smhumayun
30   * @since 1.0
31   */
32  public interface MIObjectCache {
33  
34      /**
35       * Get cached MI Container Proxy object against given <code>miContainerClass</code>
36       *
37       * @param miContainerClass MI Container class - the class which has the {@link MISupport} annotation
38       * @return cached MI Container Proxy object against given <code>miContainerClass</code>
39       * @throws com.smhumayun.mi_plus.MIException
40       *          {@link com.smhumayun.mi_plus.MIException}
41       */
42      Object getCachedMiContainerProxy(Class miContainerClass) throws MIException;
43  
44      /**
45       * Cache given <code>miContainerProxy</code> object against given <code>miContainerClass</code>
46       *
47       * @param miContainerClass MI Container class - the class which has the {@link MISupport} annotation
48       * @param miContainerProxy      MI Container Proxy object to cache
49       * @throws com.smhumayun.mi_plus.MIException
50       *          {@link com.smhumayun.mi_plus.MIException}
51       */
52      void cacheMiContainerProxy(Class miContainerClass, Object miContainerProxy) throws MIException;
53  
54      /**
55       * Get cached Composed Objects against given <code>miContainerClass</code>
56       *
57       * @param miContainerClass MI Container class - the class which has the {@link MISupport} annotation
58       * @return cached Composed Objects against given <code>miContainerClass</code>
59       * @throws com.smhumayun.mi_plus.MIException
60       *          {@link com.smhumayun.mi_plus.MIException}
61       */
62      LinkedHashMap<Class, Object> getCachedComposedObjects (Class miContainerClass) throws MIException;
63  
64      /**
65       * Cache given <code>composedObjects</code> against given <code>miContainerClass</code>
66       *
67       * @param miContainerClass MI Container class - the class which has the {@link MISupport} annotation
68       * @param composedObjects  composed objects to cache
69       * @throws com.smhumayun.mi_plus.MIException
70       *          {@link com.smhumayun.mi_plus.MIException}
71       */
72      void cacheComposedObjects (Class miContainerClass, LinkedHashMap<Class, Object> composedObjects) throws MIException;
73  
74      /**
75       * Returns true of the <code>classToValidate</code> has already been validated
76       *
77       * @param classToValidate class to
78       * @return true if validates, false otherwise
79       * @throws com.smhumayun.mi_plus.MIException
80       *          {@link com.smhumayun.mi_plus.MIException}
81       */
82      boolean isValidated (Class classToValidate) throws MIException;
83  
84      /**
85       * Cache this <code>validatedClass</code> and mark it as validated
86       *
87       * @param validatedClass validated class to cache
88       * @throws com.smhumayun.mi_plus.MIException
89       *          {@link com.smhumayun.mi_plus.MIException}
90       */
91      void validated (Class validatedClass) throws MIException;
92  }