EJB design: Swing and EJB
How does a Java Swing application communicate with EJB's residing on WebLogic 6.0 server. In case on COM and DCom we make a MTS package which is deployed on the client machine. How can we do it with Java
ThankYou in Advance
In intranet environment Swing app can behave just like servlet, calling ejbs directly. In internet environment it can function as a web browser, routing it's calls through servlets over HTTP.
Good design would be (with a lot of security considerations) to expose ejb methods through XML (http://xml.apache.org/soap/), where both servlets and Swing apps can be clients. That way you write one backend for multiple front ends.
Usaully EJB's are connected from JSP/Beans/Servelts. How can we call an EJB from a standalone Java application running on a cleint machine. Should servelts be involved in this scenario. If so how? What about the performance issue? How do u call a servelt from a application. And where can we deploy servelts application server or the clinet machine. If its clinet machine where do we need HTTP server.
Can u give me some exapmle code
You can access EJBs from and application so long as there is no firewall between the client and the server. The client code is really no different from what you would do in a JSP or servlet. There are three things to watch for.
1) The InitialContext needs to get its connection parameters from somewhere. One way to do this is to place a jndi.properties file on the classpath. In this file you need to specify the factory class and the provider URL as hardcoded strings. This will let you use the constructor InitialContext(). The advantage of this approach is that if the URL changes (and it probably will at some point) all that needs to happen is to use a text editor to change the file.
2) The InitialContext needs to get its connection parameters from somewhere. Another way to do this is to create a Hashtable or Properties object and add settings for the factory and provider url. I personally prefer option 1 over this solution. If you do it this way you're usually hardcoding the strings.
3) The interfaces, and serializable support classes must be on the clients classpath.
If the client and server are separated by a firewall then you will need to 'HTTP tunnel' and have the Swing client talk to a servlet. To do this you need to look at opening an HTTP socket and manage the communication between client and server through the HTTP protocol.