lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r425538 [1/4] - in /lucene/java/trunk: ./ contrib/gdata-server/ contrib/gdata-server/src/java/org/apache/lucene/gdata/data/ contrib/gdata-server/src/java/org/apache/lucene/gdata/server/ contrib/gdata-server/src/java/org/apache/lucene/gdata/...
Date Tue, 25 Jul 2006 22:23:06 GMT
Author: yonik
Date: Tue Jul 25 15:23:01 2006
New Revision: 425538

URL: http://svn.apache.org/viewvc?rev=425538&view=rev
Log:
gdata update

Added:
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataRequestListener.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/Scope.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitable.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitor.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/ModificationConflictException.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/ConcurrentStorageLock.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/SingleHostConcurrentStorageLock.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/utils/Pool.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/utils/PoolObjectFactory.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/utils/SimpleObjectPool.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/utils/SimpleSaxErrorHandler.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/gdata-account.xsd   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/StorageCoreControllerStub.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/StorageQueryStub.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestSingelHostConcurrencyLock.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageBuffer.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageImplementation.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/MultiThreadEntryStub.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestSimpleObjectPool.java   (with props)
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/Visitor.java   (with props)
    lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xsd   (with props)
Modified:
    lucene/java/trunk/common-build.xml
    lucene/java/trunk/contrib/gdata-server/build.xml
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/GDataAccount.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/ServerBaseEntry.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataRequest.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataResponse.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/authentication/BlowfishAuthenticationController.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DeleteFeedHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/InsertFeedHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/RequestAuthenticator.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/UpdateFeedHandler.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/IDGenerator.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/Storage.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageController.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/StorageException.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageBuffer.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageCoreController.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageEntryWrapper.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageImplementation.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageModifier.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/StorageQuery.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/recover/RecoverController.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/recover/RecoverException.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/recover/RecoverReader.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/storage/lucenestorage/recover/RecoverWriter.java
    lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/utils/DateFormater.java
    lucene/java/trunk/contrib/gdata-server/src/test/gdata-config.xml
    lucene/java/trunk/contrib/gdata-server/src/test/lucenestorage.properties.xml
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/data/TestGDataUser.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/server/TestGDataRequest.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/server/administration/TestAccountBuilder.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/server/authentication/TestBlowfishAuthenticationController.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/server/registry/TestFeedRegistry.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/servlet/handler/TestAbstractFeedHandler.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/TestIDGenerator.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/StorageModifierStub.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageModifier.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/TestStorageQuery.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRecoverController.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/storage/lucenestorage/recover/TestRevocerReader.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/ProvidedServiceStub.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageControllerStub.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/StorageStub.java
    lucene/java/trunk/contrib/gdata-server/src/test/org/apache/lucene/gdata/utils/TestDateFormater.java
    lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/gdata-config.xml
    lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/classes/lucenestorage.properties.xml
    lucene/java/trunk/contrib/gdata-server/webroot/WEB-INF/web.xml

Modified: lucene/java/trunk/common-build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/common-build.xml?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/common-build.xml (original)
+++ lucene/java/trunk/common-build.xml Tue Jul 25 15:23:01 2006
@@ -43,6 +43,7 @@
   <property name="junit.output.dir" location="${build.dir}/test"/>
   <property name="junit.reports" location="${build.dir}/test/reports"/>
   <property name="junit.includes" value="**/Test*.java,**/*Test.java"/>
+  <property name="junit.excludes" value=""/>
 
   <available
     property="javacc.present"
@@ -179,7 +180,7 @@
       <formatter type="xml"/>
       <formatter type="brief" usefile="false"/>
       <batchtest fork="yes" todir="${junit.output.dir}" unless="testcase">
-        <fileset dir="src/test" includes="${junit.includes}"/>
+        <fileset dir="src/test" includes="${junit.includes}" excludes="${junit.excludes}"/>
       </batchtest>
       <batchtest fork="yes" todir="${junit.output.dir}" if="testcase">
         <fileset dir="src/test" includes="**/${testcase}.java"/>

Modified: lucene/java/trunk/contrib/gdata-server/build.xml
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/build.xml?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/build.xml (original)
+++ lucene/java/trunk/contrib/gdata-server/build.xml Tue Jul 25 15:23:01 2006
@@ -1,58 +1,84 @@
 <?xml version="1.0"?> 
- 
-<project name="gdata-server" default="default"> 
- 
-    <description> 
-    Serverside Google Data API implementation 
-  </description> 
-     
-    <property name="gdata.war.name" value="gdata-server"/> 
-    <property name="gdata.lib.dir" value="lib"/> 
-     
-    <path id="additional.dependencies"> 
-        <pathelement location="lib/servlet-api.jar" /> 
-        <!-- easymock version 1.2 for java 1.3 --> 
-        <pathelement location="lib/easymock.jar" /> 
-        <pathelement location="lib/gdata-client-1.0.jar" /> 
-        <pathelement location="lib/commons-logging-1.1.jar" /> 
-        <pathelement location="lib/commons-jxpath-1.2.jar" /> 
-        <pathelement location="lib/commons-digester-1.7.jar" /> 
-        <pathelement location="lib/commons-beanutils.jar" /> 
-        <pathelement location="lib/commons-collections-3.2.jar" /> 
 
-  
-         
-         
+<project name="gdata-server" default="default" > 
+    <description>  
+        Serverside Google Data API implementation  
+    </description> 
+    <property name="javac.source" value="1.5" /> 
+    <property name="javac.target" value="1.5" /> 
+    <property name="gdata.war.name" value="gdata-server" /> 
+    <property name="gdata.lib.dir" value="lib" /> 
+    <property name="db4o.jar" value="db4o-5.2-java5.jar" /> 
+    <!-- set property for third party jars --> 
+    <available property="db4o.jar.present" type="file" file="${gdata.lib.dir}/${db4o.jar}" value="test"/> 
+    <condition property="junit.excludes" value="**/TestDb4o*.java"> 
+        <not> 
+            <isset property="db4o.jar.present"/> 
+        </not> 
+    </condition> 
+    <path id="additional.dependencies"> 
+        <fileset dir="${gdata.lib.dir}"> 
+            <include name="easymock.jar" /> 
+            <include name="servlet-api.jar" /> 
+            <include name="commons-logging-1.1.jar" /> 
+            <include name="gdata-client-1.0.jar" /> 
+            <include name="commons-digester-1.7.jar" /> 
+            <include name="commons-beanutils.jar" /> 
+            <include name="commons-collections-3.2.jar" /> 
+            <include name="${db4o.jar}" if="db4o.jar.present" /> 
+        </fileset> 
     </path> 
-     
+
+    <!-- redefine compile-core and compile-test to exclude 3rd party dependend sources --> 
+    <target name="compile-core" depends="init"> 
+        <echo>Use gdata - compile-core task </echo> 
+        <compile srcdir="src/java" destdir="${build.dir}/classes/java"> 
+            <classpath refid="classpath" /> 
+            <exclude name="org/apache/lucene/gdata/storage/db4o/**" unless="db4o.jar.present" /> 
+        </compile> 
+
+    </target> 
  
-    <pathconvert property="project.classpath" targetos="unix" refid="additional.dependencies" /> 
+    <target name="compile-test" depends="compile-core"> 
+        <echo>Use gdata - compile-test task </echo> 
+        <compile srcdir="src/test" destdir="${build.dir}/classes/test"> 
+            <classpath refid="test.classpath" /> 
+            <exclude name="org/apache/lucene/gdata/storage/db4o/**" unless="db4o.jar.present" /> 
+        </compile> 
+        <copy todir="${build.dir}/classes/test"> 
+            <fileset dir="src/test" excludes="**/*.java" /> 
+        </copy> 
+    </target> 
  
