static ReferenceType getReferenceTypeFromToken(String idToken) { ReferenceType cls = null; if (Character.isDigit(idToken.charAt(0))) { cls = null; } else if (idToken.startsWith("*.")) { // This notation saves typing by letting the user omit leading // package names. The first // loaded class whose name matches this limited regular // expression is selected. idToken = idToken.substring(1); for (ReferenceType type : Env.vm().allClasses()) { if (type.name().endsWith(idToken)) { cls = type; break; } } } else { // It's a class name List<ReferenceType> classes = Env.vm().classesByName(idToken); if (classes.size() > 0) { // TO DO: handle multiples cls = classes.get(0); } } return cls; }
synchronized VirtualMachine open() { if (connector instanceof LaunchingConnector) { vm = launchTarget(); } else if (connector instanceof AttachingConnector) { vm = attachTarget(); } else if (connector instanceof ListeningConnector) { vm = listenTarget(); } else { throw new InternalError(MessageOutput.format("Invalid connect type")); } vm.setDebugTraceMode(traceFlags); if (vm.canBeModified()) { setEventRequests(vm); resolveEventRequests(); } /* * Now that the vm connection is open, fetch the debugee * classpath and set up a default sourcepath. * (Unless user supplied a sourcepath on the command line) * (Bug ID 4186582) */ if (Env.getSourcePath().length() == 0) { if (vm instanceof PathSearchingVirtualMachine) { PathSearchingVirtualMachine psvm = (PathSearchingVirtualMachine) vm; Env.setSourcePath(psvm.classPath()); } else { Env.setSourcePath("."); } } return vm; }
static ThreadGroupReference group() { if (group == null) { // Current thread group defaults to the first top level // thread group. setThreadGroup((ThreadGroupReference) Env.vm().topLevelThreadGroups().get(0)); } return group; }
/** Constructor */ CUP$GMP2OPTParser$actions(GMP2OPTParser parser) throws IOException { this.parser = parser; // temp1 = new ParseGSCF2(Settings.defaultDirStr + temp1 = new ParseGSCF2(Env.getApplicationDataDir() + Settings.fileSeparator + "Energy_data"); // temp2 = new ParseGSCF2(Settings.defaultDirStr + temp2 = new ParseGSCF2(Env.getApplicationDataDir() + Settings.fileSeparator + "temporary2"); // temp3 = new ParseGSCF2(Settings.defaultDirStr + temp3 = new ParseGSCF2(Env.getApplicationDataDir() + Settings.fileSeparator + "temporary3"); temp1.putField("TitleText: Energy versus Iteration" + " - " + JobPanel.jobName + "\n"); temp1.putField("XLabel: Iteration\n YLabel: Energy\n"); temp1.putField("DataSet: Energy\n"); temp1.putField("1, "); temp2.putField("TitleText: Gradient versus Iteration" + " - " + JobPanel.jobName + "\n"); temp2.putField("XLabel: Iteration\n YLabel: Maximum Gradient\n"); temp2.putField("DataSet: Maximum Gradient\n"); temp3.putField("\n\n"); temp3.putField("XLabel: Iteration\n YLabel: RMS Gradient\n"); temp3.putField("DataSet: RMS Gradient\n"); }
private static void initThreads() { if (!gotInitialThreads) { Iterator iter = Env.vm().allThreads().iterator(); while (iter.hasNext()) { ThreadReference thread = (ThreadReference) iter.next(); threads.add(new ThreadInfo(thread)); } gotInitialThreads = true; } }
/** * 当前的报表运行环境切换到env * * @param env 需要切换去的环境 */ public static void switchToEnv(Env env) { if (env == null) { return; } Env oldEnv = FRContext.getCurrentEnv(); String oldEnvPath = oldEnv == null ? null : oldEnv.getPath(); // 看一下这个env在DesignerEnvManager里面有没有对应的,有的话就setCurrentEnvName DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); java.util.Iterator<String> nameIt = envManager.getEnvNameIterator(); while (nameIt.hasNext()) { String name = nameIt.next(); if (ComparatorUtils.equals(envManager.getEnv(name), env)) { envManager.setCurEnvName(name); break; } } // 更新CurrentEnv于FRContext & DesignerEnvManager FRContext.setCurrentEnv(env); final Env run_env = env; // 刷新DesignerFrame里面的面板 SwingUtilities.invokeLater( new Runnable() { public void run() { if (DesignerContext.getDesignerFrame() == null) { return; } DesignerContext.getDesignerFrame().refreshEnv(run_env); DesignerContext.getDesignerFrame().repaint(); // kunsnat: 切换环境后 刷新下 报表. 比如图表某些风格改变. } }); // 当换了运行环境,重置服务器,让它下次预览时重启 if (env instanceof LocalEnv && !ComparatorUtils.equals(env.getPath(), oldEnvPath)) { StartServer.currentEnvChanged(); } }
Message buildAddrMsg(int dest, Message msg, int msgSize) { AddressMsg addrMsg = new AddressMsg(AddressMsg.DEFAULT_MESSAGE_SIZE + msgSize); String moteid = Env.getenv("MOTEID"); int source = 0xFFFF; if (moteid != null) { source = Integer.parseInt(moteid); } addrMsg.dataSet(msg.dataGet(), 0, addrMsg.offset_data(0), msgSize); addrMsg.set_dest(dest); addrMsg.set_source(source); return addrMsg; }
/** * Constructor that specifies the source control environment. * * @param e Source control environment to use. */ public P4Process(Env e) { super(); if (null == rt) { rt = Runtime.getRuntime(); } if (null == e) { if (null == base) { base = this; this.environ = new Env(); } else { this.environ = new Env(base.getEnv()); } } else { this.environ = e; } if (null != environ) this.threshold = environ.getServerTimeout(); }
/** * Create an instantiation of a generic prototype given by parameter gt * * @param gt * @param env * @return */ private CompilationUnit createGenericPrototypeInstantiation( ExprGenericPrototypeInstantiation gt, Env env) { CompilationUnit genericProto = null; /* if ( gt.getName().equals("generic02.gb.G1<X>") ) { System.out.println("generic02.gb.G1<X>"); gt.ifPrototypeReturnsNameWithPackageAndType(env); } */ String genSourceFileName = gt.getGenericSourceFileName(); String genSourceFileNameVaryingNumberOfParameters = gt.getGenericSourceFileNameWithVaryingNumberOfParameters(); // if ( gt.getRealTypeListList().size() > 1 ) // System.out.println("3"); boolean isInterface = false; if (NameServer.isPrototypeFromInterface(genSourceFileName)) { // int sizePrefix = NameServer.prefixProtoInterface.length(); isInterface = true; /* genSourceFileName = genSourceFileName.substring(sizePrefix); genSourceFileNameVaryingNumberOfParameters = genSourceFileNameVaryingNumberOfParameters.substring(sizePrefix); */ genSourceFileName = NameServer.prototypeFileNameFromInterfaceFileName(genSourceFileName); genSourceFileNameVaryingNumberOfParameters = NameServer.prototypeFileNameFromInterfaceFileName( genSourceFileNameVaryingNumberOfParameters); } // something like util.Stack if gt is "util.Stack<Int>" or // Stack if gt is Stack<Int> ExprIdentStar typeIdent = gt.getTypeIdent(); if (typeIdent.getIdentSymbolArray().size() == 1) { // no package preceding the generic prototype name as in "Stack<Int>" ProgramUnit pu = env.searchProgramUnitBySourceFileName(genSourceFileName, gt.getFirstSymbol(), false); if (pu != null) { genericProto = pu.getCompilationUnit(); ProgramUnit pu2 = env.searchProgramUnitBySourceFileName( genSourceFileNameVaryingNumberOfParameters, gt.getFirstSymbol(), false); if (pu2 != null) /* found both generic prototype and generic prototype with varying number of parameters * Example: found both Tuple<T> and Tuple<T+> */ env.error( gt.getFirstSymbol(), "Ambiguity in creating a real prototype from a generic prototype. There is both " + pu.getCompilationUnit().getPackageName() + "." + genSourceFileName + " and " + pu2.getCompilationUnit().getPackageName() + "." + genSourceFileNameVaryingNumberOfParameters, true); } if (genericProto == null) { pu = env.searchProgramUnitBySourceFileName( genSourceFileNameVaryingNumberOfParameters, gt.getFirstSymbol(), false); if (pu != null) genericProto = pu.getCompilationUnit(); } } else { // package preceding the generic prototype name as in "util.Stack<Int>" int i = 0; ArrayList<Symbol> symbolList = typeIdent.getIdentSymbolArray(); int sizeLessOne = symbolList.size() - 1; String packageName = ""; while (i < sizeLessOne) { packageName = packageName + symbolList.get(i).getSymbolString(); ++i; if (i < sizeLessOne) packageName += "."; } CyanPackage cyanPackage = env.getProject().searchPackage(packageName); if (cyanPackage == null) { env.error(typeIdent.getFirstSymbol(), "Package '" + packageName + "' was not found", true); return null; } // first searches for something like "Stack(1)" in package 'util' for (CompilationUnit cunit : cyanPackage.getCompilationUnitList()) { if (genSourceFileName.equals(cunit.getFileNameWithoutExtension())) { genericProto = cunit; break; } } CompilationUnit genericProto2 = null; // searches for a generic prototype with varying number of parameters // something like "Stack(1+)" for (CompilationUnit cunit : cyanPackage.getCompilationUnitList()) { if (genSourceFileNameVaryingNumberOfParameters.equals( cunit.getFileNameWithoutExtension())) { genericProto2 = cunit; break; } } if (genericProto != null && genericProto2 != null) { env.error( gt.getFirstSymbol(), "Ambiguity in creating a real prototype from a generic prototype. There is both " + genericProto.getPackageName() + "." + genSourceFileName + " and " + genericProto2.getPackageName() + "." + genSourceFileNameVaryingNumberOfParameters, true); } if (genericProto == null) genericProto = genericProto2; } // genericProto = nameGenProtoUnitTable.get(genSourceFileName); if (genericProto == null) { env.error( true, gt.getFirstSymbol(), "Prototype '" + gt.getName() + "' was not found", gt.getName(), ErrorKind.prototype_was_not_found_inside_method); /*gt.getProgramUnit().getCompilationUnit().error(null, "Internal error at CompilerManager::createInterfaceObjectFunctionAndArray: cannot create " + gt.getName()); */ return null; } else { /** * if there was no compilation error in "Stack(1).cyan", then create an instance of the * generic prototype */ if (isInterface) { gt.removeProtoPrefix(); } CompilationUnit newCompilationUnit = genericProto.createInstanceGenericPrototype(gt, env); CompilationUnit interCompilationUnit = null; /** * if the package for this generic prototype instantiation was not created before, create it * now. */ CyanPackage cyanPackage = genericProto.getCyanPackage(); cyanPackage.addCompilationUnit(newCompilationUnit); newCompilationUnit.setCyanPackage(cyanPackage); nonGenericCompilationUnitList.add(newCompilationUnit); if (nameSet.contains(newCompilationUnit.getFullFileNamePath())) { env.error(gt.getFirstSymbol(), "Internal error in CompilerManager"); gt.ifPrototypeReturnsNameWithPackageAndType(env); } else nameSet.add(newCompilationUnit.getFullFileNamePath()); program.addCompilationUnit(newCompilationUnit); newCompilationUnit.readSourceFile(); HashSet<saci.CompilationInstruction> compInstSet = new HashSet<>(); compInstSet.add(CompilationInstruction.dpa_actions); compInstSet.add(CompilationInstruction.pp_addCode); if (compilationStep.compareTo(CompilationStep.step_5) >= 0) compInstSet.add(CompilationInstruction.new_addCode); Compiler compiler = new Compiler(newCompilationUnit, compInstSet, compilationStep, project, null); compiler.parse(); if (newCompilationUnit.hasCompilationError()) { // newCompilationUnit.printErrorList(printWriter); env.setThereWasError(true); throw new CompileErrorException(); } else if (compInstSet.contains(CompilationInstruction.createPrototypesForInterfaces) && newCompilationUnit.getPrototypeIsNotGeneric() && newCompilationUnit.getPublicPrototype() instanceof InterfaceDec) { // if public program unit is an interface, create ProtoInterface interCompilationUnit = newCompilationUnit.createProtoInterface(); if (interCompilationUnit != null) { interCompilationUnit.setCyanPackage(cyanPackage); cyanPackage.addCompilationUnit(interCompilationUnit); newCompilationUnit.setCyanPackage(cyanPackage); nonGenericCompilationUnitList.add(interCompilationUnit); String nameInter = interCompilationUnit.getFilename(); if (nameInter.endsWith(NameServer.dotCyanSourceFileExtension)) nameInter = nameInter.substring( 0, nameInter.length() - NameServer.sizeCyanSourceFileExtensionPlusOne); // nameRealGenProtoUnitTable.put(nameInter, interCompilationUnit); program.addCompilationUnit(interCompilationUnit); interCompilationUnit.readSourceFile(); compiler = new Compiler(interCompilationUnit, compInstSet, compilationStep, project, null); compiler.parse(); if (interCompilationUnit.getActionList().size() > 0) interCompilationUnit.doActionList(printWriter); interCompilationUnit.clearErrorsActions(); } } // newCompilationUnit.clearErrorsActions(); if (isInterface) return interCompilationUnit; else return newCompilationUnit; } }
/** * Create a generic prototype from parameter gpi. The new prototype is compiled. If it is an * interface, the prototype Proto_IntefaceName is created too. Methods calcInterfaceTypes and * calcInternalTypes are called for both the prototype and its Proto_InterfaceName, if any. * * @param gpi * @param env * @return */ public static ProgramUnit createGenericPrototype(ExprGenericPrototypeInstantiation gpi, Env env) { saci.Tuple<String, Type> t = gpi.ifPrototypeReturnsNameWithPackageAndType(env); // t.f1 is the name of the prototype if (t != null && t.f2 != null) { /* * prototype has already been created before */ if (t.f2 instanceof ProgramUnit) { return (ProgramUnit) t.f2; } else { env.error( gpi.getFirstSymbol(), "Internal error: a type that is not a program unit is used to instantiate a generic prototype"); return null; } } else { /* * prototype has not been created. Create it. */ // if ( env.getCurrentMethod() != null && env.getCurrentMethod().getName().contains("run2") ) // gpi.ifPrototypeReturnsItsNameWithPackage(env); /* * first, create all prototypes that are real parameters to this generic prototype instantiation */ for (ArrayList<Expr> realTypeList : gpi.getRealTypeListList()) { for (Expr realType : realTypeList) { if (realType instanceof ExprGenericPrototypeInstantiation) { ExprGenericPrototypeInstantiation genRealType = (ExprGenericPrototypeInstantiation) realType; genRealType.setType(createGenericPrototype(genRealType, env)); // javaName = type.getJavaName(); genRealType.setJavaName(genRealType.getType().getJavaName()); } } } CompilationUnit compUnit = env.getProject().getCompilerManager().createGenericPrototypeInstantiation(gpi, env); Env newEnv = new Env(env.getProject()); /* * If a generic prototype is created when method calcInterfaceTypes of Program is being executed * (env.getProject().getProgram().getInCalcInterfaceTypes() returns true), it is not necessary * to call its method calcInterfaceTypes. It will be called in the loop of * method Program::calcInterfaceTypes. * If a generic prototype is created when method calcInternalTypes of Program is being executed, * method calcInterfaceTypes of this generic prototype should be called because the interface * of this prototype is necessary in methods calcInternalTypes. Method calcInternalTypes * of this newly created generic prototype will be called in the loop of * method Program::calcInternalTypes. * * calcInternalTypes cannot be called when a generic prototype is created when * the compiler is calling calcInterfaceTypes. If this is allowed, some calcInternalType * method could try to use the interface of some prototype P whose method calcInterfaceTypes * have not been called. */ if (!env.getProject().getProgram().getInCalcInterfaceTypes()) { compUnit.calcInterfaceTypes(newEnv); // compUnit.calcInternalTypes(newEnv); } CompilationUnit interfaceCompilationUnit = compUnit.getInterfaceCompilationUnit(); if (interfaceCompilationUnit != null) { newEnv = new Env(env.getProject()); if (!env.getProject().getProgram().getInCalcInterfaceTypes()) { interfaceCompilationUnit.calcInterfaceTypes(newEnv); } } /* * if the generic prototype was created from phase (4), included, onwards, then execute * the ati actions. A generic prototype instantiation can only change itself and * no other prototype can change it. */ if (env.getProject().getCompilerManager().getCompilationStep().ordinal() > CompilationStep.step_3.ordinal()) { apply_ati_ActionsToGenericPrototype(newEnv, compUnit); if (interfaceCompilationUnit != null) { apply_ati_ActionsToGenericPrototype(env, interfaceCompilationUnit); } } return compUnit.getPublicPrototype(); } }
/** * Test / Load * * @param args */ public static void main(String[] args) { Compiere.startup(true); /** * To add your regions, complete the code below. Please make sure that the file is converted via * the Java utility native2ascii - i.e. all seven bit code with /u0000 unicode stuff */ int C_Country_ID = 216; // Japan MCountry country = new MCountry(Env.getCtx(), C_Country_ID, null); // Hokkaido MRegion temp = new MRegion(country, "\u5317\u6d77\u9053"); temp.setDescription("\u5317\u6d77\u9053(Hokkaido)"); temp.save(); // Aomori temp = new MRegion(country, "\u9752\u68ee\u770c"); temp.setDescription("\u9752\u68ee\u770c(Aomori)"); temp.save(); // Iwate temp = new MRegion(country, "\u5ca9\u624b\u770c"); temp.setDescription("\u5ca9\u624b\u770c(Iwate)"); temp.save(); // Miyagi temp = new MRegion(country, "\u5bae\u57ce\u770c"); temp.setDescription("\u5bae\u57ce\u770c(Miyagi)"); temp.save(); // Akita temp = new MRegion(country, "\u79cb\u7530\u770c"); temp.setDescription("\u79cb\u7530\u770c(Akita)"); temp.save(); // Yamagata temp = new MRegion(country, "\u5c71\u5f62\u770c"); temp.setDescription("\u5c71\u5f62\u770c(Yamagata)"); temp.save(); // Fukushima temp = new MRegion(country, "\u798f\u5cf6\u770c"); temp.setDescription("\u798f\u5cf6\u770c(Fukushima)"); temp.save(); // Ibaraki temp = new MRegion(country, "\u8328\u57ce\u770c"); temp.setDescription("\u8328\u57ce\u770c(Ibaraki)"); temp.save(); // Gunma temp = new MRegion(country, "\u7fa4\u99ac\u770c"); temp.setDescription("\u7fa4\u99ac\u770c(Gunma)"); temp.save(); // Saitama temp = new MRegion(country, "\u57fc\u7389\u770c"); temp.setDescription("\u57fc\u7389\u770c(Saitama)"); temp.save(); // Chiba temp = new MRegion(country, "\u5343\u8449\u770c"); temp.setDescription("\u5343\u8449\u770c(Chiba)"); temp.save(); // Tokyo temp = new MRegion(country, "\u6771\u4eac\u90fd"); temp.setDescription("\u6771\u4eac\u90fd(Tokyo)"); temp.save(); // Kanagawa temp = new MRegion(country, "\u795e\u5948\u5ddd\u770c"); temp.setDescription("\u795e\u5948\u5ddd\u770c(Kanagawa)"); temp.save(); // Niigata temp = new MRegion(country, "\u65b0\u6f5f\u770c"); temp.setDescription("\u65b0\u6f5f\u770c(Niigata)"); temp.save(); // Toyama temp = new MRegion(country, "\u5bcc\u5c71\u770c"); temp.setDescription("\u5bcc\u5c71\u770c(Toyama)"); temp.save(); // Ishikawa temp = new MRegion(country, "\u77f3\u5ddd\u770c"); temp.setDescription("\u77f3\u5ddd\u770c(Ishikawa)"); temp.save(); // Fukui temp = new MRegion(country, "\u798f\u4e95\u770c"); temp.setDescription("\u798f\u4e95\u770c(Fukui)"); temp.save(); // Yamanashi temp = new MRegion(country, "\u5c71\u68a8\u770c"); temp.setDescription("\u5c71\u68a8\u770c(Yamanashi)"); temp.save(); // Gifu temp = new MRegion(country, "\u5c90\u961c\u770c"); temp.setDescription("\u5c90\u961c\u770c(Gifu)"); temp.save(); // Shizuoka temp = new MRegion(country, "\u9759\u5ca1\u770c"); temp.setDescription("\u9759\u5ca1\u770c(Shizuoka)"); temp.save(); // Aichi temp = new MRegion(country, "\u611b\u77e5\u770c"); temp.setDescription("\u611b\u77e5\u770c(Aichi)"); temp.save(); // Mie temp = new MRegion(country, "\u4e09\u91cd\u770c"); temp.setDescription("\u4e09\u91cd\u770c(Mie)"); temp.save(); // Siga temp = new MRegion(country, "\u6ecb\u8cc0\u770c"); temp.setDescription("\u6ecb\u8cc0\u770c(Siga)"); temp.save(); // Kyoto temp = new MRegion(country, "\u4eac\u90fd\u5e9c"); temp.setDescription("\u4eac\u90fd\u5e9c(Kyoto)"); temp.save(); // Osaka temp = new MRegion(country, "\u5927\u962a\u5e9c"); temp.setDescription("\u5927\u962a\u5e9c(Osaka)"); temp.save(); // Hyogo temp = new MRegion(country, "\u5175\u5eab\u770c"); temp.setDescription("\u5175\u5eab\u770c(Hyogo)"); temp.save(); // Nara temp = new MRegion(country, "\u5948\u826f\u770c"); temp.setDescription("\u5948\u826f\u770c(Nara)"); temp.save(); // Wakayama temp = new MRegion(country, "\u548c\u6b4c\u5c71\u770c"); temp.setDescription("\u548c\u6b4c\u5c71\u770c(Wakayama)"); temp.save(); // Tottori temp = new MRegion(country, "\u9ce5\u53d6\u770c"); temp.setDescription("\u9ce5\u53d6\u770c(Tottori)"); temp.save(); // Shimane temp = new MRegion(country, "\u5cf6\u6839\u770c"); temp.setDescription("\u5cf6\u6839\u770c(Shimane)"); temp.save(); // Okayama temp = new MRegion(country, "\u5ca1\u5c71\u770c"); temp.setDescription("\u5ca1\u5c71\u770c(Okayama)"); temp.save(); // Hiroshima temp = new MRegion(country, "\u5e83\u5cf6\u770c"); temp.setDescription("\u5e83\u5cf6\u770c(Hiroshima)"); temp.save(); // Yamaguchi temp = new MRegion(country, "\u5c71\u53e3\u770c"); temp.setDescription("\u5c71\u53e3\u770c(Yamaguchi)"); temp.save(); // Tokushima temp = new MRegion(country, "\u5fb3\u5cf6\u770c"); temp.setDescription("\u5fb3\u5cf6\u770c(Tokushima)"); temp.save(); // Kagawa temp = new MRegion(country, "\u9999\u5ddd\u770c"); temp.setDescription("\u9999\u5ddd\u770c(Kagawa)"); temp.save(); // Ehime temp = new MRegion(country, "\u611b\u5a9b\u770c"); temp.setDescription("\u611b\u5a9b\u770c(Ehime)"); temp.save(); // Kouchi temp = new MRegion(country, "\u9ad8\u77e5\u770c"); temp.setDescription("\u9ad8\u77e5\u770c(Kouchi)"); temp.save(); // Fukuoka temp = new MRegion(country, "\u798f\u5ca1\u770c"); temp.setDescription("\u798f\u5ca1\u770c(Fukuoka)"); temp.save(); // Saga temp = new MRegion(country, "\u4f50\u8cc0\u770c"); temp.setDescription("\u4f50\u8cc0\u770c(Saga)"); temp.save(); // Nagasaki temp = new MRegion(country, "\u9577\u5d0e\u770c"); temp.setDescription("\u9577\u5d0e\u770c(Nagasaki)"); temp.save(); // Kumamoto temp = new MRegion(country, "\u718a\u672c\u770c"); temp.setDescription("\u718a\u672c\u770c(Kumamoto)"); temp.save(); // Ohita temp = new MRegion(country, "\u5927\u5206\u770c"); temp.setDescription("\u5927\u5206\u770c(Ohita)"); temp.save(); // Miyasaki temp = new MRegion(country, "\u5bae\u5d0e\u770c"); temp.setDescription("\u5bae\u5d0e\u770c(Miyasaki)"); temp.save(); // Kagoshima temp = new MRegion(country, "\u9e7f\u5150\u5cf6\u770c"); temp.setDescription("\u9e7f\u5150\u5cf6\u770c(Kagoshima)"); temp.save(); // Okinawa temp = new MRegion(country, "\u6c96\u7e04\u770c"); temp.setDescription("\u6c96\u7e04\u770c(Okinawa)"); temp.save(); } // main
/** * Sets the environment to use. * * @param e Source control environment. */ public void setEnv(Env e) { this.environ = e; if (null != environ) this.threshold = environ.getServerTimeout(); }
public static void main(String argv[]) throws MissingResourceException { redirectOutMessage(); String cmdLine = ""; String javaArgs = ""; int traceFlags = VirtualMachine.TRACE_NONE; boolean launchImmediately = false; String connectSpec = null; MessageOutput.textResources = ResourceBundle.getBundle( "com.sun.tools.example.debug.tty.TTYResources", Locale.getDefault()); for (int i = 0; i < argv.length; i++) { String token = argv[i]; if (token.equals("-dbgtrace")) { if ((i == argv.length - 1) || !Character.isDigit(argv[i + 1].charAt(0))) { traceFlags = VirtualMachine.TRACE_ALL; } else { String flagStr = ""; try { flagStr = argv[++i]; traceFlags = Integer.decode(flagStr).intValue(); } catch (NumberFormatException nfe) { usageError("dbgtrace flag value must be an integer:", flagStr); return; } } } else if (token.equals("-X")) { usageError("Use java minus X to see"); return; } else if ( // Standard VM options passed on token.equals("-v") || token.startsWith("-v:") || // -v[:...] token.startsWith("-verbose") || // -verbose[:...] token.startsWith("-D") || // -classpath handled below // NonStandard options passed on token.startsWith("-X") || // Old-style options (These should remain in place as long as // the standard VM accepts them) token.equals("-noasyncgc") || token.equals("-prof") || token.equals("-verify") || token.equals("-noverify") || token.equals("-verifyremote") || token.equals("-verbosegc") || token.startsWith("-ms") || token.startsWith("-mx") || token.startsWith("-ss") || token.startsWith("-oss")) { javaArgs = addArgument(javaArgs, token); } else if (token.equals("-tclassic")) { usageError("Classic VM no longer supported."); return; } else if (token.equals("-tclient")) { // -client must be the first one javaArgs = "-client " + javaArgs; } else if (token.equals("-tserver")) { // -server must be the first one javaArgs = "-server " + javaArgs; } else if (token.equals("-sourcepath")) { if (i == (argv.length - 1)) { usageError("No sourcepath specified."); return; } Env.setSourcePath(argv[++i]); } else if (token.equals("-classpath")) { if (i == (argv.length - 1)) { usageError("No classpath specified."); return; } javaArgs = addArgument(javaArgs, token); javaArgs = addArgument(javaArgs, argv[++i]); } else if (token.equals("-attach")) { if (connectSpec != null) { usageError("cannot redefine existing connection", token); return; } if (i == (argv.length - 1)) { usageError("No attach address specified."); return; } String address = argv[++i]; /* * -attach is shorthand for one of the reference implementation's * attaching connectors. Use the shared memory attach if it's * available; otherwise, use sockets. Build a connect * specification string based on this decision. */ if (supportsSharedMemory()) { connectSpec = "com.sun.jdi.SharedMemoryAttach:name=" + address; } else { String suboptions = addressToSocketArgs(address); connectSpec = "com.sun.jdi.SocketAttach:" + suboptions; } } else if (token.equals("-listen") || token.equals("-listenany")) { if (connectSpec != null) { usageError("cannot redefine existing connection", token); return; } String address = null; if (token.equals("-listen")) { if (i == (argv.length - 1)) { usageError("No attach address specified."); return; } address = argv[++i]; } /* * -listen[any] is shorthand for one of the reference implementation's * listening connectors. Use the shared memory listen if it's * available; otherwise, use sockets. Build a connect * specification string based on this decision. */ if (supportsSharedMemory()) { connectSpec = "com.sun.jdi.SharedMemoryListen:"; if (address != null) { connectSpec += ("name=" + address); } } else { connectSpec = "com.sun.jdi.SocketListen:"; if (address != null) { connectSpec += addressToSocketArgs(address); } } } else if (token.equals("-launch")) { launchImmediately = true; } else if (token.equals("-listconnectors")) { Commands evaluator = new Commands(); evaluator.commandConnectors(Bootstrap.virtualMachineManager()); return; } else if (token.equals("-connect")) { /* * -connect allows the user to pick the connector * used in bringing up the target VM. This allows * use of connectors other than those in the reference * implementation. */ if (connectSpec != null) { usageError("cannot redefine existing connection", token); return; } if (i == (argv.length - 1)) { usageError("No connect specification."); return; } connectSpec = argv[++i]; } else if (token.equals("-help")) { usage(); } else if (token.equals("-version")) { Commands evaluator = new Commands(); evaluator.commandVersion(progname, Bootstrap.virtualMachineManager()); System.exit(0); } else if (token.startsWith("-")) { usageError("invalid option", token); return; } else { // Everything from here is part of the command line cmdLine = addArgument("", token); for (i++; i < argv.length; i++) { cmdLine = addArgument(cmdLine, argv[i]); } break; } } /* * Unless otherwise specified, set the default connect spec. */ /* * Here are examples of jdb command lines and how the options * are interpreted as arguments to the program being debugged. * arg1 arg2 * ---- ---- * jdb hello a b a b * jdb hello "a b" a b * jdb hello a,b a,b * jdb hello a, b a, b * jdb hello "a, b" a, b * jdb -connect "com.sun.jdi.CommandLineLaunch:main=hello a,b" illegal * jdb -connect com.sun.jdi.CommandLineLaunch:main=hello "a,b" illegal * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a,b"' arg1 = a,b * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a b"' arg1 = a b * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello a b' arg1 = a arg2 = b * jdb -connect 'com.sun.jdi.CommandLineLaunch:main=hello "a," b' arg1 = a, arg2 = b */ if (connectSpec == null) { connectSpec = "com.sun.jdi.CommandLineLaunch:"; } else if (!connectSpec.endsWith(",") && !connectSpec.endsWith(":")) { connectSpec += ","; // (Bug ID 4285874) } cmdLine = cmdLine.trim(); javaArgs = javaArgs.trim(); if (cmdLine.length() > 0) { if (!connectSpec.startsWith("com.sun.jdi.CommandLineLaunch:")) { usageError("Cannot specify command line with connector:", connectSpec); return; } connectSpec += "main=" + cmdLine + ","; } if (javaArgs.length() > 0) { if (!connectSpec.startsWith("com.sun.jdi.CommandLineLaunch:")) { usageError("Cannot specify target vm arguments with connector:", connectSpec); return; } connectSpec += "options=" + javaArgs + ","; } try { if (!connectSpec.endsWith(",")) { connectSpec += ","; // (Bug ID 4285874) } Env.init(connectSpec, launchImmediately, traceFlags); new ThreadDumper(); } catch (Exception e) { MessageOutput.printException("Internal exception:", e); } }
/** * Execute Process Instance and Lock UI. Calls lockUI and unlockUI if parent is a ASyncProcess * * <pre> * - Get Process Information * - Call Class * - Submit SQL Procedure * - Run SQL Procedure * </pre> */ public void run() { log.fine("AD_PInstance_ID=" + m_pi.getAD_PInstance_ID() + ", Record_ID=" + m_pi.getRecord_ID()); // Lock // lock(); // try {System.out.println(">> sleeping ..");sleep(20000);System.out.println(".. sleeping <<");} // catch (Exception e) {} // Get Process Information: Name, Procedure Name, ClassName, IsReport, IsDirectPrint String ProcedureName = ""; int AD_ReportView_ID = 0; int AD_Workflow_ID = 0; boolean IsReport = false; boolean IsDirectPrint = false; // String sql = "SELECT p.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE," + " p.IsServerProcess " + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + "WHERE p.IsActive='Y'" + " AND i.AD_PInstance_ID=?"; if (!Env.isBaseLanguage(m_wscctx, "AD_Process")) sql = "SELECT t.Name, p.ProcedureName,p.ClassName, p.AD_Process_ID," // 1..4 + " p.isReport, p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID," // 5..8 + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END CASE," + " p.IsServerProcess " + "FROM AD_Process p" + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) " + " INNER JOIN AD_Process_Trl t ON (p.AD_Process_ID=t.AD_Process_ID" + " AND t.AD_Language='" + Env.getAD_Language(m_wscctx) + "') " + "WHERE p.IsActive='Y'" + " AND i.AD_PInstance_ID=?"; // try { PreparedStatement pstmt = DB.prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, null); pstmt.setInt(1, m_pi.getAD_PInstance_ID()); ResultSet rs = pstmt.executeQuery(); if (rs.next()) { m_pi.setTitle(rs.getString(1)); if (m_waiting != null) m_waiting.setTitle(m_pi.getTitle()); ProcedureName = rs.getString(2); m_pi.setClassName(rs.getString(3)); m_pi.setAD_Process_ID(rs.getInt(4)); // Report if ("Y".equals(rs.getString(5))) { IsReport = true; if ("Y".equals(rs.getString(6)) && !Ini.isPropertyBool(Ini.P_PRINTPREVIEW)) IsDirectPrint = true; } AD_ReportView_ID = rs.getInt(7); AD_Workflow_ID = rs.getInt(8); // int estimate = rs.getInt(9); if (estimate != 0) { m_pi.setEstSeconds(estimate + 1); // admin overhead if (m_waiting != null) m_waiting.setTimerEstimate(m_pi.getEstSeconds()); } m_IsServerProcess = "Y".equals(rs.getString(10)); } else log.log(Level.SEVERE, "No AD_PInstance_ID=" + m_pi.getAD_PInstance_ID()); rs.close(); pstmt.close(); } catch (SQLException e) { m_pi.setSummary( Msg.getMsg(m_wscctx, "ProcessNoProcedure") + " " + e.getLocalizedMessage(), true); // unlock(); log.log(Level.SEVERE, "run", e); return; } // No PL/SQL Procedure if (ProcedureName == null) ProcedureName = ""; /** ******************************************************************** Workflow */ if (AD_Workflow_ID > 0) { startWorkflow(AD_Workflow_ID); // unlock(); return; } /** ******************************************************************** Start Optional Class */ if (m_pi.getClassName() != null) { // Run Class if (!startProcess()) { // unlock(); return; } // No Optional SQL procedure ... done if (!IsReport && ProcedureName.length() == 0) { // unlock (); return; } // No Optional Report ... done if (IsReport && AD_ReportView_ID == 0) { // unlock (); return; } } // If not a report, we need a prodedure name if (!IsReport && ProcedureName.length() == 0) { m_pi.setSummary(Msg.getMsg(m_wscctx, "ProcessNoProcedure"), true); // unlock(); return; } /** ******************************************************************** Report submission */ if (IsReport) { // Optional Pre-Report Process if (ProcedureName.length() > 0) { if (!startDBProcess(ProcedureName)) { // unlock(); return; } } // Pre-Report // Start Report ----------------------------------------------- boolean ok = ReportCtl.start(m_pi, IsDirectPrint); m_pi.setSummary("Report", !ok); // unlock (); } /** ******************************************************************** Process submission */ else { if (!startDBProcess(ProcedureName)) { // unlock(); return; } // Success - getResult ProcessInfoUtil.setSummaryFromDB(m_pi); // unlock(); } // *** Process submission *** // log.fine(Log.l3_Util, "ProcessCtl.run - done"); } // run