org.apache.cxf.jca.servant
Class EJBServant

java.lang.Object
  extended by org.apache.cxf.jca.servant.AbstractServant
      extended by org.apache.cxf.jca.servant.EJBServant
All Implemented Interfaces:
java.lang.reflect.InvocationHandler
Direct Known Subclasses:
CXFConnectEJBServant

public class EJBServant
extends AbstractServant

This servant is used to dispatch invocations to an EJB.


Field Summary
static java.lang.String INITIAL_CONTEXT_PROPS_FILE
          Name of the default Initial Context properties file.
protected  java.util.Properties props
          Properties for Initial Context.
 
Constructor Summary
EJBServant(java.lang.String wsdlLoc, org.apache.cxf.Bus bus, java.lang.String jndiName)
          Constructor for creating an EJBServant.
EJBServant(java.lang.String wsdlLoc, org.apache.cxf.Bus bus, java.lang.String jndiName, java.util.Properties initialContextProps)
          Constructor for creating an EJBServant.
 
Method Summary
protected  java.util.Properties getContextProperties(java.lang.String jndiName, java.lang.String defaultPropsName)
          Get properties for InitialContext.
protected  javax.ejb.EJBHome getEJBHome(javax.naming.Context ejbContext, java.lang.String jndiName)
          Looksup EJBHome in the context based on the JNDI name.
 javax.naming.Context getInitialContext(java.util.Properties propers)
          Creates a new Initial Context with the specified properties.
 java.lang.Object getTargetObject()
          Based on the information from properties.xml, locate the remote object reference of the target EJB.
 java.lang.Object invoke(java.lang.Object target, java.lang.reflect.Method method, java.lang.Object[] args)
          Invokes on the operation of the target object with the arguments provided.
 void setProperties(java.util.Properties p)
           
 
Methods inherited from class org.apache.cxf.jca.servant.AbstractServant
getBus, getWSDLLocation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_CONTEXT_PROPS_FILE

public static final java.lang.String INITIAL_CONTEXT_PROPS_FILE
Name of the default Initial Context properties file.

See Also:
Constant Field Values

props

protected java.util.Properties props
Properties for Initial Context.

Constructor Detail

EJBServant

public EJBServant(java.lang.String wsdlLoc,
                  org.apache.cxf.Bus bus,
                  java.lang.String jndiName,
                  java.util.Properties initialContextProps)
Constructor for creating an EJBServant.

Parameters:
wsdlLoc - wsdl location.
bus - Bus
jndiName - JNDI name
initialContextProps - initial context properties.

EJBServant

public EJBServant(java.lang.String wsdlLoc,
                  org.apache.cxf.Bus bus,
                  java.lang.String jndiName)
           throws java.lang.Exception
Constructor for creating an EJBServant. If you use this constructor, initial context properties can be provided via properties file available in classpath. @see EJBServant#INITIAL_CONTEXT_PROPS_FILE

Parameters:
wsdlLoc - wsdl location.
bus - Bus.
jndiName - JNDI Name.
Throws:
java.lang.Exception - if there is an error creating servant.
Method Detail

invoke

public java.lang.Object invoke(java.lang.Object target,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Invokes on the operation of the target object with the arguments provided.

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Specified by:
invoke in class AbstractServant
Parameters:
target - Object to be invoked upon.
method - Method to be invoked.
args - Object[] arguments.
Returns:
Object the result of dispatching the method. Void.TYPE for void methods.
Throws:
org.apache.cxf.BusException - if there is an errror invoking operation.
java.lang.Throwable

setProperties

public void setProperties(java.util.Properties p)

getTargetObject

public java.lang.Object getTargetObject()
                                 throws org.apache.cxf.BusException
Based on the information from properties.xml, locate the remote object reference of the target EJB.

Specified by:
getTargetObject in class AbstractServant
Returns:
Object EJBObject created by calling create function on EJBHome.
Throws:
org.apache.cxf.BusException - if there is an error getting Target EJB Object.

getContextProperties

protected final java.util.Properties getContextProperties(java.lang.String jndiName,
                                                          java.lang.String defaultPropsName)
                                                   throws java.lang.Exception
Get properties for InitialContext. Looks for properties file in the classpath with either INITIAL_CONTEXT_PROPS_FILE or jndi name + INITIAL_CONTEXT_PROPS_FILE names.

Parameters:
jndiName - JNDI Name
defaultPropsName - name of the default properties file.
Returns:
Properties properties for initial context.
Throws:
java.lang.Exception - if there is an error getting properties.

getInitialContext

public javax.naming.Context getInitialContext(java.util.Properties propers)
                                       throws javax.naming.NamingException
Creates a new Initial Context with the specified properties.

Parameters:
propers - Properties for initial context.
Returns:
Context initial context for EJB lookup.
Throws:
javax.naming.NamingException - if there is an error getting initial context.

getEJBHome

protected javax.ejb.EJBHome getEJBHome(javax.naming.Context ejbContext,
                                       java.lang.String jndiName)
                                throws javax.naming.NamingException
Looksup EJBHome in the context based on the JNDI name.

Parameters:
ejbContext - Context to be used in lookup of EJB.
jndiName - JNDI name
Returns:
EJBHome
Throws:
javax.naming.NamingException - if there is an error getting EJBHome.


Copyright © 2006 Apache Software Foundation. All Rights Reserved.