X-Git-Url: https://xp-dev.com/git/ISBets21MAUBRY/blobdiff_plain/cbae1464e51d90bc80afc97083afd6462fd3c54f..3cf4057e97448d401b49261033b8ab566105944e:/eclipse-workspace/ISBets21MAUBRY/src/main/java/gui/ApplicationLauncher.java diff --git a/eclipse-workspace/ISBets21MAUBRY/src/main/java/gui/ApplicationLauncher.java b/eclipse-workspace/ISBets21MAUBRY/src/main/java/gui/ApplicationLauncher.java new file mode 100644 index 0000000..70a4828 --- /dev/null +++ b/eclipse-workspace/ISBets21MAUBRY/src/main/java/gui/ApplicationLauncher.java @@ -0,0 +1,83 @@ +package gui; + +import java.net.URL; +import java.util.Locale; + +import javax.swing.UIManager; +import javax.xml.namespace.QName; +import javax.xml.ws.Service; + +import businessLogic.BLFacade; +import businessLogic.BLFacadeImplementation; +import configuration.ConfigXML; +import dataAccess.DataAccess; + +public class ApplicationLauncher { + + public static void main(String[] args) { + + ConfigXML c = ConfigXML.getInstance(); + + System.out.println(c.getLocale()); + + Locale.setDefault(new Locale(c.getLocale())); + + System.out.println("Locale: " + Locale.getDefault()); + + LoginGUI a = new LoginGUI(); + a.setVisible(true); + + try { + + BLFacade appFacadeInterface; +// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel"); +// UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel"); + UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); + + if (c.isBusinessLogicLocal()) { + + // In this option the DataAccess is created by FacadeImplementationWS + // appFacadeInterface=new BLFacadeImplementation(); + + // In this option, you can parameterize the DataAccess (e.g. a Mock DataAccess + // object) + + DataAccess da = new DataAccess(c.getDataBaseOpenMode().equals("initialize")); + appFacadeInterface = new BLFacadeImplementation(da); + + } + + else { // If remote + + String serviceName = "http://" + c.getBusinessLogicNode() + ":" + c.getBusinessLogicPort() + "/ws/" + + c.getBusinessLogicName() + "?wsdl"; + + // URL url = new URL("http://localhost:9999/ws/ruralHouses?wsdl"); + URL url = new URL(serviceName); + + // 1st argument refers to wsdl document above + // 2nd argument is service name, refer to wsdl document above +// QName qname = new QName("http://businessLogic/", "FacadeImplementationWSService"); + QName qname = new QName("http://businessLogic/", "BLFacadeImplementationService"); + + Service service = Service.create(url, qname); + + appFacadeInterface = service.getPort(BLFacade.class); + } + /* + * if (c.getDataBaseOpenMode().equals("initialize")) + * appFacadeInterface.initializeBD(); + */ + LoginGUI.setBusinessLogic(appFacadeInterface); + + } catch (Exception e) { +// a.jLabelSelectOption.setText("Error: " + e.toString()); +// a.jLabelSelectOption.setForeground(Color.RED); + e.printStackTrace(); + System.out.println("Error in ApplicationLauncher: " + e.toString()); + } + // a.pack(); + + } + +}