ClassConnectionFactory.java
1.81 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
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.slf4j.Logger
*/
package com.adobe.service;
import com.adobe.service.ConnectionFactoryManager;
import com.adobe.service.ConnectionResource;
import com.adobe.service.ConnectionResourceFactory;
import java.lang.reflect.Constructor;
import java.lang.reflect.UndeclaredThrowableException;
class ClassConnectionFactory
implements ConnectionResourceFactory {
private final Constructor constructor;
private final Object[] constructorArgs;
ClassConnectionFactory(Class connectionResourceClass, Object[] args) {
if (!ConnectionResource.class.isAssignableFrom(connectionResourceClass)) {
throw new IllegalArgumentException("Class " + connectionResourceClass.getName() + " must extend " + ConnectionResource.class.getName());
}
this.constructorArgs = args;
Class[] argTypes = new Class[this.constructorArgs.length];
for (int i = 0; i < this.constructorArgs.length; ++i) {
argTypes[i] = this.constructorArgs[i].getClass();
}
try {
this.constructor = connectionResourceClass.getConstructor(argTypes);
}
catch (NoSuchMethodException e) {
ConnectionFactoryManager.logger.warn("Error getting required constructor from class " + connectionResourceClass.getName(), (Throwable)e);
throw new IllegalArgumentException("Class " + connectionResourceClass.getName() + " no matching constructor");
}
}
public ConnectionResource create() {
try {
return (ConnectionResource)this.constructor.newInstance(this.constructorArgs);
}
catch (Exception e) {
throw new UndeclaredThrowableException(e, "Can't create " + this.constructor.getDeclaringClass().getName());
}
}
}