link start!
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import javax.baja.job.BJob;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.sys.BInterface;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
public interface BIJobService
|
||||
extends BInterface {
|
||||
public static final Type TYPE;
|
||||
|
||||
public BJob[] getJobs();
|
||||
|
||||
public BOrd submit(BJob var1, Context var2);
|
||||
|
||||
static {
|
||||
Class clazz = 1.class$javax$baja$job$BIJobService;
|
||||
if (clazz == null) {
|
||||
clazz = 1.class$javax$baja$job$BIJobService = 1.class("[Ljavax.baja.job.BIJobService;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,237 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import javax.baja.job.BJobService;
|
||||
import javax.baja.job.BJobState;
|
||||
import javax.baja.job.JobCancelException;
|
||||
import javax.baja.job.JobLog;
|
||||
import javax.baja.job.JobLogItem;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BString;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Clock;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Property;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BJob
|
||||
extends BComponent {
|
||||
public static final Property jobState = BJob.newProperty(3, BJobState.unknown, null);
|
||||
public static final Property progress = BJob.newProperty(3, -1, null);
|
||||
public static final Property startTime = BJob.newProperty(1, BAbsTime.NULL, null);
|
||||
public static final Property heartbeatTime = BJob.newProperty(1, BAbsTime.NULL, null);
|
||||
public static final Property endTime = BJob.newProperty(1, BAbsTime.NULL, null);
|
||||
public static final Action cancel = BJob.newAction(0, null);
|
||||
public static final Action dispose = BJob.newAction(0, null);
|
||||
public static final Action readLog = BJob.newAction(0, null);
|
||||
public static final Type TYPE;
|
||||
private static final BIcon icon;
|
||||
JobLog log;
|
||||
static /* synthetic */ Class class$javax$baja$job$BJob;
|
||||
|
||||
public BJobState getJobState() {
|
||||
return (BJobState)this.get(jobState);
|
||||
}
|
||||
|
||||
public void setJobState(BJobState bJobState) {
|
||||
this.set(jobState, (BValue)bJobState, null);
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return this.getInt(progress);
|
||||
}
|
||||
|
||||
public void setProgress(int n) {
|
||||
this.setInt(progress, n, null);
|
||||
}
|
||||
|
||||
public BAbsTime getStartTime() {
|
||||
return (BAbsTime)this.get(startTime);
|
||||
}
|
||||
|
||||
public void setStartTime(BAbsTime bAbsTime) {
|
||||
this.set(startTime, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public BAbsTime getHeartbeatTime() {
|
||||
return (BAbsTime)this.get(heartbeatTime);
|
||||
}
|
||||
|
||||
public void setHeartbeatTime(BAbsTime bAbsTime) {
|
||||
this.set(heartbeatTime, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public BAbsTime getEndTime() {
|
||||
return (BAbsTime)this.get(endTime);
|
||||
}
|
||||
|
||||
public void setEndTime(BAbsTime bAbsTime) {
|
||||
this.set(endTime, (BValue)bAbsTime, null);
|
||||
}
|
||||
|
||||
public void cancel() {
|
||||
this.invoke(cancel, null, null);
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
this.invoke(dispose, null, null);
|
||||
}
|
||||
|
||||
public BString readLog() {
|
||||
return (BString)this.invoke(readLog, null, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public BOrd submit(Context context) {
|
||||
return BJobService.getService().submit(this, context);
|
||||
}
|
||||
|
||||
public void doSubmit(Context context) {
|
||||
this.setJobState(BJobState.running);
|
||||
this.setStartTime(Clock.time());
|
||||
this.setProgress(-1);
|
||||
this.resetLog();
|
||||
try {
|
||||
this.doRun(context);
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
this.failed(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAlive() {
|
||||
boolean bl = false;
|
||||
if (this.getJobState() == BJobState.running) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public abstract void doRun(Context var1) throws Exception;
|
||||
|
||||
public abstract void doCancel(Context var1) throws Exception;
|
||||
|
||||
public void doDispose(Context context) {
|
||||
if (this.getJobState().isRunning()) {
|
||||
throw new IllegalStateException("Cannot dispose while running");
|
||||
}
|
||||
this.setJobState(BJobState.unknown);
|
||||
if (this.getParent() != null) {
|
||||
((BComponent)this.getParent()).remove(this);
|
||||
}
|
||||
}
|
||||
|
||||
public String toString(Context context) {
|
||||
String string = this.getType().getDisplayName(null);
|
||||
if (string.endsWith(" Job")) {
|
||||
string = string.substring(0, string.length() - 4);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public void progress(int n) {
|
||||
if (n > 100) {
|
||||
n = 100;
|
||||
}
|
||||
this.setProgress(n);
|
||||
this.heartbeat();
|
||||
}
|
||||
|
||||
public void heartbeat() {
|
||||
this.setHeartbeatTime(Clock.time());
|
||||
}
|
||||
|
||||
public void success() {
|
||||
this.log().success("Job Success");
|
||||
this.complete(BJobState.success);
|
||||
}
|
||||
|
||||
public void canceled() {
|
||||
this.log().add(new JobLogItem(2, "Job Canceled"));
|
||||
this.complete(BJobState.canceled);
|
||||
}
|
||||
|
||||
public void failed(Throwable throwable) {
|
||||
if (this.getJobState() == BJobState.canceling || throwable instanceof InterruptedException || throwable instanceof JobCancelException) {
|
||||
this.canceled();
|
||||
return;
|
||||
}
|
||||
this.log().failed("Job Failed", throwable);
|
||||
this.complete(BJobState.failed);
|
||||
}
|
||||
|
||||
public void complete(BJobState bJobState) {
|
||||
if (!bJobState.isComplete()) {
|
||||
throw new IllegalArgumentException("Cannot complete as " + bJobState);
|
||||
}
|
||||
this.setJobState(bJobState);
|
||||
this.setProgress(100);
|
||||
this.setEndTime(Clock.time());
|
||||
}
|
||||
|
||||
public JobLog log() {
|
||||
return this.log;
|
||||
}
|
||||
|
||||
public BString doReadLog() {
|
||||
return BString.make(this.log.encode());
|
||||
}
|
||||
|
||||
public void resetLog() {
|
||||
this.log = new JobLog();
|
||||
}
|
||||
|
||||
public void spy(SpyWriter spyWriter) throws Exception {
|
||||
super.spy(spyWriter);
|
||||
spyWriter.w("<hr><pre>").w(this.readLog()).w("</pre>");
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.log = new JobLog();
|
||||
}
|
||||
|
||||
public BJob() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$job$BJob;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$job$BJob = BJob.class("[Ljavax.baja.job.BJob;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
icon = BIcon.std("build.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import com.tridium.sys.service.ServiceManager;
|
||||
import com.tridium.sys.station.BStationSaveJob;
|
||||
import javax.baja.job.BIJobService;
|
||||
import javax.baja.job.BJob;
|
||||
import javax.baja.naming.BOrd;
|
||||
import javax.baja.spy.SpyWriter;
|
||||
import javax.baja.sys.Action;
|
||||
import javax.baja.sys.BComponent;
|
||||
import javax.baja.sys.BIService;
|
||||
import javax.baja.sys.BIcon;
|
||||
import javax.baja.sys.BValue;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.ServiceNotFoundException;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Topic;
|
||||
import javax.baja.sys.Type;
|
||||
import javax.baja.util.BNotification;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BJobService
|
||||
extends BComponent
|
||||
implements BIService,
|
||||
BIJobService {
|
||||
public static final Action submitAction = BJobService.newAction(4, new BStationSaveJob(), null);
|
||||
public static final Topic notification = BJobService.newTopic(4, null);
|
||||
public static final Type TYPE;
|
||||
private static final BIcon icon;
|
||||
static /* synthetic */ Class class$javax$baja$job$BJobService;
|
||||
static /* synthetic */ Class class$javax$baja$job$BJob;
|
||||
|
||||
public BOrd submitAction(BJob bJob) {
|
||||
return (BOrd)this.invoke(submitAction, bJob, null);
|
||||
}
|
||||
|
||||
public void fireNotification(BNotification bNotification) {
|
||||
this.fire(notification, bNotification, null);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static BIJobService getService() {
|
||||
try {
|
||||
return (BIJobService)((Object)Sys.getService(TYPE));
|
||||
}
|
||||
catch (ServiceNotFoundException serviceNotFoundException) {
|
||||
try {
|
||||
BOrd bOrd = BOrd.make("tool:workbench:WbJobService|slot:/");
|
||||
return (BIJobService)((Object)bOrd.resolve().get());
|
||||
}
|
||||
catch (Exception exception) {
|
||||
throw new ServiceNotFoundException("IJobService", exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final BJob[] getJobs() {
|
||||
Class clazz = class$javax$baja$job$BJob;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$job$BJob = BJobService.class("[Ljavax.baja.job.BJob;", false);
|
||||
}
|
||||
return (BJob[])this.getChildren(clazz);
|
||||
}
|
||||
|
||||
public BOrd submit(BJob bJob, Context context) {
|
||||
return (BOrd)this.invoke(submitAction, bJob, context);
|
||||
}
|
||||
|
||||
public BOrd doSubmitAction(BJob bJob, Context context) {
|
||||
this.add(bJob.getType().getTypeName() + '?', (BValue)bJob, 2);
|
||||
bJob.doSubmit(context);
|
||||
ServiceManager.houseKeeping(this);
|
||||
return bJob.getSlotPathOrd();
|
||||
}
|
||||
|
||||
public Type[] getServiceTypes() {
|
||||
return new Type[]{TYPE};
|
||||
}
|
||||
|
||||
public void serviceStarted() {
|
||||
}
|
||||
|
||||
public void serviceStopped() {
|
||||
}
|
||||
|
||||
public BIcon getIcon() {
|
||||
return icon;
|
||||
}
|
||||
|
||||
public void spy(SpyWriter spyWriter) throws Exception {
|
||||
BJob[] bJobArray = this.getJobs();
|
||||
spyWriter.startTable(true);
|
||||
spyWriter.trTitle("Jobs", 6);
|
||||
spyWriter.w("<tr>").th("Name").th("State").th("Progress").th("Start").th("Heartbeat").th("End").w("</tr>").nl();
|
||||
int n = 0;
|
||||
while (n < bJobArray.length) {
|
||||
BJob bJob = bJobArray[n];
|
||||
spyWriter.tr(bJob.getName(), bJob.getJobState(), "" + bJob.getProgress(), bJob.getStartTime(), bJob.getHeartbeatTime(), bJob.getEndTime());
|
||||
++n;
|
||||
}
|
||||
spyWriter.endTable();
|
||||
super.spy(spyWriter);
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$job$BJobService;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$job$BJobService = BJobService.class("[Ljavax.baja.job.BJobService;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
icon = BIcon.std("build.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import javax.baja.sys.BFrozenEnum;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class BJobState
|
||||
extends BFrozenEnum {
|
||||
public static final int UNKNOWN = 0;
|
||||
public static final int RUNNING = 1;
|
||||
public static final int CANCELING = 2;
|
||||
public static final int CANCELED = 3;
|
||||
public static final int SUCCESS = 4;
|
||||
public static final int FAILED = 5;
|
||||
public static final BJobState unknown = new BJobState(0);
|
||||
public static final BJobState running = new BJobState(1);
|
||||
public static final BJobState canceling = new BJobState(2);
|
||||
public static final BJobState canceled = new BJobState(3);
|
||||
public static final BJobState success = new BJobState(4);
|
||||
public static final BJobState failed = new BJobState(5);
|
||||
public static final Type TYPE;
|
||||
public static final BJobState DEFAULT;
|
||||
static /* synthetic */ Class class$javax$baja$job$BJobState;
|
||||
|
||||
public final Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public static final BJobState make(int n) {
|
||||
return (BJobState)unknown.getRange().get(n, false);
|
||||
}
|
||||
|
||||
public static final BJobState make(String string) {
|
||||
return (BJobState)unknown.getRange().get(string);
|
||||
}
|
||||
|
||||
public final boolean isRunning() {
|
||||
boolean bl = false;
|
||||
if (this == running) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
public final boolean isComplete() {
|
||||
boolean bl = false;
|
||||
if (this == success || this == canceled || this == failed) {
|
||||
bl = true;
|
||||
}
|
||||
return bl;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private BJobState(int n) {
|
||||
super(n);
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$job$BJobState;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$job$BJobState = BJobState.class("[Ljavax.baja.job.BJobState;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
DEFAULT = unknown;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import javax.baja.job.BSimpleJob;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public class BRunnableJob
|
||||
extends BSimpleJob {
|
||||
public static final Type TYPE;
|
||||
private Runnable runnable;
|
||||
static /* synthetic */ Class class$javax$baja$job$BRunnableJob;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public final void run(Context context) throws Exception {
|
||||
if (this.runnable != null) {
|
||||
this.runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.runnable = null;
|
||||
}
|
||||
|
||||
public BRunnableJob(Runnable runnable) {
|
||||
this.this();
|
||||
this.runnable = runnable;
|
||||
}
|
||||
|
||||
public BRunnableJob() {
|
||||
this.this();
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$job$BRunnableJob;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$job$BRunnableJob = BRunnableJob.class("[Ljavax.baja.job.BRunnableJob;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import javax.baja.job.BJob;
|
||||
import javax.baja.job.BJobState;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.sys.Sys;
|
||||
import javax.baja.sys.Type;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public abstract class BSimpleJob
|
||||
extends BJob {
|
||||
public static final Type TYPE;
|
||||
JobThread thread;
|
||||
static /* synthetic */ Class class$javax$baja$job$BSimpleJob;
|
||||
|
||||
public Type getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
public void doRun(Context context) {
|
||||
this.thread = new JobThread(this.toPathString(), context);
|
||||
this.thread.start();
|
||||
}
|
||||
|
||||
public void doCancel(Context context) {
|
||||
if (this.getJobState().isRunning()) {
|
||||
this.setJobState(BJobState.canceling);
|
||||
if (this.thread != null) {
|
||||
this.thread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void run(Context var1) throws Exception;
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
Class clazz = class$javax$baja$job$BSimpleJob;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$job$BSimpleJob = BSimpleJob.class("[Ljavax.baja.job.BSimpleJob;", false);
|
||||
}
|
||||
TYPE = Sys.loadType(clazz);
|
||||
}
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
class JobThread
|
||||
extends Thread {
|
||||
Context cx;
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
BSimpleJob.this.run(this.cx);
|
||||
BSimpleJob.this.success();
|
||||
}
|
||||
catch (Throwable throwable) {
|
||||
BSimpleJob.this.failed(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
JobThread(String string, Context context) {
|
||||
super(string);
|
||||
this.cx = context;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import javax.baja.sys.BajaRuntimeException;
|
||||
|
||||
public class JobCancelException
|
||||
extends BajaRuntimeException {
|
||||
public JobCancelException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
public JobCancelException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
|
||||
public JobCancelException() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,238 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*
|
||||
* Could not load the following classes:
|
||||
* javax.baja.nre.util.Array
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import com.tridium.util.ThrowableUtil;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.baja.job.JobLogItem;
|
||||
import javax.baja.nre.util.Array;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.util.BFormat;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class JobLog {
|
||||
Array items;
|
||||
int limit;
|
||||
static /* synthetic */ Class class$javax$baja$job$JobLogItem;
|
||||
|
||||
public final int size() {
|
||||
return this.items.size();
|
||||
}
|
||||
|
||||
public final JobLogItem getItem(int n) {
|
||||
return (JobLogItem)this.items.get(n);
|
||||
}
|
||||
|
||||
public final JobLogItem[] getItems() {
|
||||
return (JobLogItem[])this.items.trim();
|
||||
}
|
||||
|
||||
public final void setLimit(int n) {
|
||||
this.limit = n;
|
||||
if (n > -1) {
|
||||
while (this.items.size() > n) {
|
||||
this.items.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final int getLimit() {
|
||||
return this.limit;
|
||||
}
|
||||
|
||||
public final void start(String string) {
|
||||
this.add(new JobLogItem(1, string));
|
||||
}
|
||||
|
||||
public final void start(String string, String string2, String[] stringArray) {
|
||||
this.add(new JobLogItem(1, string, string2, stringArray));
|
||||
}
|
||||
|
||||
public final void endSuccess(String string) {
|
||||
this.end(3, string, null);
|
||||
}
|
||||
|
||||
public final void endSuccess(String string, String string2, String[] stringArray) {
|
||||
this.end(3, string, string2, stringArray, null);
|
||||
}
|
||||
|
||||
public final void endSuccess() {
|
||||
this.end(3, null, null);
|
||||
}
|
||||
|
||||
public final void endFailed(String string, Throwable throwable) {
|
||||
this.end(4, string, throwable);
|
||||
}
|
||||
|
||||
public final void endFailed(String string, String string2, String[] stringArray, Throwable throwable) {
|
||||
this.end(4, string, string2, stringArray, throwable);
|
||||
}
|
||||
|
||||
public final void endFailed(Throwable throwable) {
|
||||
this.end(4, null, throwable);
|
||||
}
|
||||
|
||||
public final void endFailed(String string) {
|
||||
this.end(4, string, null);
|
||||
}
|
||||
|
||||
public final void endFailed(String string, String string2, String[] stringArray) {
|
||||
this.end(4, string, string2, stringArray, null);
|
||||
}
|
||||
|
||||
public final void end(int n, String string, Throwable throwable) {
|
||||
JobLogItem jobLogItem = (JobLogItem)this.items.last();
|
||||
if (jobLogItem == null) {
|
||||
return;
|
||||
}
|
||||
jobLogItem.id = n;
|
||||
jobLogItem.timestamp = BAbsTime.make();
|
||||
if (string != null && string.length() > 0) {
|
||||
jobLogItem.message = jobLogItem.message + "; " + string;
|
||||
}
|
||||
if (throwable != null) {
|
||||
jobLogItem.details = ThrowableUtil.dumpToString(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public final void end(int n, String string, String string2, String[] stringArray, Throwable throwable) {
|
||||
JobLogItem jobLogItem = (JobLogItem)this.items.last();
|
||||
if (jobLogItem == null) {
|
||||
return;
|
||||
}
|
||||
jobLogItem.id = n;
|
||||
jobLogItem.timestamp = BAbsTime.make();
|
||||
if (string != null && string.length() > 0) {
|
||||
String string3 = BFormat.getLexiconPattern(string, string2, stringArray);
|
||||
jobLogItem.message = jobLogItem.message + "; " + string3;
|
||||
}
|
||||
if (throwable != null) {
|
||||
jobLogItem.details = ThrowableUtil.dumpToString(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
public final void message(String string) {
|
||||
this.add(new JobLogItem(0, string));
|
||||
}
|
||||
|
||||
public final void message(String string, String string2, String[] stringArray) {
|
||||
this.add(new JobLogItem(0, string, string2, stringArray));
|
||||
}
|
||||
|
||||
public final void message(String string, String string2, String string3) {
|
||||
this.add(new JobLogItem(0, string, string2, new String[]{string3}));
|
||||
}
|
||||
|
||||
public final void message(String string, String string2) {
|
||||
this.add(new JobLogItem(0, string, string2, null));
|
||||
}
|
||||
|
||||
public final void success(String string) {
|
||||
this.add(new JobLogItem(3, string));
|
||||
}
|
||||
|
||||
public final void success(String string, String string2, String string3) {
|
||||
this.add(new JobLogItem(3, string, string2, new String[]{string3}));
|
||||
}
|
||||
|
||||
public final void success(String string, String string2) {
|
||||
this.add(new JobLogItem(3, string, string2, null));
|
||||
}
|
||||
|
||||
public final void success(String string, String string2, String[] stringArray) {
|
||||
this.add(new JobLogItem(3, string, string2, stringArray));
|
||||
}
|
||||
|
||||
public final void failed(String string) {
|
||||
this.add(new JobLogItem(4, string));
|
||||
}
|
||||
|
||||
public final void failed(String string, String string2, String[] stringArray) {
|
||||
this.add(new JobLogItem(4, string, string2, stringArray));
|
||||
}
|
||||
|
||||
public final void failed(String string, String string2, String string3) {
|
||||
this.add(new JobLogItem(4, string, string2, new String[]{string3}));
|
||||
}
|
||||
|
||||
public final void failed(String string, String string2) {
|
||||
this.add(new JobLogItem(4, string, string2, null));
|
||||
}
|
||||
|
||||
public final void failed(String string, Throwable throwable) {
|
||||
this.add(new JobLogItem(4, string, throwable));
|
||||
}
|
||||
|
||||
public final void failed(String string, String string2, String[] stringArray, Throwable throwable) {
|
||||
this.add(new JobLogItem(4, string, string2, stringArray, throwable));
|
||||
}
|
||||
|
||||
public final void failed(String string, String string2, String string3, Throwable throwable) {
|
||||
this.add(new JobLogItem(4, string, string2, new String[]{string3}, throwable));
|
||||
}
|
||||
|
||||
public final void failed(String string, String string2, Throwable throwable) {
|
||||
this.add(new JobLogItem(4, string, string2, null, throwable));
|
||||
}
|
||||
|
||||
public final void add(JobLogItem jobLogItem) {
|
||||
this.items.add((Object)jobLogItem);
|
||||
if (this.limit > -1) {
|
||||
while (this.items.size() > this.limit) {
|
||||
this.items.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final String encode() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
int n = 0;
|
||||
while (n < this.size()) {
|
||||
stringBuffer.append(this.getItem(n).encode()).append('\n');
|
||||
++n;
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public static final JobLog decode(String string) throws Exception {
|
||||
JobLog jobLog = new JobLog();
|
||||
StringTokenizer stringTokenizer = new StringTokenizer(string, "\n");
|
||||
while (stringTokenizer.hasMoreTokens()) {
|
||||
jobLog.add(JobLogItem.decode(stringTokenizer.nextToken()));
|
||||
}
|
||||
return jobLog;
|
||||
}
|
||||
|
||||
static /* synthetic */ Class class(String string, boolean bl) {
|
||||
try {
|
||||
Class<?> clazz = Class.forName(string);
|
||||
if (!bl) {
|
||||
clazz = clazz.getComponentType();
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
catch (ClassNotFoundException classNotFoundException) {
|
||||
throw new NoClassDefFoundError(classNotFoundException.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
Class clazz = class$javax$baja$job$JobLogItem;
|
||||
if (clazz == null) {
|
||||
clazz = class$javax$baja$job$JobLogItem = JobLog.class("[Ljavax.baja.job.JobLogItem;", false);
|
||||
}
|
||||
this.items = new Array(clazz);
|
||||
this.limit = -1;
|
||||
}
|
||||
|
||||
public JobLog() {
|
||||
this.this();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package javax.baja.job;
|
||||
|
||||
import com.tridium.util.ThrowableUtil;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import javax.baja.sys.BAbsTime;
|
||||
import javax.baja.sys.Context;
|
||||
import javax.baja.util.BFormat;
|
||||
import javax.baja.util.Lexicon;
|
||||
|
||||
/*
|
||||
* Illegal identifiers - consider using --renameillegalidents true
|
||||
*/
|
||||
public final class JobLogItem {
|
||||
public static final int MESSAGE = 0;
|
||||
public static final int RUNNING = 1;
|
||||
public static final int CANCELED = 2;
|
||||
public static final int SUCCESS = 3;
|
||||
public static final int FAILED = 4;
|
||||
private static final String[] IDS = new String[]{"Message", "Running", "Canceled", "Success", "Failed"};
|
||||
private DateFormat format;
|
||||
int id;
|
||||
BAbsTime timestamp;
|
||||
String message;
|
||||
String details;
|
||||
|
||||
public final int getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public final String getIdString() {
|
||||
return this.getIdString(null);
|
||||
}
|
||||
|
||||
public final String getIdStringPattern() {
|
||||
return IDS[this.id];
|
||||
}
|
||||
|
||||
public final String getIdString(Context context) {
|
||||
return Lexicon.make("baja", context).get(IDS[this.id].toLowerCase());
|
||||
}
|
||||
|
||||
public final BAbsTime getTimestamp() {
|
||||
return this.timestamp;
|
||||
}
|
||||
|
||||
public final String getMessage() {
|
||||
return this.getMessage(null);
|
||||
}
|
||||
|
||||
public final String getMessagePattern() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public final String getMessage(Context context) {
|
||||
return BFormat.format(this.message, this, context);
|
||||
}
|
||||
|
||||
public final String getDetails() {
|
||||
return this.getDetails(null);
|
||||
}
|
||||
|
||||
public final String getDetailsPattern() {
|
||||
return this.details;
|
||||
}
|
||||
|
||||
public final String getDetails(Context context) {
|
||||
if (this.details == null) {
|
||||
return null;
|
||||
}
|
||||
return BFormat.format(this.details, this, context);
|
||||
}
|
||||
|
||||
public final String toString() {
|
||||
return this.toString(null);
|
||||
}
|
||||
|
||||
public final String toString(Context context) {
|
||||
String string = this.getIdString(context) + " [" + this.format.format(new Date(this.timestamp.getMillis())) + "] " + this.getMessage(context);
|
||||
if (this.details != null) {
|
||||
string = string + '\n' + this.getDetails(context);
|
||||
}
|
||||
return string;
|
||||
}
|
||||
|
||||
public final String encode() {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
stringBuffer.append(IDS[this.id]).append('|').append(this.timestamp.encodeToString()).append('|').append(JobLogItem.escape(this.message)).append('|').append(JobLogItem.escape(this.details == null ? "" : this.details));
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
public static final JobLogItem decode(String string) throws Exception {
|
||||
String[] stringArray = JobLogItem.unescape(string);
|
||||
String string2 = stringArray[0];
|
||||
String string3 = stringArray[1];
|
||||
String string4 = stringArray[2];
|
||||
String string5 = stringArray[3];
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
while (n2 < IDS.length) {
|
||||
if (string2.equals(IDS[n2])) {
|
||||
n = n2;
|
||||
break;
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
BAbsTime bAbsTime = (BAbsTime)BAbsTime.DEFAULT.decodeFromString(string3);
|
||||
return new JobLogItem(n, bAbsTime, string4, string5);
|
||||
}
|
||||
|
||||
static final String escape(String string) {
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
int n = 0;
|
||||
while (n < string.length()) {
|
||||
char c = string.charAt(n);
|
||||
if (c == '\\') {
|
||||
stringBuffer.append("\\\\");
|
||||
} else if (c == '|') {
|
||||
stringBuffer.append("\\|");
|
||||
} else if (c == '\n') {
|
||||
stringBuffer.append("\\n");
|
||||
} else {
|
||||
stringBuffer.append(c);
|
||||
}
|
||||
++n;
|
||||
}
|
||||
return stringBuffer.toString();
|
||||
}
|
||||
|
||||
static final String[] unescape(String string) {
|
||||
String[] stringArray = new String[10];
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
int n = 0;
|
||||
int n2 = 0;
|
||||
while (n2 < string.length()) {
|
||||
char c = string.charAt(n2);
|
||||
if (c == '\\') {
|
||||
if ((c = string.charAt(++n2)) == 'n') {
|
||||
stringBuffer.append('\n');
|
||||
} else {
|
||||
stringBuffer.append(c);
|
||||
}
|
||||
} else if (c == '|') {
|
||||
stringArray[n++] = stringBuffer.toString();
|
||||
stringBuffer = new StringBuffer();
|
||||
} else {
|
||||
stringBuffer.append(c);
|
||||
}
|
||||
++n2;
|
||||
}
|
||||
stringArray[n++] = stringBuffer.toString();
|
||||
return stringArray;
|
||||
}
|
||||
|
||||
private final /* synthetic */ void this() {
|
||||
this.format = new SimpleDateFormat("HH:mm:ss dd-MMM-yy");
|
||||
}
|
||||
|
||||
public JobLogItem(int n, BAbsTime bAbsTime, String string, String string2) {
|
||||
this.this();
|
||||
if (n < 0 || n >= IDS.length || string == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (string2 != null && string2.length() == 0) {
|
||||
string2 = null;
|
||||
}
|
||||
this.id = n;
|
||||
this.timestamp = bAbsTime;
|
||||
this.message = string;
|
||||
this.details = string2;
|
||||
}
|
||||
|
||||
public JobLogItem(int n, String string, Throwable throwable) {
|
||||
this(n, BAbsTime.make(), string, ThrowableUtil.dumpToString(throwable));
|
||||
}
|
||||
|
||||
public JobLogItem(int n, String string, String string2, String[] stringArray, Throwable throwable) {
|
||||
this(n, BAbsTime.make(), BFormat.getLexiconPattern(string, string2, stringArray), ThrowableUtil.dumpToString(throwable));
|
||||
}
|
||||
|
||||
public JobLogItem(int n, String string, String string2) {
|
||||
this(n, BAbsTime.make(), string, string2);
|
||||
}
|
||||
|
||||
public JobLogItem(int n, String string, String string2, String[] stringArray, String string3) {
|
||||
this(n, BAbsTime.make(), BFormat.getLexiconPattern(string, string2, stringArray), string3);
|
||||
}
|
||||
|
||||
public JobLogItem(int n, String string) {
|
||||
this(n, BAbsTime.make(), string, null);
|
||||
}
|
||||
|
||||
public JobLogItem(int n, String string, String string2, String[] stringArray) {
|
||||
this(n, BAbsTime.make(), BFormat.getLexiconPattern(string, string2, stringArray), null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user