use of com.genexus.internet.HttpContext in project JavaClasses by genexuslabs.
the class GXGridStateHandler method setState.
public void setState(SdtGridState state) {
this.state = state;
String jsonState = state.toJSonString();
HttpContext httpContext = (HttpContext) context.getHttpContext();
WebSession session = httpContext.getWebSession();
session.setValue(gridName, jsonState);
}
use of com.genexus.internet.HttpContext in project JavaClasses by genexuslabs.
the class GXutil method setLanguage.
public static int setLanguage(String language, ModelContext context, com.genexus.db.UserInformation ui) {
HttpContext httpContext = (HttpContext) context.getHttpContext();
int res = httpContext.setLanguage(language);
ui.setLocalUtil(httpContext.getLanguageProperty("decimal_point").charAt(0), context.getHttpContext().getLanguageProperty("date_fmt"), context.getHttpContext().getLanguageProperty("time_fmt"), context.getClientPreferences().getYEAR_LIMIT(), context.getHttpContext().getLanguageProperty("code"));
return res;
}
use of com.genexus.internet.HttpContext in project JavaClasses by genexuslabs.
the class SubmitThread method run.
public void run() {
com.genexus.internet.HttpContext httpContext = (HttpContext) ModelContext.getModelContext().getHttpContext();
synchronized (this) {
initialized = true;
}
while (!exit) {
synchronized (this) {
if (!inUse) {
try {
this.wait();
} catch (InterruptedException e) {
;
}
if (exit) {
break;
}
}
}
// Ejecuto el submit
try {
SQLAndroidSQLiteHelper.beginTransaction();
proc.submit(submitId, submitParms);
SQLAndroidSQLiteHelper.endTransaction();
} catch (Throwable e) {
e.printStackTrace();
}
proc = null;
submitParms = null;
SubmitThreadPool.decRemainingSubmits();
// Veo si hay un nuevo submit para ejecutar
Object[] nextSubmit = SubmitThreadPool.getNextSubmit();
synchronized (this) {
// Aqui debo sincronizar pues se setea la variable inUse
if (nextSubmit != null) {
setProc((ISubmitteable) nextSubmit[0], ((Integer) nextSubmit[1]).intValue(), (Object[]) new GXParameterUnpacker((byte[]) nextSubmit[2]).readObject());
} else {
inUse = false;
}
}
}
}
use of com.genexus.internet.HttpContext in project JavaClasses by genexuslabs.
the class SubmitThread method submit.
public static synchronized void submit(final ISubmitteable proc, final int id, final Object[] submitParms) {
if (threadPool == null) {
// Si el pool todav�a no fue creado
threadPool = new SubmitThread[Preferences.getDefaultPreferences().getSUBMIT_POOL_SIZE()];
parameterPacker = new GXParameterPacker();
}
SubmitThreadPool.incRemainingSubmits();
if (threadPool.length == 0) {
// Si en la preference se puso 0 como cantidad del poolSize esto se considera como 'unlimited'
// En ese caso levantamos un thread por cada submit y no utilizamos el pool
new Thread(new Runnable() {
public void run() {
com.genexus.internet.HttpContext httpContext = (HttpContext) ModelContext.getModelContext().getHttpContext();
SQLAndroidSQLiteHelper.beginTransaction();
proc.submit(id, submitParms);
SQLAndroidSQLiteHelper.endTransaction();
SubmitThreadPool.decRemainingSubmits();
}
}, SUBMIT_THREAD + id).start();
return;
}
// Debo serializar los parametros porque si x ej un parametro era un SDT se debe mantener
// exacto el estado dado que el submit puede que se ejecute mucho mas adelante!, incluso
// aunque se ejecute en el momento, para el caso de sdts el caller puede aun cambiar algun
// dato y tampoco queremos eso
parameterPacker.reset();
parameterPacker.writeObject(submitParms);
// Ahora busco un thread libre
for (int i = 0; i < threadPool.length; i++) {
if (threadPool[i] == null) {
// Si nunca se ha utilizado este thread, debo crearlo
threadPool[i] = new SubmitThread(i);
threadPool[i].start();
// porque sino se puede perder el primer notify() (y en efecto era lo que pasaba)
while (!threadPool[i].isInitialized()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
;
}
}
}
synchronized (threadPool[i]) {
if (threadPool[i].inUse()) {
// Si el thread esta en uso, sigo buscando
continue;
}
threadPool[i].setProc(proc, id, (Object[]) new GXParameterUnpacker(parameterPacker.toByteArray()).readObject());
threadPool[i].notify();
return;
}
}
// Si llego aqui es porque tengo utilizados todos los thread, asi que encolo el submit
submitQueue.addElement(new Object[] { proc, new Integer(id), parameterPacker.toByteArray() });
}
use of com.genexus.internet.HttpContext in project JavaClasses by genexuslabs.
the class GXResultSet method getBlobFileName.
private String getBlobFileName(String name, String extension) {
String blobPath = com.genexus.Preferences.getDefaultPreferences().getBLOB_PATH();
String fileName = com.genexus.PrivateUtilities.getTempFileName(blobPath, name, extension, true);
if (Application.getExternalProvider() == null) {
File file = new File(fileName);
if (!file.isAbsolute()) {
if (!lastBlobsDir.equals("")) {
return lastBlobsDir + fileName;
}
if (con.getContext() != null) {
com.genexus.internet.HttpContext webContext = (HttpContext) con.getContext().getHttpContext();
if ((webContext != null) && (webContext instanceof com.genexus.webpanels.HttpContextWeb)) {
try {
String origFileName = fileName;
fileName = ((com.genexus.webpanels.HttpContextWeb) webContext).getRealPath(fileName);
lastBlobsDir = fileName.substring(0, fileName.indexOf(origFileName));
} catch (NullPointerException e) {
// en el caso de error.
if (!lastBlobsDir.equals("")) {
fileName = lastBlobsDir + fileName;
}
}
}
}
}
} else {
fileName = fileName.replace(java.io.File.separator, "/");
}
return fileName;
}
Aggregations