1////////////////////////////////////////////////////////////////////////////////
2//
3//  ADOBE SYSTEMS INCORPORATED
4//  Copyright 2005-2007 Adobe Systems Incorporated
5//  All Rights Reserved.
6//
7//  NOTICE: Adobe permits you to use, modify, and distribute this file
8//  in accordance with the terms of the license agreement accompanying it.
9//
10////////////////////////////////////////////////////////////////////////////////
11
12package mx.core
13{
14
15/**
16 *  The IFlexModuleFactory interface represents the contract expected
17 *  for bootstrapping Flex applications and dynamically loaded
18 *  modules.
19 *
20 *  <p>Calling the <code>info()</code> method is legal immediately after
21 *  the <code>complete</code> event is dispatched.</p>
22 *
23 *  <p>A well-behaved module dispatches a <code>ready</code> event when
24 *  it is safe to call the <code>create()</code> method.</p>
25 *
26 *  @langversion 3.0
27 *  @playerversion Flash 9
28 *  @playerversion AIR 1.1
29 *  @productversion Flex 3
30 */
31public interface IFlexModuleFactory
32{
33    import flash.display.LoaderInfo;
34    import flash.utils.Dictionary;
35
36    import mx.core.RSLData;
37
38    //--------------------------------------------------------------------------
39    //
40    //  Properties
41    //
42    //--------------------------------------------------------------------------
43
44    /**
45     *  Controls whether the domains allowed by calls to <code>allowDomain()</code>
46     *  are also allowed by RSLs loaded after the call. Additional RSLs
47     *  may be loaded into this module factory by sub-applications or modules.
48     *
49     *  @default true
50     *
51     *  @langversion 3.0
52     *  @playerversion Flash 10.2
53     *  @playerversion AIR 2.6
54     *  @productversion Flex 4.5
55     */
56    function get allowDomainsInNewRSLs():Boolean;
57    function set allowDomainsInNewRSLs(value:Boolean):void;
58
59    /**
60     *  Controls whether the domains allowed by calls to <code>allowInsecureDomain()
61     *  </code> are also allowed by RSLs loaded after the call. Additional RSLs
62     *  may be added to this module factory by sub-applications or modules.
63     *
64     *  @default true
65     *
66     *  @langversion 3.0
67     *  @playerversion Flash 10.2
68     *  @playerversion AIR 2.6
69     *  @productversion Flex 4.5
70     */
71    function get allowInsecureDomainsInNewRSLs():Boolean;
72    function set allowInsecureDomainsInNewRSLs(value:Boolean):void;
73
74    /**
75     *  The RSLs loaded by this SystemManager or FlexModuleFactory before the
76     *  application starts. This dictionary may also include RSLs loaded into this
77     *  module factory's application domain by other modules or
78     *  sub-applications. When a new dictionary entry is added by a child module
79     *  factory an <code>RSLEvent.RSL_ADD_PRELOADED</code> event is dispatched
80     *  by module factory owning the dictionary.
81     *
82     *  Information about preloadedRSLs is stored in a Dictionary. The key is
83     *  the RSL's LoaderInfo. The value is the a Vector of RSLData where the
84     *  first element is the primary RSL and the remaining elements are
85     *  failover RSLs.
86     *
87     *  @langversion 3.0
88     *  @playerversion Flash 10
89     *  @playerversion AIR 1.5
90     *  @productversion Flex 3
91     */
92    function get preloadedRSLs():Dictionary;
93
94    //--------------------------------------------------------------------------
95    //
96    //  Methods
97    //
98    //--------------------------------------------------------------------------
99
100    /**
101     *  Adds an RSL to the preloadedRSLs list. This method is called by child
102     *  module factories when they add load an RSL into this module factory's
103     *  application domain.
104     *
105     *  <p>You do not call this method directly. This method is called by child
106     *  module factories when they add load an RSL into this module factory's
107     *  application domain.</p>
108     *
109     *  @param loaderInfo The loaderInfo of the loaded RSL.
110     *  @param rsl The RSL's configuration information. A Vector of RSLData.
111     *  The first element in the array is the primary RSL. The remaining
112     *  elements are failover RSLs.
113     *
114     *  @langversion 3.0
115     *  @playerversion Flash 10.2
116     *  @playerversion AIR 2.6
117     *  @productversion Flex 4.5
118     */
119    function addPreloadedRSL(loaderInfo:LoaderInfo, rsl:Vector.<RSLData>):void;
120
121    /**
122     *  Calls the <code>Security.allowDomain()</code> method for the SWF
123     *  associated with this IFlexModuleFactory plus all the SWFs associated
124     *  with RSLs preloaded by this IFlexModuleFactory. RSLs loaded after this
125     *  call will, by default, allow the same domains as have been allowed by
126     *  previous calls to this method. This behavior is controlled by the <code>
127     *  allowDomainsInNewRSLs</code> property.
128     *
129     *  @param domains One or more strings or URLRequest objects that name
130     *  the domains from which you want to allow access.
131     *  You can specify the special domain "&#42;" to allow access from all domains.
132     *
133     *  @see flash.system.Security#allowDomain()
134     *
135     *  @langversion 3.0
136     *  @playerversion Flash 10.2
137     *  @playerversion AIR 2.6
138     *  @productversion Flex 4.5
139     */
140    function allowDomain(... domains):void;
141
142    /**
143     *  Calls the <code>Security.allowInsecureDomain()</code> method for the
144     *  SWF associated with this IFlexModuleFactory
145     *  plus all the SWFs associated with RSLs preloaded by this
146     *  IFlexModuleFactory. RSLs loaded after this call will, by default,
147     *  allow the same domains as have been allowed by
148     *  previous calls to this method. This behavior is controlled by the <code>
149     *  allowInsecureDomainsInNewRSLs</code> property.
150     *
151     *  @param domains One or more strings or URLRequest objects that name
152     *  the domains from which you want to allow access.
153     *  You can specify the special domain "&#42;" to allow access from all domains.
154     *
155     *  @see flash.system.Security#allowInsecureDomain()
156     *
157     *  @langversion 3.0
158     *  @playerversion Flash 10.2
159     *  @playerversion AIR 2.6
160     *  @productversion Flex 4.5
161     */
162    function allowInsecureDomain(... domains):void;
163
164    /**
165     *  A way to call a method in this IFlexModuleFactory's context
166     *
167     *  @param fn The function or method to call.
168     *  @param thisArg The <code>this</code> pointer for the function.
169     *  @param argArray The arguments for the function.
170     *  @param returns If <code>true</code>, the function returns a value.
171     *
172     *  @return Whatever the function returns, if anything.
173     *
174     *  @see Function.apply
175     *
176     *  @langversion 3.0
177     *  @playerversion Flash 10
178     *  @playerversion AIR 1.5
179     *  @productversion Flex 3
180     */
181    function callInContext(fn:Function, thisArg:Object,
182                           argArray:Array, returns:Boolean = true):*;
183
184    /**
185     *  A factory method that requests
186     *  an instance of a definition known to the module.
187     *
188     *  <p>You can provide an optional set of parameters to let
189     *  building factories change what they create based
190     *  on the input.
191     *  Passing <code>null</code> indicates that the default
192     *  definition is created, if possible.</p>
193     *
194     *  @param parameters An optional list of arguments. You can pass any number
195     *  of arguments, which are then stored in an Array called <code>parameters</code>.
196     *
197     *  @return An instance of the module, or <code>null</code>.
198     *
199     *  @langversion 3.0
200     *  @playerversion Flash 9
201     *  @playerversion AIR 1.1
202     *  @productversion Flex 3
203     */
204    function create(... parameters):Object;
205
206    /**
207     *  Get the implementation for an interface.
208     *  Similar to <code>Singleton.getInstance()</code> method, but per-
209     *  IFlexModuleFactory.
210     *
211     *  @param interfaceName The interface.
212     *
213     *  @return The implementation for the interface.
214     *
215     *  @langversion 3.0
216     *  @playerversion Flash 10
217     *  @playerversion AIR 1.5
218     *  @productversion Flex 4
219     */
220    function getImplementation(interfaceName:String):Object;
221
222    /**
223     *  Returns a block of key/value pairs
224     *  that hold static data known to the module.
225     *  This method always succeeds, but can return an empty object.
226     *
227     *  @return An object containing key/value pairs. Typically, this object
228     *  contains information about the module or modules created by this
229     *  factory; for example:
230     *
231     *  <pre>
232     *  return {"description": "This module returns 42."};
233     *  </pre>
234     *
235     *  Other common values in the returned object include the following:
236     *  <ul>
237     *   <li><code>fonts</code>: A list of embedded font faces.</li>
238     *   <li><code>rsls</code>: A list of run-time shared libraries.</li>
239     *   <li><code>mixins</code>: A list of classes initialized at startup.</li>
240     *  </ul>
241     *
242     *  @langversion 3.0
243     *  @playerversion Flash 9
244     *  @playerversion AIR 1.1
245     *  @productversion Flex 3
246     */
247    function info():Object;
248
249    /**
250     *  Register an implementation for an interface.
251     *  Similar to the <code>Singleton.registerClass()</code> method, but per-
252     *  IFlexModuleFactory, and takes an instance not a class.
253     *
254     *  @param interfaceName The interface.
255     *
256     *  @param impl The implementation.
257     *
258     *  @langversion 3.0
259     *  @playerversion Flash 10
260     *  @playerversion AIR 1.5
261     *  @productversion Flex 4
262     */
263    function registerImplementation(interfaceName:String,
264                                    impl:Object):void;
265
266}
267
268}
269