directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r1073170 - in /directory/shared/branches/akarasulu/ldap-extras/codec/src: main/java/org/apache/directory/shared/ldap/extras/ main/java/org/apache/directory/shared/ldap/extras/extended/ main/java/org/apache/directory/shared/ldap/extras/exten...
Date Mon, 21 Feb 2011 22:14:27 GMT
Author: akarasulu
Date: Mon Feb 21 22:14:27 2011
New Revision: 1073170

URL: http://svn.apache.org/viewvc?rev=1073170&view=rev
Log:
DIRSHARED-86: properly implemented the stored procedure plumbing

Added:
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureRequest.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureResponse.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureRequestDecorator.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureResponseDecorator.java
Modified:
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequest.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureResponse.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureFactory.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureGrammar.java
    directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/ExtrasBundleActivator.java Mon Feb 21 22:14:27 2011
@@ -40,7 +40,7 @@ import org.apache.directory.shared.ldap.
 import org.apache.directory.shared.ldap.extras.extended.CancelRequest;
 import org.apache.directory.shared.ldap.extras.extended.CertGenerationRequest;
 import org.apache.directory.shared.ldap.extras.extended.GracefulShutdownRequest;
-import org.apache.directory.shared.ldap.extras.extended.StoredProcedureRequest;
+import org.apache.directory.shared.ldap.extras.extended.IStoredProcedureRequest;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.CancelFactory;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.CertGenerationFactory;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.GracefulDisconnectFactory;
@@ -122,7 +122,7 @@ public class ExtrasBundleActivator imple
         extReqfactory = new GracefulShutdownFactory( codec );
         codec.registerExtendedRequest( extReqfactory );
         
-        extReqfactory = new StoredProcedureFactory();
+        extReqfactory = new StoredProcedureFactory( codec );
         codec.registerExtendedRequest( extReqfactory );
         
         
@@ -153,7 +153,7 @@ public class ExtrasBundleActivator imple
         codec.unregisterExtendedRequest( CancelRequest.EXTENSION_OID );
         codec.unregisterExtendedRequest( CertGenerationRequest.EXTENSION_OID );
         codec.unregisterExtendedRequest( GracefulShutdownRequest.EXTENSION_OID );
-        codec.unregisterExtendedRequest( StoredProcedureRequest.EXTENSION_OID );
+        codec.unregisterExtendedRequest( IStoredProcedureRequest.EXTENSION_OID );
         
         codec.unregisterUnsolicitedResponse( GracefulDisconnectResponse.EXTENSION_OID );
     }

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureRequest.java?rev=1073170&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureRequest.java (added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureRequest.java Mon Feb 21 22:14:27 2011
@@ -0,0 +1,122 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.
+ *
+ */
+package org.apache.directory.shared.ldap.extras.extended;
+
+
+import org.apache.directory.shared.ldap.model.message.ExtendedRequest;
+
+
+/**
+ * An extended operation requesting the server to execute a stored procedure.
+ * 
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface IStoredProcedureRequest extends ExtendedRequest<IStoredProcedureResponse>
+{
+
+    /** The OID for the stored procedure extended operation request. */
+    public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.6";
+
+
+    /**
+     * Gets the language.
+     *
+     * @return the language
+     */
+    String getLanguage();
+
+
+    /**
+     * Sets the language.
+     *
+     * @param language the new language
+     */
+    void setLanguage( String language );
+
+
+    /**
+     * Sets the procedure.
+     *
+     * @param procedure the new procedure
+     */
+    void setProcedure( String procedure );
+
+
+    /**
+     * Gets the procedure specification.
+     *
+     * @return the procedure specification
+     */
+    String getProcedureSpecification();
+
+
+    /**
+     * Size.
+     *
+     * @return the int
+     */
+    int size();
+
+
+    /**
+     * Gets the parameter type.
+     *
+     * @param index the index
+     * @return the parameter type
+     */
+    Object getParameterType( int index );
+
+
+    /**
+     * Gets the java parameter type.
+     *
+     * @param index the index
+     * @return the java parameter type
+     */
+    Class<?> getJavaParameterType( int index );
+
+
+    /**
+     * Gets the parameter value.
+     *
+     * @param index the index
+     * @return the parameter value
+     */
+    Object getParameterValue( int index );
+
+
+    /**
+     * Gets the java parameter value.
+     *
+     * @param index the index
+     * @return the java parameter value
+     */
+    Object getJavaParameterValue( int index );
+
+
+    /**
+     * Adds the parameter.
+     *
+     * @param type the type
+     * @param value the value
+     */
+    void addParameter( Object type, Object value );
+
+}
\ No newline at end of file

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureResponse.java?rev=1073170&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureResponse.java (added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/IStoredProcedureResponse.java Mon Feb 21 22:14:27 2011
@@ -0,0 +1,35 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.
+ *
+ */
+package org.apache.directory.shared.ldap.extras.extended;
+
+
+import org.apache.directory.shared.ldap.model.message.ExtendedResponse;
+
+
+/**
+ * The stored procedure extended operation response.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public interface IStoredProcedureResponse extends ExtendedResponse
+{
+    /** The OID for the stored procedure extended operation response. */
+    String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.7";
+}
\ No newline at end of file

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequest.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequest.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureRequest.java Mon Feb 21 22:14:27 2011
@@ -20,23 +20,14 @@
 package org.apache.directory.shared.ldap.extras.extended;
 
 
