AppInstanceProviderFactory.java
3.94 KB
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
80
81
82
83
84
85
86
87
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Activate
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.PropertyUnbounded
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.Resource
* org.apache.sling.commons.osgi.PropertiesUtil
* org.osgi.service.component.ComponentContext
*/
package com.adobe.cq.mobile.phonegap.impl;
import com.adobe.cq.mobile.appcache.impl.AppCacheManagerAdapterFactory;
import com.adobe.cq.mobile.phonegap.impl.AppInstanceProviderImpl;
import com.adobe.cq.mobile.platform.MobileResourceType;
import com.adobe.cq.mobile.platform.impl.AbstractMobileAppProviderFactory;
import com.adobe.cq.mobile.platform.impl.MobileAppProvider;
import com.adobe.cq.mobile.platform.impl.MobileAppProviderFactory;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Dictionary;
import java.util.List;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.PropertyUnbounded;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.commons.osgi.PropertiesUtil;
import org.osgi.service.component.ComponentContext;
@Component(metatype=1, label="%cq.mobile.phonegap.AppInstanceProviderFactory.name", description="%cq.mobile.phonegap.AppInstanceProviderFactory.description")
@Service
@Properties(value={@Property(name="service.ranking", intValue={100}, propertyPrivate=1)})
public class AppInstanceProviderFactory
extends AbstractMobileAppProviderFactory
implements MobileAppProviderFactory {
private static List<String> appPlatforms = new ArrayList<String>();
@Property(label="%cq.mobile.phonegap.AppInstanceProviderFactory.defaultPlatforms.label", description="%cq.mobile.phonegap.AppInstanceProviderFactory.defaultPlatforms.description", value={"android", "ios"}, unbounded=PropertyUnbounded.ARRAY)
private static final String DEFAULT_PLATFORM_NAMES = "cq.mobile.phonegap.instance.defaultPlatforms";
private List<String> defaultPlatforms = new ArrayList<String>();
@Reference
private AppCacheManagerAdapterFactory appCacheManagerAdapterFactory;
private final String[] acceptableTypes = new String[]{MobileResourceType.INSTANCE.getType(), "mobileapps/phonegap/components/instance"};
@Override
public MobileAppProvider getMobileAppProvider(Resource res) {
if (this.accepts(res)) {
AppInstanceProviderImpl provider = new AppInstanceProviderImpl(res, this.appCacheManagerAdapterFactory, this.defaultPlatforms);
return provider;
}
return null;
}
@Override
protected String[] getAcceptableTypes() {
return this.acceptableTypes;
}
@Activate
protected void activate(ComponentContext ctx) {
Dictionary props = ctx.getProperties();
this.defaultPlatforms.clear();
if (props.get("cq.mobile.phonegap.instance.defaultPlatforms") != null) {
this.defaultPlatforms.addAll(Arrays.asList(PropertiesUtil.toStringArray(props.get("cq.mobile.phonegap.instance.defaultPlatforms"))));
}
}
protected void bindAppCacheManagerAdapterFactory(AppCacheManagerAdapterFactory appCacheManagerAdapterFactory) {
this.appCacheManagerAdapterFactory = appCacheManagerAdapterFactory;
}
protected void unbindAppCacheManagerAdapterFactory(AppCacheManagerAdapterFactory appCacheManagerAdapterFactory) {
if (this.appCacheManagerAdapterFactory == appCacheManagerAdapterFactory) {
this.appCacheManagerAdapterFactory = null;
}
}
}