chemistry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fguilla...@apache.org
Subject svn commit: r783061 - in /incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app: model/APPConnection.java model/APPRepository.java service/
Date Tue, 09 Jun 2009 16:27:06 GMT
Author: fguillaume
Date: Tue Jun  9 16:27:06 2009
New Revision: 783061

URL: http://svn.apache.org/viewvc?rev=783061&view=rev
Log:
AtomPub client cleanup: remove generic extension management for now, subclassing will be used
for extension

Removed:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/service/
Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
    incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java?rev=783061&r1=783060&r2=783061&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPConnection.java
Tue Jun  9 16:27:06 2009
@@ -25,8 +25,6 @@
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
 
 import org.apache.chemistry.BaseType;
 import org.apache.chemistry.CMISObject;
@@ -51,8 +49,6 @@
 import org.apache.chemistry.atompub.client.app.Connector;
 import org.apache.chemistry.atompub.client.app.Request;
 import org.apache.chemistry.atompub.client.app.Response;
-import org.apache.chemistry.atompub.client.app.service.ServiceContext;
-import org.apache.chemistry.atompub.client.app.service.ServiceInfo;
 import org.apache.chemistry.atompub.client.common.atom.ReadContext;
 import org.apache.chemistry.atompub.client.common.atom.XmlProperty;
 
@@ -436,48 +432,4 @@
         throw new UnsupportedOperationException();
     }
 
-    /*
-     * ----- Extensions -----
-     */
-
-    /**
-     * Get an extension service in connection scope
-     *
-     * @param <T>
-     * @param clazz service interface class
-     * @param connection the connection to bound the service on
-     * @return the service instance or null if none
-     */
-    public <T> T getExtension(Class<T> clazz) {
-        repository.loadServices(); // be sure services information is loaded
-        ServiceInfo info = repository.services.get(clazz);
-        if (info != null) {
-            if (info.isSingleton()) {
-                Object service = getSingletonService(clazz);
-                if (service != null) {
-                    return (T) service;
-                }
-            }
-            ServiceContext ctx = new ServiceContext(info, this);
-            try {
-                Object service = info.newInstance(ctx);
-                if (info.isSingleton()) {
-                    putSingletonService(clazz, service);
-                }
-                return (T) service;
-            } catch (Exception e) {
-                // do nothing
-            }
-        }
-        return null;
-    }
-
-    protected void putSingletonService(Class<?> clazz, Object service) {
-        singletons.put(clazz, service);
-    }
-
-    protected Object getSingletonService(Class<?> clazz) {
-        return singletons.get(clazz);
-    }
-
 }

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java?rev=783061&r1=783060&r2=783061&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
(original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-client/src/main/java/org/apache/chemistry/atompub/client/app/model/APPRepository.java
Tue Jun  9 16:27:06 2009
@@ -36,9 +36,6 @@
 import org.apache.chemistry.atompub.client.app.APPContentManager;
 import org.apache.chemistry.atompub.client.app.Request;
 import org.apache.chemistry.atompub.client.app.Response;
-import org.apache.chemistry.atompub.client.app.service.ServiceContext;
-import org.apache.chemistry.atompub.client.app.service.ServiceFeedReader;
-import org.apache.chemistry.atompub.client.app.service.ServiceInfo;
 import org.apache.chemistry.atompub.client.common.atom.ReadContext;
 
 /**
@@ -52,8 +49,6 @@
 
     protected String id;
 
-    protected Map<String, ServiceInfo> services;
-
     protected Map<String, Type> typeRegistry;
 
     protected Map<String, String> collections = new HashMap<String, String>();
@@ -172,81 +167,16 @@
         }
     }
 
-    protected void loadServices() {
-        if (services == null) {
-            String href = getCollectionHref("services");
-            if (href != null) {
-                Request req = new Request(href);
-                Response resp = cm.getConnector().get(req);
-                if (!resp.isOk()) {
-                    throw new ContentManagerException(
-                            "Remote server returned error code: "
-                                    + resp.getStatusCode());
-                }
-                InputStream in = resp.getStream();
-                try {
-                    try {
-                        services = ServiceFeedReader.getBuilder().read(
-                                new ReadContext(this), in);
-                    } finally {
-                        in.close();
-                    }
-                } catch (Exception e) {
-                    throw new ContentManagerException("Failed to read response");
-                }
-            }
-            if (services == null) {
-                services = new HashMap<String, ServiceInfo>();
-            }
-        }
-    }
-
-    protected void putSingletonService(Class<?> clazz, Object service) {
-        singletons.put(clazz, service);
-    }
-
-    protected Object getSingletonService(Class<?> clazz) {
-        return singletons.get(clazz);
-    }
-
-    /**
-     * Get an extension service in repository scope
-     *
-     * @param <T>
-     * @param clazz service interface class
-     * @param repository the repository to bound the service on
-     * @return the service instance or null if none
+    /*
+     * Subclasses should override this.
      */
     public <T> T getExtension(Class<T> clazz) {
-        loadServices(); // be sure services information is loaded
-        ServiceInfo info = services.get(clazz.getName());
-        if (info != null) {
-            if (info.requiresConnection()) {
-                return null;
-            }
-            if (info.isSingleton()) {
-                Object service = getSingletonService(clazz);
-                if (service != null) {
-                    return (T) service;
-                }
-            }
-            ServiceContext ctx = new ServiceContext(info, this);
-            try {
-                Object service = info.newInstance(ctx);
-                if (info.isSingleton()) {
-                    putSingletonService(clazz, service);
-                }
-                return (T) service;
-            } catch (Exception e) {
-                // do nothing
-            }
-        }
         return null;
     }
 
     @Override
     public String toString() {
-        return getName();
+        return this.getClass().getSimpleName() + '(' + getName() + ')';
     }
 
 }



Mime
View raw message