1 package com.atlassian.user.impl.delegation.properties;
2
3 import com.atlassian.user.Entity;
4 import com.atlassian.user.EntityException;
5 import com.atlassian.user.properties.PropertySetFactory;
6 import com.atlassian.util.profiling.UtilTimerStack;
7 import com.opensymphony.module.propertyset.PropertySet;
8
9 import java.util.List;
10 import java.util.Collections;
11
12
13
14
15
16
17 public class DelegatingPropertySetFactory implements PropertySetFactory
18 {
19 private final List<PropertySetFactory> propertySetFactories;
20
21 public DelegatingPropertySetFactory(List<PropertySetFactory> propertySetFactories)
22 {
23 this.propertySetFactories = propertySetFactories;
24 }
25
26 public PropertySet getPropertySet(Entity entity) throws EntityException
27 {
28 if (UtilTimerStack.isActive())
29 UtilTimerStack.push(this.getClass().getName() + "_delegating_getPropertySet(" + entity.getName() + ")");
30
31 for (PropertySetFactory propertySetFactory : propertySetFactories)
32 {
33 PropertySet propertySet = propertySetFactory.getPropertySet(entity);
34 if (propertySet != null)
35 {
36 if (UtilTimerStack.isActive())
37 UtilTimerStack.pop(this.getClass().getName() + "_delegating_getPropertySet(" + entity.getName() + ")");
38
39 return propertySet;
40 }
41 }
42
43 if (UtilTimerStack.isActive())
44 UtilTimerStack.pop(this.getClass().getName() + "_delegating_getPropertySet(" + entity.getName() + ")");
45
46 return null;
47 }
48
49 public List<PropertySetFactory> getPropertySetFactories()
50 {
51 return Collections.unmodifiableList(propertySetFactories);
52 }
53 }