1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
package org.apache.tapestry.pageload; |
16 |
|
|
17 |
|
import org.apache.commons.logging.Log; |
18 |
|
import org.apache.hivemind.ApplicationRuntimeException; |
19 |
|
import org.apache.hivemind.ClassResolver; |
20 |
|
import org.apache.hivemind.HiveMind; |
21 |
|
import org.apache.hivemind.Location; |
22 |
|
import org.apache.hivemind.service.ThreadLocale; |
23 |
|
import org.apache.tapestry.*; |
24 |
|
import org.apache.tapestry.asset.AssetSource; |
25 |
|
import org.apache.tapestry.binding.BindingSource; |
26 |
|
import org.apache.tapestry.engine.IPageLoader; |
27 |
|
import org.apache.tapestry.resolver.ComponentSpecificationResolver; |
28 |
|
import org.apache.tapestry.services.ComponentConstructor; |
29 |
|
import org.apache.tapestry.services.ComponentConstructorFactory; |
30 |
|
import org.apache.tapestry.services.ComponentPropertySource; |
31 |
|
import org.apache.tapestry.services.ComponentTemplateLoader; |
32 |
|
import org.apache.tapestry.spec.*; |
33 |
|
|
34 |
|
import java.util.*; |
35 |
|
|
36 |
|
|
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
2 |
public class PageLoader implements IPageLoader { |
48 |
|
|
49 |
|
private Log _log; |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
private ComponentSpecificationResolver _componentResolver; |
54 |
|
|
55 |
|
|
56 |
|
|
57 |
|
private BindingSource _bindingSource; |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
private ComponentTemplateLoader _componentTemplateLoader; |
62 |
|
|
63 |
2 |
private List _inheritedBindingQueue = new ArrayList(); |
64 |
|
|
65 |
|
|
66 |
|
private IComponentVisitor _establishDefaultParameterValuesVisitor; |
67 |
|
|
68 |
|
private ComponentTreeWalker _establishDefaultParameterValuesWalker; |
69 |
|
|
70 |
|
private ComponentTreeWalker _verifyRequiredParametersWalker; |
71 |
|
|
72 |
|
private IComponentVisitor _eventConnectionVisitor; |
73 |
|
|
74 |
|
private ComponentTreeWalker _eventConnectionWalker; |
75 |
|
|
76 |
|
private IComponentVisitor _componentTypeVisitor; |
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
private ComponentConstructorFactory _componentConstructorFactory; |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
private AssetSource _assetSource; |
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
private ComponentClassProvider _pageClassProvider; |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
private ComponentClassProvider _componentClassProvider; |
103 |
|
|
104 |
|
|
105 |
|
|
106 |
|
|
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
private ComponentPropertySource _componentPropertySource; |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
private ThreadLocale _threadLocale; |
119 |
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
private Locale _locale; |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
private int _count; |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
private int _depth; |
139 |
|
|
140 |
|
|
141 |
|
|
142 |
|
|
143 |
|
|
144 |
|
private int _maxDepth; |
145 |
|
|
146 |
|
|
147 |
|
|
148 |
|
private ClassResolver _classResolver; |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
154 |
2 |
private Stack _componentStack = new Stack(); |
155 |
|
|
156 |
|
public void initializeService() |
157 |
|
{ |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
0 |
IComponentVisitor verifyRequiredParametersVisitor = new VerifyRequiredParametersVisitor(); |
162 |
|
|
163 |
0 |
_verifyRequiredParametersWalker = |
164 |
|
new ComponentTreeWalker( new IComponentVisitor[] { verifyRequiredParametersVisitor }); |
165 |
|
|
166 |
0 |
_establishDefaultParameterValuesWalker = |
167 |
|
new ComponentTreeWalker( new IComponentVisitor[] { _establishDefaultParameterValuesVisitor }); |
168 |
|
|
169 |
0 |
_eventConnectionWalker = |
170 |
|
new ComponentTreeWalker( new IComponentVisitor[] { _eventConnectionVisitor, _componentTypeVisitor }); |
171 |
0 |
} |
172 |
|
|
173 |
|
|
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
|
|
182 |
|
|
183 |
|
|
184 |
|
|
185 |
|
|
186 |
|
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
|
|
192 |
|
void bind(IComponent container, IComponent component, |
193 |
|
IContainedComponent contained, String defaultBindingPrefix) |
194 |
|
{ |
195 |
2 |
IComponentSpecification spec = component.getSpecification(); |
196 |
2 |
boolean formalOnly = !spec.getAllowInformalParameters(); |
197 |
|
|
198 |
2 |
if (contained.getInheritInformalParameters()) |
199 |
|
{ |
200 |
0 |
if (formalOnly) |
201 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.inheritInformalInvalidComponentFormalOnly(component), |
202 |
|
component, contained.getLocation(), null); |
203 |
|
|
204 |
0 |
IComponentSpecification containerSpec = container.getSpecification(); |
205 |
|
|
206 |
0 |
if (!containerSpec.getAllowInformalParameters()) |
207 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.inheritInformalInvalidContainerFormalOnly(container, component), |
208 |
|
component, contained.getLocation(), null); |
209 |
|
|
210 |
0 |
IQueuedInheritedBinding queued = new QueuedInheritInformalBindings(component); |
211 |
0 |
_inheritedBindingQueue.add(queued); |
212 |
|
} |
213 |
|
|
214 |
2 |
Iterator i = contained.getBindingNames().iterator(); |
215 |
|
|
216 |
4 |
while(i.hasNext()) |
217 |
|
{ |
218 |
2 |
String name = (String) i.next(); |
219 |
|
|
220 |
2 |
IParameterSpecification pspec = spec.getParameter(name); |
221 |
|
|
222 |
2 |
boolean isFormal = pspec != null; |
223 |
|
|
224 |
2 |
String parameterName = isFormal ? pspec.getParameterName() : name; |
225 |
|
|
226 |
2 |
IBindingSpecification bspec = contained.getBinding(name); |
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
2 |
if (formalOnly && !isFormal) |
233 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.formalParametersOnly(component, name), |
234 |
|
component, bspec.getLocation(), null); |
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
2 |
if (!isFormal && spec.isReservedParameterName(name)) |
240 |
0 |
continue; |
241 |
|
|
242 |
2 |
if (isFormal) |
243 |
|
{ |
244 |
2 |
if (!name.equals(parameterName)) |
245 |
|
{ |
246 |
1 |
_log.warn(PageloadMessages.usedParameterAlias(contained, name, parameterName, bspec.getLocation())); |
247 |
|
} |
248 |
1 |
else if (pspec.isDeprecated()) |
249 |
1 |
_log.warn(PageloadMessages.deprecatedParameter(name, bspec.getLocation(), contained.getType())); |
250 |
|
} |
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
2 |
BindingType type = bspec.getType(); |
260 |
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
2 |
if (type == BindingType.INHERITED) |
270 |
|
{ |
271 |
0 |
QueuedInheritedBinding queued = new QueuedInheritedBinding(component, bspec.getValue(), parameterName); |
272 |
0 |
_inheritedBindingQueue.add(queued); |
273 |
0 |
continue; |
274 |
|
} |
275 |
|
|
276 |
2 |
String description = PageloadMessages.parameterName(name); |
277 |
|
|
278 |
2 |
IBinding binding = convert(container, description, pspec, defaultBindingPrefix, bspec); |
279 |
|
|
280 |
2 |
addBindingToComponent(component, parameterName, binding); |
281 |
2 |
} |
282 |
2 |
} |
283 |
|
|
284 |
|
|
285 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
|
|
291 |
|
|
292 |
|
|
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
|
|
300 |
|
|
301 |
|
static void addBindingToComponent(IComponent component, String parameterName, IBinding binding) |
302 |
|
{ |
303 |
3 |
IBinding existing = component.getBinding(parameterName); |
304 |
|
|
305 |
3 |
if (existing != null) |
306 |
1 |
throw new ApplicationRuntimeException(PageloadMessages.duplicateParameter(parameterName, existing), |
307 |
|
component, binding.getLocation(), null); |
308 |
|
|
309 |
2 |
component.setBinding(parameterName, binding); |
310 |
2 |
} |
311 |
|
|
312 |
|
private IBinding convert(IComponent container, String description, IParameterSpecification param, |
313 |
|
String defaultBindingType, IBindingSpecification spec) |
314 |
|
{ |
315 |
2 |
Location location = spec.getLocation(); |
316 |
2 |
String bindingReference = spec.getValue(); |
317 |
|
|
318 |
2 |
return _bindingSource.createBinding(container, param, description, |
319 |
|
bindingReference, defaultBindingType, location); |
320 |
|
} |
321 |
|
|
322 |
|
|
323 |
|
|
324 |
|
|
325 |
|
|
326 |
|
|
327 |
|
|
328 |
|
|
329 |
|
|
330 |
|
|
331 |
|
|
332 |
|
|
333 |
|
|
334 |
|
|
335 |
|
|
336 |
|
|
337 |
|
|
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
343 |
|
|
344 |
|
|
345 |
|
|
346 |
|
private void constructComponent(IRequestCycle cycle, IPage page, |
347 |
|
IComponent container, IComponentSpecification containerSpec, |
348 |
|
INamespace namespace) |
349 |
|
{ |
350 |
0 |
_depth++; |
351 |
0 |
if (_depth > _maxDepth) |
352 |
0 |
_maxDepth = _depth; |
353 |
|
|
354 |
0 |
beginConstructComponent(container, containerSpec); |
355 |
|
|
356 |
0 |
String defaultBindingPrefix = _componentPropertySource.getComponentProperty(container, TapestryConstants.DEFAULT_BINDING_PREFIX_NAME); |
357 |
|
|
358 |
0 |
List ids = new ArrayList(containerSpec.getComponentIds()); |
359 |
0 |
int count = ids.size(); |
360 |
|
|
361 |
|
try |
362 |
|
{ |
363 |
0 |
for(int i = 0; i < count; i++) |
364 |
|
{ |
365 |
0 |
String id = (String) ids.get(i); |
366 |
|
|
367 |
|
|
368 |
|
|
369 |
|
|
370 |
0 |
IContainedComponent contained = containerSpec.getComponent(id); |
371 |
|
|
372 |
0 |
String type = contained.getType(); |
373 |
0 |
Location location = contained.getLocation(); |
374 |
|
|
375 |
0 |
_componentResolver.resolve(cycle, namespace, type, location); |
376 |
|
|
377 |
0 |
IComponentSpecification componentSpecification = _componentResolver.getSpecification(); |
378 |
0 |
INamespace componentNamespace = _componentResolver.getNamespace(); |
379 |
|
|
380 |
|
|
381 |
|
|
382 |
0 |
IComponent component = instantiateComponent(page, container, |
383 |
|
id, componentSpecification, _componentResolver.getType(), componentNamespace, contained); |
384 |
|
|
385 |
|
|
386 |
|
|
387 |
0 |
container.addComponent(component); |
388 |
|
|
389 |
|
|
390 |
|
|
391 |
0 |
bind(container, component, contained, defaultBindingPrefix); |
392 |
|
|
393 |
|
|
394 |
|
|
395 |
|
|
396 |
0 |
constructComponent(cycle, page, component, componentSpecification, componentNamespace); |
397 |
|
} |
398 |
|
|
399 |
0 |
addAssets(container, containerSpec); |
400 |
|
|
401 |
|
|
402 |
|
|
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
407 |
|
|
408 |
0 |
container.finishLoad(cycle, this, containerSpec); |
409 |
|
|
410 |
|
|
411 |
|
|
412 |
0 |
container.enterActiveState(); |
413 |
|
} |
414 |
0 |
catch (ApplicationRuntimeException ex) |
415 |
|
{ |
416 |
0 |
throw ex; |
417 |
|
} |
418 |
0 |
catch (RuntimeException ex) |
419 |
|
{ |
420 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.unableToInstantiateComponent(container, ex), |
421 |
|
container, null, ex); |
422 |
|
} finally { |
423 |
|
|
424 |
0 |
endConstructComponent(container); |
425 |
0 |
} |
426 |
|
|
427 |
0 |
_depth--; |
428 |
0 |
} |
429 |
|
|
430 |
|
|
431 |
|
|
432 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
436 |
|
|
437 |
|
|
438 |
|
|
439 |
|
void beginConstructComponent(IComponent component, IComponentSpecification specification) |
440 |
|
{ |
441 |
|
|
442 |
|
|
443 |
0 |
int position = _componentStack.search(component); |
444 |
0 |
if (position > -1) |
445 |
|
{ |
446 |
0 |
Location location = specification.getLocation(); |
447 |
|
|
448 |
|
|
449 |
|
|
450 |
|
|
451 |
0 |
IContainedComponent container = component.getContainedComponent(); |
452 |
0 |
if (container != null) |
453 |
0 |
location = container.getLocation(); |
454 |
|
|
455 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.recursiveComponent(component), location, null); |
456 |
|
} |
457 |
|
|
458 |
0 |
_componentStack.push(component); |
459 |
0 |
} |
460 |
|
|
461 |
|
|
462 |
|
|
463 |
|
|
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
void endConstructComponent(IComponent component) |
468 |
|
{ |
469 |
0 |
_componentStack.pop(); |
470 |
0 |
} |
471 |
|
|
472 |
|
|
473 |
|
|
474 |
|
|
475 |
|
|
476 |
|
|
477 |
|
|
478 |
|
|
479 |
|
|
480 |
|
|
481 |
|
public IComponent createImplicitComponent(IRequestCycle cycle, |
482 |
|
IComponent container, String componentId, String componentType, |
483 |
|
Location location) |
484 |
|
{ |
485 |
0 |
IPage page = container.getPage(); |
486 |
|
|
487 |
0 |
_componentResolver.resolve(cycle, container.getNamespace(), componentType, location); |
488 |
|
|
489 |
0 |
INamespace componentNamespace = _componentResolver.getNamespace(); |
490 |
0 |
IComponentSpecification spec = _componentResolver.getSpecification(); |
491 |
|
|
492 |
0 |
IContainedComponent contained = new ContainedComponent(); |
493 |
0 |
contained.setLocation(location); |
494 |
0 |
contained.setType(componentType); |
495 |
|
|
496 |
0 |
IComponent result = instantiateComponent(page, container, componentId, |
497 |
|
spec, _componentResolver.getType(), componentNamespace, |
498 |
|
contained); |
499 |
|
|
500 |
0 |
container.addComponent(result); |
501 |
|
|
502 |
|
|
503 |
|
|
504 |
0 |
constructComponent(cycle, page, result, spec, componentNamespace); |
505 |
|
|
506 |
0 |
return result; |
507 |
|
} |
508 |
|
|
509 |
|
|
510 |
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
|
|
516 |
|
|
517 |
|
|
518 |
|
|
519 |
|
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
|
|
524 |
|
|
525 |
|
|
526 |
|
|
527 |
|
|
528 |
|
|
529 |
|
|
530 |
|
|
531 |
|
|
532 |
|
|
533 |
|
private IComponent instantiateComponent(IPage page, IComponent container, |
534 |
|
String id, IComponentSpecification spec, String type, |
535 |
|
INamespace namespace, IContainedComponent containedComponent) |
536 |
|
{ |
537 |
0 |
ComponentClassProviderContext context = new ComponentClassProviderContext(type, spec, namespace); |
538 |
|
|
539 |
0 |
String className = _componentClassProvider.provideComponentClassName(context); |
540 |
|
|
541 |
0 |
if (HiveMind.isBlank(className)) |
542 |
0 |
className = BaseComponent.class.getName(); |
543 |
|
else |
544 |
|
{ |
545 |
0 |
Class componentClass = _classResolver.findClass(className); |
546 |
|
|
547 |
0 |
if (!IComponent.class.isAssignableFrom(componentClass)) |
548 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.classNotComponent(componentClass), |
549 |
|
container, spec.getLocation(), null); |
550 |
|
|
551 |
0 |
if (IPage.class.isAssignableFrom(componentClass)) |
552 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.pageNotAllowed(id), |
553 |
|
container, spec.getLocation(), null); |
554 |
|
} |
555 |
|
|
556 |
0 |
ComponentConstructor cc = _componentConstructorFactory.getComponentConstructor(spec, className); |
557 |
|
|
558 |
0 |
IComponent result = (IComponent) cc.newInstance(); |
559 |
|
|
560 |
0 |
result.setNamespace(namespace); |
561 |
0 |
result.setPage(page); |
562 |
0 |
result.setContainer(container); |
563 |
0 |
result.setId(id); |
564 |
0 |
result.setContainedComponent(containedComponent); |
565 |
0 |
result.setLocation(containedComponent.getLocation()); |
566 |
|
|
567 |
0 |
_count++; |
568 |
|
|
569 |
0 |
return result; |
570 |
|
} |
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
|
585 |
|
|
586 |
|
|
587 |
|
|
588 |
|
|
589 |
|
private IPage instantiatePage(String name, INamespace namespace, IComponentSpecification spec) |
590 |
|
{ |
591 |
0 |
Location location = spec.getLocation(); |
592 |
0 |
ComponentClassProviderContext context = new ComponentClassProviderContext(name, spec, namespace); |
593 |
|
|
594 |
0 |
String className = _pageClassProvider.provideComponentClassName(context); |
595 |
|
|
596 |
0 |
Class pageClass = _classResolver.findClass(className); |
597 |
|
|
598 |
0 |
if (!IPage.class.isAssignableFrom(pageClass)) |
599 |
0 |
throw new ApplicationRuntimeException(PageloadMessages.classNotPage(pageClass), location, null); |
600 |
|
|
601 |
0 |
String pageName = namespace.constructQualifiedName(name); |
602 |
|
|
603 |
0 |
ComponentConstructor cc = _componentConstructorFactory.getComponentConstructor(spec, className); |
604 |
|
|
605 |
0 |
IPage result = (IPage) cc.newInstance(); |
606 |
|
|
607 |
0 |
result.setNamespace(namespace); |
608 |
0 |
result.setPageName(pageName); |
609 |
0 |
result.setPage(result); |
610 |
0 |
result.setLocale(_locale); |
611 |
0 |
result.setLocation(location); |
612 |
|
|
613 |
0 |
return result; |
614 |
|
} |
615 |
|
|
616 |
|
public IPage loadPage(String name, INamespace namespace, |
617 |
|
IRequestCycle cycle, IComponentSpecification specification) |
618 |
|
{ |
619 |
0 |
IPage page = null; |
620 |
|
|
621 |
0 |
_count = 0; |
622 |
0 |
_depth = 0; |
623 |
0 |
_maxDepth = 0; |
624 |
0 |
_componentStack.clear(); |
625 |
|
|
626 |
0 |
_locale = _threadLocale.getLocale(); |
627 |
|
|
628 |
|
try |
629 |
|
{ |
630 |
0 |
page = instantiatePage(name, namespace, specification); |
631 |
|
|
632 |
|
|
633 |
|
|
634 |
|
|
635 |
|
|
636 |
|
|
637 |
0 |
page.attach(cycle.getEngine(), cycle); |
638 |
|
|
639 |
0 |
constructComponent(cycle, page, page, specification, namespace); |
640 |
|
|
641 |
|
|
642 |
|
|
643 |
|
|
644 |
0 |
_establishDefaultParameterValuesWalker.walkComponentTree(page); |
645 |
|
|
646 |
0 |
establishInheritedBindings(); |
647 |
|
|
648 |
|
|
649 |
|
|
650 |
|
|
651 |
0 |
_verifyRequiredParametersWalker.walkComponentTree(page); |
652 |
|
|
653 |
|
|
654 |
|
|
655 |
0 |
_eventConnectionWalker.walkComponentTree(page); |
656 |
|
} |
657 |
|
finally |
658 |
|
{ |
659 |
0 |
_locale = null; |
660 |
0 |
_inheritedBindingQueue.clear(); |
661 |
0 |
} |
662 |
|
|
663 |
0 |
if (_log.isDebugEnabled()) |
664 |
0 |
_log.debug("Loaded page " + page + " with " + _count + " components (maximum depth " + _maxDepth + ")"); |
665 |
|
|
666 |
0 |
return page; |
667 |
|
} |
668 |
|
|
669 |
|
|
670 |
|
|
671 |
|
public void loadTemplateForComponent(IRequestCycle cycle, ITemplateComponent component) |
672 |
|
{ |
673 |
0 |
_componentTemplateLoader.loadTemplate(cycle, component); |
674 |
0 |
} |
675 |
|
|
676 |
|
private void establishInheritedBindings() |
677 |
|
{ |
678 |
0 |
_log.debug("Establishing inherited bindings"); |
679 |
|
|
680 |
0 |
int count = _inheritedBindingQueue.size(); |
681 |
|
|
682 |
0 |
for(int i = 0; i < count; i++) |
683 |
|
{ |
684 |
0 |
IQueuedInheritedBinding queued = (IQueuedInheritedBinding) _inheritedBindingQueue.get(i); |
685 |
|
|
686 |
0 |
queued.connect(); |
687 |
|
} |
688 |
0 |
} |
689 |
|
|
690 |
|
private void addAssets(IComponent component, IComponentSpecification specification) |
691 |
|
{ |
692 |
0 |
List names = specification.getAssetNames(); |
693 |
|
|
694 |
0 |
if (names.isEmpty()) return; |
695 |
|
|
696 |
0 |
Iterator i = names.iterator(); |
697 |
|
|
698 |
0 |
while(i.hasNext()) |
699 |
|
{ |
700 |
0 |
String name = (String) i.next(); |
701 |
|
|
702 |
0 |
IAssetSpecification assetSpec = specification.getAsset(name); |
703 |
|
|
704 |
0 |
IAsset asset = _assetSource.findAsset(assetSpec.getLocation().getResource(), specification, |
705 |
|
assetSpec.getPath(), _locale, assetSpec.getLocation()); |
706 |
|
|
707 |
0 |
component.addAsset(name, asset); |
708 |
0 |
} |
709 |
0 |
} |
710 |
|
|
711 |
|
public void setLog(Log log) |
712 |
|
{ |
713 |
2 |
_log = log; |
714 |
2 |
} |
715 |
|
|
716 |
|
public void setComponentResolver(ComponentSpecificationResolver resolver) |
717 |
|
{ |
718 |
0 |
_componentResolver = resolver; |
719 |
0 |
} |
720 |
|
|
721 |
|
public void setBindingSource(BindingSource bindingSource) |
722 |
|
{ |
723 |
2 |
_bindingSource = bindingSource; |
724 |
2 |
} |
725 |
|
|
726 |
|
public void setComponentTemplateLoader(ComponentTemplateLoader componentTemplateLoader) |
727 |
|
{ |
728 |
0 |
_componentTemplateLoader = componentTemplateLoader; |
729 |
0 |
} |
730 |
|
|
731 |
|
public void setEstablishDefaultParameterValuesVisitor(IComponentVisitor establishDefaultParameterValuesVisitor) |
732 |
|
{ |
733 |
0 |
_establishDefaultParameterValuesVisitor = establishDefaultParameterValuesVisitor; |
734 |
0 |
} |
735 |
|
|
736 |
|
public void setEventConnectionVisitor(IComponentVisitor eventConnectionVisitor) |
737 |
|
{ |
738 |
0 |
_eventConnectionVisitor = eventConnectionVisitor; |
739 |
0 |
} |
740 |
|
|
741 |
|
public void setComponentTypeVisitor(IComponentVisitor visitor) |
742 |
|
{ |
743 |
0 |
_componentTypeVisitor = visitor; |
744 |
0 |
} |
745 |
|
|
746 |
|
public void setComponentConstructorFactory(ComponentConstructorFactory componentConstructorFactory) |
747 |
|
{ |
748 |
0 |
_componentConstructorFactory = componentConstructorFactory; |
749 |
0 |
} |
750 |
|
|
751 |
|
public void setAssetSource(AssetSource assetSource) |
752 |
|
{ |
753 |
0 |
_assetSource = assetSource; |
754 |
0 |
} |
755 |
|
|
756 |
|
public void setPageClassProvider(ComponentClassProvider pageClassProvider) |
757 |
|
{ |
758 |
0 |
_pageClassProvider = pageClassProvider; |
759 |
0 |
} |
760 |
|
|
761 |
|
public void setClassResolver(ClassResolver classResolver) |
762 |
|
{ |
763 |
0 |
_classResolver = classResolver; |
764 |
0 |
} |
765 |
|
|
766 |
|
public void setComponentClassProvider(ComponentClassProvider componentClassProvider) |
767 |
|
{ |
768 |
0 |
_componentClassProvider = componentClassProvider; |
769 |
0 |
} |
770 |
|
|
771 |
|
public void setThreadLocale(ThreadLocale threadLocale) |
772 |
|
{ |
773 |
0 |
_threadLocale = threadLocale; |
774 |
0 |
} |
775 |
|
|
776 |
|
public void setComponentPropertySource(ComponentPropertySource componentPropertySource) |
777 |
|
{ |
778 |
0 |
_componentPropertySource = componentPropertySource; |
779 |
0 |
} |
780 |
|
} |