Absolutely new to EJB.. Regarding implementing methods in interfaces..

Hi all.. Please answer this asap..
I have ".java" files in a package like this:

---------------------------------------------------------------------------
Authentication.java:-

package com.it.foundation.signon;
import javax.ejb.*;
import java.rmi.Remote;
import java.rmi.RemoteException;
import com.it.foundation.*;
public interface Authentication extends EJBObject, BeanInterface{
}
---------------------------------------------------------------------------
AuthenticationHome.java:-

package com.it.foundation.signon;
import javax.ejb.*;
import java.rmi.RemoteException;
public interface AuthenticationHome extends EJBHome {
      public Authentication create() throws RemoteException, CreateException;
}
---------------------------------------------------------------------------
The "BeanInterface.java" which is used in the "Authentication.java" is as given below:

package com.it.foundation;
import java.rmi.RemoteException;
import com.it.foundation.action.CommandRequest;
import com.it.foundation.action.CommandResponse;
public interface BeanInterface
{
          public CommandResponse execute(CommandRequest request) throws RemoteException;
}
---------------------------------------------------------------------------
**********************************************
Note that both the files above contain interfaces.
**********************************************

Now I have a file by the name "EJBGetter.java":

package com.it.foundation.utils;

import javax.rmi.PortableRemoteObject;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import com.it.foundation.signon.AuthenticationHome;

public final class EJBGetter {
    private static InitialContext initial = null;

    public static InitialContext getContext() throws NamingException {
        if (initial == null) {
            initial = new InitialContext();
        }

        return initial;
    }

    public static AuthenticationHome getAuthenticationHome() throws NamingException {
        InitialContext context = getContext();
        Object objref = context.lookup(CConst.AUTHENTICATION_EJBHOME);

        return (AuthenticationHome) PortableRemoteObject.narrow(objref, AuthenticationHome.class);
    }

}
---------------------------------------------------------------------------
**********************************************
QUESTION : How is it possible that the EJBGetter class is creating a function "getAuthenticationHome()" of the interface "AuthenticationHome"?  
**********************************************
---------------------------------------------------------------------------

It is even being used in another servlet as follows :

static {
        try {
            AuthenticationHome home = EJBGetter.getAuthenticationHome();
            authenticationBean = home.create();
        } catch (RemoteException rex) {
            rex.printStackTrace();
        } catch (CreateException cex) {
            cex.printStackTrace();
        } catch (NamingException nex) {
            nex.printStackTrace();
        }
    }
-----------------------------------------------------------------------------------------------
************************************************************
How is this possible? Could someone please explain. I have this code working correctly. I think I am missing somerthing here. But isn't an interface NOT allowed to implement code in its method. Moreover how is another class implementing the body of the method of an interface that it does implement?
deshaniAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
> But isn't an interface NOT allowed to implement code in its method.

EJBGetter is not an interface, it is a class

> Moreover how is another class implementing the body of the method of an interface that it does implement?

A class can create methods of any sig, the fact that the sig is used by an interface is irrelevant.
The signature of that method is actually a littl different, in that it is a static class method.
0
deshaniAuthor Commented:
Hi objects,
"The signature of that method is actually a littl different, in that it is a static class method."
---Does this mean that you are talking about this particular case or in a general sense?
---Does a method with a signature of another class/interface mean that when we use that method we can instantiate the object of that class, as is done in this case? See the EJBGetter class, where we say:
             ------------------------------------------------------
       AuthenticationHome home = EJBGetter.getAuthenticationHome();
             ------------------------------------------------------
Does this not amount to actually creating an object "home" of the interface "AuthenticationHome"?

Thanks,
Anup
0
objectsCommented:
am talking about this particular case.

yes, EJBGetter.getAuthenticationHome() will return an object of a class that does implement AuthenticationHome
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
deshaniAuthor Commented:
thanks a million...this clarifies it a lot. Still have some doubts, but I believe they are due to lack of knowledge in EJBs. One last request: Could you tell me a few resources that can point to the concept of "creating methods with signature of a different class" and on any reference guide to EJB?
Thanks again.
Regards,
Anup
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.