Sie sind auf Seite 1von 39

LIST OF EXPERIMENTS

COM COMPONENT: Development of simple com components in VB and use them in applications. [2 example]. Creation Of DLL Using VB And Deploy it in Java [2 Experiments] RMI: Deploying RMI for client server applications. [2 Experiments]. ENTERPRISE JAVA BEANS: Deploying EJB for simple arithmetic operator. SIMPLE APPLICATION USING CORBA. Naming Services In CORBA INTER ORB IN COMMUNICATION [IIOP, IOR] Jac ORB & Visi broker ORB STUDYING J2EE SERVER.

Ex.No : 1 COM COMPONENT Program :1a Aim : To create simple com component to display Date and Time using Active-X control option in VB and use them in VB application. Algorithm: 1. 2. 3. 4. 5. 6. 7. 8. 9. Start the program Open a new Active-X control project. Design the program and write the codings. Make project as .OCX file Open a new standard EXE project Select components from project menu Selecting the required project , the Active-X components created will be placed in the tool box Place the component on the program and execute it End the program

FormDesign : DateProject.vbp Control UserControl Label Property Name Name Caption Setting DateCtrl Datelbl -

Project properties -> Project Name : Date Control File -> Make DateProject.ocx TimeProject.vbp Control UserControl Label Property Name Name Caption Setting TimeCtrl Timelbl -

Project properties -> Project Name : Time Control File -> Make TimeProject.ocx

Coding : DateProject.vbp Private Sub Timer1_Timer() Datelbl.Caption = Format("dd/mm/yyyy") End Sub Private Sub UserControl_Initialize() Datelbl.Caption = Format("dd/mm/yyyy") End Sub TimeProject.vbp Private Sub Timer1_Timer() Timelbl.Caption = Format("HH:MM:SS") End Sub Private Sub UserControl_Initialize() Timelbl.Caption = Format("HH:MM:SS") End Sub Output

Ex.No : 1 COM COMPONENT Program :1b Aim : To create simple calculator component in VB and use them in another VB application. Algorithm: 1. 2. 3. 4. 5. 6. 7. 8. 9. Start the program Open a new Active-X control project. Design the program and write the codings Make project as .OCX file Open a new standard EXE project Select components from project menu Selecting the required project , the Active-X components created will be placed in the tool box Place the component on the program and execute it End the program

Form Design : Step 1 : Create a control array with index ranging from 0-9 to represent the numerical numbers from 0-9 and also change its caption to its numbers. Step 2 : Create control array to represent the mathematical operations + , - , * , / Step 3 : Also create buttons to perform the operations like M+,M-,MC,MA,SIN,COS, TAN,SQRT, = , CE , EXP . Step 4 : Write the coding to design a calculator. Name Command1(0) Caption Command1(1) Caption Setting 0 1

Program Dim num As Double Dim symb As String Dim flag As Boolean Dim mem As Double Private Sub Command1_Click(Index As Integer) If Text1.Text = "0" Then Text1.Text = "0" End If Text1.Text = Text1.Text + Command1(Index).Caption End Sub Private Sub Command10_Click() mem = mem + Text1.Text End Sub Private Sub Command11_Click() mem = 0 End Sub Private Sub Command12_Click() Text1.Text = mem End Sub Private Sub Command13_Click() Unload Me End Sub Private Sub Command14_Click() Text1.Text = Sin(Val(Text1.Text)) End Sub Private Sub Command15_Click() Text1.Text = Cos(Val(Text1.Text)) End Sub Private Sub Command16_Click() Text1.Text = Tan(Val(Text1.Text)) End Sub Private Sub Command2_Click() Text1.Text = Text1.Text + Command2.Caption End Sub

