FileDocCategorySizeDatePackage
CORBAProvider.javaAPI DocApache Axis 1.45161Sat Apr 22 18:57:26 BST 2006org.apache.axis.providers.java

CORBAProvider

public class CORBAProvider extends RPCProvider
A basic CORBA Provider
author
Davanum Srinivas (dims@yahoo.com)

Fields Summary
protected static Log
log
private static final String
DEFAULT_ORB_INITIAL_HOST
private static final String
DEFAULT_ORB_INITIAL_PORT
protected static Log
entLog
public static final String
OPTION_ORB_INITIAL_HOST
public static final String
OPTION_ORB_INITIAL_PORT
public static final String
OPTION_NAME_ID
public static final String
OPTION_NAME_KIND
public static final String
OPTION_INTERFACE_CLASSNAME
public static final String
OPTION_HELPER_CLASSNAME
private static final Class[]
CORBA_OBJECT_CLASS
Constructors Summary
Methods Summary
protected java.lang.StringgetServiceClassNameOptionName()
Return the option in the configuration that contains the service class name.


                       
      
    
        return OPTION_INTERFACE_CLASSNAME;
    
protected java.lang.StringgetStrOption(java.lang.String optionName, org.apache.axis.Handler service)
Get a String option by looking first in the service options, and then at the Handler's options. This allows defaults to be specified at the provider level, and then overriden for particular services.

param
optionName the option to retrieve
return
String the value of the option or null if not found in either scope

        String value = null;
        if (service != null)
            value = (String)service.getOption(optionName);
        if (value == null)
            value = (String)getOption(optionName);
        return value;
    
protected java.lang.ObjectmakeNewServiceObject(org.apache.axis.MessageContext msgContext, java.lang.String clsName)
Return a object which implements the service.

param
msgContext the message context
param
clsName The JNDI name of the EJB home class
return
an object that implements the service


                                       
       
                                           
         
    
        // Read deployment descriptor options
        String orbInitialHost = getStrOption(OPTION_ORB_INITIAL_HOST,msgContext.getService()); 
        if (orbInitialHost == null)
          orbInitialHost = DEFAULT_ORB_INITIAL_HOST;
        String orbInitialPort = getStrOption(OPTION_ORB_INITIAL_PORT,msgContext.getService());
        if (orbInitialPort == null)
          orbInitialPort = DEFAULT_ORB_INITIAL_PORT;
        String nameId = getStrOption(OPTION_NAME_ID,msgContext.getService());
        String nameKind = getStrOption(OPTION_NAME_KIND,msgContext.getService());
        String helperClassName = getStrOption(OPTION_HELPER_CLASSNAME,msgContext.getService());

        // Initialize ORB
        Properties orbProps = new Properties();
        orbProps.put("org.omg.CORBA.ORBInitialHost", orbInitialHost);
        orbProps.put("org.omg.CORBA.ORBInitialPort", orbInitialPort);
        ORB orb = ORB.init(new String[0], orbProps);

        // Find the object
        NamingContext root = NamingContextHelper.narrow(orb.resolve_initial_references("NameService"));
        NameComponent nc = new NameComponent(nameId, nameKind);
        NameComponent[] ncs = {nc};
        org.omg.CORBA.Object corbaObject = root.resolve(ncs);

        Class helperClass = ClassUtils.forName(helperClassName);
        // Narrow the object reference
        Method narrowMethod = helperClass.getMethod("narrow", CORBA_OBJECT_CLASS);
        Object targetObject = narrowMethod.invoke(null, new Object[] {corbaObject});

        return targetObject;