-       <property name="javac.source" value="1.5"/> 
-       <property name="javac.target" value="1.5"/> 
+    <pathconvert property="project.classpath" targetos="unix" refid="additional.dependencies" /> 
     <import file="../contrib-build.xml" /> 
  
     <target name="prepare-dist" depends="jar-core"> 
         <echo>Prepare dist directory</echo> 
-        <delete dir="${dist.dir}"/> 
-        <mkdir dir="${dist.dir}"/> 
+        <delete dir="${dist.dir}" /> 
+        <mkdir dir="${dist.dir}" /> 
     </target> 
-     <target name="war-gdata" depends="prepare-dist"> 
-         <echo>Distributing GData War </echo> 
-        <war destfile="${dist.dir}/${gdata.war.name}.war" 
-             webxml="webroot/WEB-INF/web.xml" > 
-        	<metainf dir="webroot/meta-inf"/>
-        		
-
-        <fileset dir="webroot" excludes="WEB-INF/web.xml"/> 
-            <lib dir="${gdata.lib.dir}" includes="commons-logging-1.1.jar"/> 
-            <lib dir="${gdata.lib.dir}" includes="gdata-client-1.0.jar"/> 
-        	<lib dir="${gdata.lib.dir}" includes="commons-digester-1.7.jar" /> 
-        	<lib dir="${gdata.lib.dir}" includes="commons-beanutils.jar" /> 
-        	<lib dir="${gdata.lib.dir}" includes="commons-collections-3.2.jar" /> 
-        <lib dir="${build.dir}" includes="${final.name}.jar"/> 
-        <lib file="${lucene.jar}" /> 
+ 
+    <target name="war-gdata" depends="prepare-dist"> 
+        <echo>Distributing GData War </echo> 
+        <war destfile="${dist.dir}/${gdata.war.name}.war" webxml="webroot/WEB-INF/web.xml"> 
+            <metainf dir="webroot/meta-inf" /> 
+            <fileset dir="webroot" defaultexcludes="true"> 
+                <exclude name="meta-inf/context.xml" /> 
+                <exclude name="meta-inf/" /> 
+                <exclude name="WEB-INF/web.xml" /> 
+            </fileset> 
+            <lib dir="${gdata.lib.dir}"> 
+                <include name="commons-logging-1.1.jar" /> 
+                <include name="gdata-client-1.0.jar" /> 
+                <include name="commons-digester-1.7.jar" /> 
+                <include name="commons-beanutils.jar" /> 
+                <include name="commons-collections-3.2.jar" /> 
+                <include name="${db4o.jar}" if="db4o.jar.present" /> 
+            </lib> 
+            <lib dir="${build.dir}" includes="${final.name}.jar" /> 
+            <lib file="${lucene.jar}" /> 
         </war> 
-      </target> 
-
+    </target> 
+ 
 </project> 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/GDataAccount.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/GDataAccount.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/GDataAccount.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/GDataAccount.java Tue Jul 25 15:23:01 2006
@@ -226,9 +226,11 @@
      * @see java.lang.Object#equals(java.lang.Object)
      */
     public boolean equals(Object o) {
+        if(o == null)
+            return false;
         if (this == o)
             return true;
-        if (!(o instanceof GDataAccount) || o == null)
+        if (!(o instanceof GDataAccount))
             return false;
         GDataAccount toCompare = (GDataAccount) o;
         if (this.name.equals(toCompare.name))
@@ -301,6 +303,8 @@
         retVal.setRole(AccountRole.ENTRYAMINISTRATOR);
         return retVal;
     }
+    
+
 
     /**
      * This enum respesents all account roles an account can have.

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/ServerBaseEntry.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/ServerBaseEntry.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/ServerBaseEntry.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/data/ServerBaseEntry.java Tue Jul 25 15:23:01 2006
@@ -66,7 +66,8 @@
 
     private ProvidedService serviceConfig;
     private BaseEntry entry;
-    
+    private static final int DEFAULTVERSION = 1;
+    private int version;
 
     
    
@@ -100,8 +101,8 @@
      */
     @SuppressWarnings("unchecked")
     public ServerBaseEntry() {
+        this(new Entry());
         
-        this.entry = new Entry();
     }
 
     /**
@@ -110,7 +111,7 @@
     @SuppressWarnings("unchecked")
     public ServerBaseEntry(BaseEntry arg0) {
         this.entry = arg0;
-
+        this.setVersion(DEFAULTVERSION);
     }
 
 
@@ -612,6 +613,23 @@
     
     public void declareExtensions(ExtensionProfile arg0) {
         this.entry.declareExtensions(arg0);
+    }
+
+    /**
+     * @return Returns the version.
+     */
+    public int getVersion() {
+        return this.version;
+    }
+
+    /**
+     * @param version The version to set.
+     */
+    public void setVersion(int version) {
+        if(version < this.version)
+            throw new IllegalArgumentException("Version must be greater than the current version -- current version: "+this.version);
+        this.version = version;
+        setVersionId(""+this.version);
     }
     
     

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataRequest.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataRequest.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataRequest.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataRequest.java Tue Jul 25 15:23:01 2006
@@ -29,8 +29,8 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.server.authentication.AuthenticationController;
 import org.apache.lucene.gdata.server.registry.ComponentType;
-import org.apache.lucene.gdata.server.registry.ProvidedService;
 import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
+import org.apache.lucene.gdata.server.registry.ProvidedService;
 import org.apache.lucene.gdata.storage.Storage;
 import org.apache.lucene.gdata.storage.StorageController;
 
@@ -129,6 +129,7 @@
             Storage storage = controller.getStorage();
 
             String service = storage.getServiceForFeed(this.feedId);