Private Sub Command4_Click(Index As Integer) symb = Command4(Index).Caption num = Val(Text1.Text) Text1.Text = "" End Sub Private Sub Command5_Click() Text1.Text = "" End Sub Private Sub Command6_Click() If symb = "+" Then num = num + Val(Text1.Text) ElseIf symb = "_" Then num = num - Val(Text1.Text) ElseIf symb = "*" Then num = num * Val(Text1.Text) ElseIf symb = "/" Then num = num / Val(Text1.Text) End If Text1.Text = num End Sub Private Sub Command7_Click() Text1.Text = Sqr(Text1.Text) End Sub Private Sub Command9_Click() mem = mem - Text1.Text End Sub Output

Ex.No : 2 CREATION OF DLL USING VB AND DEPLOY IT IN VB Aim : To create a DLL in VB and use in another VB application. Algorithm: 1. 2. 3. 4. 5. 6. 7. 8. 9. Start the program Open a new Active-DLL project. Write a function to add two numbers(addNum)in the class module. Make project as .DLL file Open a new standard EXE project Select references from project menu Selecting the required DLL enables the object usage. Initialize the object and use it in the application, End the program.

Input / Output :

Ex.No : 3 DEPLOYING RMI FOR CLIENT SERVER APPLICATIONS Program : 3a Aim : To write an Java RMI program to add two numbers. Algorithm : 1. Create a folder by name AddRMI 2. Write the four java programs Add.java , AddImpl.java , AddServer.java , AddClient.java and save them in the AddRMI folder. 3. Compile all the four programs. 4. Using the command rmic to compile the interface implementation file to generate the stub and skeleton files. 5. Start the rmiregistry. 6. Start the server program that will register its object using nameing service to the rmi registry. 7. Start the client . The lookup methods is used to access the remote method on the server using the naming service. 8. Stop the progran. Program : 1) Add.java import java.rmi.*; import java.io.*; public interface Add extends Remote { public int add(int a,int b) throws RemoteException; } 2) AddImpl.java import java.rmi.*; import java.rmi.server.*; public class AddImpl extends UnicastRemoteObject implements Add { public AddImpl() throws RemoteException{} public int add(int d1,int d2) throws RemoteException { return d1+d2; } }

3) AddServer.java import java.rmi.*; import java.rmi.server.*; import java.net.*; import java.rmi.registry.*; public class AddServer { public static void main(String arg[]) throws Exception { try{ Add obj=new AddImpl(); Naming.rebind("sum",obj); } catch(Exception e){} } } 4) AddClient.java import java.rmi.*; import java.rmi.registry.*; import java.io.*; public class AddClient { public static void main(String arg[]) { try{ DataInputStream dis=new DataInputStream(System.in); System.out.println("Enter No 1"); String s1=dis.readLine(); int n1=Integer.parseInt(s1); System.out.println("Enter No 2"); String s2=dis.readLine(); int n2=Integer.parseInt(s2); Add a=(Add)Naming.lookup("summation"); int s=a.add(n1,n2); System.out.println("Sum : " +s); } catch(Exception e){} } } Steps 1. Create a folder by name AddRMI 2. Write the four java programs Add.java , AddImpl.java , AddServer.java , AddClient.java and save them in the AddRMI folder. 3. Compile all the four programs using the command D:\>AddRMI > javac Add.java

4. 5. 6. 7.

D:\>AddRMI > javac AddImpl.java D:\>AddRMI > javac AddServer.java D:\>AddRMI > javac AddClient.java Use the command rmic AddImpl to generate the stub and skeleton files. Start the rmiregistry. Start the server using the command java AddServer Start the client using the command java AddClient

Input / Output

