1 |
package appl.parallel.data; |
2 |
|
3 |
import java.awt.Rectangle; |
4 |
|
5 |
import org.apache.log4j.LogManager; |
6 |
import org.apache.log4j.Logger; |
7 |
|
8 |
import appl.ext.XuluConfig; |
9 |
import appl.parallel.client.ClientDataServer; |
10 |
|
11 |
/** |
12 |
* Reads out of {@link XuluConfig} which {@link PartitionDataHandler} needs to |
13 |
* be used for data loading/unloading and constructs an instance of this class. |
14 |
* The classname is read out of the property <br> |
15 |
* <br> |
16 |
* Parallel.partitionhandlerfactory.classname |
17 |
* |
18 |
* @author Dominik Appl |
19 |
*/ |
20 |
public class PartitionHandlerFactory { |
21 |
|
22 |
private static Logger LOG = LogManager |
23 |
.getLogger("appl.data.PartitionHandlerFactory"); |
24 |
|
25 |
/** |
26 |
* @param rootID |
27 |
* the id of the data |
28 |
* @param partitionBounds |
29 |
* the bounds of the partition to be retrieved on server side |
30 |
* @param unloadBounds |
31 |
* the bounds of the partition which is to be uploaded to the |
32 |
* client after calculation |
33 |
* @return a new {@link PartitionDataHandler} instance |
34 |
*/ |
35 |
public static PartitionDataHandler newInstance(int rootID, |
36 |
ClientDataServer client, Rectangle partitionBounds, |
37 |
Rectangle unloadBounds) { |
38 |
PartitionDataHandler returnhandler = null; |
39 |
// try to get info from xulu config |
40 |
String classname = XuluConfig.getXuluConfig().getProperty( |
41 |
"Parallel.partitionhandlerfactory.classname"); |
42 |
if (classname != null) { |
43 |
try { |
44 |
returnhandler = (PartitionDataHandler) Class.forName(classname) |
45 |
.newInstance(); |
46 |
} catch (InstantiationException e) { |
47 |
LOG.error(e); |
48 |
e.printStackTrace(); |
49 |
} catch (IllegalAccessException e) { |
50 |
LOG.error(e); |
51 |
e.printStackTrace(); |
52 |
} catch (ClassNotFoundException e) { |
53 |
e.printStackTrace(); |
54 |
LOG.error("Could not find PartitionHandler class '" + classname |
55 |
+ "'", e); |
56 |
} |
57 |
} |
58 |
if (returnhandler != null) { |
59 |
return returnhandler.newInstance(rootID, client, partitionBounds, |
60 |
unloadBounds); |
61 |
} |
62 |
return null; |
63 |
} |
64 |
|
65 |
} |