+            storage.close();
             /*
              * ExtensionProfile and the type is used for building the Entry /
              * Feed Instances from an inputstream or reader
@@ -141,8 +142,11 @@
                         "feed is not registered or extension profile could not be created");
 
         } catch (Exception e) {
+            e.printStackTrace();
+            
             throw new GDataRequestException(
-                    "feed is not registered or extension profile could not be created");
+                    "feed is not registered or extension profile could not be created -- "
+                            + e.getMessage(), e);
         }
 
     }
@@ -307,27 +311,27 @@
         builder.append(buildRequestIDString(false));
         builder.append("?");
 
+        if (builder.charAt(builder.length() - 1) != '?')
+            builder.append('&');
         Enumeration parameters = this.request.getParameterNames();
         while (parameters.hasMoreElements()) {
             String element = (String) parameters.nextElement();
-            String[] values = this.request.getParameterValues(element);
-            for (int i = 0; i < values.length; i++) {
+            String values = this.request.getParameter(element);
 
-                builder.append(element).append("=");
-                if (element.equals(START_INDEX_NEXT_PAGE_PARAMETER)) {
-                    int tempVal = DEFAULT_START_INDEX;
-                    try {
-                        tempVal = Integer.parseInt(values[i]);
-                    } catch (Exception e) {
-                        LOG.info("Can not parse StartIndex -- use defaut");
-                    }
-                    builder.append(tempVal + getItemsPerPage());
-                    break;
+            builder.append(element).append("=");
+            if (element.equals(START_INDEX_NEXT_PAGE_PARAMETER)) {
+                int tempVal = DEFAULT_START_INDEX;
+                try {
+                    tempVal = Integer.parseInt(values);
+                } catch (Exception e) {
+                    LOG.info("Can not parse StartIndex -- use defaut");
                 }
+                builder.append(tempVal + getItemsPerPage());
+                continue;
+            }
 
-                builder.append(values[i]);
+            builder.append(values);
 
-            }
             if (parameters.hasMoreElements())
                 builder.append("&");
 
@@ -339,9 +343,10 @@
                     DEFAULT_ITEMS_PER_PAGE);
         }
         if (this.request.getParameter(START_INDEX_NEXT_PAGE_PARAMETER) == null) {
-            builder.append('&');
+            if (builder.charAt(builder.length() - 1) != '?')
+                builder.append('&');
             builder.append(START_INDEX_NEXT_PAGE_PARAMETER).append("=");
-            builder.append(DEFAULT_ITEMS_PER_PAGE + 1);
+            builder.append(getItemsPerPage() + 1);
         }
 
         return builder.toString();
@@ -352,7 +357,9 @@
         StringBuilder builder = new StringBuilder("http://");
         builder.append(this.request.getHeader("Host"));
         builder.append(this.request.getRequestURI());
-        if (endingSlash && !this.request.getRequestURI().endsWith("/"))
+        if (!endingSlash && builder.charAt(builder.length() - 1) == '/')
+            builder.setLength(builder.length() - 1);
+        if (endingSlash && builder.charAt(builder.length() - 1) != '/')
             builder.append("/");
 
         return builder.toString();
@@ -454,7 +461,7 @@
      */
     public boolean isFeedRequested() {
 
-        return (this.type.equals(GDataRequestType.GET) && (this.entryId == null
+        return (this.type == GDataRequestType.GET && (this.entryId == null
                 || this.entryId.length() == 0 || (this.entryId.equals('/'))));
     }
 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataResponse.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataResponse.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataResponse.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataResponse.java Tue Jul 25 15:23:01 2006
@@ -22,6 +22,8 @@
 
 import javax.servlet.http.HttpServletResponse;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.server.GDataRequest.OutputFormat;
 import org.apache.lucene.gdata.utils.DateFormater;
 
@@ -68,6 +70,7 @@
  * 
  */
 public class GDataResponse {
+    private static final Log LOG = LogFactory.getLog(GDataResponse.class);
     private int error;
 
     private boolean isError = false;
@@ -169,7 +172,7 @@
         if (time != null)
             setLastModifiedHeader(time.getValue());
         XmlWriter writer = createWriter();
-
+        
         if (this.outputFormat.equals(OutputFormat.ATOM)) {
             this.response.setContentType(XMLMIME_ATOM);
             feed.generateAtom(writer, profile);
@@ -177,7 +180,7 @@
             this.response.setContentType(XMLMIME_RSS);
             feed.generateRss(writer, profile);
         }
-
+        writer.close();
     }
 
     /**
@@ -210,6 +213,8 @@
             entry.generateAtom(writer, profile);
         else
             entry.generateRss(writer, profile);
+        writer.close();
+        
     }
 
     private XmlWriter createWriter() throws IOException {

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/GDataService.java Tue Jul 25 15:23:01 2006
@@ -27,6 +27,7 @@
 import org.apache.lucene.gdata.data.ServerBaseFeed;
 import org.apache.lucene.gdata.server.registry.ComponentType;
 import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
+import org.apache.lucene.gdata.storage.ModificationConflictException;
 import org.apache.lucene.gdata.storage.ResourceNotFoundException;
 import org.apache.lucene.gdata.storage.Storage;
 import org.apache.lucene.gdata.storage.StorageController;
@@ -103,7 +104,9 @@
         ServerBaseEntry entry = buildEntry(request, response);
         entry.setFeedId(request.getFeedId());
         entry.setServiceConfig(request.getConfigurator());
-        setTimeStamps(entry.getEntry());
+        BaseEntry tempEntry = entry.getEntry();
+        tempEntry.setPublished(getCurrentDateTime());
+        tempEntry.setUpdated(getCurrentDateTime());
         BaseEntry retVal = null;
         try {
             retVal = this.storage.storeEntry(entry);
@@ -129,6 +132,7 @@
         entry.setServiceConfig(request.getConfigurator());
         entry.setFeedId(request.getFeedId());
         entry.setId(request.getEntryId());
+        setVersionId(entry,request,response);
         if (entry.getId() == null)
             throw new ServiceException(
                     "entry id is null -- can not delete null entry");
@@ -140,7 +144,13 @@
                     "Could not delete entry", e);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
-        } catch (Exception e) {
+        }catch (ModificationConflictException e) {
+            response.setError(HttpServletResponse.SC_CONFLICT);
+            ServiceException ex = new ServiceException(
+                    "Could not delete entry - version confilict", e);
+            ex.setStackTrace(e.getStackTrace());
+            throw ex;  
+        }catch (StorageException e) {
             response.setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
             ServiceException ex = new ServiceException(
                     "Could not delete entry", e);
@@ -160,7 +170,7 @@
 
         ServerBaseEntry entry = buildEntry(request, response);
         entry.setFeedId(request.getFeedId());
-
+        setVersionId(entry,request,response);
         entry.setServiceConfig(request.getConfigurator());
         if (LOGGER.isInfoEnabled())
             LOGGER.info("update Entry" + entry.getId() + " for feedId: "
@@ -180,7 +190,11 @@
             throw new ServiceException(
                     "Entry id in the entry xml does not match the requested resource");
         }
-        setTimeStamps(entry.getEntry());
+        BaseEntry tempEntry = entry.getEntry();
+        tempEntry.setUpdated(getCurrentDateTime());
+        Link selfLink = entry.getSelfLink();
+        if(selfLink != null)
+            entry.getLinks().remove(selfLink);
         BaseEntry retVal = null;
         try {
             retVal = this.storage.updateEntry(entry);
@@ -190,7 +204,13 @@
                     "Could not update entry", e);
             ex.setStackTrace(e.getStackTrace());
             throw ex;
-        } catch (StorageException e) {
+        }catch (ModificationConflictException e) {
+            response.setError(HttpServletResponse.SC_CONFLICT);
+            ServiceException ex = new ServiceException(
+                    "Could not update entry - version confilict", e);
+            ex.setStackTrace(e.getStackTrace());
+            throw ex;
+        }catch (StorageException e) {
             response.setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
             ServiceException ex = new ServiceException(
                     "Could not update entry", e);
@@ -261,13 +281,6 @@
         }
     }
 
-    private BaseEntry setTimeStamps(final BaseEntry entry) {
-        if (entry.getUpdated() == null)
-            entry.setUpdated(DateTime.now());
-        if (entry.getPublished() == null)
-            entry.setPublished(DateTime.now());
-        return entry;
-    }
 
     /**
      * @see org.apache.lucene.gdata.server.Service#getSingleEntry(org.apache.lucene.gdata.server.GDataRequest,
@@ -282,6 +295,8 @@
             entry.setServiceConfig(request.getConfigurator());
             entry.setFeedId(request.getFeedId());
             entry.setId(request.getEntryId());
+
+            
             if(entry.getId() == null){
                 response.setError(HttpServletResponse.SC_BAD_REQUEST);
                 throw new ServiceException("entry is null can't get entry");
@@ -318,10 +333,10 @@
     @SuppressWarnings("unchecked")
     private void dynamicElementFeedStragey(final BaseFeed feed,
             final GDataRequest request) {
-        buildDynamicFeedElements(request, feed);
+         buildDynamicFeedElements(request, feed);
         List<BaseEntry> entryList = feed.getEntries();
         for (BaseEntry entry : entryList) {
-            String id = request.getContextPath() + entry.getId();
+            String id = new StringBuilder(request.getContextPath()).append(entry.getId()).append("/").toString();
             setSelfLink(entry, id);
         }
 
@@ -334,7 +349,12 @@
      */@SuppressWarnings("unchecked")
     private BaseEntry setSelfLink(final BaseEntry entry, String id) {
         Link self = buildLink(Link.Rel.SELF, XMLMIME, id);
-        entry.getLinks().add(self);
+        StringBuilder builder = new StringBuilder(id);
+        builder.append(entry.getVersionId());
+        Link edit = buildLink(Link.Rel.ENTRY_EDIT,XMLMIME,builder.toString());
+        List<Link> list = entry.getLinks();
+        list.add(edit);
+        list.add(self);
         return entry;
     }
 
@@ -347,10 +367,12 @@
         feed.setItemsPerPage(request.getItemsPerPage());
         feed.setStartIndex(request.getStartIndex());
         feed.setId(request.getContextPath());
-        feed.getLinks().add(
+        List<Link> links = feed.getLinks();
+        links.add(
                 buildLink(Link.Rel.SELF, Link.Type.ATOM, request.getSelfId()));
-        feed.getLinks().add(
+        links.add(
                 buildLink(Link.Rel.NEXT, XMLMIME, request.getNextId()));
+        
 
     }
 
@@ -394,5 +416,23 @@
             }
         
     }
-
+    private ServerBaseEntry setVersionId(final ServerBaseEntry entry, final GDataRequest request, final GDataResponse response)throws ServiceException{
+        try{
+            entry.setVersion(Integer.parseInt(request.getEntryVersion()));
+            return entry;
+        }catch (Exception e) {
+            LOGGER.error("Can not parse entry version -- version is not an integer -- versionid: "+request.getEntryVersion(),e);
+            response.setError(HttpServletResponse.SC_BAD_REQUEST);
+            throw new ServiceException("Can not parse entry version -- version is not an integer -- versionid: "+request.getEntryVersion(),e);
+           
+        }
+    }
+    /*
+     * provide current time to set as published / updated values
+     * always use servertime to prevent client / server time lag
+     * Timezoneshift is 0
+     */
+    protected DateTime getCurrentDateTime(){
+        return new DateTime(System.currentTimeMillis(),0);
+    }
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/AccountBuilder.java Tue Jul 25 15:23:01 2006
@@ -20,6 +20,7 @@
 
 import org.apache.commons.digester.Digester;
 import org.apache.lucene.gdata.data.GDataAccount;
+import org.apache.lucene.gdata.utils.SimpleSaxErrorHandler;
 import org.xml.sax.SAXException;
 
 /**
@@ -42,9 +43,12 @@
             SAXException {
         if (reader == null)
             throw new IllegalArgumentException("Reader must not be null");
+        String schemaFile = AccountBuilder.class.getResource("/gdata-account.xsd").getFile();
         GDataAccount account = null;
         Digester digester = new Digester();
-        digester.setValidating(false);
+        digester.setValidating(true);
+        digester.setErrorHandler(new SimpleSaxErrorHandler());
+        digester.setSchema(schemaFile);
         digester.addObjectCreate("account", GDataAccount.class);
         digester.addBeanPropertySetter("account/account-name", "name");
         digester.addBeanPropertySetter("account/password", "password");
@@ -55,8 +59,12 @@
                 "authorMail");
         digester.addBeanPropertySetter("account/account-owner/url",
                 "authorLink");
+
         account = (GDataAccount) digester.parse(reader);
+
         return account;
     }
-
+    
+    
+  
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/administration/GDataAdminService.java Tue Jul 25 15:23:01 2006
@@ -55,6 +55,7 @@
         if(account.getName() == null)
             throw new ServiceException("Account name is null -- can't create feed");
     try {
+        feed.setUpdated(getCurrentDateTime());
         feed.setAccount(account);
         this.storage.storeFeed(feed,account.getName());
     } catch (StorageException e) {
@@ -81,6 +82,7 @@
             throw new ServiceException("Account name is null -- can't update feed");
     try {
         feed.setAccount(account);
+        feed.setUpdated(getCurrentDateTime());
         this.storage.updateFeed(feed,account.getName());
     } catch (StorageException e) {
         if(LOG.isInfoEnabled())

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/authentication/BlowfishAuthenticationController.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/authentication/BlowfishAuthenticationController.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/authentication/BlowfishAuthenticationController.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/authentication/BlowfishAuthenticationController.java Tue Jul 25 15:23:01 2006
@@ -35,6 +35,7 @@
 import org.apache.lucene.gdata.data.GDataAccount.AccountRole;
 import org.apache.lucene.gdata.server.registry.Component;
 import org.apache.lucene.gdata.server.registry.ComponentType;
+import org.apache.lucene.gdata.server.registry.configuration.Requiered;
 
 import sun.misc.BASE64Decoder;
 import sun.misc.BASE64Encoder;
@@ -81,7 +82,6 @@
 
     private Cipher enCrypt;
 
-    // TODO make this configurable
     private int minuteOffset = 30;
 
     private long milisecondOffset;
@@ -92,8 +92,8 @@
 
     private ReentrantLock lock = new ReentrantLock();
 
-    // TODO make this configurable
-    private String key = "myTestKey";
+    
+    private  String key;
 
     /**
      * @see org.apache.lucene.gdata.server.authentication.AuthenticationController#initialize()
@@ -236,7 +236,8 @@
     /**
      * @return Returns the minuteOffset.
      */
-    public int getMinuteOffset() {
+    @Requiered
+    public int getLoginTimeout() {
         return this.minuteOffset;
     }
 
@@ -244,7 +245,8 @@
      * @param minuteOffset
      *            The minuteOffset to set.
      */
-    public void setMinuteOffset(int minuteOffset) {
+    @Requiered
+    public void setLoginTimeout(int minuteOffset) {
         this.minuteOffset = minuteOffset;
         calculateTimeOffset();
     }

Added: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataRequestListener.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataRequestListener.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataRequestListener.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataRequestListener.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,91 @@
+/**
+ * Copyright 2004 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.
+ */
+
+package org.apache.lucene.gdata.server.registry;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.servlet.ServletRequestEvent;
+import javax.servlet.ServletRequestListener;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.gdata.server.registry.Scope.ScopeType;
+
+/**
+ * This <tt>ServletRequestListener</tt> is used by the registry to notify
+ * registered {@link org.apache.lucene.gdata.server.registry.ScopeVisitor}
+ * implementations when a request is initialized e.g destroyed.
+ * 
+ * 
+ * @see org.apache.lucene.gdata.server.registry.ScopeVisitable
+ * @see javax.servlet.ServletRequestListener
+ * @author Simon Willnauer
+ * 
+ */
+@Scope(scope = ScopeType.REQUEST)
+public class GDataRequestListener implements ServletRequestListener,
+        ScopeVisitable {
+    private final GDataServerRegistry registry;
+
+    private final List<ScopeVisitor> visitors = new ArrayList<ScopeVisitor>(5);
+
+    private static final Log LOG = LogFactory
+            .getLog(GDataRequestListener.class);
+
+    /**
+     * @throws RegistryException
+     * 
+     */
+    public GDataRequestListener() throws RegistryException {
+        this.registry = GDataServerRegistry.getRegistry();
+        this.registry.registerScopeVisitable(this);
+
+    }
+
+    /**
+     * @see javax.servlet.ServletRequestListener#requestDestroyed(javax.servlet.ServletRequestEvent)
+     */
+    public void requestDestroyed(ServletRequestEvent arg0) {
+        for (ScopeVisitor visitor : this.visitors) {
+            visitor.visiteDestroy();
+        }
+
+    }
+
+    /**
+     * @see javax.servlet.ServletRequestListener#requestInitialized(javax.servlet.ServletRequestEvent)
+     */
+    public void requestInitialized(ServletRequestEvent arg0) {
+        for (ScopeVisitor visitor : this.visitors) {
+            visitor.visiteInitialize();
+        }
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.server.registry.ScopeVisitable#accept(org.apache.lucene.gdata.server.registry.ScopeVisitor)
+     */
+    public void accept(ScopeVisitor visitor) {
+
+        if (!this.visitors.contains(visitor) && visitor != null) {
+            this.visitors.add(visitor);
+            if(LOG.isDebugEnabled())
+                LOG.debug("visitor added -- " + visitor.getClass());
+        }
+    }
+
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataRequestListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataRequestListener.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/GDataServerRegistry.java Tue Jul 25 15:23:01 2006
@@ -15,11 +15,16 @@
  */
 package org.apache.lucene.gdata.server.registry;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration;
+import org.apache.lucene.gdata.server.registry.configuration.PropertyInjector;
 
 /**
  * 
@@ -41,7 +46,9 @@
  * occures the server will not start up. To cause of the exception or error will
  * be logged to the standart server output.
  * </p>
- * <p>The GDataServerRegistry is a Singleton</p>
+ * <p>
+ * The GDataServerRegistry is a Singleton
+ * </p>
  * 
  * 
  * @author Simon Willnauer
@@ -53,10 +60,18 @@
     private static final Log LOGGER = LogFactory
             .getLog(GDataServerRegistry.class);
 
+    private ScopeVisitable requestVisitable;
+
+    private ScopeVisitable sessionVisitable;
+    //not available yet
+    private ScopeVisitable contextVisitable;
+
+    private List<ScopeVisitor> visitorBuffer = new ArrayList<ScopeVisitor>(5);
+
     private final Map<String, ProvidedService> serviceTypeMap = new HashMap<String, ProvidedService>();
 
     private final Map<ComponentType, ComponentBean> componentMap = new HashMap<ComponentType, ComponentBean>(
-            10);
+            ComponentType.values().length);
 
     private GDataServerRegistry() {
         // private - singleton
@@ -86,6 +101,72 @@
     }
 
     /**
+     * @param visitor -
+     *            the visitor to register
+     * @throws RegistryException
+     */
+    public synchronized void registerScopeVisitor(final ScopeVisitor visitor)
+            throws RegistryException {
+        if (visitor == null)
+            throw new IllegalArgumentException("visitor must not be null");
+        Scope scope = visitor.getClass().getAnnotation(Scope.class);
+        if (scope == null)
+            throw new RegistryException("Visitor has not Scope");
+        if (LOGGER.isInfoEnabled())
+            LOGGER.info("Register scope visitor -- " + visitor.getClass());
+        if (scope.scope().equals(Scope.ScopeType.REQUEST)
+                && this.requestVisitable != null)
+            this.requestVisitable.accept(visitor);
+        else if (scope.scope() == Scope.ScopeType.SESSION
+                && this.sessionVisitable != null)
+            this.sessionVisitable.accept(visitor);
+        else if (scope.scope() == Scope.ScopeType.CONTEXT
+                && this.contextVisitable != null)
+            this.sessionVisitable.accept(visitor);
+        else if (!this.visitorBuffer.contains(visitor))
+            this.visitorBuffer.add(visitor);
+    }
+
+    /**
+     * @param visitable -
+     *            the instance to register
+     * @throws RegistryException
+     * @see ScopeVisitable
+     */
+    public synchronized void registerScopeVisitable(
+            final ScopeVisitable visitable) throws RegistryException {
+        if (visitable == null)
+            throw new IllegalArgumentException("visitable must not be null");
+
+        Scope scope = visitable.getClass().getAnnotation(Scope.class);
+        if (scope == null)
+            throw new RegistryException("Visitable has not Scope");
+        if (LOGGER.isInfoEnabled())
+            LOGGER.info("Register scope visitable -- " + visitable.getClass());
+        if (scope.scope() == Scope.ScopeType.REQUEST
+                && this.requestVisitable == null)
+            this.requestVisitable = visitable;
+        else if (scope.scope() == Scope.ScopeType.SESSION
+                && this.sessionVisitable == null)
+            this.sessionVisitable = visitable;
+        else if (scope.scope() == Scope.ScopeType.CONTEXT
+                && this.contextVisitable == null)
+            this.sessionVisitable = visitable;
+
+        if (!this.visitorBuffer.isEmpty()) {
+
+            List<ScopeVisitor> tempList = this.visitorBuffer;
+            this.visitorBuffer = new ArrayList<ScopeVisitor>(5);
+            for (ScopeVisitor visitor : tempList) {
+                registerScopeVisitor(visitor);
+            }
+            tempList.clear();
+
+        }
+
+    }
+
+    /**
      * Looks up the {@link ProvidedServiceConfig} by the given service name.
      * 
      * @param service
@@ -100,6 +181,10 @@
     }
 
     protected void flushRegistry() {
+        Collection<ProvidedService> services = this.serviceTypeMap.values();
+        for (ProvidedService service : services) {
+            service.destroy();
+        }
         this.serviceTypeMap.clear();
         this.componentMap.clear();
     }
@@ -122,6 +207,7 @@
         for (ComponentBean component : this.componentMap.values()) {
             component.getObject().destroy();
         }
+
         flushRegistry();
 
     }
@@ -157,23 +243,51 @@
     }
 
     /**
-     * @param <E> 
-     * @param componentClass
-     * @throws RegistryException
+     * All registered {@link ServerComponent} registered via this method are
+     * available via the
+     * {@link GDataServerRegistry#lookup(Class, ComponentType)} method. For each
+     * {@link ComponentType} there will be one single instance registered in the
+     * registry.
+     * <p>
+     * Eventually this method invokes the initialize method of the
+     * ServerComponent interface to prepare the component to be available via
+     * the lookup service
+     * </p>
+     * 
+     * @param <E> -
+     *            The interface of the component to register
+     * @param componentClass -
+     *            a implementation of a ServerComponent interface to register in
+     *            the registry
+     * @param configuration -
+     *            the component configuration {@link ComponentConfiguration}
+     * @throws RegistryException -
+     *             if the provided class does not implement the
+     *             {@link ServerComponent} interface, if the mandatory
+     *             annotations not visible at runtime or not set, if the super
+     *             type provided by the {@link ComponentType} for the class to
+     *             register is not a super type of the class or if the
+     *             invokation of the {@link ServerComponent#initialize()} method
+     *             throws an exception.
      */
     @SuppressWarnings("unchecked")
-    public  <E extends ServerComponent> void  registerComponent(final Class<E> componentClass)
+    public <E extends ServerComponent> void registerComponent(
+            final Class<E> componentClass,
+            final ComponentConfiguration configuration)
             throws RegistryException {
-        
+
         if (componentClass == null)
             throw new IllegalArgumentException(
                     "component class must not be null");
-  
-        if(!checkImplementsServerComponent(componentClass))
-            throw new RegistryException("can not register component. the given class does not implement ServerComponent interface -- "+componentClass.getName());
+
+        if (!checkSuperType(componentClass, ServerComponent.class))
+            throw new RegistryException(
+                    "can not register component. the given class does not implement ServerComponent interface -- "
+                            + componentClass.getName());
         try {
 
-            Component annotation =  componentClass.getAnnotation(Component.class);
+            Component annotation = componentClass
+                    .getAnnotation(Component.class);
             if (annotation == null)
                 throw new RegistryException(
                         "can not register component. the given class is not a component -- "
@@ -189,49 +303,53 @@
                         + superType.getName() + "> is not a super type of <"
                         + componentClass + ">");
             ServerComponent comp = componentClass.newInstance();
+            if (configuration == null) {
+                if (LOGGER.isInfoEnabled())
+                    LOGGER.info("no configuration for ComponentType: "
+                            + type.name());
+            } else
+                configureComponent(comp, type, configuration);
             comp.initialize();
             ComponentBean bean = new ComponentBean(comp, superType);
-            
-            this.componentMap.put(type, bean);
 
+            this.componentMap.put(type, bean);
+            if (checkSuperType(componentClass, ScopeVisitor.class))
+                this.registerScopeVisitor((ScopeVisitor) comp);
         } catch (Exception e) {
+            e.printStackTrace();
             throw new RegistryException("Can not register component -- "
                     + e.getMessage(), e);
         }
 
     }
-    
-    private static boolean checkImplementsServerComponent(Class type){
-        if(type == null)
-            return false;
-        if(type.equals(Object.class))
-            return false;
-        if(type.equals(ServerComponent.class))
-            return true;
-        Class[] compInterfaces = type.getInterfaces();
-        for (int i = 0; i < compInterfaces.length; i++) {
-           if(checkImplementsServerComponent(compInterfaces[i]))
-               return true;
-        }
-        return checkImplementsServerComponent(type.getSuperclass());
-        
+
+    /*
+     * Injects the configured properties located in the configuration into the
+     * given server component
+     */
+    private void configureComponent(final ServerComponent component,
+            final ComponentType type, final ComponentConfiguration configuration) {
+        PropertyInjector injector = new PropertyInjector();
+        injector.setTargetObject(component);
+        injector.injectProperties(configuration);
     }
 
     private static boolean checkSuperType(Class type, Class consideredSuperType) {
-
+        if (type == null)
+            return false;
         if (type.equals(Object.class))
             return false;
         if (type.equals(consideredSuperType))
             return true;
         Class[] interfaces = type.getInterfaces();
         for (int i = 0; i < interfaces.length; i++) {
-            if (interfaces[i].equals(consideredSuperType))
+            if (checkSuperType(interfaces[i], consideredSuperType))
                 return true;
         }
         return checkSuperType(type.getSuperclass(), consideredSuperType);
     }
 
-    private class ComponentBean {
+    private static class ComponentBean {
         private final Class superType;
 
         private final ServerComponent object;

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedService.java Tue Jul 25 15:23:01 2006
@@ -45,4 +45,9 @@
      */
     public abstract String getName();
 
+    /**
+     * releases all dependencies and resources
+     */
+    public abstract void destroy();
+
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ProvidedServiceConfig.java Tue Jul 25 15:23:01 2006
@@ -15,6 +15,14 @@
  */
 package org.apache.lucene.gdata.server.registry;
 
+import java.lang.reflect.Constructor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.lucene.gdata.utils.Pool;
+import org.apache.lucene.gdata.utils.PoolObjectFactory;
+import org.apache.lucene.gdata.utils.SimpleObjectPool;
+
 import com.google.gdata.data.ExtensionProfile;
 
 /**
@@ -22,11 +30,40 @@
  * {@link org.apache.lucene.gdata.server.registry.ProvidedService} to be used
  * inside the
  * {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry}
+ * <p>
+ * ExtensionProfiles are used to generate and parse xml by the gdata api. For
+ * that case all methodes are synchronized. This will slow down the application
+ * when performing lots of xml generation concurrently. For that case the
+ * extensionProfile for a specific service will be pooled and reused.
+ * </p>
+ * 
  * 
  * @author Simon Willnauer
  * 
  */
-public class ProvidedServiceConfig implements ProvidedService {
+@Scope(scope = Scope.ScopeType.REQUEST)
+public class ProvidedServiceConfig implements ProvidedService, ScopeVisitor {
+    private final static Log LOG = LogFactory
+            .getLog(ProvidedServiceConfig.class);
+
+    private static final int DEFAULT_POOL_SIZE = 5;
+
+    /*
+     * To ensure a extensionprofile instance will not be shared within multiple
+     * threads each thread requesting a config will have one instance for the
+     * entire request.
+     */
+    private final ThreadLocal<ExtensionProfile> extProfThreadLocal = new ThreadLocal<ExtensionProfile>();
+
+    /*
+     * ExtensionProfiles are used to generate and parse xml by the gdata api.
+     * For that case all methodes are synchronized. This will slow down the
+     * application when performing lots of xml generation concurrently. for that
+     * case the extensionProfile for a specific service will be pooled and
+     * reused.
+     */
+    private Pool<ExtensionProfile> profilPool;
+
     private String serviceName;
 
     private Class entryType;
@@ -35,21 +72,35 @@
 
     private ExtensionProfile extensionProfile;
 
-   
-    ProvidedServiceConfig(ExtensionProfile profile, Class feedType,
-            Class entryType, String serviceName) {
-        this.extensionProfile = profile;
-        this.feedType = feedType;
-        this.entryType = entryType;
-        this.serviceName = serviceName;
+    private int poolSize = DEFAULT_POOL_SIZE;
 
+    /**
+     * @return Returns the poolSize.
+     */
+    public int getPoolSize() {
+        return this.poolSize;
     }
 
     /**
-     * Default constructor to instanciate via reflection 
+     * @param poolSize
+     *            The poolSize to set.
+     */
+    public void setPoolSize(int poolSize) {
+        
+        this.poolSize = poolSize >= DEFAULT_POOL_SIZE ? poolSize
+                : DEFAULT_POOL_SIZE;
+    }
+
+    /**
+     * Default constructor to instanciate via reflection
      */
     public ProvidedServiceConfig() {
-        //
+        try {
+            GDataServerRegistry.getRegistry().registerScopeVisitor(this);
+        } catch (RegistryException e) {
+            throw new RuntimeException("Can not register ScopeVisitor -- "
+                    + e.getMessage(), e);
+        }
     }
 
     /**
@@ -71,20 +122,44 @@
      * @see org.apache.lucene.gdata.server.registry.ProvidedService#getExtensionProfile()
      */
     public ExtensionProfile getExtensionProfile() {
-        return this.extensionProfile;
+        ExtensionProfile ext = this.extProfThreadLocal.get();
+        if (ext != null) {
+            return ext;
+        }
+        if (this.profilPool == null)
+            createProfilePool();
+        ext = this.profilPool.aquire();
+        this.extProfThreadLocal.set(ext);
+        return ext;
     }
 
     /**
      * @param extensionProfil -
      *            the extensionprofile for this feed configuration
      */
+    @SuppressWarnings("unchecked")
     public void setExtensionProfile(ExtensionProfile extensionProfil) {
+        if (extensionProfil == null)
+            throw new IllegalArgumentException(
+                    "ExtensionProfile  must not be null");
+        if (this.extensionProfile != null)
+            return;
         this.extensionProfile = extensionProfil;
+
+    }
+
+    private void createProfilePool() {
+        if (LOG.isInfoEnabled())
+            LOG.info("Create ExtensionProfile pool with poolsize:"
+                    + this.poolSize + " for service " + this.serviceName);
+        this.profilPool = new SimpleObjectPool<ExtensionProfile>(this.poolSize,
+                new ExtensionProfileFactory<ExtensionProfile>(
+                        this.extensionProfile.getClass()));
     }
 
-    
     /**
-     *TODO add comment
+     * TODO add comment
+     * 
      * @param <E>
      * @param extensionProfileClass
      * @throws InstantiationException
@@ -97,7 +172,8 @@
             throw new IllegalArgumentException(
                     "ExtensionProfile class must not be null");
 
-        this.extensionProfile = extensionProfileClass.newInstance();
+        setExtensionProfile(extensionProfileClass.newInstance());
+
     }
 
     /**
@@ -106,7 +182,7 @@
     public Class getEntryType() {
         return this.entryType;
     }
-    
+
     /**
      * @param entryType
      */
@@ -126,6 +202,97 @@
      */
     public void setName(String serviceName) {
         this.serviceName = serviceName;
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.server.registry.ProvidedService#destroy()
+     */
+    public void destroy() {
+        if (this.profilPool != null)
+            this.profilPool.destroy();
+        if (LOG.isInfoEnabled())
+            LOG.info("Destroy Service " + this.serviceName
+                    + " -- release all resources");
+        this.feedType = null;
+        this.entryType = null;
+        this.extensionProfile = null;
+    }
+
+    private static class ExtensionProfileFactory<Type extends ExtensionProfile>
+            implements PoolObjectFactory<Type> {
+        private final Class<? extends ExtensionProfile> clazz;
+
+        private final Constructor<? extends ExtensionProfile> constructor;
+
+        private static final Object[] constArray = new Object[0];
+
+        ExtensionProfileFactory(Class<? extends ExtensionProfile> clazz) {
+            this.clazz = clazz;
+            try {
+                this.constructor = clazz.getConstructor(new Class[0]);
+            } catch (Exception e) {
+                throw new IllegalArgumentException(
+                        "The given class has no defaul constructor -- can not use as a ExtensionProfile -- "
+                                + this.clazz.getName(), e);
+            }
+        }
+
+        /**
+         * @see org.apache.lucene.gdata.utils.PoolObjectFactory#getInstance()
+         */
+        @SuppressWarnings("unchecked")
+        public Type getInstance() {
+
+            try {
+                return (Type) this.constructor.newInstance(constArray);
+            } catch (Exception e) {
+                throw new RuntimeException(
+                        "Can not instanciate new ExtensionProfile -- ", e);
+
+            }
+        }
+
+        /**
+         * @param type -
+         *            the ExtensionProfile to destroy
+         * @see org.apache.lucene.gdata.utils.PoolObjectFactory#destroyInstance(Object)
+         */
+        public void destroyInstance(Type type) {
+            //
+        }
+
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.server.registry.ScopeVisitor#visiteInitialize()
+     */
+    public void visiteInitialize() {
+        if(this.profilPool == null)
+            createProfilePool();
+        /*
+         * don't set a extension profile for each thread. The current thread
+         * might use another service and does not need the extensionprofile of
+         * this service
+         */
+    }
+
+    /**
+     * @see org.apache.lucene.gdata.server.registry.ScopeVisitor#visiteDestroy()
+     */
+    public void visiteDestroy() {
+        /*
+         * Check every thread after request destroyed to release all profiles to
+         * the pool
+         */
+        ExtensionProfile ext = this.extProfThreadLocal.get();
+        if (ext == null) {
+            if(LOG.isDebugEnabled())
+            LOG.debug("ThreadLocal owns no ExtensionProfile in requestDestroy for service "
+                            + this.serviceName);
+            return;
+        }
+        this.extProfThreadLocal.set(null);
+        this.profilPool.release(ext);
     }
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/RegistryBuilder.java Tue Jul 25 15:23:01 2006
@@ -18,6 +18,8 @@
 import java.io.IOException;
 
 import org.apache.commons.digester.Digester;
+import org.apache.lucene.gdata.server.registry.configuration.ComponentConfiguration;
+import org.apache.lucene.gdata.utils.SimpleSaxErrorHandler;
 import org.xml.sax.SAXException;
 
 /**
@@ -49,11 +51,14 @@
 
     private static void buildFromConfiguration(Digester digester,
             GDataServerRegistry registry) throws IOException, SAXException {
-        
-        digester.setValidating(false);
+        String schemaFile = RegistryBuilder.class.getResource("/gdata-config.xsd").getFile();
+        digester.setValidating(true);
+        digester.setSchema(schemaFile);
+        digester.setErrorHandler(new SimpleSaxErrorHandler());
         digester.push(registry);
-        digester.addCallMethod("gdata/server-components/component",
-                "registerComponent", 0, new Class[] { Class.class });
+        /*
+         * register services
+         */
         digester.addObjectCreate("gdata/service", ProvidedServiceConfig.class);
         digester.addSetProperties("gdata/service");
         digester.addSetNext("gdata/service", "registerService");
@@ -61,10 +66,22 @@
         digester.addBeanPropertySetter("gdata/service/entry-class", "entryType");
         digester.addBeanPropertySetter("gdata/service/extension-profile",
                 "extensionProfileClass");
+      
+        /*
+         * load components and configurations
+         */
+        digester.addCallMethod("gdata/server-components/component",
+                "registerComponent", 2, new Class[] { Class.class , ComponentConfiguration.class});
+        digester.addCallParam("gdata/server-components/component/class",0);
+            digester.addObjectCreate("gdata/server-components/component/configuration",ComponentConfiguration.class);
+            digester.addCallMethod("gdata/server-components/component/configuration/property","set",2,new Class[]{String.class,String.class});
+            digester.addCallParam("gdata/server-components/component/configuration/property",0,"name");
+            digester.addCallParam("gdata/server-components/component/configuration/property",1);
+        digester.addCallParam("gdata/server-components/component/configuration",1,0);    
         digester.parse(RegistryBuilder.class
                 .getResourceAsStream("/gdata-config.xml"));
+        
     }
 
-   
 
 }

Added: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/Scope.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/Scope.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/Scope.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/Scope.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,63 @@
+/**
+ * Copyright 2004 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.
+ */
+
+package org.apache.lucene.gdata.server.registry;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+/**
+ * The Scope annotation is used in
+ * {@link org.apache.lucene.gdata.server.registry.ScopeVisitable} and
+ * {@link org.apache.lucene.gdata.server.registry.ScopeVisitor} implementations
+ * to indicate which scope should be visited.
+ * 
+ * @author Simon Willnauer
+ * 
+ */
+@Target( { TYPE })
+@Retention(value = RUNTIME)
+public @interface Scope {
+    /**
+     * @return - the scope type the class was annotated with
+     */
+    ScopeType scope();
+
+    /**
+     * Defines a Scope for {@link Scope} annotations
+     * 
+     * @author Simon Willnauer
+     * 
+     */
+    public static enum ScopeType {
+        /**
+         * Request scope
+         */
+        REQUEST,
+        /**
+         * Session scope
+         */
+        SESSION,
+        /**
+         * Context scope
+         */
+        CONTEXT
+
+    }
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/Scope.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/Scope.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitable.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitable.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitable.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitable.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,33 @@
+/**
+ * Copyright 2004 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.
+ */
+
+package org.apache.lucene.gdata.server.registry;
+
+/**
+ * Implementation of this interface accept
+ * {@link org.apache.lucene.gdata.server.registry.ScopeVisitor} objects and call
+ * their methods on the desired action.
+ * 
+ * @author Simon Willnauer
+ * 
+ */
+public interface ScopeVisitable {
+    /**
+     * @param visitor -
+     *            the visitor to accept
+     */
+    public abstract void accept(ScopeVisitor visitor);
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitable.java
------------------------------------------------------------------------------
    svn:executable = *

Added: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitor.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitor.java?rev=425538&view=auto
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitor.java (added)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitor.java Tue Jul 25 15:23:01 2006
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2004 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.
+ */
+
+package org.apache.lucene.gdata.server.registry;
+
+/**
+ * <p>
+ * <code>ScopeVisitor</code> is used to implement the <code>Visitor</code>
+ * pattern in GDATAServer. An object of this interface can be passed to a
+ * <code>ScopeVistable</code> which will then call its methods. <br/>
+ * {@link org.apache.lucene.gdata.server.registry.Component} Classes registered
+ * in the {@link org.apache.lucene.gdata.server.registry.GDataServerRegistry}
+ * will be added to the Visitableimplementation automatically. Please refer to
+ * the <i>Gang of Four </i> book of Design Patterns for more details on the
+ * <code>Visitor</code> pattern.
+ * </p>
+ * <p>
+ * A scope can be Session, Request or Context if one of the ScopeVisitors for
+ * the desired scope is available by the registry.
+ * </p>
+ * <p>
+ * This <a href="http://www.patterndepot.com/put/8/JavaPatterns.htm">site </a>
+ * has further discussion on design patterns and links to the GOF book. This <a
+ * href="http://www.patterndepot.com/put/8/visitor.pdf">link </a> describes the
+ * Visitor pattern in detail.
+ * </p>
+ * 
+ * @author Simon Willnauer
+ * 
+ */
+public interface ScopeVisitor {
+    /**
+     * Visites the initialization of the scope
+     */
+    public abstract void visiteInitialize();
+
+    /**
+     * Visites the destory of the scope
+     * 
+     */
+    public abstract void visiteDestroy();
+}

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/server/registry/ScopeVisitor.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractAccountHandler.java Tue Jul 25 15:23:01 2006
@@ -60,7 +60,7 @@
     @SuppressWarnings("unused")
     public void processRequest(HttpServletRequest request,
             HttpServletResponse response) throws ServletException, IOException {
-        
+      try{  
             this.authenticated = authenticateAccount(request,
                 AccountRole.USERADMINISTRATOR);
         
@@ -92,6 +92,10 @@
             setError(HttpServletResponse.SC_UNAUTHORIZED,"Authorization failed");
         }
         sendResponse(response);
+      }finally{
+          if(this.service!=null)
+              this.service.close();
+      }
 
     }
     

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractFeedHandler.java Tue Jul 25 15:23:01 2006
@@ -141,7 +141,7 @@
         return this.errorMessage;
     }
     
-    class FeedHandlerException extends Exception{
+    static class FeedHandlerException extends Exception{
 
         /**
          * 

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AbstractGdataRequestHandler.java Tue Jul 25 15:23:01 2006
@@ -41,7 +41,10 @@
         GDataRequestHandler {
     private final static Log LOG = LogFactory
             .getLog(AbstractGdataRequestHandler.class);
-
+    /*
+     * UTF-8 is the encoding used in the client API to send the entries to the server
+     */
+    private final static String ENCODING = "UTF-8";
     protected Service service;
     protected GDataRequest feedRequest;
     protected GDataResponse feedResponse;
@@ -57,6 +60,7 @@
             throws GDataRequestException, ServletException {
         this.feedRequest = new GDataRequest(request, type);
         this.feedResponse = new GDataResponse(response);
+        this.feedResponse.setEncoding(ENCODING);
         getService();
         try {       
             this.feedRequest.initializeRequest();

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/AuthenticationHandler.java Tue Jul 25 15:23:01 2006
@@ -100,8 +100,14 @@
     
     
    private GDataAccount getAccount(String accountName) throws ServiceException{
+       
        AdminService service = this.serviceFactory.getAdminService();
+       try{
        return service.getAccount(accountName);
+       }finally{
+            service.close();
+       }
+            
         
     }
    private void sendError(HttpServletResponse response, int code, String message)throws IOException{

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultDeleteHandler.java Tue Jul 25 15:23:01 2006
@@ -75,9 +75,9 @@
 			LOG.error("Could not process DeleteFeed request - "
 					+ e.getMessage(), e);
 			sendError();
-		}
+		}finally{
         closeService();
-
+        }
 	}
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultGetHandler.java Tue Jul 25 15:23:01 2006
@@ -102,9 +102,9 @@
             LOG.error("Could not process GetFeed request - " + e.getMessage(),
                     e);
             sendError();
-        }
+        }finally{
         closeService();
-
+        }
     }
 
     /**

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultInsertHandler.java Tue Jul 25 15:23:01 2006
@@ -78,9 +78,9 @@
         }catch (ServiceException e) {
            LOG.error("Could not process GetFeed request - "+e.getMessage(),e);
            this.feedResponse.sendError();
-        }
+        }finally{
         closeService();
-        
+        }
     }
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DefaultUpdateHandler.java Tue Jul 25 15:23:01 2006
@@ -82,8 +82,9 @@
 			LOG.error("Could not process UpdateFeed request - "
 					+ e.getMessage(), e);
 			sendError();
-		}
+		}finally{
         closeService();
+        }
 	}
 
 }

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DeleteFeedHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DeleteFeedHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DeleteFeedHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/DeleteFeedHandler.java Tue Jul 25 15:23:01 2006
@@ -26,6 +26,7 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.gdata.data.ServerBaseFeed;
 import org.apache.lucene.gdata.server.ServiceFactory;
+import org.apache.lucene.gdata.server.administration.AdminService;
 import org.apache.lucene.gdata.server.registry.ComponentType;
 import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
 
@@ -44,6 +45,7 @@
     public void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
             super.processRequest(request,response);
             if(this.authenticated){
+                AdminService service = null;
             try {
                 ServerBaseFeed feed = createDeleteFeed(request);
                 
@@ -53,13 +55,17 @@
                     setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"required component is not available");
                     throw new FeedHandlerException("Can't save feed - ServiceFactory is null");
                 }
-                serviceFactory.getAdminService().deleteFeed(feed);
+                service = serviceFactory.getAdminService();
+                service.deleteFeed(feed);
             } catch (FeedHandlerException e) {
                 LOG.error("Can not delete feed -- "+e.getMessage(),e);
             }catch (Exception e) {
                 LOG.error("Can not delete feed -- "+e.getMessage(),e);
                 setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,"can not create feed");
-            } 
+            }finally{
+                if(service != null)
+                    service.close();
+            }
             }
             sendResponse(response);
            

Modified: lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/InsertFeedHandler.java
URL: http://svn.apache.org/viewvc/lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/InsertFeedHandler.java?rev=425538&r1=425537&r2=425538&view=diff
==============================================================================
--- lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/InsertFeedHandler.java (original)
+++ lucene/java/trunk/contrib/gdata-server/src/java/org/apache/lucene/gdata/servlet/handler/InsertFeedHandler.java Tue Jul 25 15:23:01 2006
@@ -28,6 +28,7 @@
 import org.apache.lucene.gdata.data.ServerBaseFeed;
 import org.apache.lucene.gdata.server.ServiceException;
 import org.apache.lucene.gdata.server.ServiceFactory;
+import org.apache.lucene.gdata.server.administration.AdminService;
 import org.apache.lucene.gdata.server.registry.ComponentType;
 import org.apache.lucene.gdata.server.registry.GDataServerRegistry;
 
@@ -47,6 +48,7 @@
             HttpServletResponse response) throws ServletException, IOException {
         super.processRequest(request, response);
         if (this.authenticated) {
+            AdminService service = null;
             try {
                 ServerBaseFeed feed = createFeedFromRequest(request);
                 GDataAccount account = createRequestedAccount(request);
@@ -61,7 +63,8 @@
                     throw new FeedHandlerException(
                             "Can't save feed - ServiceFactory is null");
                 }
-                serviceFactory.getAdminService().createFeed(feed, account);
+                service = serviceFactory.getAdminService();
+                service.createFeed(feed, account);
             } catch (ServiceException e) {
                 setError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                         "can not create feed");
@@ -69,6 +72,9 @@
             } catch (Exception e) {
                 LOG.error("Can not create feed -- " + e.getMessage(), e);
 
+            }finally{
+                if(service != null)
+                    service.close();
             }
 
         }



Mime
View raw message