Ex.No : 3 DEPLOYING RMI FOR CLIENT SERVER APPLICATIONS Program : 3b Aim : To write an Java RMI program to implement a chat application. Algorithm : 1. Create a folder by name RMIChat 2. Write the four java programs Chat.java , ChatImpl.java , ChatServer.java , ChatClient.java and save them in the RMIChat folder. 3. Compile all the four programs. 4. Use the command rmic to compile the interface implementation file ChatImpl to generate the stub and skeleton files. 5. Start the rmiregistry. 6. Start the server program 7. Start the client . 8. Execute the program. 9. Stop the progran. Program : 1) Chat.java import java.rmi.*; public interface Chat extends Remote { public String sendmsg(String sender,String receiver,String msg) throws RemoteException; } 2) ChatImpl.java import java.rmi.server.*; import java.rmi.*; import java.io.*; public class ChatClient { public static void main(String arg[]) { String sender,receiver,msg; try{ DataInputStream dis=new DataInputStream(System.in); System.out.println("Enter the Sender"); sender=dis.readLine();

System.out.println("Enter the receiver"); receiver=dis.readLine(); System.out.println("Enter the msg"); msg=dis.readLine(); Chat cc=(Chat)Naming.lookup("chat"); int er; String ss; do{ ss=cc.sendmsg(sender,receiver,msg); System.out.println("The message from "+receiver+" is "+ss); if(ss.equals(" ")) { System.out.println("The server has quit the connection"); break; } System.out.println("Do you want to send amy more message"); msg=dis.readLine(); if(msg.equals("yes")) { msg=dis.readLine(); } else { break; } }while(true); } catch(Exception e){} } } 3) ChatServer.java import java.rmi.*; import java.rmi.server.*; import java.rmi.registry.*; import java.io.*; public class ChatServer { public static void main(String arg[]) throws Exception { Chat ci=new ChatImpl(); System.out.println("Binding"); Naming.rebind("chat",ci); System.out.println("Ready"); }

} 4) ChatClient.java import java.rmi.server.*; import java.rmi.*; import java.io.*; public class ChatClient { public static void main(String arg[]) { String sender,receiver,msg; try{ DataInputStream dis=new DataInputStream(System.in); System.out.println("Enter the Sender"); sender=dis.readLine(); System.out.println("Enter the receiver"); receiver=dis.readLine(); System.out.println("Enter the msg"); msg=dis.readLine(); t cc=(Chat)Naming.lookup("chat"); int er; String ss; do{ ss=cc.sendmsg(sender,receiver,msg); System.out.println("The message from "+receiver+" is "+ss); if(ss.equals(" ")) { System.out.println("The server has quit the connection"); break; } System.out.println("Do you want to send amy more message"); msg=dis.readLine(); if(msg.equals("yes")) { msg=dis.readLine(); } else { break; } }while(true); } catch(Exception e){} } }

Input / Output :

Ex.No : 4

ENTERPRISE JAVA BEANS Program : 4a Aim: To write a EJB program to deploy that display a simple text message HelloWorld. Algorithm: 1. 2. 3. 4. 5. 6. 7. Create a New Enterprise Application. Create a New EJB Project , Hello.java, HelloEJB.java, HelloHome.java, HelloClient.java Create a stateless session bean. Include the method to display a simple text message Hello World. Promote the method included inside bean class to Remote Interface. Deploy the Enterprise Application and generate RMIC code. Run the Application.

