1
2
3
4
5
6
7
8
9 package net.sf.jour.log4j;
10
11 import org.apache.log4j.spi.LoggingEvent;
12
13 public class ProfilerArraySocketAppender extends ProfilerSocketAppender {
14
15 int arraySize = 10;
16
17 int acounter = 0;
18
19 public ProfilerArraySocketAppender() {
20 }
21
22 LoggingEvent[] lEvents = null;
23
24 ProfilerEvent[] pEvents = null;
25
26 ProfilerEventExt[] pEventsExt = null;
27
28 protected Object getObject(LoggingEvent event) {
29 if (acounter == 0) {
30 switch (useLoggingEvent) {
31 case 0:
32 lEvents = new LoggingEvent[arraySize];
33 break;
34 case 1:
35 pEvents = new ProfilerEvent[arraySize];
36 break;
37 case 2:
38 pEventsExt = new ProfilerEventExt[arraySize];
39 break;
40 default:
41 errorHandler.error("Wrong useLoggingEvent" + useLoggingEvent);
42 return null;
43 }
44 }
45 Object ret = null;
46
47 switch (useLoggingEvent) {
48 case 0: {
49 lEvents[acounter] = event;
50 ret = lEvents;
51 break;
52 }
53 case 1: {
54 pEvents[acounter] = ProfilerEvent.extract(event);
55 ret = pEvents;
56 break;
57 }
58 case 2: {
59 pEventsExt[acounter] = ProfilerEventExt.extract(event);
60 ret = pEventsExt;
61 break;
62 }
63 }
64
65 acounter++;
66 if (acounter < arraySize) {
67 return null;
68 }
69 acounter = 0;
70 return ret;
71 }
72
73 public void setArraySize(int arraySize) {
74 this.arraySize = arraySize;
75 }
76
77 public int getArraySize() {
78 return this.arraySize;
79 }
80
81 }