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 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
|
/*___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_rmi_jgdi_cache.jsp
* !!! DO NOT EDIT THIS FILE !!!
*/
<%
final com.sun.grid.cull.JavaHelper jh = (com.sun.grid.cull.JavaHelper)params.get("javaHelper");
final com.sun.grid.cull.CullDefinition cullDef = (com.sun.grid.cull.CullDefinition)params.get("cullDef");
class JGDIRMICacheGenerator extends com.sun.grid.cull.AbstractGDIGenerator {
public JGDIRMICacheGenerator(com.sun.grid.cull.CullObject cullObject) {
super(cullObject.getIdlName(), jh.getClassName(cullObject), cullObject);
addPrimaryKeys(cullObject, jh);
}
public void genImport() {
if(!(cullObject.getType() == cullObject.TYPE_PRIMITIVE ||
cullObject.getType() == cullObject.TYPE_MAPPED)) {
%>import com.sun.grid.jgdi.configuration.<%=classname%>;
<%
}
} // end of genImport
public void genUpdateMethod() {
%>
/**
* Update <%=getPrimaryKeyCount() == 0 ? "the" : "a"%> <%=name%> object
*
* @param obj the <%=name%> object with the new values
* @throws RemoteException on any error
*/
public void update<%=name%>(<%=classname%> obj) throws RemoteException {
try {
jgdi.update<%=name%>(obj);
} catch( RemoteException re ) {
handleError(re);
throw re;
}
<%
if (cullObject.hasGetListOperation()) {
%>
finally {
<%=name%>Cache = null;
}
<%
}
%>
}
<%
} // end of genUpdateMethod
public void genGetMethod() {
%>
private <%=classname%> <%=name%>Cache = null;
/**
* Get the <code><%=name%></code> object.
* @return the <code><%=name%></code> object
* @throws RemoteException on any error
*/
public <%=classname%> get<%=name%>() throws RemoteException {
if ( jgdi == null ) {
return null;
}
if (<%=name%>Cache == null ) {
try {
<%=name%>Cache = jgdi.get<%=name%>();
} catch( RemoteException re ) {
handleError(re);
return null;
}
}
return <%=name%>Cache;
}
<% } // end of genGetMethod
public void genGetListMethod() {
%>
private List <%=name%>Cache = null;
/**
* Get all <code><%=name%></code> objects.
*
* @return a list of <code><%=name%></code> objects
* @throws RemoteException on any error
*/
public List get<%=name%>List() throws RemoteException {
if ( jgdi == null ) {
return Collections.EMPTY_LIST;
}
if (<%=name%>Cache == null ) {
try {
<%=name%>Cache = jgdi.get<%=name%>List();
} catch( RemoteException re ) {
handleError(re);
return Collections.EMPTY_LIST;
}
}
return <%=name%>Cache;
}
<%
} // end of genGetListMethod
public void genAddMethod() {
%>
/**
* Add a new <code><%=name%></code> object.
*
* @param obj the new <code><%=name%></code> object
* @throws RemoteException on any error
*/
public void add<%=name%>(<%=classname%> obj) throws RemoteException {
try {
jgdi.add<%=name%>(obj);
} catch( RemoteException re ) {
handleError(re);
throw re;
} <%
if (cullObject.hasGetListOperation()) {
%> finally {
<%=name%>Cache = null;
}
<%
}
%>
}
<%
} // end of genAddMethod
public void genDeleteMethod() {
%>
/**
* Add a delete <code><%=name%></code> object.
*
* @param obj the <code><%=name%></code> object with the primary key information
* @throws RemoteException on any error
*/
public void delete<%=name%>(<%=classname%> obj) throws RemoteException {
try {
jgdi.delete<%=name%>(obj);
} catch( RemoteException re ) {
handleError(re);
throw re;
} <%
if (cullObject.hasGetListOperation()) {
%> finally {
<%=name%>Cache = null;
}
<%
}
%>
}
<%
} // end of genDeleteMethod
public void genDeleteByPrimaryKeyMethod() {
%>
/**
* Delete a a <code><%=name%></code> object by its primary key
*
<%
boolean first = true;
for (java.util.Map.Entry<String, String> entry: primaryKeys.entrySet()) {
String pkName = entry.getKey();
%> * @param <%=pkName%> the <%=pkName%> of the <code><%=name%></code> object <%
}
%>
* @throws RemoteException on any error
*/
public void delete<%=name%>(<%
first = true;
for (java.util.Map.Entry<String, String> entry: primaryKeys.entrySet()) {
String pkName = entry.getKey();
String pkType = entry.getValue();
if(first) {
first = false;
} else {
%>, <%
}
%> <%=pkType%> <%=pkName%><%
}
%>) throws RemoteException {
try {
jgdi.delete<%=name%>(<%
first = true;
for (java.util.Map.Entry<String, String> entry: primaryKeys.entrySet()) {
String pkName = entry.getKey();
if(first) {
first = false;
} else {
%>, <%
}
%><%=pkName%><%
}
%>);
} catch( RemoteException re ) {
handleError(re);
}
}
<%
} // end of genDeleteByPrimaryKeyMethod
public void genGetByPrimaryKeyMethod() {
%>
/**
* Get a a <code><%=name%></code> object by its primary key
*
<%
boolean first = true;
for (java.util.Map.Entry<String, String> entry: primaryKeys.entrySet()) {
String pkName = entry.getKey();
%> * @param <%=pkName%> the <%=pkName%> of the <code><%=name%></code> object <%
}
%>
* @return the <code><%=name%></code> object or <code>null</code>
* @throws RemoteException on any error
*/
public <%=classname%> get<%=name%>(<%
first = true;
for (java.util.Map.Entry<String, String> entry: primaryKeys.entrySet()) {
String pkName = entry.getKey();
String pkType = entry.getValue();
if(first) {
first = false;
} else {
%>, <%
}
%> <%=pkType%> <%=pkName%><%
}
%>) throws RemoteException {
try {
return jgdi.get<%=name%>(<%
first = true;
for (java.util.Map.Entry<String, String> entry: primaryKeys.entrySet()) {
String pkName = entry.getKey();
if(first) {
first = false;
} else {
%>, <%
}
%><%=pkName%><%
}
%>);
} catch( RemoteException re ) {
handleError(re);
return null;
}
}
<%
} // end of genGetByPrimaryKeyMethod
} // end of class JGDIRMICacheGenerator
// ---------------------------------------------------------------------------
// Build Generator instances
// ---------------------------------------------------------------------------
java.util.List<JGDIRMICacheGenerator> generators = new java.util.ArrayList<JGDIRMICacheGenerator>();
com.sun.grid.cull.CullObject cullObj = null;
for (String name : cullDef.getObjectNames()) {
cullObj = cullDef.getCullObject(name);
generators.add(new JGDIRMICacheGenerator(cullObj));
}
%>
package com.sun.grid.jgdi.rmi;
import java.rmi.RemoteException;
import java.rmi.Remote;
import java.util.List;
import java.util.Collections;
import com.sun.grid.jgdi.JGDI;
import com.sun.grid.jgdi.JGDIException;
<% // Import all cull object names;
for (JGDIRMICacheGenerator gen : generators) {
gen.genImport();
} // end of for
%>
/**
* This class implements a cache for the {@link JGDIRemote} interface.
*/
public class JGDIRemoteCache extends JGDIRemoteCacheBase implements JGDIRemote {
/** Creates a new instance of JGDIRemoteCache */
public JGDIRemoteCache() {
}
/**
* Create a new instanceof of JGDIRemoteCache
* @param jgdi the jgdi remote service
*/
public JGDIRemoteCache(JGDIRemote jgdi) {
super(jgdi);
}
<%
for (JGDIRMICacheGenerator gen : generators) {
gen.genMethods();
} // end of for
%>
}
|