Program :
Hello.java import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface Hello extends EJBObject { public String hello() throws RemoteException; } HelloHome.java import javax.ejb.*; import java.rmi.RemoteException; import java.io.Serializable; public interface HelloHome extends EJBHome { Hello create() throws RemoteException,CreateException; } HelloEJB.java import javax.ejb.*; public class HelloEJB implements SessionBean { public void ejbCreate()

{ System.out.println("ejbCreate()"); } public void ejbRemove() { System.out.println("ejbRemove()"); } public void ejbActivate() { System.out.println("ejbActivate()"); } public void ejbPassivate() { System.out.println("ejbPassivate()"); } public void setSessionContext(SessionContext ctx) { System.out.println("setSessionContext"); } public String hello() { System.out.println("hello()"); return "HELLO WORLD !"; } } HelloClient.java import javax.naming.Context; import javax.naming.InitialContext; import java.rmi.*; import java.util.*; public class HelloClient{ public static void main(String args[]){ try{ InitialContext initial=new InitialContext(); HelloHome home=(HelloHome)initial.lookup("MyHello"); Hello mHello=home.create(); String s=mHello.hello(); System.out.println("String is :"+s); } catch(Exception ee)

{ System.err.println("Caught an Unexpected Error"); ee.printStackTrace(); } } } compileEJB.bat set J2EE_HOME=c:\j2sdkee1.3.1 set CPATH=.;%J2EE_HOME%\lib\j2ee.jar javac -classpath %CPATH% Hello.java HelloHome.java HelloEJB.java compileClient.bat set J2EE_HOME=c:\j2sdkee1.3.1 set CPATH=.;%J2EE_HOME%\lib\j2ee.jar javac -classpath %CPATH% HelloClient.java testClient.java set J2EE_HOME=c:\j2sdkee1.3.1 set CPATH=.;%J2EE_HOME%\lib\j2ee.jar;HelloAppClient.jar java -classpath "%CPATH%" HelloClient

Input / Output :

Ex.No : 4

ENTERPRISE JAVA BEANS Program : 4a Aim: To write a EJB program to deploy a bean for simple arithmetic operation using websphere server. Algorithm: 1. 2. 3. 4. 5. 6. 7. Create a New Enterprise Application. Create a New EJB Project , Cal.java, CalEJB.java, CalHome.java, CalClient.java Create a stateless session bean. Include the method to perform arithmetic operations within bean class Promote the method included inside bean class to Remote Interface. Deploy the Enterprise Application and generate RMIC code. Run the Application.

Program :
Cal.java import javax.ejb.EJBObject; import java.rmi.RemoteException; public interface Cal extends EJBObject { public int add(int x,int y) throws RemoteException; public int sub(int x,int y) throws RemoteException; public int mul(int x,int y) throws RemoteException; public int div(int x,int y) throws RemoteException; } CalHome.java import javax.ejb.*; import java.rmi.RemoteException; import java.io.Serializable; public interface CalHome extends EJBHome { Cal create() throws RemoteException,CreateException; } CalEJB.java import javax.ejb.*;

public class CalEJB implements SessionBean { public void ejbCreate() { System.out.println("ejbCreate()"); } public void ejbRemove() { System.out.println("ejbRemove()"); } public void ejbActivate() { System.out.println("ejbActivate()"); } public void ejbPassivate() { System.out.println("ejbPassivate()"); } public void setSessionContext(SessionContext ctx) { System.out.println("setSessionContext"); } public int add(int x,int y) { return(x+y); } public int sub(int x,int y) { return(x-y); } public int mul(int x,int y) { return(x*y); } public int div(int x,int y) { return(x/y); } } CalClient.java import javax.naming.Context; import javax.naming.InitialContext; import java.rmi.*; import java.io.*; import java.util.*; public class CalClient{

public static void main(String args[]){ try{ InitialContext initial=new InitialContext(); CalHome cal=(CalHome)initial.lookup("MyCal"); Cal mCal=cal.create(); DataInputStream dis=new DataInputStream(System.in); do { System.out.println(1 Add); System.out.println(2 Subtract); System.out.println(3 Multiply); System.out.println(4 Divide); System.out.println(5 Exit); System.out.println(Enter the First No :); String c=dis.readLine(); int n1=Integer.parseInt(c); System.out.println(Enter the Second No :); String c=dis.readLine(); int n2=Integer.parseInt(c); System.out.println(Enter your choice); String c=dis.readLine(); int ch=Integer.parseInt(c); switch(ch) { case 1: int aa=mCal.add(n1,n2);break; case 2: int aa=mCal.sub(n1,n2);break; case 3: int aa=mCal.mul(n1,n2);break; case 4: int aa=mCal.div(n1,n2);break; case 5 : System.exit(); } }while( choice >=1 && choice <=5); } catch(Exception ee) { System.err.println("Caught an Unexpected Error"); ee.printStackTrace(); } } }