-import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.List;
 
-import javax.naming.NamingException;
-import javax.naming.ldap.ExtendedResponse;
-
-import org.apache.directory.shared.asn1.EncoderException;
 import org.apache.directory.shared.i18n.I18n;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedure;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedureContainer;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedureDecoder;
-import org.apache.directory.shared.ldap.model.message.ResultResponse;
+import org.apache.directory.shared.ldap.model.message.AbstractExtendedRequest;
 import org.apache.directory.shared.util.exception.NotImplementedException;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedure.StoredProcedureParameter;
-import org.apache.directory.shared.ldap.model.message.ExtendedRequestImpl;
 import org.apache.directory.shared.util.Strings;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 
 /**
@@ -44,20 +35,18 @@ import org.slf4j.LoggerFactory;
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoredProcedureRequest extends ExtendedRequestImpl
+public class StoredProcedureRequest extends AbstractExtendedRequest<IStoredProcedureResponse> implements IStoredProcedureRequest
 {
-    
-    /** The logger. */
-    private static final Logger LOG = LoggerFactory.getLogger( StoredProcedureRequest.class );
-    
     /** The serialVersionUID. */
     private static final long serialVersionUID = -4682291068700593492L;
     
-    /** The OID for the stored procedure extended operation request. */
-    public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.6";
+    private String language;
 
-    /** The procedure. */
-    private StoredProcedure procedure;
+    private byte[] procedure;
+
+    private List<StoredProcedureParameter> parameters = new ArrayList<StoredProcedureParameter>();
+    
+    private IStoredProcedureResponse response;
 
 
     /**
@@ -69,7 +58,6 @@ public class StoredProcedureRequest exte
     {
         super( messageId );
         this.setRequestName( EXTENSION_OID );
-        this.procedure = new StoredProcedure();
     }
 
 
@@ -79,7 +67,6 @@ public class StoredProcedureRequest exte
     public StoredProcedureRequest()
     {
         this.setRequestName( EXTENSION_OID );
-        this.procedure = new StoredProcedure();
     }
 
 
@@ -94,154 +81,108 @@ public class StoredProcedureRequest exte
     {
         super( messageId );
         this.setRequestName( EXTENSION_OID );
-        this.procedure = new StoredProcedure();
-        this.setLanguage( language );
-        this.setProcedure( procedure );
+        this.language = language;
+        this.procedure = Strings.getBytesUtf8( procedure );
     }
+    
+    
+    // -----------------------------------------------------------------------
+    // Parameters of the Extended Request Payload
+    // -----------------------------------------------------------------------
 
 
     /**
      * {@inheritDoc}
      */
