AppCacheManagerAdapterFactory.java
4.87 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.contentsync.ContentSyncManager
* com.day.cq.replication.Replicator
* com.day.jcr.vault.packaging.Packaging
* javax.jcr.Session
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.Service
* org.apache.sling.api.resource.ResourceResolverFactory
* org.apache.sling.jcr.api.SlingRepository
* org.osgi.service.cm.ConfigurationAdmin
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.cq.mobile.appcache.impl;
import com.adobe.cq.mobile.appcache.impl.AppCacheManager;
import com.adobe.cq.mobile.appcache.impl.AppCacheManagerImpl;
import com.day.cq.contentsync.ContentSyncManager;
import com.day.cq.replication.Replicator;
import com.day.jcr.vault.packaging.Packaging;
import javax.jcr.Session;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.api.resource.ResourceResolverFactory;
import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.service.cm.ConfigurationAdmin;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(metatype=0)
@Service(value={AppCacheManagerAdapterFactory.class})
public class AppCacheManagerAdapterFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(AppCacheManagerAdapterFactory.class);
@Property(name="adapters", propertyPrivate=1)
private static final String[] ADAPTER_CLASSES = new String[]{AppCacheManager.class.getName()};
@Property(name="adaptables", propertyPrivate=1)
private static final String[] ADAPTABLE_CLASSES = new String[]{Session.class.getName()};
@Reference
private ContentSyncManager contentSyncManager;
@Reference
private Replicator replicator;
@Reference
private Packaging packagingService;
@Reference
private ConfigurationAdmin configurationAdmin = null;
@Reference
private SlingRepository repository;
@Reference
private ResourceResolverFactory resourceResolverFactory;
public <AdapterType> AdapterType getAdapter(Object adaptable, Class<AdapterType> type) {
if (adaptable instanceof Session) {
return this.getAdapter((Session)adaptable, type);
}
LOGGER.info("Can't adapt {} to {}", (Object)(adaptable == null ? "null" : adaptable.getClass().getName()), type);
return null;
}
private <AdapterType> AdapterType getAdapter(Session session, Class<AdapterType> type) {
if (AppCacheManager.class == type) {
AppCacheManagerImpl impl = new AppCacheManagerImpl(session, this.contentSyncManager, this.replicator, this.packagingService, this.configurationAdmin, this.repository, this.resourceResolverFactory);
return (AdapterType)impl;
}
return null;
}
protected void bindContentSyncManager(ContentSyncManager contentSyncManager) {
this.contentSyncManager = contentSyncManager;
}
protected void unbindContentSyncManager(ContentSyncManager contentSyncManager) {
if (this.contentSyncManager == contentSyncManager) {
this.contentSyncManager = null;
}
}
protected void bindReplicator(Replicator replicator) {
this.replicator = replicator;
}
protected void unbindReplicator(Replicator replicator) {
if (this.replicator == replicator) {
this.replicator = null;
}
}
protected void bindPackagingService(Packaging packaging) {
this.packagingService = packaging;
}
protected void unbindPackagingService(Packaging packaging) {
if (this.packagingService == packaging) {
this.packagingService = null;
}
}
protected void bindConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
this.configurationAdmin = configurationAdmin;
}
protected void unbindConfigurationAdmin(ConfigurationAdmin configurationAdmin) {
if (this.configurationAdmin == configurationAdmin) {
this.configurationAdmin = null;
}
}
protected void bindRepository(SlingRepository slingRepository) {
this.repository = slingRepository;
}
protected void unbindRepository(SlingRepository slingRepository) {
if (this.repository == slingRepository) {
this.repository = null;
}
}
protected void bindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
this.resourceResolverFactory = resourceResolverFactory;
}
protected void unbindResourceResolverFactory(ResourceResolverFactory resourceResolverFactory) {
if (this.resourceResolverFactory == resourceResolverFactory) {
this.resourceResolverFactory = null;
}
}
}