1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
33
com.sun.grid.cull.JavaHelper jh = (com.sun.grid.cull.JavaHelper)params.get("javaHelper");
34
com.sun.grid.cull.CullDefinition cullDef = (com.sun.grid.cull.CullDefinition)params.get("cullDef");
35
com.sun.grid.cull.CullObject cullObj = (com.sun.grid.cull.CullObject)params.get("cullObj");
37
if( cullObj == null ) {
38
throw new IllegalStateException("param cullObj not found");
41
if( cullObj.getIdlName() == null ) {
42
throw new IllegalStateException("cullObj " + cullObj.getName() + " is has no a idl name");
46
if( cullDef == null ) {
47
throw new IllegalStateException("param cullDef not found");
50
String name = jh.getClassName(cullObj);
52
String fullClassName = jh.getFullClassName(cullObj);
54
fullClassName = fullClassName.replace('.', '/');
56
String methodName = "Java_com_sun_grid_jgdi_jni_JGDI_fill" + name + "List";
58
String listName = cullObj.getListName();
60
if (listName == null) {
61
// we not a ILISTDEF, return
68
#include "basis_types.h"
72
#include "sge_all_listsL.h"
73
#include "sge_answer.h"
75
#include "sge_bootstrap.h"
76
#include "sge_gdi_ctx.h"
77
#include "cl_errors.h"
79
#include "sge_error_class.h"
80
#include "jgdi_common.h"
83
ILISTDEF(<%=cullObj.getName()%>, <%=cullObj.getIdlName()%>, <%=cullObj.getListName()%>, <%
84
for(int i = 0; i < cullObj.getParamCount(); i++ ) {
85
if ( i > 0 ) { %> , <% } %> <%=cullObj.getParam(i)%> <% } %> )
87
/* ------------------ GET --------------------------------------------------- */
89
* Class: com_sun_grid_jgdi_jni_JGDI
90
* Method: get<%=jh.getClassName(cullObj)%>List
92
JNIEXPORT void JNICALL <%=methodName%>(JNIEnv *env, jobject jgdi, jobject list) {
97
/* receive Cull Object */
99
const lDescr *descr = NULL;
101
lCondition *where = NULL;
102
static lEnumeration *what = NULL;
103
jmethodID add_mid = NULL;
104
lListElem *ep = NULL;
106
char classname[] = "<%=fullClassName%>";
107
sge_gdi_ctx_class_t *ctx = NULL;
109
sge_error_class_t *eh = NULL;
112
DENTER(TOP_LAYER, "<%=methodName%>");
114
/* create error handler */
115
eh = sge_error_class_create();
117
THROW_ERROR((env, "sge_error_class_create failed"));
122
/* create what and where */
124
what = lWhat("%T(ALL)", <%=cullObj.getName()%>);
128
ctx = getGDIContext(env, jgdi, &alp);
130
alp = ctx->gdi(ctx, <%=listName%>, SGE_GDI_GET, &lp, where, what, NULL);
131
/* if error throw exception */
132
if(answer_list_has_error(&alp)) {
133
dstring ds = DSTRING_INIT;
134
answer_list_to_dstring(alp, &ds);
135
THROW_ERROR((env, "sge_gdi() reported error: %s", sge_dstring_get_string(&ds)));
136
sge_dstring_free(&ds);
142
cls = (*env)->GetObjectClass(env, list);
143
obj_class = (*env)->FindClass(env, classname);
150
add_mid = get_methodid(env, cls, "add", "(Ljava/lang/Object;)Z", &alp);
152
dstring ds = DSTRING_INIT;
153
answer_list_to_dstring(alp, &ds);
154
THROW_ERROR((env, "get_methodid failed: %s", sge_dstring_get_string(&ds)));
155
sge_dstring_free(&ds);
161
descr = lGetListDescr(lp);
163
// convert to Java representation
164
obj = listelem_to_obj(env, ep, descr, obj_class, &alp);
169
(*env)->CallVoidMethod( env, list, add_mid, obj );
172
// if error throw exception
173
if(answer_list_has_error(&alp)) {
174
dstring ds = DSTRING_INIT;
175
answer_list_to_dstring(alp, &ds);
176
THROW_ERROR((env, "listelem_to_obj failed: %s", sge_dstring_get_string(&ds)));
177
sge_dstring_free(&ds);
185
methodName = "Java_com_sun_grid_jgdi_jni_JGDI_add" + name;
187
/* -------------- ADD ------------------------------------------------------- */
189
* Class: com_sun_grid_jgdi_jni_JGDI
190
* Method: add<%=jh.getClassName(cullObj)%>
191
* Signature: (L<%=fullClassName%>;)V
193
JNIEXPORT void JNICALL <%=methodName%>(JNIEnv *env, jobject jgdi, jobject jobj)
197
lCondition *where = NULL;
198
static lEnumeration *what = NULL;
199
lListElem *ep = NULL;
200
sge_gdi_ctx_class_t *ctx = NULL;
201
sge_error_class_t *eh = NULL;
203
DENTER( TOP_LAYER, "<%=methodName%>" );
205
eh = sge_error_class_create();
207
THROW_ERROR((env, "sge_error_class_create failed"));
212
/* create what and where */
214
what = lWhat("%T(ALL)", <%=cullObj.getName()%>);
217
ep = obj_to_listelem(env, jobj, <%=cullObj.getName()%>, &alp);
219
if (answer_list_has_error(&alp)) {
220
dstring ds = DSTRING_INIT;
221
answer_list_to_dstring(alp, &ds);
222
THROW_ERROR((env, "obj_to_listelem: %s", sge_dstring_get_string(&ds)));
223
sge_dstring_free(&ds);
228
lp = lCreateList("<%=listName%> list to add", <%=cullObj.getName()%>);
232
ctx = getGDIContext(env, jgdi, &alp);
234
/* add to <%=cullObj.getName()%> list */
236
alp = ctx->gdi(ctx, <%=listName%>, SGE_GDI_ADD, &lp, where, what, NULL);
239
/* if error throw exception */
240
if (answer_list_has_error(&alp)) {
241
dstring ds = DSTRING_INIT;
242
answer_list_to_dstring(alp, &ds);
243
THROW_ERROR((env, "sge_gdi() reported error: %s", sge_dstring_get_string(&ds)));
244
sge_dstring_free(&ds);
254
methodName = "Java_com_sun_grid_jgdi_jni_JGDI_delete" + name;
258
* Class: com_sun_grid_jgdi_jni_JGDI
259
* Method: delete<%=name%>
260
* Signature: (L<%=fullClassName%>;)V
262
JNIEXPORT void JNICALL <%=methodName%>(JNIEnv *env, jobject jgdi, jobject jobj)
266
lCondition *where = NULL;
267
static lEnumeration *what = NULL;
268
lListElem *ep = NULL;
269
sge_gdi_ctx_class_t *ctx = NULL;
271
DENTER( TOP_LAYER, "<%=methodName%>" );
273
/* create what and where */
275
what = lWhat("%T(ALL)", <%=cullObj.getName()%>);
278
ep = obj_to_listelem(env, jobj, <%=cullObj.getName()%>, &alp);
280
if (answer_list_has_error(&alp)) {
281
dstring ds = DSTRING_INIT;
282
answer_list_to_dstring(alp, &ds);
283
THROW_ERROR((env, "obj_to_listelem: %s", sge_dstring_get_string(&ds)));
284
sge_dstring_free(&ds);
289
lp = lCreateList("<%=listName%> list to delete", <%=cullObj.getName()%>);
293
ctx = getGDIContext(env,jgdi, &alp);
295
/* delete from <%=cullObj.getName()%> list */
296
alp = ctx->gdi(ctx, <%=listName%>, SGE_GDI_DEL, &lp, where, what, NULL);
299
/* if error throw exception */
300
if (answer_list_has_error(&alp)) {
301
dstring ds = DSTRING_INIT;
302
answer_list_to_dstring(alp, &ds);
303
THROW_ERROR((env, "sge_gdi() reported error: %s", sge_dstring_get_string(&ds)));
304
sge_dstring_free(&ds);