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