-    public void setRequestValue( byte[] payload )
+    public String getLanguage()
     {
-        StoredProcedureDecoder decoder = new StoredProcedureDecoder();
-        StoredProcedureContainer container = new StoredProcedureContainer();
-
-        try
-        {
-            decoder.decode( ByteBuffer.wrap( payload ), container );
-            this.procedure = container.getStoredProcedure();
-        }
-        catch ( Exception e )
-        {
-            LOG.error( I18n.err( I18n.ERR_04165 ), e );
-            throw new RuntimeException( e );
-        }
+        return language;
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public ExtendedResponse createExtendedResponse( String id, byte[] berValue, int offset, int length )
-        throws NamingException
+    public void setLanguage( String language )
     {
-        StoredProcedureResponse resp = ( StoredProcedureResponse ) getResultResponse();
-        resp.setResponseValue( berValue );
-        resp.setResponseName( id );
-        return resp;
+        this.language = language;
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public byte[] getRequestValue()
+    public byte[] getProcedure()
     {
-        if ( requestValue == null )
+        if ( procedure == null )
         {
-            try
-            {
-                requestValue = procedure.encode().array();
-            }
-            catch ( EncoderException e )
-            {
-                LOG.error( I18n.err( I18n.ERR_04174 ), e );
-                throw new RuntimeException( e );
-            }
+            return null;
         }
 
-        return requestValue;
+        final byte[] copy = new byte[ procedure.length ];
+        System.arraycopy( procedure, 0, copy, 0, procedure.length );
+        return copy;
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
-    public ResultResponse getResultResponse()
+    public void setProcedure( byte[] procedure )
     {
-        if ( response == null )
+        if ( procedure != null )
         {
-            StoredProcedureResponse spr = new StoredProcedureResponse( getMessageId() );
-            spr.setResponseName( EXTENSION_OID );
-            response = spr;
+            this.procedure = new byte[ procedure.length ];
+            System.arraycopy( procedure, 0, this.procedure, 0, procedure.length );
+        } 
+        else 
+        {
+            this.procedure = null;
         }
-
-        return response;
     }
 
 
-    // -----------------------------------------------------------------------
-    // Parameters of the Extended Request Payload
-    // -----------------------------------------------------------------------
-
-    /**
-     * Gets the language.
-     *
-     * @return the language
-     */
-    public String getLanguage()
+    public List<StoredProcedureParameter> getParameters()
     {
-        return procedure.getLanguage();
+        return parameters;
     }
 
 
-    /**
-     * Sets the language.
-     *
-     * @param language the new language
-     */
-    public void setLanguage( String language )
+    public void addParameter( StoredProcedureParameter parameter )
     {
-        this.procedure.setLanguage( language );
+        parameters.add( parameter );
     }
 
 
     /**
-     * Sets the procedure.
-     *
-     * @param procedure the new procedure
+     * {@inheritDoc}
      */
     public void setProcedure( String procedure )
     {
-        this.procedure.setProcedure( Strings.getBytesUtf8(procedure) );
+        this.procedure = Strings.getBytesUtf8( procedure );
     }
 
 
     /**
-     * Gets the procedure specification.
-     *
-     * @return the procedure specification
+     * {@inheritDoc}
      */
     public String getProcedureSpecification()
     {
-        return Strings.utf8ToString(procedure.getProcedure());
+        return Strings.utf8ToString( procedure );
     }
 
 
     /**
-     * Size.
-     *
-     * @return the int
+     * {@inheritDoc}
      */
     public int size()
     {
-        return this.procedure.getParameters().size();
+        return parameters.size();
     }
 
 
     /**
-     * Gets the parameter type.
-     *
-     * @param index the index
-     * @return the parameter type
+     * {@inheritDoc}
      */
     public Object getParameterType( int index )
     {
-        if ( !this.procedure.getLanguage().equals( "java" ) )
+        if ( ! language.equals( "java" ) )
         {
-            return procedure.getParameters().get( index ).getType();
+            return parameters.get( index ).getType();
         }
 
         return getJavaParameterType( index );
@@ -249,10 +190,7 @@ public class StoredProcedureRequest exte
 
 
     /**
-     * Gets the java parameter type.
-     *
-     * @param index the index
-     * @return the java parameter type
+     * {@inheritDoc}
      */
     public Class<?> getJavaParameterType( int index )
     {
@@ -261,16 +199,13 @@ public class StoredProcedureRequest exte
 
 
     /**
-     * Gets the parameter value.
-     *
-     * @param index the index
-     * @return the parameter value
+     * {@inheritDoc}
      */
     public Object getParameterValue( int index )
     {
-        if ( !this.procedure.getLanguage().equals( "java" ) )
+        if ( ! language.equals( "java" ) )
         {
-            return procedure.getParameters().get( index ).getValue();
+            return parameters.get( index ).getValue();
         }
 
         return getJavaParameterValue( index );
@@ -278,10 +213,7 @@ public class StoredProcedureRequest exte
 
 
     /**
-     * Gets the java parameter value.
-     *
-     * @param index the index
-     * @return the java parameter value
+     * {@inheritDoc}
      */
     public Object getJavaParameterValue( int index )
     {
@@ -290,10 +222,7 @@ public class StoredProcedureRequest exte
 
 
     /**
-     * Adds the parameter.
-     *
-     * @param type the type
-     * @param value the value
+     * {@inheritDoc}
      */
     public void addParameter( Object type, Object value )
     {
@@ -317,7 +246,7 @@ public class StoredProcedureRequest exte
         StoredProcedureParameter parameter = new StoredProcedureParameter();
         parameter.setType( ( byte[] ) type );
         parameter.setValue( ( byte[] ) value );
-        this.procedure.addParameter( parameter );
+        parameters.add( parameter );
 
         // below here try to convert parameters to their appropriate byte[] representations
 
@@ -327,4 +256,21 @@ public class StoredProcedureRequest exte
          * throw new NotImplementedException( "conversion of value to java type not implemented" );
          */
     }
+
+
+    @Override
+    /**
+     * {@inheritDoc}
+     */
+    public IStoredProcedureResponse getResultResponse()
+    {
+        if ( response == null )
+        {
+            StoredProcedureResponse spr = new StoredProcedureResponse( getMessageId() );
+            spr.setResponseName( EXTENSION_OID );
+            response = spr;
+        }
+
+        return response;
+    }
 }

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureResponse.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureResponse.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureResponse.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/StoredProcedureResponse.java Mon Feb 21 22:14:27 2011
@@ -29,15 +29,11 @@ import org.apache.directory.shared.ldap.
  * 
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoredProcedureResponse extends ExtendedResponseImpl
+public class StoredProcedureResponse extends ExtendedResponseImpl implements IStoredProcedureResponse
 {
     /** The Constant serialVersionUID. */
     private static final long serialVersionUID = 7689434378578829994L;
 
-    /** The OID for the stored procedure extended operation response. */
-    public static final String EXTENSION_OID = "1.3.6.1.4.1.18060.0.1.7";
-
-
     /**
      * Instantiates a new stored procedure response.
      *

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownFactory.java Mon Feb 21 22:14:27 2011
@@ -61,7 +61,7 @@ public class GracefulShutdownFactory 
      */
     public GracefulShutdownRequest newRequest()
     {
-        return new GracefulShutdownRequestImpl();
+        return new GracefulShutdownRequestDecorator( codec, new GracefulShutdownRequestImpl() );
     }
 
 

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/GracefulShutdownResponseDecorator.java Mon Feb 21 22:14:27 2011
@@ -33,7 +33,7 @@ import org.apache.directory.shared.ldap.
 public class GracefulShutdownResponseDecorator extends ExtendedResponseDecorator<GracefulShutdownResponse> implements GracefulShutdownResponse
 {
     /**
-     * Creates a new instance of CancelResponseDecorator.
+     * Creates a new instance of GracefulShutdownResponseDecorator.
      *
      * @param codec
      * @param decoratedMessage

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedure.java Mon Feb 21 22:14:27 2011
@@ -17,13 +17,11 @@
  *  under the License. 
  *  
  */
-
 package org.apache.directory.shared.ldap.extras.extended.ads_impl;
 
 
 import java.nio.BufferOverflowException;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
@@ -33,6 +31,7 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.asn1.ber.tlv.UniversalTag;
 import org.apache.directory.shared.asn1.ber.tlv.Value;
 import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.extras.extended.StoredProcedureRequest;
 import org.apache.directory.shared.util.Strings;
 
 
@@ -43,11 +42,6 @@ import org.apache.directory.shared.util.
  */
 public class StoredProcedure extends AbstractAsn1Object
 {
-    private String language;
-
-    private byte[] procedure;
-
-    private List<StoredProcedureParameter> parameters = new ArrayList<StoredProcedureParameter>();
 
     private StoredProcedureParameter currentParameter;
     
@@ -66,54 +60,21 @@ public class StoredProcedure extends Abs
     /** The list of all parameter value lengths */
     private List<Integer> paramValueLength;
 
-    public String getLanguage()
-    {
-        return language;
-    }
-
-
-    public void setLanguage( String language )
-    {
-        this.language = language;
-    }
-
-
-    public byte[] getProcedure()
-    {
-        if ( procedure == null )
-        {
-            return null;
-        }
-
-        final byte[] copy = new byte[ procedure.length ];
-        System.arraycopy( procedure, 0, copy, 0, procedure.length );
-        return copy;
-    }
-
-
-    public void setProcedure( byte[] procedure )
-    {
-        if ( procedure != null )
-        {
-            this.procedure = new byte[ procedure.length ];
-            System.arraycopy( procedure, 0, this.procedure, 0, procedure.length );
-        } else {
-            this.procedure = null;
-        }
-    }
-
+    /** The underlying request */
+    private StoredProcedureRequest request;
+    
 
-    public List<StoredProcedureParameter> getParameters()
+    public StoredProcedure( StoredProcedureRequest request )
     {
-        return parameters;
+        this.request = request;
     }
+    
 
-
-    public void addParameter( StoredProcedureParameter parameter )
+    public StoredProcedure()
     {
-        parameters.add( parameter );
+        this.request = new StoredProcedureRequest();
     }
-
+    
 
     public StoredProcedureParameter getCurrentParameter()
     {
@@ -156,7 +117,9 @@ public class StoredProcedure extends Abs
             {
                 this.type = new byte[ type.length ];
                 System.arraycopy( type, 0, this.type, 0, type.length );
-            } else {
+            } 
+            else 
+            {
                 this.type = null;
             }
         }
@@ -181,12 +144,15 @@ public class StoredProcedure extends Abs
             {
                 this.value = new byte[ value.length ];
                 System.arraycopy( value, 0, this.value, 0, value.length );
-            } else {
+            } 
+            else 
+            {
                 this.value = null;
             }
         }
     }
 
+    
     /**
      * Compute the StoredProcedure length 
      * 
@@ -216,23 +182,25 @@ public class StoredProcedure extends Abs
     public int computeLength()
     {
         // The language
-        byte[] languageBytes = Strings.getBytesUtf8(language);
+        byte[] languageBytes = Strings.getBytesUtf8( request.getLanguage() );
         
         int languageLength = 1 + TLV.getNbBytes( languageBytes.length )
             + languageBytes.length;
         
+        byte[] procedure = request.getProcedure();
+        
         // The procedure
         int procedureLength = 1 + TLV.getNbBytes( procedure.length )
             + procedure.length;
         
         // Compute parameters length value
-        if ( parameters != null )
+        if ( request.getParameters() != null )
         {
             parameterLength = new LinkedList<Integer>();
             paramTypeLength = new LinkedList<Integer>();
             paramValueLength = new LinkedList<Integer>();
             
-            for ( StoredProcedureParameter spParam:parameters )
+            for ( StoredProcedureParameter spParam : request.getParameters() )
             {
                 int localParameterLength = 0;
                 int localParamTypeLength = 0;
@@ -274,21 +242,21 @@ public class StoredProcedure extends Abs
             bb.put( TLV.getBytes( storedProcedureLength ) );
 
             // The language
-            Value.encode( bb, language );
+            Value.encode( bb, request.getLanguage() );
 
             // The procedure
-            Value.encode( bb, procedure );
+            Value.encode( bb, request.getProcedure() );
             
             // The parameters sequence
             bb.put( UniversalTag.SEQUENCE.getValue() );
             bb.put( TLV.getBytes( parametersLength ) );
 
             // The parameters list
-            if ( ( parameters != null ) && ( parameters.size() != 0 ) )
+            if ( ( request.getParameters() != null ) && ( request.getParameters().size() != 0 ) )
             {
                 int parameterNumber = 0;
 
-                for ( StoredProcedureParameter spParam:parameters )
+                for ( StoredProcedureParameter spParam : request.getParameters() )
                 {
                     // The parameter sequence
                     bb.put( UniversalTag.SEQUENCE.getValue() );
@@ -326,10 +294,10 @@ public class StoredProcedure extends Abs
         StringBuffer sb = new StringBuffer();
 
         sb.append( "    StoredProcedure\n" );
-        sb.append( "        Language : '" ).append( language ).append( "'\n" );
-        sb.append( "        Procedure\n" ).append( Strings.utf8ToString(procedure) ).append( "'\n" );
+        sb.append( "        Language : '" ).append( request.getLanguage() ).append( "'\n" );
+        sb.append( "        Procedure\n" ).append( request.getProcedureSpecification() ).append( "'\n" );
 
-        if ( ( parameters == null ) || ( parameters.size() == 0 ) )
+        if ( ( request.getParameters() == null ) || ( request.getParameters().size() == 0 ) )
         {
             sb.append( "        No parameters\n" );
         }
@@ -339,7 +307,7 @@ public class StoredProcedure extends Abs
 
             int i = 1;
             
-            for ( StoredProcedureParameter spParam:parameters )
+            for ( StoredProcedureParameter spParam : request.getParameters() )
             {
                 sb.append( "            type[" ).append( i ) .append( "] : '" ).
                     append( Strings.utf8ToString(spParam.type) ).append( "'\n" );
@@ -350,4 +318,76 @@ public class StoredProcedure extends Abs
 
         return sb.toString();
     }
+
+    
+    public String getLanguage()
+    {
+        return request.getLanguage();
+    }
+
+
+    public void setLanguage( String language )
+    {
+        request.setLanguage( language );
+    }
+
+
+    public void setProcedure( String procedure )
+    {
+        request.setProcedure( procedure );
+    }
+
+
+    public void setProcedure( byte[] procedure )
+    {
+        request.setProcedure( procedure );
+    }
+
+
+    public String getProcedureSpecification()
+    {
+        return request.getProcedureSpecification();
+    }
+
+
+    public int size()
+    {
+        return request.size();
+    }
+
+
+    public Object getParameterType( int index )
+    {
+        return request.getParameterType( index );
+    }
+
+
+    public Class<?> getJavaParameterType( int index )
+    {
+        return request.getJavaParameterType( index );
+    }
+
+
+    public Object getParameterValue( int index )
+    {
+        return request.getParameterValue( index );
+    }
+
+
+    public Object getJavaParameterValue( int index )
+    {
+        return request.getJavaParameterValue( index );
+    }
+
+
+    public void addParameter( Object type, Object value )
+    {
+        request.addParameter( type, value );
+    }
+
+
+    public void addParameter( StoredProcedureParameter parameter )
+    {
+        request.addParameter( parameter );
+    }
 }

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureFactory.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureFactory.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureFactory.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureFactory.java Mon Feb 21 22:14:27 2011
@@ -22,6 +22,9 @@ package org.apache.directory.shared.ldap
 
 import org.apache.directory.shared.asn1.DecoderException;
 import org.apache.directory.shared.ldap.codec.api.ExtendedRequestFactory;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.extras.extended.IStoredProcedureRequest;
+import org.apache.directory.shared.ldap.extras.extended.IStoredProcedureResponse;
 import org.apache.directory.shared.ldap.extras.extended.StoredProcedureRequest;
 import org.apache.directory.shared.ldap.extras.extended.StoredProcedureResponse;
 
@@ -32,32 +35,46 @@ import org.apache.directory.shared.ldap.
  *
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  */
-public class StoredProcedureFactory implements ExtendedRequestFactory<StoredProcedureRequest, StoredProcedureResponse>
+public class StoredProcedureFactory implements ExtendedRequestFactory<IStoredProcedureRequest, IStoredProcedureResponse>
 {
+    private LdapCodecService codec;
+    
+    
+    /**
+     * Creates a new instance of StoredProcedureFactory.
+     *
+     * @param codec
+     */
+    public StoredProcedureFactory( LdapCodecService codec )
+    {
+        this.codec = codec;
+    }
+    
+    
     /**
      * {@inheritDoc}
      */
     public String getOid()
     {
-        return StoredProcedureRequest.EXTENSION_OID;
+        return IStoredProcedureRequest.EXTENSION_OID;
     }
 
     
     /**
      * {@inheritDoc}
      */
-    public StoredProcedureRequest newRequest()
+    public IStoredProcedureRequest newRequest()
     {
-        return new StoredProcedureRequest();
+        return new StoredProcedureRequestDecorator( codec, new StoredProcedureRequest() );
     }
 
 
     /**
      * {@inheritDoc}
      */
-    public StoredProcedureResponse newResponse( byte[] encodedValue ) throws DecoderException
+    public IStoredProcedureResponse newResponse( byte[] encodedValue ) throws DecoderException
     {
-        StoredProcedureResponse response = new StoredProcedureResponse();
+        StoredProcedureResponseDecorator response = new StoredProcedureResponseDecorator( codec, new StoredProcedureResponse() );
         response.setResponseValue( encodedValue );
         return response;
     }

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureGrammar.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureGrammar.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureGrammar.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureGrammar.java Mon Feb 21 22:14:27 2011
@@ -149,7 +149,7 @@ public final class StoredProcedureGramma
 
                     if ( LOG.isDebugEnabled() )
                     {
-                        LOG.debug( "Procedure found : " + Strings.utf8ToString(storedProcedure.getProcedure()) );
+                        LOG.debug( "Procedure found : " + storedProcedure.getProcedureSpecification() );
                     }
                 }
             } );

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureRequestDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureRequestDecorator.java?rev=1073170&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureRequestDecorator.java (added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureRequestDecorator.java Mon Feb 21 22:14:27 2011
@@ -0,0 +1,188 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.
+ *
+ */
+package org.apache.directory.shared.ldap.extras.extended.ads_impl;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.directory.shared.asn1.EncoderException;
+import org.apache.directory.shared.i18n.I18n;
+import org.apache.directory.shared.ldap.codec.api.ExtendedRequestDecorator;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.extras.extended.IStoredProcedureRequest;
+import org.apache.directory.shared.ldap.extras.extended.IStoredProcedureResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * A Decorator for stored procedure extended operation requests.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureRequestDecorator 
+    extends ExtendedRequestDecorator<IStoredProcedureRequest,IStoredProcedureResponse> 
+    implements IStoredProcedureRequest
+{
+    private static final Logger LOG = LoggerFactory.getLogger( StoredProcedureRequestDecorator.class );
+
+    private StoredProcedure procedure;
+    
+    
+    public StoredProcedureRequestDecorator( LdapCodecService codec, IStoredProcedureRequest decoratedMessage )
+    {
+        super( codec, decoratedMessage );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setRequestValue( byte[] payload )
+    {
+        StoredProcedureDecoder decoder = new StoredProcedureDecoder();
+        StoredProcedureContainer container = new StoredProcedureContainer();
+
+        try
+        {
+            decoder.decode( ByteBuffer.wrap( payload ), container );
+            this.procedure = container.getStoredProcedure();
+        }
+        catch ( Exception e )
+        {
+            LOG.error( I18n.err( I18n.ERR_04165 ), e );
+            throw new RuntimeException( e );
+        }
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public byte[] getRequestValue()
+    {
+        if ( requestValue == null )
+        {
+            try
+            {
+                requestValue = procedure.encode().array();
+            }
+            catch ( EncoderException e )
+            {
+                LOG.error( I18n.err( I18n.ERR_04174 ), e );
+                throw new RuntimeException( e );
+            }
+        }
+
+        return requestValue;
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getLanguage()
+    {
+        return getDecorated().getLanguage();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setLanguage( String language )
+    {
+        getDecorated().setLanguage( language );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void setProcedure( String procedure )
+    {
+        getDecorated().setProcedure( procedure );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getProcedureSpecification()
+    {
+        return getDecorated().getProcedureSpecification();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public int size()
+    {
+        return getDecorated().size();
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object getParameterType( int index )
+    {
+        return getDecorated().getParameterType( index );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+
+    public Class<?> getJavaParameterType( int index )
+    {
+        return getDecorated().getJavaParameterType( index );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+
+    public Object getParameterValue( int index )
+    {
+        return getDecorated().getParameterValue( index );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public Object getJavaParameterValue( int index )
+    {
+        return getDecorated().getJavaParameterValue( index );
+    }
+
+
+    /**
+     * {@inheritDoc}
+     */
+    public void addParameter( Object type, Object value )
+    {
+        getDecorated().addParameter( type, value );
+    }
+}

Added: directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureResponseDecorator.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureResponseDecorator.java?rev=1073170&view=auto
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureResponseDecorator.java (added)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/main/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureResponseDecorator.java Mon Feb 21 22:14:27 2011
@@ -0,0 +1,45 @@
+/*
+ *   Licensed to the Apache Software Foundation (ASF) under one
+ *   or more contributor license agreements.  See the NOTICE file
+ *   distributed with this work for additional information
+ *   regarding copyright ownership.  The ASF licenses this file
+ *   to you 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.
+ *
+ */
+package org.apache.directory.shared.ldap.extras.extended.ads_impl;
+
+
+import org.apache.directory.shared.ldap.codec.api.ExtendedResponseDecorator;
+import org.apache.directory.shared.ldap.codec.api.LdapCodecService;
+import org.apache.directory.shared.ldap.extras.extended.IStoredProcedureResponse;
+
+
+/**
+ * A Decorator for CancelResponses.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ */
+public class StoredProcedureResponseDecorator extends ExtendedResponseDecorator<IStoredProcedureResponse> implements IStoredProcedureResponse
+{
+    /**
+     * Creates a new instance of CancelResponseDecorator.
+     *
+     * @param codec
+     * @param decoratedMessage
+     */
+    public StoredProcedureResponseDecorator( LdapCodecService codec, IStoredProcedureResponse decoratedMessage )
+    {
+        super( codec, decoratedMessage );
+    }
+}

Modified: directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java
URL: http://svn.apache.org/viewvc/directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java?rev=1073170&r1=1073169&r2=1073170&view=diff
==============================================================================
--- directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java (original)
+++ directory/shared/branches/akarasulu/ldap-extras/codec/src/test/java/org/apache/directory/shared/ldap/extras/extended/ads_impl/StoredProcedureTest.java Mon Feb 21 22:14:27 2011
@@ -33,7 +33,6 @@ import org.apache.directory.shared.asn1.
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedure;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedureContainer;
 import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedureDecoder;
-import org.apache.directory.shared.ldap.extras.extended.ads_impl.StoredProcedure.StoredProcedureParameter;
 import org.apache.directory.shared.util.Strings;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -96,32 +95,24 @@ public class StoredProcedureTest
 
         assertEquals("Java", storedProcedure.getLanguage());
         
-        assertEquals( "execute", Strings.utf8ToString(storedProcedure.getProcedure()) );
+        assertEquals( "execute", storedProcedure.getProcedureSpecification() );
 
-        assertEquals( 3, storedProcedure.getParameters().size() );
+        assertEquals( 3, storedProcedure.size() );
 
-        StoredProcedureParameter param = storedProcedure.getParameters().get( 0 );
+        assertEquals( "int", storedProcedure.getParameterType( 0 ) );
+        assertEquals( 1, storedProcedure.getParameterValue( 0 ) );
 
-        assertEquals( "int", Strings.utf8ToString(param.getType()) );
-        assertEquals( 1, param.getValue()[0] );
+        assertEquals( "boolean", storedProcedure.getParameterType( 1 ) );
+        assertEquals( "true", storedProcedure.getParameterValue( 1 ) );
 
-        param = storedProcedure.getParameters().get( 1 );
-
-        assertEquals( "boolean", Strings.utf8ToString(param.getType()) );
-        assertEquals( "true", Strings.utf8ToString(param.getValue()) );
-
-        param = storedProcedure.getParameters().get( 2 );
-
-        assertEquals( "String", Strings.utf8ToString(param.getType()) );
-        assertEquals( "parameter3", Strings.utf8ToString(param.getValue()) );
+        assertEquals( "String", storedProcedure.getParameterType( 2 ) );
+        assertEquals( "parameter3", storedProcedure.getParameterValue( 2 ) );
 
         // Check the encoding
         try
         {
             ByteBuffer bb = storedProcedure.encode();
-
-            String encodedPdu = Strings.dumpBytes(bb.array());
-
+            String encodedPdu = Strings.dumpBytes( bb.array() );
             assertEquals( encodedPdu, decodedPdu );
         }
         catch ( EncoderException ee )
@@ -167,9 +158,9 @@ public class StoredProcedureTest
 
         assertEquals("Java", storedProcedure.getLanguage());
         
-        assertEquals( "execute", Strings.utf8ToString(storedProcedure.getProcedure()) );
+        assertEquals( "execute", storedProcedure.getProcedureSpecification() );
 
-        assertEquals( 0, storedProcedure.getParameters().size() );
+        assertEquals( 0, storedProcedure.size() );
         
         // Check the encoding
         try
@@ -227,14 +218,12 @@ public class StoredProcedureTest
 
         assertEquals("Java", storedProcedure.getLanguage());
         
-        assertEquals( "execute", Strings.utf8ToString(storedProcedure.getProcedure()) );
-
-        assertEquals( 1, storedProcedure.getParameters().size() );
+        assertEquals( "execute", storedProcedure.getProcedureSpecification() );
 
-        StoredProcedureParameter param = storedProcedure.getParameters().get( 0 );
+        assertEquals( 1, storedProcedure.size() );
 
-        assertEquals( "int", Strings.utf8ToString(param.getType()) );
-        assertEquals( 1, param.getValue()[0] );
+        assertEquals( "int", storedProcedure.getParameterType( 0 ) );
+        assertEquals( 1, storedProcedure.getParameterValue( 0 ) );
 
         // Check the encoding
         try



Mime
View raw message