abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r447929 - /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSingletonProviderManager.java
Date Tue, 19 Sep 2006 18:50:56 GMT
Author: jmsnell
Date: Tue Sep 19 11:50:56 2006
New Revision: 447929

URL: http://svn.apache.org/viewvc?view=rev&rev=447929
Log:
Helpful ProviderManager implementation that makes it easier
for an implementation to provide a single Provider instance
for all handlers

Added:
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSingletonProviderManager.java

Added: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSingletonProviderManager.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSingletonProviderManager.java?view=auto&rev=447929
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSingletonProviderManager.java
(added)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/util/AbstractSingletonProviderManager.java
Tue Sep 19 11:50:56 2006
@@ -0,0 +1,27 @@
+package org.apache.abdera.protocol.server.util;
+
+import org.apache.abdera.protocol.server.provider.Provider;
+import org.apache.abdera.protocol.server.provider.ProviderManager;
+
+public abstract class AbstractSingletonProviderManager 
+  implements ProviderManager {
+
+  protected Provider provider;
+  
+  public Provider getProvider() {
+    if (provider == null) {
+      synchronized(this) {
+        provider = initProvider();
+      }
+    }
+    return provider;
+  }
+
+  protected abstract Provider initProvider();
+  
+  public void release(Provider provider) {
+    // nothing to release. subclasses could choose to do reference counting
+    // if they want
+  }
+
+}



Mime
View raw message