You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gn...@apache.org on 2009/07/02 16:00:39 UTC
svn commit: r790595 - in
/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container:
ReferenceListRecipe.java ServiceRecipe.java
Author: gnodet
Date: Thu Jul 2 14:00:38 2009
New Revision: 790595
URL: http://svn.apache.org/viewvc?rev=790595&view=rev
Log:
Fix support for ServiceFactory and use the correct filter for ServiceUnavailableException
Modified:
geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java
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/ReferenceListRecipe.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java?rev=790595&r1=790594&r2=790595&view=diff
==============================================================================
--- geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java (original)
+++ geronimo/sandbox/blueprint/blueprint-core/src/main/java/org/apache/geronimo/blueprint/container/ReferenceListRecipe.java Thu Jul 2 14:00:38 2009
@@ -198,7 +198,7 @@
* The ServiceDispatcher is used when creating the cglib proxy.
* Thic class is responsible for getting the actual service that will be used.
*/
- public static class ServiceDispatcher implements Callable<Object> {
+ public class ServiceDispatcher implements Callable<Object> {
public ServiceReference reference;
public Object service;
@@ -219,7 +219,7 @@
public synchronized Object call() throws Exception {
if (reference == null) {
- throw new ServiceUnavailableException("Service is unavailable", null);
+ throw new ServiceUnavailableException("Service is unavailable", getOsgiFilter());
}
if (service == null) {
service = reference.getBundle().getBundleContext().getService(reference);
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=790595&r1=790594&r2=790595&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 Thu Jul 2 14:00:38 2009
@@ -126,7 +126,7 @@
}
ServiceRegistrationProxy proxy = new ServiceRegistrationProxy();
addObject(proxy, true);
- internalGetService();
+ internalGetService(null, null); // null bundle means we don't want to retrieve the actual service when used with a ServiceFactory
return proxy;
}
@@ -192,7 +192,7 @@
if (listeners != null) {
LOGGER.debug("Calling listeners for service unregistration");
for (ServiceListener listener : listeners) {
- listener.unregister(prototypeService || service instanceof ServiceFactory ? null : service, registrationProperties);
+ listener.unregister(service instanceof ServiceFactory || !prototypeService ? service : null, registrationProperties);
}
}
reg.unregister();
@@ -239,14 +239,14 @@
if (registered) { // Do not call isRegistered() because of the synchronization
LOGGER.debug("Calling listeners for initial service registration");
for (ServiceListener listener : listeners) {
- listener.register(prototypeService || service instanceof ServiceFactory ? null : service,
+ listener.register(service instanceof ServiceFactory || !prototypeService ? service : null,
registrationProperties);
}
} else {
LOGGER.debug("Calling listeners for initial service unregistration");
for (ServiceListener listener : listeners) {
- listener.unregister(prototypeService || service instanceof ServiceFactory ? null : service,
- registrationProperties);
+ listener.unregister(service instanceof ServiceFactory || !prototypeService ? service : null,
+ registrationProperties);
}
}
}
@@ -257,24 +257,26 @@
}
}
Object service = this.service;
- if (service instanceof ServiceFactory) {
- service = ((ServiceFactory) service).getService(bundle, registration);
- } else if (prototypeService && bundle != blueprintContainer.getBundleContext().getBundle()) {
- service = createInstance();
- LOGGER.debug("Created service instance for bundle: " + bundle + " " + service.hashCode());
- }
- if (service == null) {
- throw new IllegalStateException("service is null");
- }
- // Check if the service actually implement all the requested interfaces
- if (metadata.getAutoExport() == ServiceMetadata.AUTO_EXPORT_DISABLED) {
- Set<String> allClasses = new HashSet<String>();
- ReflectionUtils.getSuperClasses(allClasses, service.getClass());
- ReflectionUtils.getImplementedInterfaces(allClasses, service.getClass());
- Set<String> classes = getClasses();
- classes.removeAll(allClasses);
- if (!classes.isEmpty()) {
- throw new ComponentDefinitionException("The service implementation does not implement the required interfaces: " + classes);
+ if (bundle != null) {
+ if (service instanceof ServiceFactory) {
+ service = ((ServiceFactory) service).getService(bundle, registration);
+ } else if (prototypeService && bundle != blueprintContainer.getBundleContext().getBundle()) {
+ service = createInstance();
+ LOGGER.debug("Created service instance for bundle: " + bundle + " " + service.hashCode());
+ }
+ if (service == null) {
+ throw new IllegalStateException("service is null");
+ }
+ // Check if the service actually implement all the requested interfaces
+ if (metadata.getAutoExport() == ServiceMetadata.AUTO_EXPORT_DISABLED) {
+ Set<String> allClasses = new HashSet<String>();
+ ReflectionUtils.getSuperClasses(allClasses, service.getClass());
+ ReflectionUtils.getImplementedInterfaces(allClasses, service.getClass());
+ Set<String> classes = getClasses();
+ classes.removeAll(allClasses);
+ if (!classes.isEmpty()) {
+ throw new ComponentDefinitionException("The service implementation does not implement the required interfaces: " + classes);
+ }
}
}
return service;