1 19 20 import java.io.File ; 21 import java.io.FileInputStream ; 22 import java.io.FileOutputStream ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 26 import samples.j2ee.web_app_2_2.*; 28 import samples.j2ee.enhydra_service_1_0.*; 29 import samples.j2ee.ejb_jar_2_0.*; 30 31 public class TestJ2EEDTDs { 32 33 public static void main(String [] args) { 34 if (args.length != 3) { 35 System.out.println("Usage: java TestJ2EEDTDs " + 36 "<web.xml location> <enhydra-service.xml location> " + 37 "<ejb-jar.xml location>"); 38 return; 39 } 40 41 try { 42 WebAppUnmarshaller.setErrorHandler(new CommandLineErrorHandler()); 43 WebApp webApp = 44 WebAppUnmarshaller.unmarshal(new File (args[0]), false); 45 System.out.println("\n\nProcessed Web XML..."); 46 47 webApp.setDocType(null, null, null); 49 51 webApp.setOutputEncoding("ISO-8859-1"); 53 54 webApp.marshal(new File ("outputWeb.xml")); 56 } catch (Exception e) { 57 e.printStackTrace(); 58 return; 59 } 60 61 try { 62 EnhydraServiceUnmarshaller.setErrorHandler( 63 new CommandLineErrorHandler()); 64 EnhydraService enhydraService = 65 EnhydraServiceUnmarshaller.unmarshal(new File (args[1])); 66 System.out.println("\n\nProcessed Enhydra Service XML..."); 67 68 69 List services = enhydraService.getServiceList(); 70 71 for (Iterator i = services.iterator(); i.hasNext(); ) { 72 Service service = (Service)i.next(); 73 System.out.print(" Found service"); 74 if (service.getDisplayName() != null) { 75 System.out.print(" named " + 76 service.getDisplayName().getValue()); 77 } 78 System.out.println(); 79 80 ServiceDesc serviceDesc = service.getServiceDesc(); 81 if (serviceDesc != null) { 82 System.out.println(" + Service Name: " + 83 serviceDesc.getServiceName().getValue()); 84 System.out.println(" + Service Class Name: " + 85 serviceDesc.getServiceClassName().getValue()); 86 System.out.println(" + M-Bean Name: " + 87 serviceDesc.getMbeanName()); 88 89 List exportJars = serviceDesc.getExportJarList(); 90 for (Iterator j = exportJars.iterator(); j.hasNext(); ) { 91 ExportJar exportJar = (ExportJar)j.next(); 92 System.out.println(" + Exported Jar: " + 93 exportJar.getValue()); 94 } 95 } 96 } 97 98 enhydraService.marshal(new File ("outputEnhydraService.xml")); 100 } catch (Exception e) { 101 e.printStackTrace(); 102 return; 103 } 104 105 try { 106 EjbJarUnmarshaller.setErrorHandler(new CommandLineErrorHandler()); 107 EjbJar ejbJar = 108 EjbJarUnmarshaller.unmarshal(new File (args[2])); 109 System.out.println("\n\nProcessed EJB Jar XML..."); 110 111 ejbJar.marshal(new File ("outputEJBJar.xml")); 113 } catch (Exception e) { 114 e.printStackTrace(); 115 return; 116 } 117 } 118 } 119 120 121 | Popular Tags |