Upload
ziazan
View
111
Download
0
Embed Size (px)
DESCRIPTION
Integration with CORBA. Liang Tian. April 23, 2001. Outline. J2EE and CORBA. Integration. Servlet and CORBA Objects. JSP and CORBA Objects. EJB and CORBA Objects. Summary. J2EE and CORBA. J2EE and CORBA architectures both can provide developing environment for distributed applications. - PowerPoint PPT Presentation
Citation preview
Integration with CORBAIntegration with CORBA Page Page 11
Integration with CORBAIntegration with CORBA
Liang TianLiang Tian
April 23, 2001April 23, 2001
Integration with CORBAIntegration with CORBA Page Page 22
OutlineOutline
J2EE and CORBAJ2EE and CORBA
IntegrationIntegration
JSP and CORBA Objects JSP and CORBA Objects
EJB and CORBA ObjectsEJB and CORBA Objects
SummarySummary
Servlet and CORBA ObjectsServlet and CORBA Objects
Integration with CORBAIntegration with CORBA Page Page 33
J2EE and CORBAJ2EE and CORBA
J2EE and CORBA architectures both can provide developing environment for distributed applications.
Each of the two architectures can provide multi-platform support, which makes application running in heterogeneous environment possible and easier.
The implementation language is different.
Integration with CORBAIntegration with CORBA Page Page 44
J2EE and CORBAJ2EE and CORBA
J2EE: entirely in Java.
Application components benefit from “Write Once, Run Anywhere” model.
Difficult in using the existing third-party non-Java code and making components running in non-Java client environments.
Integration with CORBAIntegration with CORBA Page Page 55
J2EE and CORBAJ2EE and CORBA
CORBA: any one of supported programming languages.
APIs written in different languages.
Difficult in moving non-Java CORBA components from one platform to another.
Flexible in implementation language and portability is not very good.
Integration with CORBAIntegration with CORBA Page Page 66
J2EE and CORBAJ2EE and CORBA
Integration of J2EE and CORBA architectures.
Share the benefits and reduce the limitations.
J2EE and CORBA can work together very well.
Our objective is to show how objects in CORBA architecture can be accessed from various J2EE application components.
Integration with CORBAIntegration with CORBA Page Page 77
Set Initial Object Reference PortSet Initial Object Reference Port
WroxQuotes CORBA Object DemoWroxQuotes CORBA Object Demo
Integration with CORBAIntegration with CORBA Page Page 88
Server RunningServer Running
WroxQuotes CORBA Object DemoWroxQuotes CORBA Object Demo
Integration with CORBAIntegration with CORBA Page Page 99
WroxQuotes CORBA Object DemoWroxQuotes CORBA Object DemoClient OutputClient Output
Integration with CORBAIntegration with CORBA Page Page 1010
IntegrationIntegration
Web ContainerWeb Container
EJB ContainerEJB Container
Servlet
JSP
EJB
CORBA ServerCORBA Server
WroxQuotes
CORBAObject
Integration with CORBAIntegration with CORBA Page Page 1111
IntegrationIntegration
Creating a Java Servlet that retrieves quotes information from WroxQuotes CORBA Object.
Constructing a JavaServer Page that retrieves quotes information from WroxQuotes CORBA Object .
Constructing Enterprise JavaBean that “wrap” CORBA Object and provide information to client.
Integration with CORBAIntegration with CORBA Page Page 1212
Servlets and CORBA ObjectsServlets and CORBA Objects
HTML FormHTML Form ServletServlet CORBACORBAObjectObject
Integration with CORBAIntegration with CORBA Page Page 1313
Servlets and CORBA ObjectsServlets and CORBA Objects
Initializing ORB
Accessing Naming Services
Locating the Object
Invoking the Method on Object
Constructing resulting HTML Page
Servlet.javaServlet.java
Integration with CORBAIntegration with CORBA Page Page 1414
……. String port = getServletContext().getInitParameter("ORBInitialPort" );
String host = getServletContext().getInitParameter("ORBInitialHost" );
Properties orbProps = new Properties();
orbProps.put("org.omg.CORBA.ORBInitialPort", port);
orbProps.put("org.omg.CORBA.ORBInitialHost", host);
orb = org.omg.CORBA.ORB.init(args, orbProps); …….
Servlets and CORBA ObjectsServlets and CORBA Objects
Initializing ORBInitializing ORB
Servlet.javaServlet.java
Integration with CORBAIntegration with CORBA Page Page 1515
Servlets and CORBA ObjectsServlets and CORBA Objects
Accessing Naming Services & Locating the ObjectAccessing Naming Services & Locating the Object
org.omg.CORBA.Object contextObj = orb.resolve_initial_references("NameService");
NamingContext rootContext = NamingContextHelper.narrow (contextObj);
NameComponent name = new NameComponent("WroxQuotes", ""); NameComponent namePath[] = { name };
org.omg.CORBA.Object obj = rootContext.resolve(namePath); quoteObj = WroxStocks.WroxQuotesHelper.narrow(obj);Servlet.javaServlet.java
Integration with CORBAIntegration with CORBA Page Page 1616
Servlets and CORBA ObjectsServlets and CORBA Objects
Invoking the Method on CORBA ObjectInvoking the Method on CORBA Object
…… String symbolList = request.getParameter("Symbols");String symbols[ ] = parseSymbolList(symbolList);
try { if (quoteObj != null) { quotes = quoteObj.getQuoteList(symbols); }
response.setContentType("text/html");……
Servlet.javaServlet.java
Integration with CORBAIntegration with CORBA Page Page 1717
…… if (quotes != null) {
out.println("<td align=\"center\">" + quotes[i].symb + "</td>"); out.println("<td>" + quotes[i].volume + "</td>"); out.println("<td>" + quotes[i].bid + "</td>"); out.println("<td>" + quotes[i].ask + "</td>");
}……
Servlets and CORBA ObjectsServlets and CORBA Objects
Constructing Resulting HTML PageConstructing Resulting HTML Page
Servlet.javaServlet.java
Integration with CORBAIntegration with CORBA Page Page 1818
…… <form method=GET action="servlet/WroxQuotesServlet">
<br/><h3>WroxStocks Quote Service</h3><p>Symbol(s): <input type="TEXT" name="Symbols" size=30><p><p>Enter stock symbol or multiple symbols delimited by spaces<p><input type="SUBMIT" name="SUBMIT" value="Get"><input type="RESET" name="RESET" value="Reset">
</form>……
Servlets and CORBA ObjectsServlets and CORBA Objects
HTML FormHTML Form
Form.htmlForm.html
Integration with CORBAIntegration with CORBA Page Page 1919
java -jar orion.jar
tnameserv -ORBInitialPort 1100
java -cp %CLASSPATH% WroxQuotesServer -ORBInitialPort 1100
Servlets and CORBA Objects DemoServlets and CORBA Objects Demo
web.xml, application.xml, server.xml, default-web-site.xml
http://localhost/WroxQuotes/
Integration with CORBAIntegration with CORBA Page Page 2020
Servlets and CORBA Objects DemoServlets and CORBA Objects Demo
Integration with CORBAIntegration with CORBA Page Page 2121
Servlets and CORBA Objects DemoServlets and CORBA Objects Demo
Integration with CORBAIntegration with CORBA Page Page 2222
HTML FormHTML Form JSPJSP
JavaBeanJavaBean
CORBACORBAObjectObject
JSP and CORBA Objects JSP and CORBA Objects
Integration with CORBAIntegration with CORBA Page Page 2323
Initializing ORB
Accessing Naming Services
Locating the Object
Invoking the Method on Object
Bean.javaBean.java
JSP and CORBA Objects JSP and CORBA Objects
Integration with CORBAIntegration with CORBA Page Page 2424
JSP and CORBA Objects JSP and CORBA Objects
Resulting PageResulting Page
Quotes.jspQuotes.jsp
<%@ page import="WroxStocks.WroxQuotesPackage.Quote" errorPage="WroxQuotesError.jsp"%>
<jsp:useBean id="WroxQuotesBean" scope="application" class="WroxQuotesBean" ><% String port = application.getInitParameter("ORBInitialPort" ); String host = application.getInitParameter("ORBInitialHost" ); WroxQuotesBean.init(port, host ); %></jsp:useBean><% String symbols = request.getParameter( "Symbols" );%>
Integration with CORBAIntegration with CORBA Page Page 2525
JSP and CORBA Objects JSP and CORBA Objects
Resulting PageResulting Page
Quotes.jspQuotes.jsp
……<td align="center"> <%= quotes[i].symb %> </td>
<td> <%= quotes[i].volume %> </td>
<td> <%= quotes[i].bid %> </td>
<td> <%= quotes[i].ask %> </td>
<td align="center">04/23/2001 20:59:00</td>……
Integration with CORBAIntegration with CORBA Page Page 2626
JSP and CORBA Objects JSP and CORBA Objects
HTML FormHTML Form
Form.htmlForm.html
…… <form method=GET action="WroxQuotes.jsp">
<br/><h3>WroxStocks Quote Service</h3><p>Symbol(s): <input type="TEXT" name="Symbols" size=30><p><p>Enter stock symbol or multiple symbols delimited by spaces<p><input type="SUBMIT" name="SUBMIT" value="Get"><input type="RESET" name="RESET" value="Reset">
</form>……
Integration with CORBAIntegration with CORBA Page Page 2727
java -jar orion.jar
tnameserv -ORBInitialPort 1100
java -cp %CLASSPATH% WroxQuotesServer -ORBInitialPort 1100
web.xml, application.xml, server.xml, default-web-site.xml
http://localhost/WroxQuotes/
JSP and CORBA Objects Demo JSP and CORBA Objects Demo
Integration with CORBAIntegration with CORBA Page Page 2828
JSP and CORBA Objects Demo JSP and CORBA Objects Demo
Integration with CORBAIntegration with CORBA Page Page 2929
JSP and CORBA Objects Demo JSP and CORBA Objects Demo
Integration with CORBAIntegration with CORBA Page Page 3030
EJB and CORBA Objects EJB and CORBA Objects
ClientClientApplicationApplication
EJBEJB CORBACORBAObjectObject
Integration with CORBAIntegration with CORBA Page Page 3131
EJB and CORBA Objects EJB and CORBA Objects
…… public interface WroxQuotes extends EJBObject {
public StockQuote getQuote(String symbol) throws UnknownSymbolException, RemoteException;
public StockQuote[] getQuoteList(String[] symbols) throws UnknownSymbolException, RemoteException;
}……
Remote InterfaceRemote Interface
Quotes.javaQuotes.java
Integration with CORBAIntegration with CORBA Page Page 3232
import javax.ejb.EJBHome;
import javax.ejb.CreateException;
import java.io.Serializable;
import java.rmi.RemoteException;
public interface WroxQuotesHome extends EJBHome { WroxQuotes create() throws RemoteException, CreateException;}
EJB and CORBA Objects EJB and CORBA Objects
Home InterfaceHome Interface
QuotesHome.javaQuotesHome.java
Integration with CORBAIntegration with CORBA Page Page 3333
EJB and CORBA Objects EJB and CORBA Objects
QuotesEJB.javaQuotesEJB.java
Initializing ORB
Accessing Naming Services
Locating the Object
Invoking the Method on Object
Integration with CORBAIntegration with CORBA Page Page 3434
EJB and CORBA Objects EJB and CORBA Objects
QuotesEJB.javaQuotesEJB.java
Initializing ORBInitializing ORB
Accessing Naming Services Accessing Naming Services
Locating the ObjectLocating the Object
public class WroxQuotesEJB implements SessionBean { WroxQuotesBean quotesBean;
public WroxQuotesEJB() { …… quotesBean = new WroxQuotesBean(); quotesBean.init("1100", "localhost"); } ……
Integration with CORBAIntegration with CORBA Page Page 3535
Invoking the Method on CORBA ObjectInvoking the Method on CORBA Object
EJB and CORBA Objects EJB and CORBA Objects
QuotesEJB.javaQuotesEJB.java
…… q = quotesBean.getQuotes(symbolList);
result.symbol = q[0].symb;
result.volume = q[0].volume;
result.bid = q[0].bid;
result.ask = q[0].ask;……
Integration with CORBAIntegration with CORBA Page Page 3636
Constructing ResultConstructing Result
EJB and CORBA Objects EJB and CORBA Objects
QuotesEJB.javaQuotesEJB.java
…… for (int i = 0; i < q.length; i++) { result[i] = new StockQuote(); …… result[i].symbol = q[i].symb; result[i].volume = q[i].volume; result[i].bid = q[i].bid; result[i].ask = q[i].ask; …… cal.set(q[i].asOf.year, q[i].asOf.month, q[i].asOf.day, q[i].asOf.hour, q[i].asOf.minute, q[i].asOf.second); ……
Integration with CORBAIntegration with CORBA Page Page 3737
EJB and CORBA Objects Demo EJB and CORBA Objects Demo
java -jar orion.jar
tnameserv -ORBInitialPort 1100
java -cp %CLASSPATH% WroxQuotesServer -ORBInitialPort 1100
java -cp %CLASSPATH% WroxQuotesClient
Integration with CORBAIntegration with CORBA Page Page 3838
EJB and CORBA Objects Demo EJB and CORBA Objects Demo
Integration with CORBAIntegration with CORBA Page Page 3939
SummarySummary
Initialize ORB
Connect & Access Naming Services
Obtain Object Reference & Locating the Object
Invoke the Method on Remote Object
Basic StepsBasic Steps
Integration with CORBAIntegration with CORBA Page Page 4040
SummarySummary
“With the integration of J2EE and CORBA, we can easily build n-tier applications where Java and non-Java clients objects can seamlessly interact.”
“By combining the benefits of Java and CORBA, our n-tier application can now be both accessible to new clients and able to accommodate new distributed objects without considering their implementation languages.”
-- Professional Java Server Programming. -- Professional Java Server Programming.
J2EE Edition. p.1423J2EE Edition. p.1423
Integration with CORBAIntegration with CORBA Page Page 4141
J2EE and CORBAJ2EE and CORBA
IntegrationIntegration
JSP and CORBA Objects JSP and CORBA Objects
EJB and CORBA ObjectsEJB and CORBA Objects
SummarySummary
Servlet and CORBA ObjectsServlet and CORBA Objects
SummarySummary
Integration with CORBAIntegration with CORBA Page Page 4242
ReferenceReference
[1] Professional Java Server Programming. J2EE Edition. Chapter 29. Wrox Press. 2000.
[2] Source Code of Professional Java Server Programming. J2EE Edition. Chapter 29. Wrox Press. 2000. Available at http://www.wrox.com
Integration with CORBAIntegration with CORBA Page Page 4343
Integration with CORBAIntegration with CORBA
Liang TianLiang Tian
April 23, 2001April 23, 2001