1 20 package org.enhydra.barracuda.plankton.data; 21 22 import java.io.*; 23 import java.lang.*; 24 import java.lang.reflect.*; 25 import java.util.*; 26 import javax.servlet.*; 27 import javax.servlet.http.*; 28 29 import javax.xml.parsers.*; 30 import org.xml.sax.*; 31 import org.xml.sax.helpers.*; 32 import org.apache.log4j.*; 33 import org.apache.log4j.xml.*; 34 35 import org.enhydra.barracuda.plankton.*; 36 import org.enhydra.barracuda.plankton.xml.*; 37 38 39 151 public class ObjectRepositoryAssembler extends HttpServlet { 152 153 protected static final Logger logger = Logger.getLogger(ObjectRepositoryAssembler.class.getName()); 155 156 public static String ASSEMBLY_DESCRIPTOR = "AssemblyDescriptor"; 158 public static String SAX_PARSER = "SAXParser"; 159 public static String DEFAULT_DESCRIPTOR = "object-repository.xml"; 160 public static String DEFAULT_PARSER = "org.apache.xerces.parsers.SAXParser"; public static String LOG_HEARTBEAT_STR = "LogHeartbeat"; 162 public static String GLOBAL_CONTINUE_ON_ERR = "ContinueAssemblyOnError"; 164 private static final String OBJECT = "object"; 166 private static final String METHOD = "method"; 167 private static final String PROP = "prop"; 168 private static final String PARAM = "param"; 169 private static final String RETURN = "return"; 170 private static final String REGISTER = "register"; 171 172 private static final String NAME = "name"; 174 private static final String CLASS = "class"; 175 private static final String ARG = "arg"; 176 private static final String KEY = "key"; 177 private static final String VAL = "val"; 178 private static final String CONTINUE_ON_ERR = "continue_on_err"; 180 private static final String THIS = "$this"; 182 183 protected boolean logHeartbeat = false; 185 public static boolean globalContinueOnErr = false; 187 public static Class TEST_CLASS = Object .class; 188 public static String TEST_STRING = null; 189 public static String TEST_STRING2 = null; 190 public static String TEST_STRING3 = null; 191 public static int TEST_INT = -1; 192 public static Integer TEST_INT2 = new Integer (-1); 193 public static short TEST_SHORT = -1; 194 public static Short TEST_SHORT2 = new Short ((short)-1); 195 public static long TEST_LONG = -1; 196 public static Long TEST_LONG2 = new Long (-1); 197 public static double TEST_DOUBLE = -1; 198 public static Double TEST_DOUBLE2 = new Double (-1); 199 public static float TEST_FLOAT = -1; 200 public static Float TEST_FLOAT2 = new Float (-1); 201 public static boolean TEST_BOOLEAN = false; 202 public static Boolean TEST_BOOLEAN2 = Boolean.FALSE; 203 public static String TEST_STRING88 = null; 204 public static String TEST_STRING99 = null; 205 public static void setTestString2(String s1) {TEST_STRING2 = s1;} 206 public static void setTestString3(String s1, String s2) {TEST_STRING3 = s1+s2;} 207 208 217 public void assemble(String iassemblySourceFile) { 218 assemble(null, iassemblySourceFile); 219 } 220 221 231 public void assemble(ServletConfig iservletConfig, String iassemblySourceFile) { 232 assemble(null, iservletConfig, iassemblySourceFile); 233 } 234 235 247 public void assemble(ObjectRepository ior, ServletConfig iservletConfig, String iassemblySourceFile) { 248 assemble(ior, iservletConfig, iassemblySourceFile, null); 249 } 250 251 264 public void assemble(ObjectRepository ior, ServletConfig iservletConfig, String iassemblySourceFile, String iparserClass) { 265 if (ior==null) ior = ObjectRepository.getGlobalRepository(); 266 if (iassemblySourceFile==null) iassemblySourceFile = DEFAULT_DESCRIPTOR; 267 if (iparserClass==null) iparserClass = DEFAULT_PARSER; 268 269 270 InputStream is = null; 272 try { 273 AssemblerXMLReader assemblerXmlReader = new AssemblerXMLReader(iparserClass, ior); 275 assemblerXmlReader.setup(); 276 277 String normalizedFilePath = getNormalizedPath(iassemblySourceFile); 278 if (iservletConfig!=null) { 280 if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly file via servlet context at: /"+normalizedFilePath); 283 is = iservletConfig.getServletContext().getResourceAsStream("/" + normalizedFilePath); 284 if (is==null) { 285 if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly file via servlet context at: /WEB-INF/"+normalizedFilePath); 288 is = iservletConfig.getServletContext().getResourceAsStream("/WEB-INF/" + normalizedFilePath); 289 if (is==null) { 290 if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly file via servlet context at: /WEB-INF/classes/"+normalizedFilePath); 294 is = iservletConfig.getServletContext().getResourceAsStream("/WEB-INF/classes/" + normalizedFilePath); 295 } 296 } 297 } 298 299 if (is==null) { 301 if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly file inside the local classloader: "+normalizedFilePath); 302 is = this.getClass().getClassLoader().getResourceAsStream(normalizedFilePath); 303 if (is==null) { 304 if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly file inside all available classloaders: "+normalizedFilePath); 307 Thread.currentThread().getContextClassLoader().getResourceAsStream(normalizedFilePath); 308 } 309 } 310 311 if (is==null) { 313 if (logger.isDebugEnabled()) logger.debug("Attempting to load assembly file via file IO at: "+iassemblySourceFile); 314 File f = new File(iassemblySourceFile); 315 is = new FileInputStream(f); 316 } 317 318 if (is!=null) { 319 String logString = "Configuring "+ior.getName()+" from File: "+iassemblySourceFile; 320 if (iservletConfig != null) iservletConfig.getServletContext().log(logString); 321 if (logHeartbeat) System.out.println(logString); 322 if (logger.isDebugEnabled()) logger.debug(logString); 323 } 324 assemblerXmlReader.processXmlFile(is); 325 326 } catch (Exception e) { 327 logger.warn("Error assembling system!", e); 328 e.printStackTrace(System.err); 329 } 330 331 } 332 333 private static String getNormalizedPath(String filePath) { 335 if (filePath!=null) { 336 if (filePath.startsWith("/")) filePath = (filePath.length() > 1) ? filePath.substring(1) : ""; 337 } 338 return filePath; 339 } 340 341 public class AssemblerXMLReader extends DefaultHandler { 343 String parserClass = null; 344 ObjectRepository or = null; 345 Stack objStack = null; 346 boolean needPropVal = false; 347 String className = null; 348 String propName = null; 349 String propVal = null; 350 int depth = 0; 351 Map objMap = new HashMap(); 352 List argList = new ArrayList(); 353 String methodName = null; 354 String returnName = null; 355 int paramCntr = -1; 356 boolean localContinueOnErr = false; String skipUntilTagName = null; 359 XMLReader parser = null; 362 public AssemblerXMLReader() { 363 objMap.put(THIS, ObjectRepositoryAssembler.this); 364 } 365 366 public AssemblerXMLReader(String parserClass, ObjectRepository ior) { 367 objMap.put(THIS, ObjectRepositoryAssembler.this); 368 setParserClass(parserClass); 369 setObjectRepository(ior); 370 } 371 372 376 public void setParserClass(String iparserClass) { 377 this.parserClass = iparserClass; 378 } 379 380 384 public void setObjectRepository(ObjectRepository ior) { 385 this.or = ior; 386 } 387 388 391 public void setup() { 392 try { 393 if (parserClass==null) parserClass = DEFAULT_PARSER; 394 SAXParserFactory spf = SAXParserFactory.newInstance(); 397 logger.info("Using sax parser factory "+spf); 398 spf.setNamespaceAware(true); 399 parser = spf.newSAXParser().getXMLReader(); 400 logger.info("Using sax parser impl "+parser); 401 } catch (Exception e) { 402 logger.warn("Error assembling system!", e); 403 e.printStackTrace(System.err); 404 } 405 } 406 407 public void processXmlFile(InputStream is) { 409 try { 410 InputSource source = new InputSource(is); 412 413 logger.info("Assembling source file..."); 415 parser.setContentHandler(this); 416 parser.setErrorHandler(this); 417 parser.parse(source); 418 logger.info("Assembly complete!"); 419 420 } catch (org.xml.sax.SAXParseException spe) { 421 logger.warn("Error assembling system!", spe); 422 spe.printStackTrace(System.err); 423 } catch (org.xml.sax.SAXException se) { 424 if (se.getException() != null) { 425 logger.warn("Error assembling system!", se.getException()); 426 se.getException().printStackTrace(System.err); 427 } else { 428 logger.warn("Error assembling system!", se); 429 se.printStackTrace(System.err); 430 } 431 } catch (Exception e) { 432 logger.warn("Error assembling system!", e); 433 e.printStackTrace(System.err); 434 } 435 } 436 437 public void startDocument() { 438 objStack = new Stack(); 439 } 440 441 public void startElement(String uri, String local, String raw, Attributes attrs) throws SAXException { 442 String curTag = local; 443 logger.debug("Starting w/: " + curTag); 444 logger.debug("uri:"+uri+" local:"+local+" raw:"+raw+" attrs:"+attrs); 445 446 if (skipUntilTagName!=null) { 448 logger.warn("Skipping start tag <"+curTag+"> because of error handling <"+skipUntilTagName+">"); 449 return; 450 } 451 String continue_on_err = attrs.getValue(CONTINUE_ON_ERR); 452 localContinueOnErr = (continue_on_err!=null && 453 (continue_on_err.toLowerCase().equals("true") || 454 continue_on_err.toLowerCase().equals("yes") || 455 continue_on_err.toLowerCase().equals("1"))); 456 boolean continueOnErr = (globalContinueOnErr || localContinueOnErr); 457 459 460 if (curTag.equals(OBJECT)) { 462 463 depth++; 465 String objname = attrs.getValue(NAME); 466 String clname = attrs.getValue(CLASS); 467 Object arg = resolve(attrs.getValue(ARG)); 468 469 if (THIS.equals(objname)) { 471 clname = null; 472 arg = null; 473 474 } else { 476 if (arg!=null) argList.add(arg); 477 for (int i=0; i<10; i++) { 478 arg = resolve(attrs.getValue(ARG+i)); 479 if (arg!=null) argList.add(arg); 480 } 481 } 482 483 Class cl = null; 487 Object obj = null; 488 if (objname!=null && clname==null) obj = objMap.get(objname); 489 if (obj!=null) { 490 cl = obj.getClass(); 491 logger.info("Using existing obj "+obj.getClass().getName()+"@"+Integer.toHexString(obj.hashCode())); 492 } 493 494 if (obj==null) try { 496 if (logger.isDebugEnabled()) { 497 logger.debug("Trying to create new --> objname:"+objname+" clname:"+clname); 498 if (argList.size()>0) { 499 String s = " args:"; 500 String sep = ""; 501 for (int i=0; i<argList.size(); i++) { 502 s = s+sep+argList.get(i); 503 sep = ", "; 504 } 505 logger.debug(s); 506 } 507 } 508 509 cl = Thread.currentThread().getContextClassLoader().loadClass(clname); 516 518 if (argList.size()<1) { 519 try { 520 obj = cl.newInstance(); 521 logger.info("Instantiating "+obj.getClass().getName()); 522 523 } catch (IllegalAccessException e) { 527 obj = cl; 528 logger.info("Creating handle to class "+cl.getName()+" (for subsequent static invocation)"); 529 } 530 } else { 531 Object args[] = new Object [argList.size()]; 532 Class argcl[] = new Class [argList.size()]; 533 for (int i=0; i<argList.size(); i++) { 534 args[i] = argList.get(i); 535 argcl[i] = argList.get(i).getClass(); 536 } 537 538 if (logger.isDebugEnabled()) { 539 StringBuffer sb = new StringBuffer ("Looking for constructor "+clname+"{"); 540 String sep = ""; 541 for (int i=0; i<argList.size(); i++) { 542 sb.append(sep+argcl[i].getName()); 543 sep = ", "; 544 } 545 sb.append("}"); 546 logger.debug(sb.toString()); 547 } 548 Constructor constructor = null; 549 try { 550 constructor = cl.getConstructor(argcl); 551 } catch (Exception e) { 552 } 553 obj = constructor.newInstance(args); 554 logger.info("Instantiating "+obj.getClass().getName()+"@"+Integer.toHexString(obj.hashCode())); 555 } 556 } catch (Exception e) { 557 String msg = "Error instantiating object"; 558 logger.warn(msg+": ", e); 559 if (continueOnErr) { 560 logger.warn("Skipping tag <"+curTag+"> because of error..."); 561 skipUntilTagName = curTag; 562 return; 563 } else { 564 throw new SAXException(msg, e); 565 } 566 } 567 568 objStack.push(obj); 570 571 if (objname!=null) { 573 objMap.put(objname, obj); 574 } 575 576 } else if (curTag.equals(METHOD)) { 578 argList = new ArrayList(); methodName = attrs.getValue(NAME); 580 returnName = attrs.getValue(RETURN); 581 Object arg = resolve(attrs.getValue(ARG)); 582 if (arg!=null) argList.add(arg); 583 for (int i=0; i<10; i++) { 584 arg = resolve(attrs.getValue(ARG+i)); 585 if (arg!=null) argList.add(arg); 586 } 587 propVal = null; 588 needPropVal = true; 589 paramCntr = -1; 590 591 } else if (curTag.equals(PROP)) { 594 propName = attrs.getValue(NAME); 595 propVal = null; 596 needPropVal = true; 597 paramCntr = -1; 598 599 } else if (curTag.equals(PARAM)) { 601 if (++paramCntr==0) argList = new ArrayList(); 604 propVal = null; 605 needPropVal = true; 606 607 } else if (curTag.equals(REGISTER)) { 609 String key = attrs.getValue(KEY); 610 Object val = resolve(attrs.getValue(VAL)); 611 String qt = (val instanceof String || val instanceof StringBuffer ? "'" : ""); 612 logger.info("Registering "+key+" = "+qt+val+qt+" in the object repository"); 613 or.putState(key, val); 614 } 615 } 616 617 public void endElement(String uri, String local, String raw) throws SAXException { 618 String curTag = local; 619 620 if (skipUntilTagName!=null) { 622 if (skipUntilTagName.equals(curTag)) { 623 logger.warn("Found end of error tag <"+skipUntilTagName+">"); 624 skipUntilTagName = null; 625 } else { 626 logger.warn("Skipping end tag <"+curTag+"> because of error handling <"+skipUntilTagName+">"); 627 } 628 return; 629 } 630 boolean continueOnErr = (globalContinueOnErr || localContinueOnErr); 631 633 if (curTag.equals(OBJECT)) { 635 objStack.pop(); 637 argList = new ArrayList(); 638 depth--; 639 640 } else if (curTag.equals(PARAM)) { 642 643 } else if (curTag.equals(METHOD)) { 645 StringBuffer mthsb = new StringBuffer (methodName+"("); 646 if (argList.size()>0) { 647 String s = " args:"; 648 String sep = ""; 649 for (int i=0; i<argList.size(); i++) { 650 mthsb.append(sep+argList.get(i)); 651 sep = ", "; 652 } 653 mthsb.append(")"); 654 } 655 logger.debug("Invoking method--> "+mthsb.toString()); 656 657 Object targetObj = objStack.peek(); 659 List clList = new ArrayList(); 660 List mthList = new ArrayList(); 661 Class ocl = (targetObj instanceof Class ? (Class ) targetObj : targetObj.getClass()); 662 while (true) { 663 Method allMethods[] = ocl.getDeclaredMethods(); 664 for (int i=0; i<allMethods.length; i++) { 665 Method m = allMethods[i]; 666 if (!m.getName().equals(methodName)) continue; 667 int mod = m.getModifiers(); 668 if (!Modifier.isPublic(mod)) continue; 669 Class paramCl[] = m.getParameterTypes(); 670 if (paramCl.length!=argList.size()) continue; 671 logger.debug("found possible method:"+m+" paramCl:"+paramCl+" paramCl.length:"+paramCl.length); 672 if (paramCl!=null && paramCl.length>0 && paramCl[0]==String .class) mthList.add(0, m); else mthList.add(m); 674 clList.add(ocl); 675 } 676 if (ocl==Object .class) break; 677 ocl = ocl.getSuperclass(); 678 } 679 if (mthList.size()<1) { 680 String msg = "Unable to find matching method: "+mthsb.toString(); 681 logger.warn(msg); 682 if (continueOnErr) { 683 logger.warn("Skipping tag <"+curTag+"> because of error..."); 684 skipUntilTagName = curTag; 685 return; 686 } else { 687 throw new SAXException(msg); 688 } 689 } 690 691 boolean success = false; 694 methodsIterate: for (int i=0; i<mthList.size(); i++) { 695 Method m = (Method) mthList.get(i); 697 logger.debug("trying so see if we can invoke method "+m); 698 Class paramTypes[] = m.getParameterTypes(); 699 Object args[] = new Object [paramTypes.length]; 700 for (int j=0; j<argList.size(); j++) { 701 Object arg = argList.get(j); 702 if (arg instanceof String ) { 703 String sarg = (String ) arg; 704 Class targetParamCl = null; 705 try { 706 if (paramTypes[j]==int.class) { 708 targetParamCl = Integer .class; 709 args[j] = new Integer (sarg); 710 711 } else if (paramTypes[j]==short.class) { 713 targetParamCl = Short .class; 714 args[j] = new Short (sarg); 715 716 } else if (paramTypes[j]==long.class) { 718 targetParamCl = Long .class; 719 args[j] = new Long (sarg); 720 721 } else if (paramTypes[j]==double.class) { 723 targetParamCl = Double .class; 724 args[j] = new Double (sarg); 725 726 } else if (paramTypes[j]==float.class) { 728 targetParamCl = Float .class; 729 args[j] = new Float (sarg); 730 731 } else if (paramTypes[j]==Class .class) { 733 targetParamCl = Class .class; 734 args[j] = Classes.getClass(sarg); 735 736 } else { 738 args[j] = arg; 739 } 740 } catch (Exception e) { 741 logger.debug("error trying to cast arg"+j+" to "+paramTypes[j]+"...trying next method"); 742 } 743 } else { 744 args[j] = arg; 745 } 746 } 747 748 try { 750 logger.info("...Invoking "+targetObj.getClass().getName()+"@"+Integer.toHexString(targetObj.hashCode())+"."+mthsb.toString()); 751 Object o = m.invoke(targetObj, args); 752 if (returnName!=null) { 753 logger.debug("...Saving reference "+returnName+" to "+(o!=null ? o.getClass().getName()+"@"+Integer.toHexString(o.hashCode()) : "null")); 754 objMap.put(returnName, o); 755 } 756 success = true; 757 logger.debug("successfully invoked: "+m); 758 break; 759 } catch (Exception e) { 760 logger.debug("error invoking method m:"+e); 761 continue; 762 } 763 } 764 if (!success) { 765 String msg = "Unable to invoke method: "+mthsb.toString(); 766 logger.warn(msg); 767 if (continueOnErr) { 768 logger.warn("Skipping tag <"+curTag+"> because of error..."); 769 skipUntilTagName = curTag; 770 return; 771 } else { 772 throw new SAXException(msg); 773 } 774 } 775 776 argList = new ArrayList(); 778 779 } else if (curTag.equals(PROP)) { 782 logger.debug("Setting prop--> "+propName+"="+propVal); 783 784 Object targetObj = objStack.peek(); 786 Field fld = null; 787 Class ocl = targetObj.getClass(); 788 while (true) { 789 Field allFields[] = ocl.getDeclaredFields(); 790 for (int i=0; i<allFields.length; i++) { 791 Field f = allFields[i]; 792 if (f.getName().equals(propName) && Modifier.isPublic(f.getModifiers())) { 793 logger.debug("found property:"+f); 794 fld = f; 795 break; 796 } 797 } 798 if (ocl==Object .class) break; 799 ocl = ocl.getSuperclass(); 800 } 801 if (fld==null) { 802 String msg = "Unable to find matching property: "+propName; 803 logger.warn(msg); 804 if (continueOnErr) { 805 logger.warn("Skipping tag <"+curTag+"> because of error..."); 806 skipUntilTagName = curTag; 807 return; 808 } else { 809 throw new SAXException(msg); 810 } 811 } 812 813 try { 815 Object iprop = fld.get(targetObj); 816 Class targetClass = String .class; 819 if (iprop!=null) { 820 if (iprop instanceof Class ) targetClass = Class .class; 821 else targetClass = iprop.getClass(); 822 } 823 logger.debug("targetObj:"+targetObj+" iprop:"+iprop+" targetClass:"+targetClass); 825 Object targetProp = null; 826 if (propVal!=null) { 827 828 if (targetClass.equals(Integer .class)) { 830 targetProp = new Integer (propVal); 831 832 } else if (targetClass.equals(Short .class)) { 834 targetProp = new Short (propVal); 835 836 } else if (targetClass.equals(Long .class)) { 838 targetProp = new Long (propVal); 839 840 } else if (targetClass.equals(Double .class)) { 842 targetProp = new Double (propVal); 843 844 } else if (targetClass.equals(Float .class)) { 846 targetProp = new Float (propVal); 847 848 } else if (targetClass.equals(Class .class)) { 850 targetProp = Classes.getClass(propVal); 851 852 } else if (targetClass.equals(Boolean .class)) { 854 String tpropVal = propVal.toLowerCase().trim(); 855 targetProp = new Boolean (tpropVal.equals("true") || tpropVal.equals("yes") || tpropVal.equals("on") || tpropVal.equals("1")); 856 857 } else { 859 targetProp = new String (propVal); 860 } 861 } 862 String bracket = (propVal instanceof String ? "\"" : ""); 863 logger.info("...Setting "+fld.getDeclaringClass().getName()+"."+propName+" = "+bracket+targetProp+bracket+" ("+targetClass.getName()+")"); 864 fld.set(targetObj, targetProp); 865 866 } catch (IllegalAccessException e) { 867 String msg = "Unexpected IllegalAccessException:"+e; 868 logger.warn(msg); 869 if (continueOnErr) { 870 logger.warn("Skipping tag <"+curTag+"> because of error..."); 871 skipUntilTagName = curTag; 872 return; 873 } else { 874 throw new SAXException(msg); 875 } 876 } 877 878 argList = new ArrayList(); } 881 882 logger.debug("Finished w/: " + curTag); 883 } 884 885 public void characters(char ch[], int start, int length) { 886 if (skipUntilTagName!=null) return; 888 889 if (needPropVal) { 890 propVal = XMLUtil.fromXMLUnicodeString(new String (ch, start, length)).trim(); 894 if (propVal!=null) argList.add(propVal); 895 logger.debug("got propVal:"+propVal); 896 needPropVal = false; 897 } else { 898 } 900 } 901 902 public void ignorableWhitespace(char ch[], int start, int length) { 903 } 905 906 public void warning(SAXParseException ex) { 907 System.err.println("[Warning] " + getLocationString(ex) + ": " + ex.getMessage()); 908 } 909 910 public void error(SAXParseException ex) { 911 System.err.println("[Error] " + getLocationString(ex) + ": " + ex.getMessage()); 912 } 913 914 public void fatalError(SAXParseException ex) throws SAXException { 915 System.err.println("[Fatal Error] " + getLocationString(ex) + ": " + ex.getMessage()); 916 } 917 918 private String getLocationString(SAXParseException ex) { 919 StringBuffer str = new StringBuffer (); 920 String systemId = ex.getSystemId(); 921 if (systemId!=null) { 922 int index = systemId.lastIndexOf(47); 923 if (index!=-1) systemId = systemId.substring(index + 1); 924 str.append(systemId); 925 } 926 str.append(':'); 927 str.append(ex.getLineNumber()); 928 str.append(':'); 929 str.append(ex.getColumnNumber()); 930 return str.toString(); 931 } 932 933 protected Object resolve(Object id) { 934 if (id==null) return null; 935 if (id.equals("null")) return null; 936 if (objMap.containsKey(id)) { 937 return objMap.get(id); 938 } else { 939 return id.toString(); 940 } 941 } 942 } 943 944 945 951 public void init() throws ServletException { 952 logger.info("Attempting to setup default ObjectRepository (HTTP interface)"); 953 String descriptor = getInitParameter(ASSEMBLY_DESCRIPTOR); 954 String parser = getInitParameter(SAX_PARSER); 955 String hbparm = getInitParameter(LOG_HEARTBEAT_STR); 956 if (hbparm!=null) { 957 hbparm = hbparm.toLowerCase(); 958 logHeartbeat = (hbparm.equals("true") || hbparm.equals("yes") || 959 hbparm.equals("on") || hbparm.equals("1")); 960 } 961 String continue_on_err = getInitParameter(GLOBAL_CONTINUE_ON_ERR); 963 globalContinueOnErr = (continue_on_err!=null && 964 (continue_on_err.toLowerCase().equals("true") || 965 continue_on_err.toLowerCase().equals("yes") || 966 continue_on_err.toLowerCase().equals("1"))); 967 this.assemble(null, this, descriptor, parser); 969 } 970 971 972 public static void main(String [] args) { 973 DOMConfigurator.configure("../WEB-INF/log4j.xml"); 975 976 980 logger.info("Attempting to setup default ObjectRepository (Application interface)"); 981 new ObjectRepositoryAssembler().assemble("../WEB-INF/object-repository.xml"); 982 logger.info("Assembly complete!"); 983 984 System.out.println("TEST_STRING:"+TEST_STRING); 986 System.out.println("TEST_INT:"+TEST_INT); 987 System.out.println("TEST_SHORT:"+TEST_SHORT); 988 System.out.println("TEST_LONG:"+TEST_LONG); 989 System.out.println("TEST_DOUBLE:"+TEST_DOUBLE); 990 System.out.println("TEST_FLOAT:"+TEST_FLOAT); 991 System.out.println("TEST_BOOLEAN:"+TEST_BOOLEAN); 992 System.out.println("TEST_INT2:"+TEST_INT2); 993 System.out.println("TEST_SHORT2:"+TEST_SHORT2); 994 System.out.println("TEST_LONG2:"+TEST_LONG2); 995 System.out.println("TEST_DOUBLE2:"+TEST_DOUBLE2); 996 System.out.println("TEST_FLOAT2:"+TEST_FLOAT2); 997 System.out.println("TEST_BOOLEAN2:"+TEST_BOOLEAN2); 998 999 ObjectRepository or = ObjectRepository.getGlobalRepository(); 1001 List keys = or.getStateKeys(); 1002 if (keys!=null) { 1003 Iterator it = keys.iterator(); 1004 while (it.hasNext()) { 1005 Object key = it.next(); 1006 Object val = or.getState(key); 1007 System.out.println("Key:"+key+" Val:"+val); 1008 } 1009 } 1010 } 1011 1012} 1013 | Popular Tags |