compileEJB.bat set J2EE_HOME=c:\j2sdkee1.3.1 set CPATH=.;%J2EE_HOME%\lib\j2ee.jar javac -classpath %CPATH% Cal.java CalHome.java CalEJB.java compileClient.bat set J2EE_HOME=c:\j2sdkee1.3.1 set CPATH=.;%J2EE_HOME%\lib\j2ee.jar javac -classpath %CPATH% CalClient.java testClient.java set J2EE_HOME=c:\j2sdkee1.3.1 set CPATH=.;%J2EE_HOME%\lib\j2ee.jar;CalAppClient.jar java -classpath "%CPATH%" CalClient

Input / Output :

Ex.No : 5 SIMPLE APPLICATION USING CORBA Aim : To write a simple application in corba to display a text message HelloWorld. Algorithm : 1. Create a folder GoodDay 2. Define interface as an IDL file , GoodDay.idl 3. Compile the IDL and generate the stub and skeleton 4. Develop an implementation for the interface and compile 5. Develop the Corba Server application and compile. 6. Develop the Corba Client application and compile. 7. Run the corba Naming service,tnameserv 8. Run the server application. 9. Run the client application. Program. : 1) GoodDay.idl module GoodDayApp { interface GoodDay { string hello(); }; }; 2) GoodDayImpl.java import org.omg.CORBA.*; import GoodDayApp.*; class GoodDayImpl extends _GoodDayImplBase{ public GoodDayImpl() { super(); } public String hello() { return "Hello World!"; } }

3) GoodDayImpl.java import org.omg.CORBA.*; import GoodDayApp.*; class GoodDayImpl extends _GoodDayImplBase{ public GoodDayImpl() { super(); } public String hello() { return "Hello World!"; } } 4) GoodDayServer.java import org.omg.CORBA.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContext.*; import GoodDayApp.*; public class GoodDayServer { public static void main(String args[]) { try{ ORB orb=ORB.init(args,null); GoodDayImpl gdayRef=new GoodDayImpl(); orb.connect(gdayRef); org.omg.CORBA.Object objRef=orb.resolve_initial_references("NameService"); NamingContext ncRef=NamingContextHelper.narrow(objRef); NameComponent nc=new NameComponent("goodDay",""); NameComponent path[]={nc}; ncRef.rebind(path,gdayRef); System.out.println("GoodDayServer is ready"); java.lang.Object sync=new java.lang.Object(); synchronized(sync) { sync.wait(); } } catch(Exception e){e.printStackTrace();} } }

