My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* Copyright 2011 ArcBees Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

package com.gwtplatform.common.client;

import com.google.inject.Provider;

/**
* This class can be used to contain a group of providers that should all sit
* behind the same split point. That is, if the code for one provided object is
* loaded, so is the code for the others. This is useful when the provided
* objects share the bulk of their code, which would end up in the left-overs if
* the objects were behind their individual split points.
* <p />
* Here is an example use of {@link ProviderBundle}:
*
* <pre>
* public class MyPresenterBundle extends ProviderBundle {
* public final static int ID_Object1 = 0;
* public final static int ID_Object2 = 1;
* public final static int BUNDLE_SIZE = 2;
*
* &#064;Inject
* MyPresenterBundle(
* final Provider<Object1> object1Provider,
* final Provider<Object2> object2Provider) {
* super( BUNDLE_SIZE );
* providers[ID_Object1] = object1Provider;
* providers[ID_Object2] = object2Provider;
* }
* }</pre>
*
* @author Philippe Beaudoin
*/
public class ProviderBundle {

protected final Provider<?> providers[];

/**
* Constructs a {@link ProviderBundle} containing a given number of providers.
* After calling this constructor you should set the provider manually like
* so:
*
* <pre>
* providers[0] = object1Provider;
* providers[1] = object2Provider;
* ...
* providers[bundleSize-1] = objectNProvider;</pre>
*
* @param bundleSize The number of providers in the bundle.
*/
public ProviderBundle(int bundleSize) {
providers = new Provider<?>[bundleSize];
}

/**
* Accesses a provider given its id.
*
* @param providerId The id of the provider to access.
* @return The provider.
*/
public Provider<?> get(int providerId) {
return providers[providerId];
}

}

Change log

2771427867f7 by Philippe Beaudoin <philippe.beaudoin> on Jun 6, 2011   Diff
Changed the copyright year to 2011.
Go to: 
Sign in to write a code review

Older revisions

5f9bad1a6246 by Philippe Beaudoin on Mar 17, 2011   Diff
Corrected a blunder that caused all
empty lines to be wiped out.
1b79ddbfbb75 by Philippe Beaudoin on Mar 17, 2011   Diff
Backed out changeset: 85acc7cb9c11
85acc7cb9c11 by Philippe Beaudoin on Mar 17, 2011   Diff
Update to checkstyle and files to
prohibit trailing white spaces.
All revisions of this file

File info

Size: 2447 bytes, 79 lines
Powered by Google Project Hosting