EmailServiceProviderImpl.java
2.46 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.day.cq.wcm.webservicesupport.Configuration
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Properties
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.ReferenceCardinality
* org.apache.felix.scr.annotations.ReferencePolicy
* org.apache.felix.scr.annotations.Service
*/
package com.day.cq.mcm.emailprovider.impl;
import com.day.cq.mcm.emailprovider.EmailService;
import com.day.cq.mcm.emailprovider.service.EmailServiceProvider;
import com.day.cq.wcm.webservicesupport.Configuration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
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.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
@Component
@Service
@Properties(value={@Property(name="service.description", value={"Email Provider Service Implementation"})})
@Reference(name="EmailService", referenceInterface=EmailService.class, cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC)
public class EmailServiceProviderImpl
implements EmailServiceProvider {
private Map<String, EmailService> emailServiceMapping = new ConcurrentHashMap<String, EmailService>();
@Override
public EmailService getEmailService(Configuration configuration) {
if (configuration != null) {
String providerName = (String)configuration.getInherited("providerName", (Object)"");
return this.emailServiceMapping.get(providerName);
}
return null;
}
public void bindEmailService(EmailService emailService) {
if (emailService != null) {
this.emailServiceMapping.put(emailService.getName(), emailService);
}
}
public void unbindEmailService(EmailService emailService) {
if (emailService != null) {
this.emailServiceMapping.remove(emailService.getName());
}
}
@Override
public EmailService getEmailService(String providerName) {
if (providerName != null) {
return this.emailServiceMapping.get(providerName);
}
return null;
}
}