5. GoodDayClient.java import org.omg.CORBA.*; import org.omg.CosNaming.*; import GoodDayApp.*; public class GoodDayClient { public static void main(String args[]) { try { ORB orb=ORB.init(args,null); // Get the root naming context NamingContext ncRef = NamingContextHelper.narrow(orb.resolve_initial_references("NameService")); // Resolve the object reference in naming NameComponent path[] = {new NameComponent("goodDay", "")}; GoodDay gdayRef=GoodDayHelper.narrow(ncRef.resolve(path)); // Call the GoodDay server object and print results System.out.println("Message : "+gdayRef.hello()); } catch(Exception e){e.printStackTrace();} } } Input / Ouput : D:\sai\HelloWorld>idltojava -fno-cpp GoodDay.idl D:\ sai\HelloWorld>javac GoodDayImpl.java D:\ sai\HelloWorld>javac GoodDayServer.java D:\ sai\HelloWorld>javac GoodDayClient.java

Ex.No : 6 NAMING SERVICES IN CORBA Aim : To display a text HelloWorld using corba naming service. Algorithm : 9. Create a folder HelloWorld 10. Define interface as an IDL file , Hello.idl 11. Compile the IDL and generate the stub and skeleton 12. Develop the Corba Server and Client application . 13. Compile all *.java files including the stub and skeleton generated by the IDL compiler. 14. Run the corba Naming service,orbd 15. Start the server application. 8. Run the client application. 9. Execute the program. Program : 1) Hello.idl module HelloApp { interface Hello { string sayHello(); oneway void shutdown(); }; }; 2) HelloServer.java import HelloApp.*; import org.omg.CosNaming.*; import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; import org.omg.PortableServer.*; import org.omg.PortableServer.POA; import java.util.Properties; class HelloImpl extends HelloPOA { private ORB orb;

public void setORB(ORB orb_val) { orb = orb_val; } // implement sayHello() method public String sayHello() { return "\nHello world !!\n"; } // implement shutdown() method public void shutdown() { orb.shutdown(false); } } public class HelloServer { public static void main(String args[]) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // get reference to rootpoa & activate the POAManager POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); // create servant and register it with the ORB HelloImpl helloImpl = new HelloImpl(); helloImpl.setORB(orb); // get object reference from the servant org.omg.CORBA.Object ref = rootpoa.servant_to_reference(helloImpl); Hello href = HelloHelper.narrow(ref); // get the root naming context // NameService invokes the name service org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); // Use NamingContextExt which is part of the Interoperable // Naming Service (INS) specification. NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // bind the Object Reference in Naming String name = "Hello"; NameComponent path[] = ncRef.to_name( name );

ncRef.rebind(path, href); System.out.println("HelloServer ready and waiting ..."); // wait for invocations from clients orb.run(); } catch (Exception e) { System.err.println("ERROR: " + e); e.printStackTrace(System.out); } System.out.println("HelloServer Exiting ..."); } } 3) HelloClient.java import org.omg.CosNaming.NamingContextPackage.*; import org.omg.CORBA.*; public class HelloClient { static Hello helloImpl; public static void main(String args[]) { try{ // create and initialize the ORB ORB orb = ORB.init(args, null); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); // Use NamingContextExt instead of NamingContext. This is // part of the Interoperable naming Service. NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // resolve the Object Reference in Naming String name = "Hello"; helloImpl = HelloHelper.narrow(ncRef.resolve_str(name)); System.out.println("Obtained a handle on server object: " + helloImpl); System.out.println(helloImpl.sayHello()); helloImpl.shutdown();

} catch (Exception e) { System.out.println("ERROR : " + e) ; e.printStackTrace(System.out); } } } Steps 1. Create a folder HelloWorld 2. Define interface as an IDL file , Hello.idl 3. Run the IDL-to-Java Compiler , idlj to generate the stub and skeleton.
idlj -fall javac *.java Hello.idl HelloApp/*.java

4. Compile all the .java files including the stub and skeleton. 5. Start the naming service.
start orbd -ORBInitialPort 1050

6. Start the server application. java HelloServer -ORBInitialPort 1050 7. Run the client application. java HelloClient -ORBInitialPort 1050 8. Execute the program.

Ex.No : 7 INTER ORB IN COMMUNICATION USING RMI IIOP Aim : To write a simple application do display a text HelloWorld using Inter-ORB in communication (RMI IIOP) Program : 1) HelloInterface.java import java.rmi.Remote; public interface HelloInterface extends java.rmi.Remote { public void sayHello( String from ) throws java.rmi.RemoteException; } 2) HelloImpl.java import javax.rmi.PortableRemoteObject; public class HelloImpl extends PortableRemoteObject implements HelloInterface { public HelloImpl() throws java.rmi.RemoteException { super(); // invoke rmi linking and remote object initialization } public void sayHello( String from ) throws java.rmi.RemoteException { System.out.println( "Hello from " + from + "!!" ); System.out.flush(); } } 3) HelloServer.java import javax.naming.InitialContext; import javax.naming.Context; public class HelloServer { public static void main(String[] args) { try { // Step 1: Instantiate the Hello servant HelloImpl helloRef = new HelloImpl(); // Step 2: Publish the reference in the Naming Service // using JNDI API Context initialNamingContext = new InitialContext(); initialNamingContext.rebind("HelloService", helloRef ); System.out.println("Hello Server: Ready...");

} catch (Exception e) { System.out.println("Trouble: " + e); e.printStackTrace(); } } } 4) HelloClient.java import java.rmi.RemoteException; import java.net.MalformedURLException; import java.rmi.NotBoundException; import javax.rmi.*; import java.util.Vector; import javax.naming.NamingException; import javax.naming.InitialContext; import javax.naming.Context; public class HelloClient { public static void main( String args[] ) { Context ic; Object objref; HelloInterface hi; try { ic = new InitialContext(); // STEP 1: Get the Object reference from the Name Service // using JNDI call. objref = ic.lookup("HelloService"); System.out.println("Client: Obtained a ref. to Hello server."); // STEP 2: Narrow the object reference to the concrete type and // invoke the method. hi = (HelloInterface) PortableRemoteObject.narrow( objref, HelloInterface.class); hi.sayHello( " MARS " ); } catch( Exception e ) { System.err.println( "Exception " + e + "Caught" ); e.printStackTrace( ); return; } } }

Batch File to compile and run the application. 1) spath.bat set path=%path%;c:\j2sdk1.4.0_01\bin; set classpath=%classpath%;.; 2) 1.bat javac -d . -classpath . HelloImpl.java 3) 2.bat rmic -iiop HelloImpl 4) 3.bat javac -d . -classpath . HelloInterface.java HelloServer.java HelloClient.java 5) 4.bat start orbd -ORBInitialPort 1050 6) 5.bat java -classpath . -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory -Djava.naming.provider.url=iiop://localhost:1050 HelloServer 7) 6.bat java -classpath . -Djava.naming.factory.initial=com.sun.jndi.cosnaming.CNCtxFactory -Djava.naming.provider.url=iiop://localhost:1050 HelloClient

Ex.No : 7 INTER ORB IN COMMUNICATION ( IIOP , IOR] Jac ORB & VisiBroker ORB Aim : Algorithm : 1. 2. 3. 4. 5. 6. 7. 8. 9. Create a folder Hello. Write the code for HelloServer.java, HelloClient.java, HelloImpl.java and Hello.idl Compile the interface program.This creates a folder Hello that contains stub,skeletons and POA files. Compile the programs. Run the Server. Run the Server application. Run the Client Application. Display the message HELLO WORLD End the program

Input / Output: Run Hello.idl: C:\>cd Hello C:\Hello>set path=c:\j2sdk1.4.2_04\bin;c:\jacORB\bin; C:\Hello>idlj -fall Hello.idl C:\Hello>javac *.java C:\Hello>orbd -ORBInitialHost localhost -ORBInitialPort 1050 Run HelloServer: C:\>cd hello C:\Hello>set path=c:\j2sdk1.4.2_04\bin;c:\jacORB\bin; C:\Hello>java HelloServer -ORBInitialHost localhost -ORBInitialPort 1050 HelloServer ready and waiting ... IOR:000000000000000e49444c3a48656c6c6f3a312e30000000000000010000000000000 068000102000000000 a3132372e302e302e310005bf00000021afabcb00000000207497d7e00000000100000000 000000000000000400 0000000a0000000000000100000001000000200000000000010001000000020501000100 0100200001010900000 00100010100 HelloServer Exiting ... C:\Hello> Run HelloClient: C:\>cd hello C:\Hello>set path=c:\j2sdk1.4.2_04\bin;c:\jacORB\bin; C:\Hello>java HelloClient -ORBInitialHost localhost -ORBInitialPort 1050

Obtained a handle on server object: _HelloStub:IOR:000000000000000e49444c3a48656c6c6f3a312e 30000000000000010000000000000068000102000000000a3132372e302e302e310005bf 00000021afabcb00000 000207497d7e000000001000000000000000000000004000000000a00000000000001000 0000100000020000000 0000010001000000020501000100010020000101090000000100010100 Hello world !! C:\Hello>

Ex.No: 9 STUDYING J2EE SERVER Aim To have a clear understanding of the J2EE server STUDY. Study :
The J2EE architecture is based on the Java programming language. Java enables organizations to write their code once, and deploy that code onto any platform. The process is as follows: 1. Developers write source code in Java. 2. The Java code is compiled into bytecode, which is a cross-platform intermediary,halfway between source code and machine language. 3. When the code is ready to run, the Java Runtime Environment (JRE) interprets this bytecode and executes it at run-time. J2EE is an application of Java. J2EE components are transformed into bytecode and executed by a JRE at runtime. Even the containers are typically written in Java. J2EE and Web Services J2EE is an architecture for building server-side deployments in the Java programming language. It can be used to build traditional web sites, software components, or packaged applications. J2EE has recently been extended to include support for building XML-based web services as well. These web services can interoperate with other web services that may or may not have been written to the J2EE standard. J2EE application is hosted within a container, which provides qualities of service necessary for enterprise applications, such as transactions, security, and persistence services. The business layer performs business processing and data logic. In large-scale J2EE applications, business logic is built using Enterprise JavaBeans (EJB) components. This layer performs business processing and data logic. It connects to databases using Java Database Connectivity (JDBC) or SQL/J, or existing systems using the Java Connector Architecture (JCA). It can also connect to business partners using web services technologies (SOAP, UDDI, WSDL, ebXML) through the Java APIs for XML (the JAX APIs). Business partners can connect with J2EE applications through web services technologies (SOAP, UDDI, WSDL, ebXML). A servlet, which is a request/response oriented Java object, can accept web service requests from business partners. The servlet uses the JAX APIs to perform web services operations. Shared context services will be standardized in the future through shared context standards that will be included with J2EE. Traditional 'thick' clients such as applets or applications connect directly to the EJB layer through the Internet Inter-ORB Protocol (IIOP) rather than web services, since generally the thick clients are written by the same organization that authored J2EE application, and therefore there is no need for XML-based web service collaboration. Web browsers and wireless devices connect to JavaServer Pages (JSPs) which render user interfaces in HTML, XHTML, or WML.

Reference Implementation
Sun ships a reference implementation of J2EE. Developers write applications to this to ensure portability of their components. This implementation should not be used for production, but rather just for testing purposes. All vendors that offer J2EE platforms provide additional features not found in the standard. Some of them impact portability, such as extended EAI functionality, ECommerce components, or advanced B2B integration. Other features, such as loadbalancing, transparent fail-over, and caching, do not affect portability of application code, because they are implicit services which are provided behind-the-scenes by the container.

Additional Services

Ex.No : 9 SIMPLE APPLICATION USING CORBA. Program : 1 Aim : To write a simple application in corba and generate the stub and skeleton using the idltojava compiler. Algorithm : 16. Create a folder HelloWorld 17. Define interface as an IDL file , GoodDay.idl 18. Compile the IDL and generate the stub and skeleton 19. Develop the servant class by writing an implementation for the interface and compile 20. Develop the Corba Server application and compile. 21. Develop the Corba Client application and compile. 22. Run the corba Naming service. 23. Run the server application. 9. Run the client application. 10. Execute the program. Input / Ouput : D:\sai\HelloWorld>idltojava -fno-cpp GoodDay.idl D:\ sai\HelloWorld>javac GoodDayImpl.java D:\ sai\HelloWorld>javac GoodDayServer.java D:\ sai\HelloWorld>javac GoodDayClient.java

Das könnte Ihnen auch gefallen