[prev in list] [next in list] [prev in thread] [next in thread] 

List:       soap-dev
Subject:    (Fwd) failure notice
From:       Scott Nichol <snicholnews () scottnichol ! com>
Date:       2003-04-03 17:59:15
[Download RAW message or body]

This post attempt was rejected because the poster is not a member of 
the list.  I have lost the original reject message with the poster's 
e-mail.  If you are the poster and read this, please post a diff 
against the current CVS source.

Thanks!

> Hi,
> 
> This patch bundle includes:
> 
> - Changes to StatefulEJBProvider, StatelessEJBProvider &
> EntityEJBProvider
> 
> Supports principal and credentials on InitialContext.
> InitialContext creation moved in StatefulEJBProvider to support the use
> of principal and credentials on methods in a 'session'.
> 
> - List of properties in deployment descriptor in the soap.war admin
> part.
> 
> Lists eg. ContextProviderURL etc. for the EJB web services.
> 
> Morten
> 
> Patch:
> 
> diff -ruN
> /cygdrive/c/temp/soap-2_3_1/src/org/apache/soap/providers/EntityEJBProvi
> der.java src/org/apache/soap/providers/EntityEJBProvider.java
> ---
> /cygdrive/c/temp/soap-2_3_1/src/org/apache/soap/providers/EntityEJBProvi
> der.java	2002-06-10 03:05:08.000000000 +0200
> +++ src/org/apache/soap/providers/EntityEJBProvider.java
> 2003-02-27 11:22:45.000000000 +0100
> @@ -25,11 +25,11 @@
>    /**
>     * locate method comment.
>     */
> -  public void locate(DeploymentDescriptor depDesc, 
> +  public void locate(DeploymentDescriptor depDesc,
>                       Envelope env,
> -                     Call origCall, 
> +                     Call origCall,
>                       String methodName,
> -                     String targetObjectURI, 
> +                     String targetObjectURI,
>                       SOAPContext reqContext) throws SOAPException {
>  
>      HttpServlet servletRef = (HttpServlet) reqContext.getProperty(
> Constants.BAG_HTTPSERVLET );
> @@ -57,11 +57,13 @@
>  
>      String ContxtProviderURL = (String)
> props.get("ContextProviderURL");
>      String ContxtFactoryName = (String)
> props.get("FullContextFactoryName");
> +      String ContxtPrincipal = (String) props.get("ContextPrincipal");
> +      String ContxtCredentials = (String)
> props.get("ContextCredentials");
>  
>      if ((ContxtProviderURL != null) || (ContxtFactoryName != null))
> -      initialize(ContxtProviderURL, ContxtFactoryName);
> +      initialize(ContxtProviderURL, ContxtFactoryName, ContxtPrincipal,
> ContxtCredentials);
>      else
> -      initialize(CNTXT_PROVIDER_URL, CNTXT_FACTORY_NAME);
> +      initialize(CNTXT_PROVIDER_URL, CNTXT_FACTORY_NAME, "", "");
>  
>      String homeInterfaceName = (String)
> props.get("FullHomeInterfaceName");
>      if (homeInterfaceName == null)
> diff -ruN
> /cygdrive/c/temp/soap-2_3_1/src/org/apache/soap/providers/StatefulEJBPro
> vider.java src/org/apache/soap/providers/StatefulEJBProvider.java
> ---
> /cygdrive/c/temp/soap-2_3_1/src/org/apache/soap/providers/StatefulEJBPro
> vider.java	2002-06-10 03:05:08.000000000 +0200
> +++ src/org/apache/soap/providers/StatefulEJBProvider.java
> 2003-02-27 11:22:45.000000000 +0100
> @@ -1,370 +1,391 @@
>  package org.apache.soap.providers;
>  
> -import java.io.* ;
> -import java.util.* ;
> -import java.rmi.Remote;
> -import javax.servlet.* ;
> -import javax.servlet.http.* ;
> -import org.apache.soap.* ;
> -import org.apache.soap.rpc.* ;
> -import org.apache.soap.server.* ;
> -import org.apache.soap.util.* ;
> +import org.apache.soap.Constants;
> +import org.apache.soap.Envelope;
> +import org.apache.soap.SOAPException;
>  import org.apache.soap.encoding.soapenc.Base64;
> -
> -import java.lang.reflect.*;
> -import javax.rmi.*;
> -import javax.ejb.*;
> -import javax.naming.*;
> -import javax.naming.Context.*;
> +import org.apache.soap.rpc.Call;
> +import org.apache.soap.rpc.Parameter;
> +import org.apache.soap.rpc.RPCConstants;
> +import org.apache.soap.rpc.Response;
> +import org.apache.soap.rpc.SOAPContext;
> +import org.apache.soap.server.DeploymentDescriptor;
> +import org.apache.soap.util.Bean;
> +import org.apache.soap.util.MethodUtils;
> +import org.apache.soap.util.Provider;
> +
> +import javax.ejb.EJBHome;
> +import javax.ejb.EJBObject;
> +import javax.ejb.Handle;
> +import javax.naming.Context;
> +import javax.naming.InitialContext;
> +import javax.naming.NamingException;
> +import javax.rmi.PortableRemoteObject;
> +import javax.servlet.http.HttpServlet;
> +import javax.servlet.http.HttpSession;
> +import java.io.ByteArrayInputStream;
> +import java.io.ByteArrayOutputStream;
> +import java.io.ObjectInputStream;
> +import java.io.ObjectOutputStream;
> +import java.io.StringWriter;
> +import java.lang.reflect.InvocationTargetException;
> +import java.lang.reflect.Method;
> +import java.rmi.Remote;
> +import java.util.Enumeration;
> +import java.util.Hashtable;
> +import java.util.Properties;
> +import java.util.Vector;
>  
>  public class StatefulEJBProvider implements Provider {
> -  public static String CNTXT_PROVIDER_URL = "iiop://localhost:900";
> -  public static String CNTXT_FACTORY_NAME =
> -
> "com.ibm.ejs.ns.jndi.CNInitialContextFactory";
> -  protected boolean isCreate = false;
> -  protected String ejbKey = null;
> -  public static String DELIM_CHAR = "@";
> -
> -  private DeploymentDescriptor dd ;
> -  private Envelope             envelope ;
> -  private Call                 call ;
> -  private String               targetObjectURI ;
> -  private HttpServlet          servlet ;
> -  private HttpSession          session ;
> -
> -  private Context contxt = null;
> -  private Remote remoteObjRef = null;
> -  private String methodName = null;
> -  private Vector methodParameters = null;
> -  private String respEncStyle = null;
> -
> -  /**
> -   * StatefulEJBProvider constructor comment.
> -   */
> -  public StatefulEJBProvider() {
> -    super();
> -  }
> -
> -  public EJBObject deSerialize(String ejbKey) throws SOAPException {
> -    try {
> -      byte[] ejbKeyBytes = Base64.decode(ejbKey);
> -      ByteArrayInputStream byteStream = new
> ByteArrayInputStream(ejbKeyBytes);
> -      ObjectInputStream objStream = new ObjectInputStream(byteStream);
> -      Handle ejbHandle = (Handle)objStream.readObject();
> -      objStream.close();
> -      return ejbHandle.getEJBObject();
> -    } catch (Exception e) {
> -      throw new SOAPException(Constants.FAULT_CODE_SERVER,
> e.toString()) ;
> -    }
> -  }
> -
> -  public Call getCall() {
> -    return call;
> -  }
> -
> -  public Context getContxt() {
> -    return contxt;
> -  }
> -
> -  public DeploymentDescriptor getDd() {
> -    return dd;
> -  }
> -
> -  public String getMethodName() {
> -    return methodName;
> -  }
> -
> -  public Vector getMethodParameters() {
> -    return methodParameters;
> -  }
> -
> -  public Remote getRemoteObjRef() {
> -    return remoteObjRef;
> -  }
> -
> -  public String getRespEncStyle() {
> -    return respEncStyle;
> -  }
> -
> -  public HttpServlet getServlet() {
> -    return servlet;
> -  }
> -
> -  public HttpSession getSession() {
> -    return session;
> -  }
> -
> -  public String getTargetObjectURI() {
> -    return targetObjectURI;
> -  }
> -
> -  public static String getUniqueId(String fullURI) {
> -    int occurance = fullURI.indexOf(DELIM_CHAR);
> -    if (occurance > 0) return fullURI.substring(occurance + 1);
> -    return null;
> -  }
> -
> -  protected void initialize(String url, String factory)
> -    throws SOAPException
> -  {
> -    if (contxt == null)
> -    {
> -      Properties properties = new Properties();
> -
> -      if ((url != null) && (!url.trim().equals("")))
> -      {
> -	properties.put(Context.PROVIDER_URL, url);
> -      }
> -      if ((factory != null) && (!factory.trim().equals("")))
> -      {
> -	properties.put(Context.INITIAL_CONTEXT_FACTORY, factory);
> -      }
> -
> -      try
> -      {
> -        contxt = new InitialContext(properties);
> -      }
> -      catch (NamingException ne)
> -      {
> -        // ErrorListener?
> -	System.out.println("Naming Exception caught during
> InitialContext creation @ " + url);
> -        throw new SOAPException(Constants.FAULT_CODE_SERVER,
> -                                "Unable to initialize context");
> -      }
> -    }
> -  }
> -
> -  public void invoke(SOAPContext reqContext, SOAPContext resContext)
> -                      throws SOAPException {
> -    Parameter ret = null;
> -    Object[] args = null;
> -    Class[] argTypes = null;
> -
> -    respEncStyle = call.getEncodingStyleURI();
> -
> -    if (methodParameters != null) {
> -      int parametersCount = methodParameters.size ();
> -      args = new Object[parametersCount];
> -      argTypes = new Class[parametersCount];
> -
> -      for (int i = 0; i < parametersCount; i++) {
> -        Parameter param = (Parameter) methodParameters.elementAt (i);
> -        args[i] = param.getValue ();
> -        argTypes[i] = param.getType ();
> +    public static String CNTXT_PROVIDER_URL = "iiop://localhost:900";
> +    public static String CNTXT_FACTORY_NAME =
> +            "com.ibm.ejs.ns.jndi.CNInitialContextFactory";
> +    protected boolean isCreate = false;
> +    protected String ejbKey = null;
> +    public static String DELIM_CHAR = "@";
> +
> +    private DeploymentDescriptor dd;
> +    private Envelope envelope;
> +    private Call call;
> +    private String targetObjectURI;
> +    private HttpServlet servlet;
> +    private HttpSession session;
> +
> +    private Context contxt = null;
> +    private Remote remoteObjRef = null;
> +    private String methodName = null;
> +    private Vector methodParameters = null;
> +    private String respEncStyle = null;
> +
> +    /**
> +     * StatefulEJBProvider constructor comment.
> +     */
> +    public StatefulEJBProvider() {
> +        super();
> +    }
> +
> +    public EJBObject deSerialize(String ejbKey) throws SOAPException {
> +        try {
> +            byte[] ejbKeyBytes = Base64.decode(ejbKey);
> +            ByteArrayInputStream byteStream = new
> ByteArrayInputStream(ejbKeyBytes);
> +            ObjectInputStream objStream = new
> ObjectInputStream(byteStream);
> +            Handle ejbHandle = (Handle) objStream.readObject();
> +            objStream.close();
> +            return ejbHandle.getEJBObject();
> +        } catch (Exception e) {
> +            throw new SOAPException(Constants.FAULT_CODE_SERVER,
> e.toString());
> +        }
> +    }
> +
> +    public Call getCall() {
> +        return call;
> +    }
> +
> +    public Context getContxt() {
> +        return contxt;
> +    }
> +
> +    public DeploymentDescriptor getDd() {
> +        return dd;
> +    }
> +
> +    public String getMethodName() {
> +        return methodName;
> +    }
> +
> +    public Vector getMethodParameters() {
> +        return methodParameters;
> +    }
> +
> +    public Remote getRemoteObjRef() {
> +        return remoteObjRef;
> +    }
> +
> +    public String getRespEncStyle() {
> +        return respEncStyle;
> +    }
> +
> +    public HttpServlet getServlet() {
> +        return servlet;
> +    }
> +
> +    public HttpSession getSession() {
> +        return session;
> +    }
> +
> +    public String getTargetObjectURI() {
> +        return targetObjectURI;
> +    }
> +
> +    public static String getUniqueId(String fullURI) {
> +        int occurance = fullURI.indexOf(DELIM_CHAR);
> +        if (occurance > 0) return fullURI.substring(occurance + 1);
> +        return null;
> +    }
> +
> +    protected void initialize(String url, String factory, String
> principal, String credentials)
> +            throws SOAPException {
> +        if (contxt == null) {
> +            Properties properties = new Properties();
> +
> +            if ((url != null) && (!url.trim().equals(""))) {
> +                properties.put(Context.PROVIDER_URL, url);
> +            }
> +            if ((factory != null) && (!factory.trim().equals(""))) {
> +                properties.put(Context.INITIAL_CONTEXT_FACTORY,
> factory);
> +            }
> +            if ((principal != null) && (!principal.trim().equals("")))
> {
> +                properties.put(javax.naming.Context.SECURITY_PRINCIPAL,
> principal);
> +            }
> +            if ((credentials != null) &&
> (!credentials.trim().equals(""))) {
> +
> properties.put(javax.naming.Context.SECURITY_CREDENTIALS, credentials);
> +            }
> +
> +
> +            try {
> +                contxt = new InitialContext(properties);
> +            } catch (NamingException ne) {
> +                // ErrorListener?
> +                System.out.println("Naming Exception caught during
> InitialContext creation @ " + url);
> +                throw new SOAPException(Constants.FAULT_CODE_SERVER,
> +                        "Unable to initialize context");
> +            }
> +        }
> +    }
> +
> +    public void invoke(SOAPContext reqContext, SOAPContext resContext)
> +            throws SOAPException {
> +        Parameter ret = null;
> +        Object[] args = null;
> +        Class[] argTypes = null;
> +
> +        respEncStyle = call.getEncodingStyleURI();
> +
> +        if (methodParameters != null) {
> +            int parametersCount = methodParameters.size();
> +            args = new Object[parametersCount];
> +            argTypes = new Class[parametersCount];
> +
> +            for (int i = 0; i < parametersCount; i++) {
> +                Parameter param = (Parameter)
> methodParameters.elementAt(i);
> +                args[i] = param.getValue();
> +                argTypes[i] = param.getType();
> +
> +                if (respEncStyle == null) {
> +                    respEncStyle = param.getEncodingStyleURI();
> +                }
> +            }
> +        }
>  
>          if (respEncStyle == null) {
> -          respEncStyle = param.getEncodingStyleURI ();
> +            respEncStyle = Constants.NS_URI_SOAP_ENC;
> +        }
> +
> +        try {
> +            Method m = MethodUtils.getMethod(remoteObjRef, methodName,
> argTypes);
> +            Bean result = new Bean(m.getReturnType(),
> +                    m.invoke(remoteObjRef, args));
> +
> +            if (result.type != void.class) {
> +                ret = new Parameter(RPCConstants.ELEM_RETURN,
> result.type,
> +                        result.value, null);
> +            }
> +        } catch (InvocationTargetException e) {
> +            Throwable t = e.getTargetException();
> +            throw new SOAPException(Constants.FAULT_CODE_SERVER,
> t.getMessage(), t);
> +        } catch (Throwable t) {
> +            throw new SOAPException(Constants.FAULT_CODE_SERVER,
> t.getMessage(), t);
> +        }
> +
> +        // once the super.invoke() is done, and no error occurs, the
> handle must be
> +        // serialized and stored.
> +        if (isCreate) {
> +            // The return parameter is an EJBObject (for a create
> method)
> +            //  or an Enumeration (for a find method)
> +            // IF this is an enumeration, we are only going to return
> the first
> +            // element
> +            try {
> +                remoteObjRef = (Remote) ret.getValue();
> +            } catch (ClassCastException cce) {
> +                // Try to cast to an enumeration:
> +                Enumeration enum = (Enumeration) ret.getValue();
> +                remoteObjRef = (Remote) enum.nextElement();
> +            }
> +            // Set the return value to null, so that the remote object
> is not
> +            // included in the response destined for the client.
> +            ret = null;
> +        }
> +
> +        if (ejbKey == null) {
> +            serialize();
> +        }
> +
> +        try {
> +            Response res = new Response(targetObjectURI, // URI
> +                    call.getMethodName(), // Method
> +                    (Parameter) ret, // ReturnValue
> +                    null, // Params
> +                    null, // Header
> +                    respEncStyle, // encoding
> +                    resContext);        // response soapcontext - not
> supported yet
> +            res.setFullTargetObjectURI(targetObjectURI +
> +                    StatefulEJBProvider.DELIM_CHAR + ejbKey);
> +            Envelope env = res.buildEnvelope();
> +            StringWriter sw = new StringWriter();
> +            env.marshall(sw, call.getSOAPMappingRegistry(),
> resContext);
> +            resContext.setRootPart(sw.toString(),
> Constants.HEADERVAL_CONTENT_TYPE_UTF8);
> +        } catch (Exception e) {
> +            if (e instanceof SOAPException) throw (SOAPException) e;
> +            throw new SOAPException(Constants.FAULT_CODE_SERVER,
> e.toString());
> +        }
> +    }
> +
> +    public void locate(DeploymentDescriptor depDesc,
> +                       Envelope env,
> +                       Call origCall,
> +                       String methodName,
> +                       String targURI,
> +                       SOAPContext reqContext)
> +            throws SOAPException {
> +
> +        HttpServlet servletRef = (HttpServlet)
> reqContext.getProperty(Constants.BAG_HTTPSERVLET);
> +        HttpSession sessObj = (HttpSession)
> reqContext.getProperty(Constants.BAG_HTTPSESSION);
> +
> +        dd = depDesc;
> +        envelope = env;
> +        call = origCall;
> +        targetObjectURI = origCall.getTargetObjectURI();
> +        servlet = servletRef;
> +        session = sessObj;
> +
> +        this.methodName = origCall.getMethodName();
> +        methodParameters = origCall.getParams();
> +
> +        // new initialcontext
> +        Hashtable props = dd.getProps();
> +
> +        String ContxtProviderURL = (String)
> props.get("ContextProviderURL");
> +        String ContxtFactoryName = (String)
> props.get("FullContextFactoryName");
> +        String ContxtPrincipal = (String)
> props.get("ContextPrincipal");
> +        String ContxtCredentials = (String)
> props.get("ContextCredentials");
> +
> +
> +        if ((ContxtProviderURL != null) || (ContxtFactoryName != null))
> +            initialize(ContxtProviderURL, ContxtFactoryName,
> ContxtPrincipal, ContxtCredentials);
> +        else
> +            initialize(CNTXT_PROVIDER_URL, CNTXT_FACTORY_NAME, "", "");
> +
> +        // Check if there is a key appended to the URI;
> +        String fullURI = origCall.getFullTargetObjectURI();
> +        ejbKey = StatefulEJBProvider.getUniqueId(fullURI);
> +
> +        if (ejbKey != null) {
> +            remoteObjRef = deSerialize(ejbKey);
> +            // We have obtained the necessary object.
> +            return;
> +        }
> +
> +        String homeInterfaceName = (String)
> props.get("FullHomeInterfaceName");
> +        if (homeInterfaceName == null)
> +            throw new SOAPException(Constants.FAULT_CODE_SERVER, "Error
> in Deployment Descriptor Property Settings");
> +
> +        // From the Deployment Descriptor get the JNDI lookup name that
> is inside
> +        // the "java" element...
> +        String jndiName = (String) props.get("JNDIName");
> +        if (jndiName == null) jndiName = dd.getProviderClass();
> +
> +        if ((jndiName != null) && (contxt != null)) {
> +            try {
> +                // Use service name to locate EJB home object via the
> contxt
> +                EJBHome home = (EJBHome) PortableRemoteObject.narrow(
> +                        contxt.lookup(jndiName),
> +                        Class.forName(homeInterfaceName));
> +
> +                // Must check to see if the create method has any
> parameters associated
> +                // with it.
> +                // There are 2 scenarios:
> +                //              1) if the method name in the call is
> create, then it
> +                //                 will have parameters.
> +                //              2) if the method name in the call is
> not create, and
> +                //                 because no key is associated with
> this call, then
> +                //                 we assume that we can call create
> without any
> +                //                 additional parameters, and prepare
> to invoke the
> +                //                 given method.
> +
> +                if (methodName.equals("create")) {
> +                    // The method is create, so let the invoke method
> deal with it;
> +                    //  just give it the home interface.
> +                    remoteObjRef = home;
> +                    isCreate = true;
> +                    return;
> +                }
> +
> +                // Method name is something other than create - so, the
> invoke command
> +                // has another directive to process; we just perform a
> basic 'create'
> +                // then.
> +                Method createMethod =
> home.getClass().getMethod("create",
> +                        new Class[0]);
> +                remoteObjRef = (EJBObject) createMethod.invoke((Object)
> home,
> +                        new Object[0]);
> +
> +            } catch (Exception e) {
> +                throw new SOAPException(Constants.FAULT_CODE_SERVER,
> +                        "Error in connecting to EJB" + e.toString());
> +            }
> +        }
> +    }
> +
> +    public void serialize() throws SOAPException {
> +        try {
> +            ByteArrayOutputStream biteStream = new
> ByteArrayOutputStream();
> +            ObjectOutputStream objector = new
> ObjectOutputStream(biteStream);
> +            objector.writeObject(((EJBObject)
> remoteObjRef).getHandle());
> +            objector.flush();
> +            objector.close();
> +
> +            ejbKey = Base64.encode(biteStream.toByteArray());
> +        } catch (Exception e) {
> +            throw new SOAPException(Constants.FAULT_CODE_SERVER,
> e.toString());
>          }
> -      }
>      }
>  
> -    if (respEncStyle == null) {
> -      respEncStyle = Constants.NS_URI_SOAP_ENC;
> +    public void setCall(Call newCall) {
> +        call = newCall;
>      }
>  
> -    try {
> -      Method m = MethodUtils.getMethod (remoteObjRef, methodName,
> argTypes);
> -      Bean result = new Bean (m.getReturnType (),
> -                              m.invoke (remoteObjRef, args));
> -
> -      if (result.type != void.class) {
> -        ret = new Parameter (RPCConstants.ELEM_RETURN, result.type,
> -                             result.value, null);
> -      }
> -    } catch (InvocationTargetException e) {
> -      Throwable t = e.getTargetException ();
> -      throw new SOAPException (Constants.FAULT_CODE_SERVER,
> t.getMessage(), t);
> -    } catch (Throwable t) {
> -      throw new SOAPException (Constants.FAULT_CODE_SERVER,
> t.getMessage(), t);
> -    }
> -
> -    // once the super.invoke() is done, and no error occurs, the handle
> must be
> -    // serialized and stored.
> -    if (isCreate) {
> -      // The return parameter is an EJBObject (for a create method)
> -      //  or an Enumeration (for a find method)
> -      // IF this is an enumeration, we are only going to return the
> first
> -      // element
> -      try{
> -        remoteObjRef = (Remote) ret.getValue();
> -      } catch (ClassCastException cce) {
> -        // Try to cast to an enumeration:
> -        Enumeration enum = (Enumeration) ret.getValue();
> -        remoteObjRef = (Remote) enum.nextElement();
> -      }
> -      // Set the return value to null, so that the remote object is not
> -      // included in the response destined for the client.
> -      ret = null;
> -    }
> -
> -    if (ejbKey == null) {
> -      serialize();
> -    }
> -
> -    try {
> -      Response res = new Response( targetObjectURI,            // URI
> -                                   call.getMethodName(),       //
> Method
> -                                   (Parameter) ret,            //
> ReturnValue
> -                                   null,                       //
> Params
> -                                   null,                       //
> Header
> -                                   respEncStyle,               //
> encoding
> -                                   resContext );        // response
> soapcontext - not supported yet
> -      res.setFullTargetObjectURI(targetObjectURI +
> -                                 StatefulEJBProvider.DELIM_CHAR +
> ejbKey);
> -      Envelope env = res.buildEnvelope();
> -      StringWriter  sw = new StringWriter();
> -      env.marshall( sw, call.getSOAPMappingRegistry(), resContext );
> -      resContext.setRootPart( sw.toString(),
> Constants.HEADERVAL_CONTENT_TYPE_UTF8);
> -    }
> -    catch( Exception e ) {
> -      if ( e instanceof SOAPException ) throw (SOAPException ) e ;
> -      throw new SOAPException( Constants.FAULT_CODE_SERVER,
> e.toString() );
> -    }
> -  }
> -
> -  public void locate(DeploymentDescriptor depDesc, 
> -                     Envelope env,
> -                     Call origCall, 
> -                     String methodName ,
> -                     String targURI, 
> -                     SOAPContext reqContext)
> -              throws SOAPException {
> -   
> -    HttpServlet servletRef = (HttpServlet) reqContext.getProperty(
> Constants.BAG_HTTPSERVLET );
> -    HttpSession sessObj    = (HttpSession) reqContext.getProperty(
> Constants.BAG_HTTPSESSION );
> -
> -    dd              = depDesc ;
> -    envelope        = env ;
> -    call            = origCall ;
> -    targetObjectURI = origCall.getTargetObjectURI() ;
> -    servlet         = servletRef ;
> -    session         = sessObj ;
> -
> -    this.methodName = origCall.getMethodName();
> -    methodParameters = origCall.getParams();
> -
> -    // Check if there is a key appended to the URI;
> -    String fullURI = origCall.getFullTargetObjectURI();
> -    ejbKey = StatefulEJBProvider.getUniqueId(fullURI);
> -
> -    if (ejbKey != null) {
> -      remoteObjRef = deSerialize(ejbKey);
> -
> -      // We have obtained the necessary object.
> -      return;
> -    }
> -
> -    Hashtable props = dd.getProps();
> -
> -    String ContxtProviderURL = (String)
> props.get("ContextProviderURL");
> -    String ContxtFactoryName = (String)
> props.get("FullContextFactoryName");
> -
> -    if ((ContxtProviderURL != null) || (ContxtFactoryName != null))
> -      initialize(ContxtProviderURL, ContxtFactoryName);
> -    else
> -      initialize(CNTXT_PROVIDER_URL, CNTXT_FACTORY_NAME);
> -
> -    String homeInterfaceName = (String)
> props.get("FullHomeInterfaceName");
> -    if (homeInterfaceName == null)
> -      throw new SOAPException(Constants.FAULT_CODE_SERVER, "Error in
> Deployment Descriptor Property Settings");
> -
> -    // From the Deployment Descriptor get the JNDI lookup name that is
> inside
> -    // the "java" element...
> -    String jndiName = (String) props.get("JNDIName");
> -    if ( jndiName == null ) jndiName = dd.getProviderClass();
> -
> -    if ((jndiName != null) && (contxt != null)) {
> -      try {
> -        // Use service name to locate EJB home object via the contxt
> -        EJBHome home = (EJBHome) PortableRemoteObject.narrow(
> -                                     contxt.lookup(jndiName),
> -                                     Class.forName(homeInterfaceName));
> -
> -        // Must check to see if the create method has any parameters
> associated
> -        // with it.
> -        // There are 2 scenarios:
> -        //              1) if the method name in the call is create,
> then it
> -        //                 will have parameters.
> -        //              2) if the method name in the call is not
> create, and
> -        //                 because no key is associated with this call,
> then
> -        //                 we assume that we can call create without
> any
> -        //                 additional parameters, and prepare to invoke
> the
> -        //                 given method.
> -
> -        if (methodName.equals("create")) {
> -          // The method is create, so let the invoke method deal with
> it;
> -          //  just give it the home interface.
> -          remoteObjRef = home;
> -          isCreate = true;
> -          return;
> -        }
> -
> -        // Method name is something other than create - so, the invoke
> command
> -        // has another directive to process; we just perform a basic
> 'create'
> -        // then.
> -        Method createMethod = home.getClass().getMethod("create",
> -                                                        new Class[0]);
> -        remoteObjRef = (EJBObject) createMethod.invoke((Object) home,
> -                                                       new Object[0]);
> -
> -      } catch (Exception e) {
> -        throw new SOAPException(Constants.FAULT_CODE_SERVER,
> -                                "Error in connecting to EJB"+
> e.toString());
> -      }
> -    }
> -  }
> -
> -  public void serialize() throws SOAPException {
> -    try {
> -      ByteArrayOutputStream biteStream = new ByteArrayOutputStream();
> -      ObjectOutputStream objector = new ObjectOutputStream(biteStream);
> -      objector.writeObject(((EJBObject)remoteObjRef).getHandle());
> -      objector.flush();
> -      objector.close();
> -
> -      ejbKey = Base64.encode(biteStream.toByteArray());
> -    } catch (Exception e) {
> -      throw new SOAPException(Constants.FAULT_CODE_SERVER,
> e.toString()) ;
> -    }
> -  }
> -
> -  public void setCall(Call newCall) {
> -    call = newCall;
> -  }
> -
> -  public void setContxt(Context newContxt) {
> -    contxt = newContxt;
> -  }
> -
> -  public void setDd(DeploymentDescriptor newDd) {
> -    dd = newDd;
> -  }
> -
> -  public void setMethodName(String newMethodName) {
> -    methodName = newMethodName;
> -  }
> -
> -  public void setMethodParameters(Vector newMethodParameters) {
> -    methodParameters = newMethodParameters;
> -  }
> -
> -  public void setRemoteObjRef(Remote newRemoteObjRef) {
> -    remoteObjRef = newRemoteObjRef;
> -  }
> -
> -  public void setRespEncStyle(String newRespEncStyle) {
> -    respEncStyle = newRespEncStyle;
> -  }
> -
> -  public void setServlet(HttpServlet newServlet) {
> -    servlet = newServlet;
> -  }
> -
> -  public void setSession(HttpSession newSession) {
> -    session = newSession;
> -  }
> -
> -  public void setTargetObjectURI(String newTargetObjectURI) {
> -    targetObjectURI = newTargetObjectURI;
> -  }
> +    public void setContxt(Context newContxt) {
> +        contxt = newContxt;
> +    }
> +
> +    public void setDd(DeploymentDescriptor newDd) {
> +        dd = newDd;
> +    }
> +
> +    public void setMethodName(String newMethodName) {
> +        methodName = newMethodName;
> +    }
> +
> +    public void setMethodParameters(Vector newMethodParameters) {
> +        methodParameters = newMethodParameters;
> +    }
> +
> +    public void setRemoteObjRef(Remote newRemoteObjRef) {
> +        remoteObjRef = newRemoteObjRef;
> +    }
> +
> +    public void setRespEncStyle(String newRespEncStyle) {
> +        respEncStyle = newRespEncStyle;
> +    }
> +
> +    public void setServlet(HttpServlet newServlet) {
> +        servlet = newServlet;
> +    }
> +
> +    public void setSession(HttpSession newSession) {
> +        session = newSession;
> +    }
> +
> +    public void setTargetObjectURI(String newTargetObjectURI) {
> +        targetObjectURI = newTargetObjectURI;
> +    }
>  }
> diff -ruN
> /cygdrive/c/temp/soap-2_3_1/src/org/apache/soap/providers/StatelessEJBPr
> ovider.java src/org/apache/soap/providers/StatelessEJBProvider.java
> ---
> /cygdrive/c/temp/soap-2_3_1/src/org/apache/soap/providers/StatelessEJBPr
> ovider.java	2002-06-10 03:05:06.000000000 +0200
> +++ src/org/apache/soap/providers/StatelessEJBProvider.java
> 2003-02-27 11:22:45.000000000 +0100
> @@ -113,13 +113,13 @@
>  
>  }
>  
> -  private void initialize(String url, String factory)
> +  private void initialize(String url, String factory, String principal,
> String credentials)
>      throws SOAPException
>    {
>      if(contxt == null)
>      {
>        java.util.Properties properties = new java.util.Properties();
> -      
> +
>        if ((url != null) && (!url.trim().equals("")))
>        {
>  	properties.put(javax.naming.Context.PROVIDER_URL, url);
> @@ -128,7 +128,13 @@
>        {
>  	properties.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
> factory);
>        }
> -      
> +        if ((principal != null) && (!principal.trim().equals(""))) {
> +            properties.put(javax.naming.Context.SECURITY_PRINCIPAL,
> principal);
> +        }
> +        if ((credentials != null) && (!credentials.trim().equals("")))
> {
> +            properties.put(javax.naming.Context.SECURITY_CREDENTIALS,
> credentials);
> +        }
> +
>        try
>        {
>  	contxt = new javax.naming.InitialContext(properties);
> @@ -221,11 +227,11 @@
>  /**
>   * locate method comment.
>   */
> -public void locate(DeploymentDescriptor dd, 
> -                   Envelope env, 
> -                   Call call, 
> -                   String methodName, 
> -                   String targetObjectURI, 
> +public void locate(DeploymentDescriptor dd,
> +                   Envelope env,
> +                   Call call,
> +                   String methodName,
> +                   String targetObjectURI,
>                     SOAPContext reqContext)
>                throws org.apache.soap.SOAPException {
>  
> @@ -252,9 +258,11 @@
>  
>          String ContxtProviderURL = (String)
> props.get("ContextProviderURL");
>          String ContxtFactoryName = (String)
> props.get("FullContextFactoryName");
> +        String ContxtPrincipal = (String)
> props.get("ContextPrincipal");
> +        String ContxtCredentials = (String)
> props.get("ContextCredentials");
>  
>          if ((ContxtProviderURL != null) || (ContxtFactoryName != null))
> -                initialize(ContxtProviderURL, ContxtFactoryName);
> +                initialize(ContxtProviderURL, ContxtFactoryName,
> ContxtPrincipal, ContxtCredentials);
>          else
>                  initialize();
>  
> diff -ruN /cygdrive/c/temp/soap-2_3_1/webapps/soap/admin/showdetails.jsp
> webapps/soap/admin/showdetails.jsp
> --- /cygdrive/c/temp/soap-2_3_1/webapps/soap/admin/showdetails.jsp
> 2002-06-10 03:01:04.000000000 +0200
> +++ webapps/soap/admin/showdetails.jsp	2003-03-18 11:18:49.000000000
> +0100
> @@ -110,5 +110,25 @@
>      out.println ("</tr>");
>      out.println("<tr><td>Default Mapping Registry Class</td><td>" +
> (dd.getDefaultSMRClass() != null ? dd.getDefaultSMRClass() : "") +
> "</td></tr>");
>      out.println ("</table>");
> +
> +      %>
> +      <p>Properties</p>
> +      <table border='1' width='100%'>
> +        <tr>
> +          <th>Property Name</p>
> +          <th>Property Value</p>
> +        </tr>
> +      <% for (Iterator i = dd.getProps().keySet().iterator();
> i.hasNext(); ) {
> +            String key = (String) i.next();
> +      %>
> +            <tr>
> +              <td><%= key %></td>
> +              <td><%= dd.getProps().get(key) %></td>
> +            </tr>
> +      <%
> +      }
> +      %>
> +      </table>
> +      <%
>    }
>  %>
> 


Scott Nichol

Do not reply directly to this e-mail address,
as it is filtered to only receive e-mail from
specific mailing lists.



------- End of forwarded message -------
Scott Nichol

Do not reply directly to this e-mail address,
as it is filtered to only receive e-mail from
specific mailing lists.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic