HtmlToPdfSvc.java
4.78 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
135
136
137
138
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* com.adobe.service.ProcessFactoryManager
* com.adobe.service.ResourceFactoryManager
* com.adobe.service.Service
* com.adobe.service.ServiceAPI
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Property
* org.apache.felix.scr.annotations.Service
* org.apache.sling.commons.osgi.OsgiUtil
* org.slf4j.Logger
* org.slf4j.LoggerFactory
*/
package com.adobe.html2pdf;
import com.adobe.html2pdf.HtmlToPdfSvcMBean;
import com.adobe.service.ProcessFactoryManager;
import com.adobe.service.ResourceFactoryManager;
import com.adobe.service.ServiceAPI;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Service;
import org.apache.sling.commons.osgi.OsgiUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
@Component(metatype=1, immediate=1, label="%html2pdf.bmc.name", description="%html2pdf.bmc.description", inherit=1)
@Service
public class HtmlToPdfSvc
extends com.adobe.service.Service
implements HtmlToPdfSvcMBean {
private static final boolean DEFAULT_DEBUG = false;
@Property(boolValue={0})
private static final String PROP_DEBUG = "Debug";
private static final int DEFAULT_MAX_REUSE_COUNT = 1000;
@Property(intValue={1000})
private static final String PROP_MAX_REUSE_COUNT = "MaxReuseCount";
private static final String DEFAULT_ORB_PARAMS = "";
@Property(value={""})
private static final String PROP_ORB_PARAMS = "ORBParams";
private static final long DEFAULT_GLOBAL_TIMEOUT = 300;
@Property(longValue={300})
private static final String PROP_GLOBAL_TIMEOUT = "GlobalTimeout";
private static final String EXECUTABLE_NAME_WIN = "bin/HTML2PDFConverter.exe";
private static final String EXECUTABLE_NAME_UNIX = "bin/HTML2PDFConverter.sh";
private static long m_globalTimeout;
private static final Logger logger;
private ProcessFactoryManager processFactoryManager = null;
public void onStartService(Map config) {
logger.debug("HtmlToPdfService starting");
boolean debug = OsgiUtil.toBoolean(config.get("Debug"), (boolean)false);
int maxReuseCount = OsgiUtil.toInteger(config.get("MaxReuseCount"), (int)1000);
String orbParams = OsgiUtil.toString(config.get("ORBParams"), (String)"");
long globalTimeout = OsgiUtil.toLong(config.get("GlobalTimeout"), (long)300);
this.processFactoryManager = new ProcessFactoryManager((ServiceAPI)this);
if (System.getProperty("os.name").toLowerCase().indexOf("windows") > -1) {
this.processFactoryManager.setExecutableName("bin/HTML2PDFConverter.exe");
} else {
this.processFactoryManager.setExecutableName("bin/HTML2PDFConverter.sh");
}
this.processFactoryManager.setExecutableArguments("");
this.setDebug(debug);
this.setMaximumReUseCount(maxReuseCount);
this.setORBParams(orbParams);
this.setGlobalTimeout(globalTimeout);
this.registerConnectionFactoryManager((ResourceFactoryManager)this.processFactoryManager);
}
public void onStopService() {
logger.debug("HtmlToPdfService stopping");
}
public String about() {
return "Adobe AEM Forms PDF Generator";
}
public long getGlobalTimeout() {
return m_globalTimeout;
}
public void setGlobalTimeout(long timeout) {
m_globalTimeout = timeout;
}
public long getTotalConversions() {
return 0;
}
public boolean getDebug() {
return this.processFactoryManager.getDebug();
}
public void setDebug(boolean debug) {
this.processFactoryManager.setDebug(debug);
}
public int getMaximumReUseCount() {
return this.processFactoryManager.getMaximumReUseCount();
}
public void setMaximumReUseCount(int count) {
this.processFactoryManager.setMaximumReUseCount(count);
}
public void setORBParams(String params) {
this.processFactoryManager.setORBParams(params);
}
public String getORBParams() {
return this.processFactoryManager.getORBParams();
}
public void setNativeDependencies(String nativeDependencies) {
this.processFactoryManager.setNativeDependencies(nativeDependencies);
}
public String getNativeDependencies() {
return this.processFactoryManager.getNativeDependencies();
}
public String[] getSharedLibraryPaths() {
return this.processFactoryManager.getSharedLibraryPaths();
}
public void setSharedLibraryPaths(String[] sharedLibraryPaths) {
this.processFactoryManager.setSharedLibraryPaths(sharedLibraryPaths);
}
static {
logger = LoggerFactory.getLogger(HtmlToPdfSvc.class);
}
}