1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.example.geomail.components; |
8 | |
|
9 | |
import org.mule.api.MuleEventContext; |
10 | |
import org.mule.api.lifecycle.Callable; |
11 | |
|
12 | |
import java.util.ArrayList; |
13 | |
import java.util.List; |
14 | |
import java.util.Random; |
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | 0 | public class DataGenerator implements Callable |
20 | |
{ |
21 | 0 | private Random generator = new Random(); |
22 | 0 | private int batchSize = 10; |
23 | |
|
24 | |
public Object onCall(MuleEventContext eventContext) throws Exception |
25 | |
{ |
26 | 0 | eventContext.getMessage().setOutboundProperty("from.email.address", "testdatagenerator@geomail.com"); |
27 | |
|
28 | |
|
29 | 0 | List<String> ipAddresses = new ArrayList<String>(batchSize); |
30 | 0 | for (int i = 0; i < batchSize; i++) |
31 | |
{ |
32 | 0 | String address = new StringBuffer().append(generator.nextInt(255)).append(".") |
33 | |
.append(generator.nextInt(255)).append(".").append(generator.nextInt(255)). |
34 | |
append(".").append(generator.nextInt(255)).toString(); |
35 | 0 | ipAddresses.add(address); |
36 | |
} |
37 | |
|
38 | 0 | return ipAddresses; |
39 | |
} |
40 | |
|
41 | |
public int getBatchSize() |
42 | |
{ |
43 | 0 | return batchSize; |
44 | |
} |
45 | |
|
46 | |
public void setBatchSize(int batchSize) |
47 | |
{ |
48 | 0 | this.batchSize = batchSize; |
49 | 0 | } |
50 | |
} |