axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Davanum Srinivas <dava...@gmail.com>
Subject Re: svn commit: r168555 - /webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java /webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
Date Fri, 06 May 2005 12:17:43 GMT
Yoohoo!!!!!!!!!! i was waiting for this....a commit from Sanjiva :)

-- dims

On 5/6/05, sanjiva@apache.org <sanjiva@apache.org> wrote:
> Author: sanjiva
> Date: Fri May  6 00:30:43 2005
> New Revision: 168555
> 
> URL: http://svn.apache.org/viewcvs?rev=168555&view=rev
> Log:
> improved operation context
> 
> Modified:
>     webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
>     webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
> 
> Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
> URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java?rev=168555&r1=168554&r2=168555&view=diff
> ==============================================================================
> --- webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
(original)
> +++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContext.java
Fri May  6 00:30:43 2005
> @@ -1,167 +1,204 @@
>  package org.apache.axis.context;
> 
>  /*
> -* Copyright 2004,2005 The Apache Software Foundation.
> -*
> -* Licensed under the Apache License, Version 2.0 (the "License");
> -* you may not use this file except in compliance with the License.
> -* You may obtain a copy of the License at
> -*
> -*      http://www.apache.org/licenses/LICENSE-2.0
> -*
> -* Unless required by applicable law or agreed to in writing, software
> -* distributed under the License is distributed on an "AS IS" BASIS,
> -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> -* See the License for the specific language governing permissions and
> -* limitations under the License.
> -*
> -*
> -*/
> + * Copyright 2004,2005 The Apache Software Foundation.
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License");
> + * you may not use this file except in compliance with the License.
> + * You may obtain a copy of the License at
> + *
> + *      http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing, software
> + * distributed under the License is distributed on an "AS IS" BASIS,
> + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + * See the License for the specific language governing permissions and
> + * limitations under the License.
> + */
> +
> +import java.util.Map;
> 
>  import org.apache.axis.description.AxisOperation;
> +import org.apache.axis.engine.AxisError;
>  import org.apache.axis.engine.AxisFault;
>  import org.apache.wsdl.WSDLConstants;
> 
>  /**
> - * An OperationContext represents a running "instance" of an operation. This
> - * particular implementation of OperationContext supports MEPs which have one
> - * input message and/or one output message. That is, it supports the all the
> - * MEPs that are in the WSDL 2.0 specification.
> + * An OperationContext represents a running "instance" of an operation, which is
> + * represented by an AxisOperation object. This concept is needed to allow
> + * messages to be grouped into operations as in WSDL 2.0-speak operations are
> + * essentially arbitrary message exchange patterns. So as messages are being
> + * exchanged the OperationContext remembers the state of where in the message
> + * exchange pattern it is in.
> + * <p>
> + * OperationContextFactory factory. The base implementation of OperationContext
> + * supports MEPs which have one input message and/or one output message. That
> + * is, it supports the all the MEPs that are in the WSDL 2.0 specification. In
> + * order to support another MEP one must extend this class and register its
> + * creation in the OperationContexFactory.
>   */
> -
>  public class OperationContext extends AbstractContext {
> -
> +       // the in and out messages that may be present
>         private MessageContext inMessageContext;
> -
> +
>         private MessageContext outMessageContext;
> 
> -    private String MepId;
> +       // the AxisOperation of which this is a running instance. The MEP of this
> +       // AxisOperation must be one of the 8 predefined ones in WSDL 2.0.
> +       private AxisOperation axisOperation;
> 
> -    private AxisOperation axisOperation;
> +       private String operationMEP;
> +
> +       private boolean isComplete = false;
> +
> +       // this is the global MessageID -> OperationContext map which is stored in
> +       // the EngineContext. We're caching it here for faster acccess.
> +       private Map operationContextMap;
> +
> +       /**
> +        * Construct a new OperationContext.
> +        *
> +        * @param axisOperation
> +        *            the AxisOperation whose running instances' state this
> +        *            OperationContext represents.
> +        * @param serviceContext
> +        *            the parent ServiceContext representing any state related to
> +        *            the set of all operations of the service.
> +        */
> +       public OperationContext(AxisOperation axisOperation,
> +                       ServiceContext serviceContext) {
> +               super(serviceContext);
> +               this.axisOperation = axisOperation;
> +               this.operationMEP = axisOperation.getMessageExchangePattern();
> +               this.operationContextMap = ((EngineContext) parent.parent)
> +                               .getOperationContextMap();
> +       }
> 
> -    public OperationContext(AxisOperation axisOperation,
> -                            ServiceContext serviceContext) {
> -        super(serviceContext);
> -        this.axisOperation = axisOperation;
> -    }
> -
> -
> -
> -
> -    public void addMessageContext(String messageLabel, MessageContext msgContext)
> -            throws AxisFault {
> -
> -       if(WSDLConstants.MESSAGE_LABLE_IN.equals(messageLabel)){
> -               if(null == this.inMessageContext){
> -                       this.inMessageContext = msgContext;
> -                       this.getServiceContext().getEngineContext().registerOperationContext
> -                                       (msgContext.getMessageID(), this);
> -                       return;
> -               }
> -               throw new AxisFault("Message: messageID "+msgContext.getMessageID()+"
is inconsistent " +
> -                               "with the MEP. MEP does not" +
> -                               " associate with two In Messages");
> -       }else if(WSDLConstants.MESSAGE_LABLE_OUT.equals(messageLabel)){
> -               if(null == this.outMessageContext){
> -                       this.outMessageContext = msgContext;
> -                       this.getServiceContext().getEngineContext().registerOperationContext
> -                                       (msgContext.getMessageID(), this);
> -                       return;
> -               }
> -               throw new AxisFault("Message messageID: "+msgContext.getMessageID()+"
is inconsistent " +
> -                               "with the MEP. MEP does not" +
> -                               " associate with two Out Messages");
> -       }
> -
> -       throw new AxisFault("MessageLable :"+messageLabel+" is not supported in the OperationContext"
+
> -                       " implementation. Only "+WSDLConstants.MESSAGE_LABLE_IN+" and
"+WSDLConstants.MESSAGE_LABLE_OUT+
> -                               " are the only known messageLables of the OperationContext
implemantation");
> -    }
> -
> -    /**
> -     * @return Returns the mepId.
> -     */
> -    public String getMepId() {
> -        return MepId;
> -    }
> -
> -    /**
> -     * @param mepId
> -     *            The mepId to set.
> -     */
> -    public void setMepId(String mepId) {
> -        MepId = mepId;
> -    }
> -
> -    /**
> -     * Chathura, please implement this method to return the last in message of
> -     * the MEP. I want this for addressing - Chinthaka
> -     *
> -     * @return
> -     */
> -    public MessageContext getLastInMessageContext() {
> -        throw new UnsupportedOperationException();
> -
> -    }
> -
> -    /**
> -     * Removes the pointers to this <code>OperationContext</code>
> -     * in the <code>EngineContext</code>'s OperationContextMap so
> -     * that this  <code>OperationContext</code> will eventually get garbage
> -     * collected along with the <code>MessageContext</code>s it
> -     * contain.
> -     * @throws AxisFault If the MEP is not Complete.
> -     */
> -    public void cleanup() throws AxisFault {
> -       if(!this.isComplete()){
> -               throw new AxisFault("Illegal attempt to drop the global " +
> -                               "reference of an incomplete MEPContext");
> -       }
> -
> -       if(null != this.inMessageContext){
> -               this.getServiceContext().getEngineContext().getOperationContextMap().
> -                               remove(this.inMessageContext.getMessageID());
> -       }
> -       if(null != this.outMessageContext){
> -               this.getServiceContext().getEngineContext().getOperationContextMap().
> -                               remove(this.outMessageContext.getMessageID());
> -       }
> -
> -    }
> -
> -
> -    /**
> -     * Checks to see if the MEP is complete. i.e. whether
> -     * all the messages that are associated with the MEP
> -     * has arrived and MEP is complete.
> -     * @return
> -     */
> -    public boolean isComplete() {
> -       if (WSDLConstants.MEP_URI_IN_OUT.equals
> -                               (this.axisOperation.getMessageExchangePattern())
> -                       || WSDLConstants.MEP_URI_OUT_IN.equals
> -                               (this.axisOperation.getMessageExchangePattern())) {
> -                   if (null != this.inMessageContext && null != this.outMessageContext)
> -                       return true;
> -       } else if (WSDLConstants.MEP_URI_IN_ONLY.equals
> -                       (this.axisOperation.getMessageExchangePattern())) {
> -               if (null != this.inMessageContext)
> -                       return true;
> -       } else if(WSDLConstants.MEP_URI_OUT_ONLY.equals
> -                       (this.axisOperation.getMessageExchangePattern())){
> -               if(null != this.outMessageContext)
> -                       return true;
> -       }
> -
> -        return false;
> -    }
> -    public ServiceContext getServiceContext(){
> -        return (ServiceContext)super.parent;
> -    }
>         /**
>          * @return Returns the axisOperation.
>          */
>         public AxisOperation getAxisOperation() {
>                 return axisOperation;
> +       }
> +
> +       /**
> +        * Return the ServiceContext in which this OperationContext lives.
> +        *
> +        * @return parent ServiceContext
> +        */
> +       public ServiceContext getServiceContext() {
> +               return (ServiceContext) parent;
> +       }
> +
> +       /**
> +        * Return the EngineContext in which the parent ServiceContext lives.
> +        *
> +        * @return parent ServiceContext's parent EngineContext
> +        */
> +       public EngineContext getEngineContext() {
> +               return (EngineContext) parent.parent;
> +       }
> +
> +       /**
> +        *
> +        * When a new message is added to the <code>MEPContext</code> the
logic
> +        * should be included remove the MEPContext from the table in the
> +        * <code>EngineContext</code>. Example: IN_IN_OUT At the second IN
> +        * message the MEPContext should be removed from the AxisOperation
> +        *
> +        * @param msgContext
> +        */
> +       public void addMessageContext(MessageContext msgContext) throws AxisFault {
> +               // this needs to store the msgContext in either inMessageContext or
> +               // outMessageContext depending on the MEP of the AxisOperation
> +               // and on the current state of the operation.
> +               if (WSDLConstants.MEP_URI_IN_OUT.equals(operationMEP)
> +                               || WSDLConstants.MEP_URI_IN_OPTIONAL_OUT.equals(operationMEP)
> +                               || WSDLConstants.MEP_URI_ROBUST_IN_ONLY.equals(operationMEP))
{
> +                       if (inMessageContext == null) {
> +                               inMessageContext = msgContext;
> +                       } else {
> +                               outMessageContext = msgContext;
> +                               isComplete = true;
> +                       }
> +               } else if (WSDLConstants.MEP_URI_IN_ONLY.equals(operationMEP)) {
> +                       inMessageContext = msgContext;
> +                       isComplete = true;
> +               } else if (WSDLConstants.MEP_URI_OUT_ONLY.equals(operationMEP)) {
> +                       outMessageContext = msgContext;
> +                       isComplete = true;
> +               } else if (WSDLConstants.MEP_URI_OUT_IN.equals(operationMEP)
> +                               || WSDLConstants.MEP_URI_OUT_OPTIONAL_IN.equals(operationMEP)
> +                               || WSDLConstants.MEP_URI_ROBUST_OUT_ONLY.equals(operationMEP))
{
> +                       if (outMessageContext == null) {
> +                               outMessageContext = msgContext;
> +                       } else {
> +                               inMessageContext = msgContext;
> +                               isComplete = true;
> +                       }
> +               } else {
> +                       // NOT REACHED: the factory created this context incorrectly
> +                       throw new AxisError("Invalid behavior of OperationContextFactory");
> +               }
> +       }
> +
> +       /**
> +        *
> +        * @param messageLabel
> +        * @return
> +        * @throws AxisFault
> +        */
> +       public MessageContext getMessageContext(byte messageLabel) throws AxisFault {
> +               if (messageLabel == WSDLConstants.MESSAGE_LABEL_IN) {
> +                       return inMessageContext;
> +               } else if (messageLabel == WSDLConstants.MESSAGE_LABEL_OUT) {
> +                       return outMessageContext;
> +               } else {
> +                       throw new AxisFault("Unrecognized message label: '" + messageLabel
> +                                       + "'");
> +               }
> +       }
> +
> +       /**
> +        * Returns the last message which came into the OperationContext. This is
> +        * useful for the WS-Addressing module for example to be figure out where to
> +        * get the ReplyTo information etc. from. Note that while its trivial to
> +        * implement this for the MEPs supported by this particular
> +        * OperationContext, a more complicated MEP could require a hairy
> +        * implementation (or may make you bald).
> +        *
> +        * @return the last message coming into the operation.
> +        */
> +       public MessageContext getLastInMessageContext() {
> +               return inMessageContext;
> +       }
> +
> +       /**
> +        * Checks to see if the MEP is complete. i.e. whether all the messages that
> +        * are associated with the MEP has arrived and MEP is complete.
> +        *
> +        * @return
> +        */
> +       public boolean isComplete() {
> +               return isComplete;
> +       }
> +
> +       /**
> +        * Removes the pointers to this <code>OperationContext</code> in
the
> +        * <code>EngineContext</code>'s OperationContextMap so that this
> +        * <code>OperationContext</code> will eventually get garbage collected
> +        * along with the <code>MessageContext</code>'s it contains. Note
that if
> +        * the caller wants to make sure its safe to clean up this OperationContext
> +        * he should call isComplete() first. However, in cases like IN_OPTIONAL_OUT
> +        * and OUT_OPTIONAL_IN, it is possibe this will get called without the MEP
> +        * being complete due to the optional nature of the MEP.
> +        */
> +       public void cleanup() {
> +               if (null != this.inMessageContext) {
> +                       operationContextMap.remove(inMessageContext.getMessageID());
> +               }
> +               if (null != this.outMessageContext) {
> +                       operationContextMap.remove(outMessageContext.getMessageID());
> +               }
>         }
>  }
> 
> Modified: webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
> URL: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java?rev=168555&r1=168554&r2=168555&view=diff
> ==============================================================================
> --- webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
(original)
> +++ webservices/axis/trunk/java/modules/core/src/org/apache/axis/context/OperationContextFactory.java
Fri May  6 00:30:43 2005
> @@ -1,19 +1,19 @@
>  /*
>   * Copyright 2004,2005 The Apache Software Foundation.
> - *
> - * Licensed under the Apache License, Version 2.0 (the "License");
> - * you may not use this file except in compliance with the License.
> - * You may obtain a copy of the License at
> - *
> - *      http://www.apache.org/licenses/LICENSE-2.0
> - *
> + *
> + * Licensed under the Apache License, Version 2.0 (the "License"); you may not
> + * use this file except in compliance with the License. You may obtain a copy of
> + * the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
>   * Unless required by applicable law or agreed to in writing, software
> - * distributed under the License is distributed on an "AS IS" BASIS,
> - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - * See the License for the specific language governing permissions and
> - * limitations under the License.
> - *
> - *  Runtime state of the engine
> + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
> + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
> + * License for the specific language governing permissions and limitations under
> + * the License.
> + *
> + * Runtime state of the engine
>   */
>  package org.apache.axis.context;
> 
> @@ -21,16 +21,24 @@
>  import org.apache.axis.engine.AxisFault;
>  import org.apache.wsdl.WSDLConstants;
> 
> -public class OperationContextFactory implements WSDLConstants{
> -
> -    public static OperationContext createMEP(String mepURI,boolean serverSide,AxisOperation
axisOp,ServiceContext serviceContext) throws AxisFault{
> -        if(MEP_URI_IN_ONLY.equals(mepURI) || MEP_URI_IN_OUT.equals(mepURI)){
> -            return new OperationContext(axisOp,serviceContext);
> -
> -        }else{
> -               throw new AxisFault("Cannot handle the MEP "
> -                               + mepURI+" for the current invocation of Operation ");
> -        }
> -    }
> -
> +public class OperationContextFactory implements WSDLConstants {
> +
> +       public static OperationContext createMEP(String mepURI, boolean serverSide,
> +                       AxisOperation axisOp, ServiceContext serviceContext)
> +                       throws AxisFault {
> +               if (MEP_URI_IN_OUT.equals(mepURI) || MEP_URI_IN_ONLY.equals(mepURI)
> +                               || MEP_URI_IN_OPTIONAL_OUT.equals(mepURI)
> +                               || MEP_URI_ROBUST_IN_ONLY.equals(mepURI)
> +                               || MEP_URI_OUT_ONLY.equals(mepURI)
> +                               || MEP_URI_OUT_IN.equals(mepURI)
> +                               || MEP_URI_OUT_OPTIONAL_IN.equals(mepURI)
> +                               || MEP_URI_ROBUST_OUT_ONLY.equals(mepURI)) {
> +                       return new OperationContext(axisOp, serviceContext);
> +
> +               } else {
> +                       throw new AxisFault("Cannot handle the MEP " + mepURI
> +                                       + " for the current invocation of Operation ");
> +               }
> +       }
> +
>  }
> 
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/

Mime
View raw message