Hi Subbu,
        What is the significance of the following line.
(CabinHome)javax.rmi.PortableRemoteObject.narrow((org.omg.CORBA.Object)obj,C
abinHome.class);

I think this will be used in case of CORBA only....


Rajan

-----Original Message-----
From: A mailing list for Enterprise JavaBeans development
[mailto:[EMAIL PROTECTED]]On Behalf Of Subbakrishna
Sent: Wednesday, August 09, 2000 7:31 AM
To: [EMAIL PROTECTED]
Subject: Re: URGENT:How to use stand alone java application client for
EJB in Websphere app server


Hi,

I am attaching herewith a Stand alone java application for Cabin/Titan
samples of EJB (O'Rielly) book.

The following lines are key things in making to access EJB through jndi
which is not the same as given in the book.

                        Context jndiContext = getInitialContext();
                        java.lang.Object obj =
jndiContext.lookup("CabinHome");
                        CabinHome home =
(CabinHome)javax.rmi.PortableRemoteObject.narrow((org.omg.CORBA.Object)obj,C
abinHome.class);

                        CabinKey key = new CabinKey();


Hope this will serve your purpose.

regds
subbu

--- Complete Code of Cabin_1.java  <Begin>------

package com.titan.cabin;

import com.titan.cabin.CabinHome;
import com.titan.cabin.Cabin;
import com.titan.cabin.CabinKey;

import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import java.rmi.RemoteException;
import java.util.Properties;

public class Client_1
{
        public static void main(String[] args)
        {
                try
                {
                        Context jndiContext = getInitialContext();
                        java.lang.Object obj =
jndiContext.lookup("CabinHome");
                        CabinHome home =
(CabinHome)javax.rmi.PortableRemoteObject.narrow((org.omg.CORBA.Object)obj,C
abinHome.class);

                        CabinKey key = new CabinKey();
                        key.id = 1;
                        Cabin cabin_1 = home.create(key);
                        cabin_1.setName("Master Suite");
                        cabin_1.setDeckLevel(1);
                        cabin_1.setShip(1);
                        cabin_1.setBedCount(3);

                        Cabin cabin_2 = home.findByPrimaryKey(key);
                        System.out.println(cabin_2.getName());
                        System.out.println(cabin_2.getDeckLevel());
                        System.out.println(cabin_2.getShip());
                        System.out.println(cabin_2.getBedCount());


                } catch (Exception re)
                        {
                                re.printStackTrace();
                        }
        }

        public static Context getInitialContext()
                throws javax.naming.NamingException
                {
                        Properties p = new Properties();

p.put("java.naming.factory.initial","com.ibm.ejs.ns.jndi.CNInitialContextFac
tory");

p.put("Context.PROVIDER_URL","iiop://localhost:900");
                        return new InitialContext(p);
                }
}

--- Complete Code of Cabin_1.java  <End>------



> -----Original Message-----
> From: Gaurav SDC NOIDA [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, August 09, 2000 3:54 PM
> To:   [EMAIL PROTECTED]
> Subject:      URGENT:How to use stand alone java application client for
> EJB  in Websphere app server
>
> Dear all
> Could any body  tell me how to use stand alone java application client for
> EJB  in Websphere app server.
> Thanx,
> any help would be appreciated .
>
> Gaurav
> ECode-1205
> HCL Perot Systems,Noida
> (Youngest CMM level 5 company)
> email- [EMAIL PROTECTED]
>            [EMAIL PROTECTED]
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to