You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by ka...@apache.org on 2011/03/27 14:17:00 UTC
svn commit: r1085919 - in
/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2:
Dsmlv2Parser.java request/BatchRequestDsml.java
Author: kayyagari
Date: Sun Mar 27 12:17:00 2011
New Revision: 1085919
URL: http://svn.apache.org/viewvc?rev=1085919&view=rev
Log:
o added support for parsing large DSML batchrequests
Modified:
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java
directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BatchRequestDsml.java
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java?rev=1085919&r1=1085918&r2=1085919&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/Dsmlv2Parser.java Sun Mar 27 12:17:00 2011
@@ -38,7 +38,7 @@ import org.xmlpull.v1.XmlPullParserFacto
/**
* This class represents the DSMLv2 Parser.
- * It can be used to parse a DSMLv2 Request input.
+ * It can be used to parse a plain DSMLv2 Request input document or the one inside a SOAP envelop.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
@@ -46,6 +46,13 @@ public class Dsmlv2Parser
{
/** The associated DSMLv2 container */
private Dsmlv2Container container;
+
+ /**
+ * flag to indicate if the batch request should maintain a list of all the
+ * operation request objects present in the DSML document. Default is true
+ */
+ private boolean storeMsgInBatchReq = true;
+
/** The thread safe DSMLv2 Grammar */
private Dsmlv2Grammar grammar;
@@ -57,6 +64,41 @@ public class Dsmlv2Parser
* @throws XmlPullParserException
* if an error occurs while the initialization of the parser
*/
+ public Dsmlv2Parser() throws XmlPullParserException
+ {
+ this( true );
+ }
+
+ /**
+ *
+ * Creates a new instance of Dsmlv2Parser.
+ *
+ * @param storeMsgInBatchReq flag to set if the parsed requests should b stored
+ * @throws XmlPullParserException
+ */
+ public Dsmlv2Parser( boolean storeMsgInBatchReq ) throws XmlPullParserException
+ {
+ this.storeMsgInBatchReq = storeMsgInBatchReq;
+
+ this.grammar = new Dsmlv2Grammar();
+ this.container = new Dsmlv2Container( grammar.getLdapCodecService() );
+
+ this.container.setGrammar( grammar );
+
+ XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
+ factory.setNamespaceAware( true );
+ XmlPullParser xpp = factory.newPullParser();
+
+ container.setParser( xpp );
+ }
+
+
+ /**
+ * Creates a new instance of Dsmlv2Parser.
+ *
+ * @throws XmlPullParserException
+ * if an error occurs while the initialization of the parser
+ */
public Dsmlv2Parser( Dsmlv2Grammar grammar ) throws XmlPullParserException
{
this.container = new Dsmlv2Container( grammar.getLdapCodecService() );
@@ -120,7 +162,7 @@ public class Dsmlv2Parser
/**
* Launches the parsing on the input
- *
+ * This method will parse the whole DSML document, without considering the flag {@link #storeMsgInBatchReq}
* @throws XmlPullParserException
* when an unrecoverable error occurs
* @throws IOException
@@ -171,6 +213,13 @@ public class Dsmlv2Parser
}
}
while ( container.getState() != Dsmlv2StatesEnum.BATCHREQUEST_START_TAG );
+
+ BatchRequestDsml br = container.getBatchRequest();
+
+ if ( br != null )
+ {
+ br.setStoreReq( storeMsgInBatchReq );
+ }
}
Modified: directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BatchRequestDsml.java
URL: http://svn.apache.org/viewvc/directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BatchRequestDsml.java?rev=1085919&r1=1085918&r2=1085919&view=diff
==============================================================================
--- directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BatchRequestDsml.java (original)
+++ directory/shared/trunk/dsml/parser/src/main/java/org/apache/directory/shared/dsmlv2/request/BatchRequestDsml.java Sun Mar 27 12:17:00 2011
@@ -97,6 +97,14 @@ public class BatchRequestDsml
/**
+ * flag to indicate to store the request objects present in
+ * this batch request. Default is true
+ */
+ private boolean storeReq = true;
+
+ private DsmlDecorator currentReq;
+
+ /**
* Creates a new instance of BatchResponseDsml.
*/
public BatchRequestDsml()
@@ -116,7 +124,7 @@ public class BatchRequestDsml
*/
public DsmlDecorator<? extends Request> getCurrentRequest()
{
- return requests.get( requests.size() - 1 );
+ return currentReq;
}
@@ -130,7 +138,16 @@ public class BatchRequestDsml
*/
public boolean addRequest( DsmlDecorator<? extends Request> request )
{
- return requests.add( request );
+ currentReq = request;
+
+ if ( storeReq )
+ {
+ return requests.add( request );
+ }
+ else
+ {
+ return true;
+ }
}
@@ -300,6 +317,29 @@ public class BatchRequestDsml
/**
+ * @return true if the request objects are stored, false otherwise
+ */
+ public boolean isStoringRequests()
+ {
+ return storeReq;
+ }
+
+
+ /**
+ * set the storeReq flag to turn on/off storing of request objects
+ *
+ * Note: it is better to set this flag to false while processing large DSML
+ * batch requests
+ *
+ * @param storeReq
+ */
+ public void setStoreReq( boolean storeReq )
+ {
+ this.storeReq = storeReq;
+ }
+
+
+ /**
* {@inheritDoc}
*/
@Override