File: java_event_factory.jsp

package info (click to toggle)
gridengine 8.1.9%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 56,880 kB
  • sloc: ansic: 432,689; java: 87,068; cpp: 31,958; sh: 29,429; jsp: 7,757; perl: 6,336; xml: 5,828; makefile: 4,701; csh: 3,928; ruby: 2,221; tcl: 1,676; lisp: 669; yacc: 519; python: 503; lex: 361; javascript: 200
file content (234 lines) | stat: -rw-r--r-- 7,389 bytes parent folder | download | duplicates (9)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
/*___INFO__MARK_BEGIN__*/
/*************************************************************************
 *
 *  The Contents of this file are made available subject to the terms of
 *  the Sun Industry Standards Source License Version 1.2
 *
 *  Sun Microsystems Inc., March, 2001
 *
 *
 *  Sun Industry Standards Source License Version 1.2
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.2 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *   Copyright: 2001 by Sun Microsystems, Inc.
 *
 *   All Rights Reserved.
 *
 ************************************************************************/
/*___INFO__MARK_END__*/
/**
 *  Generated from java_event_factory.jsp
 *  !!! DO NOT EDIT THIS FILE !!!
 */
<%
  com.sun.grid.cull.JavaHelper jh = (com.sun.grid.cull.JavaHelper)params.get("javaHelper");
  com.sun.grid.cull.CullDefinition cullDef = (com.sun.grid.cull.CullDefinition)params.get("cullDef");
%>
package com.sun.grid.jgdi.event;


import java.util.*;

<% // Import all cull object names;
    com.sun.grid.cull.CullObject cullObj = null;
    for (String name : cullDef.getObjectNames()) {
      cullObj = cullDef.getCullObject(name); 
/*      if (cullObj.getType() == cullObj.TYPE_PRIMITIVE) {
         continue;
      }
      if(cullObj.getType() == cullObj.TYPE_MAPPED) {
         continue;
      }
      if(!cullObj.isRootObject()) {
        continue;
      }*/
%>import <%=jh.getFullClassName(cullObj)%>;
<% 
   } // end of for
%>

/**
 *  Factory class for all List/Del/Add/Mod Events of cull objects
 */
public class EventFactory extends EventFactoryBase {

   /** store all internal event factories (key the name of the cull object,
    *  value is the internal event factory) */
   private static Map facMap;
   
   
  /**
   * Create a list event for a cull type
   * @param name        name of the cull type
   * @param timestamp   timestamp when the list event occured
   * @param eventId     unique id of the event
   * @return the list event
   */
  public static ListEvent createListEvent(String name, long timestamp, int eventId) {
   
      InternalEventFactory fac = (InternalEventFactory)facMap.get(name);
      if( fac != null ) {
         return fac.createListEvent(timestamp, eventId);
      }
      throw new IllegalArgumentException( "can not create list event for cull type " + name );
  }
  
  /**
   * Create a add event for a cull type
   * @param name        name of the cull type
   * @param timestamp   timestamp when the add event occured
   * @param eventId     unique id of the event
   * @return the add event
   */
   public static AddEvent createAddEvent(String name, long timestamp, int eventId) {
   
      InternalEventFactory fac = (InternalEventFactory)facMap.get(name);
      if( fac != null ) {
         return fac.createAddEvent(timestamp, eventId);
      }
      throw new IllegalArgumentException( "can not create add event for cull type " + name );
   }

  /**
   * Create a mod event for a cull type
   * @param name        name of the cull type
   * @param timestamp   timestamp when the mod event occured
   * @param eventId     unique id of the event
   * @return the mod event
   */
   public static ModEvent createModEvent(String name, long timestamp, int eventId) {
   
      InternalEventFactory fac = (InternalEventFactory)facMap.get(name);
      if( fac != null ) {
         return fac.createModEvent(timestamp, eventId);
      }
      throw new IllegalArgumentException( "can not create mod event for cull type " + name );
   }
  
  /**
   * Create a del event for a cull type
   * @param name        name of the cull type
   * @param timestamp   timestamp when the del event occured
   * @param eventId     unique id of the event
   * @return the del event
   */
   public static DelEvent createDelEvent(String name, long timestamp, int eventId) {
   
      InternalEventFactory fac = (InternalEventFactory)facMap.get(name);
      if( fac != null ) {
         return fac.createDelEvent(timestamp, eventId);
      }
      throw new IllegalArgumentException( "can not create del event for cull type " + name );
   }

   /**
    *  Interface for all internal event factory classes
    */
   interface InternalEventFactory  {

       public ListEvent createListEvent(long timestamp, int eventId);
       public AddEvent  createAddEvent(long timestamp, int eventId);
       public ModEvent  createModEvent(long timestamp, int eventId);
       public DelEvent  createDelEvent(long timestamp, int eventId);    
    }

    /**
     *  this static initializer creates all internal event factories an stores
     *  it the the factory map.
     */
    static {        
    
        facMap = new HashMap();
        
<%
    for (String name : cullDef.getObjectNames()) {
       cullObj = cullDef.getCullObject(name); 
       String idlName = cullObj.getIdlName();
        // <%=cullObj.getName()%>
        facMap.put("<%=cullObj.getName()%>", new <%=idlName%>EventFactory()); 
<%
    } // end of for
%>
    
    }
    // -------------------- Factory classes -----------------------------------
<%
    for (String name : cullDef.getObjectNames()) {
      cullObj = cullDef.getCullObject(name); 
      String idlName = cullObj.getIdlName();
%>
     // <%=cullObj.getName()%>
    static class <%=idlName%>EventFactory implements InternalEventFactory {
    
       public ListEvent createListEvent(long timestamp, int eventId) {
<%
        if(cullObj.hasGetListEvent()) {
%>
           return new <%=idlName%>ListEvent(timestamp, eventId);
<%
        } else {
%>
           throw new IllegalStateException("list event not supported for <%=cullObj.getName()%>");
<%
        }
%>  
       }
       public AddEvent  createAddEvent(long timestamp, int eventId) {
<%
        if(cullObj.hasAddEvent()) {
%>
           return new <%=idlName%>AddEvent(timestamp, eventId);
<%
        } else {
%>
           throw new IllegalStateException("add event not supported for <%=cullObj.getName()%>");
<%
        }
%>  
       }
       public ModEvent  createModEvent(long timestamp, int eventId) {
<%
        if(cullObj.hasModifyEvent()) {
%>
           return new <%=idlName%>ModEvent(timestamp, eventId);
<%
        } else {
%>
           throw new IllegalStateException("mod event not supported for <%=cullObj.getName()%>");
<%
        }
%>  
       }
       public DelEvent  createDelEvent(long timestamp, int eventId) {
<%
        if(cullObj.hasDeleteEvent()) {
%>
           return new <%=idlName%>DelEvent(timestamp, eventId);
<%
        } else {
%>
           throw new IllegalStateException("del event not supported for <%=cullObj.getName()%>");
<%
        }
%>  
       }
    }
    
<% 
    } // end of for
%>

}