geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r778797 - /geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
Date Tue, 26 May 2009 16:53:01 GMT
Author: gnodet
Date: Tue May 26 16:53:01 2009
New Revision: 778797

URL: http://svn.apache.org/viewvc?rev=778797&view=rev
Log:
Simplify ServiceRecipe as the OSGi framework takes care about all that

Modified:
    geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java

Modified: geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java?rev=778797&r1=778796&r2=778797&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
(original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ServiceRecipe.java
Tue May 26 16:53:01 2009
@@ -57,8 +57,6 @@
     private ServiceRegistration registration;
     private Map registrationProperties;
     private List<Listener> listeners;
-    // TODO: the framework will cache the service, so there should be need to have a list
of registrations for a given bundle
-    private Map<Bundle, Entry> instanceMap = Collections.synchronizedMap(new HashMap<Bundle,
Entry>());
     private Object service;
     private boolean bundleScope;
 
@@ -176,34 +174,16 @@
         if (service instanceof ServiceFactory) {
             service = ((ServiceFactory) service).getService(bundle, registration);
         } else if (bundleScope) {
-            Entry entry;
-            synchronized(bundle) {
-                entry = instanceMap.get(bundle);
-                if (entry == null) {
-                    entry = new Entry(createInstance(true));
-                    LOGGER.debug("Created service instance for bundle: " + bundle + " " +
entry.getServiceInstance().hashCode());
-                    instanceMap.put(bundle, entry);
-                }
-                entry.addServiceRegistration(registration);
-            }
-            service = entry.getServiceInstance();
+            service = createInstance(true);
+            LOGGER.debug("Created service instance for bundle: " + bundle + " " + service.hashCode());
         }
         return service;
     }
 
     public void ungetService(Bundle bundle, ServiceRegistration registration, Object service)
{
         if (bundleScope) {
-            synchronized(bundle) {
-                Entry entry = instanceMap.get(bundle);
-                if (entry != null) {
-                    entry.removeServiceRegistration(registration);
-                    if (!entry.hasServiceRegistrations()) {
-                        destroyInstance(entry.getServiceInstance());
-                        LOGGER.debug("Destroyed service instance for bundle: " + bundle);
-                        instanceMap.remove(bundle);
-                    }
-                }
-            }
+            destroyInstance(service);
+            LOGGER.debug("Destroyed service instance for bundle: " + bundle);
         }
     }
 
@@ -378,31 +358,4 @@
 
     }
 
-    private static class Entry {
-
-        private final Object serviceInstance;
-        private final Set<ServiceRegistration> registrations = new HashSet<ServiceRegistration>();
-
-        public Entry(Object serviceInstance) {
-            this.serviceInstance = serviceInstance;
-        }
-
-        public Object getServiceInstance() {
-            return this.serviceInstance;
-        }
-
-        public boolean hasServiceRegistrations() {
-            return !registrations.isEmpty();
-        }
-
-        public void addServiceRegistration(ServiceRegistration registration) {
-            registrations.add(registration);
-        }
-
-        public void removeServiceRegistration(ServiceRegistration registration) {
-            registrations.remove(registration);
-        }
-
-    }
-
 }



Mime
View raw message