You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2008/04/23 09:18:39 UTC
svn commit: r650769 - in
/incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core:
DefaultExtensionPointRegistry.java DefaultUtilityExtensionPoint.java
UtilityExtensionPoint.java
Author: jsdelfino
Date: Wed Apr 23 00:18:39 2008
New Revision: 650769
URL: http://svn.apache.org/viewvc?rev=650769&view=rev
Log:
Use consistent names for utilityextension point methods.
Modified:
incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java
Modified: incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java?rev=650769&r1=650768&r2=650769&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java (original)
+++ incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultExtensionPointRegistry.java Wed Apr 23 00:18:39 2008
@@ -60,8 +60,8 @@
throw new IllegalArgumentException("Cannot register null as an ExtensionPoint");
}
- Set<Class> interfaces = getAllInterfaces(extensionPoint.getClass());
- for (Class i : interfaces) {
+ Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass());
+ for (Class<?> i : interfaces) {
extensionPoints.put(i, extensionPoint);
}
}
@@ -151,8 +151,8 @@
throw new IllegalArgumentException("Cannot remove null as an ExtensionPoint");
}
- Set<Class> interfaces = getAllInterfaces(extensionPoint.getClass());
- for (Class i : interfaces) {
+ Set<Class<?>> interfaces = getAllInterfaces(extensionPoint.getClass());
+ for (Class<?> i : interfaces) {
extensionPoints.remove(i);
}
}
@@ -161,19 +161,15 @@
* Returns the set of interfaces implemented by the given class and its
* ancestors or a blank set if none
*/
- private static Set<Class> getAllInterfaces(Class clazz) {
- Set<Class> implemented = new HashSet<Class>();
+ private static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
+ Set<Class<?>> implemented = new HashSet<Class<?>>();
getAllInterfaces(clazz, implemented);
return implemented;
}
- private static void getAllInterfaces(Class clazz, Set<Class> implemented) {
- Class[] interfaces = clazz.getInterfaces();
- for (Class interfaze : interfaces) {
-// String name = interfaze.getName();
-// if (name.startsWith("java.") || name.startsWith("javax.")) {
-// continue;
-// }
+ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) {
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for (Class<?> interfaze : interfaces) {
if (Modifier.isPublic(interfaze.getModifiers())) {
implemented.add(interfaze);
}
Modified: incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java?rev=650769&r1=650768&r2=650769&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java (original)
+++ incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/DefaultUtilityExtensionPoint.java Wed Apr 23 00:18:39 2008
@@ -31,12 +31,12 @@
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
/**
- * Default implementation of an extension point to hold Tuscany utility services.
+ * Default implementation of an extension point to hold Tuscany utility utilities.
*
* @version $Rev$ $Date$
*/
public class DefaultUtilityExtensionPoint implements UtilityExtensionPoint {
- private Map<Class<?>, Object> services = new HashMap<Class<?>, Object>();
+ private Map<Class<?>, Object> utilities = new HashMap<Class<?>, Object>();
private ExtensionPointRegistry extensionPoints;
@@ -48,21 +48,21 @@
}
/**
- * Add a service to the extension point. This default implementation
- * stores services against the interfaces that they implement.
+ * Add a utility to the extension point. This default implementation
+ * stores utilities against the interfaces that they implement.
*
- * @param service The instance of the service
+ * @param utility The instance of the utility
*
- * @throws IllegalArgumentException if service is null
+ * @throws IllegalArgumentException if utility is null
*/
- public void addService(Object service) {
- if (service == null) {
+ public void addUtility(Object utility) {
+ if (utility == null) {
throw new IllegalArgumentException("Cannot register null as a Service");
}
- Set<Class> interfaces = getAllInterfaces(service.getClass());
- for (Class i : interfaces) {
- services.put(i, service);
+ Set<Class<?>> interfaces = getAllInterfaces(utility.getClass());
+ for (Class<?> i : interfaces) {
+ utilities.put(i, utility);
}
}
@@ -86,43 +86,43 @@
}
/**
- * Get the service by the interface that it implements
+ * Get the utility by the interface that it implements
*
- * @param serviceType The lookup key (service interface)
- * @return The instance of the service
+ * @param utilityType The lookup key (utility interface)
+ * @return The instance of the utility
*
- * @throws IllegalArgumentException if serviceType is null
+ * @throws IllegalArgumentException if utilityType is null
*/
- public <T> T getService(Class<T> serviceType) {
- if (serviceType == null) {
+ public <T> T getUtility(Class<T> utilityType) {
+ if (utilityType == null) {
throw new IllegalArgumentException("Cannot lookup Service of type null");
}
- Object service = services.get(serviceType);
- if (service == null) {
+ Object utility = utilities.get(utilityType);
+ if (utility == null) {
- // Dynamically load a service class declared under META-INF/services
+ // Dynamically load a utility class declared under META-INF/utilities
try {
- Class<?> serviceClass =
- ServiceDiscovery.getInstance().loadFirstServiceClass(serviceType);
- if (serviceClass != null) {
- // Construct the service
- Constructor<?>[] constructors = serviceClass.getConstructors();
+ Class<?> utilityClass =
+ ServiceDiscovery.getInstance().loadFirstServiceClass(utilityType);
+ if (utilityClass != null) {
+ // Construct the utility
+ Constructor<?>[] constructors = utilityClass.getConstructors();
Constructor<?> constructor = getConstructor(constructors, new Class<?>[] {ExtensionPointRegistry.class});
if (constructor != null) {
- service = constructor.newInstance(extensionPoints);
+ utility = constructor.newInstance(extensionPoints);
} else {
constructor = getConstructor(constructors, new Class<?>[] {});
if (constructor != null) {
- service = constructor.newInstance();
+ utility = constructor.newInstance();
} else {
throw new IllegalArgumentException(
- "No valid constructor is found for " + serviceClass);
+ "No valid constructor is found for " + utilityClass);
}
}
- // Cache the loaded service
- addService(service);
+ // Cache the loaded utility
+ addUtility(utility);
}
} catch (InvocationTargetException e) {
throw new IllegalArgumentException(e);
@@ -136,24 +136,24 @@
throw new IllegalArgumentException(e);
}
}
- return serviceType.cast(service);
+ return utilityType.cast(utility);
}
/**
- * Remove a service based on the interface that it implements
+ * Remove a utility based on the interface that it implements
*
- * @param service The service to remove
+ * @param utility The utility to remove
*
- * @throws IllegalArgumentException if service is null
+ * @throws IllegalArgumentException if utility is null
*/
- public void removeService(Object service) {
- if (service == null) {
+ public void removeUtility(Object utility) {
+ if (utility == null) {
throw new IllegalArgumentException("Cannot remove null as a Service");
}
- Set<Class> interfaces = getAllInterfaces(service.getClass());
- for (Class i : interfaces) {
- services.remove(i);
+ Set<Class<?>> interfaces = getAllInterfaces(utility.getClass());
+ for (Class<?> i : interfaces) {
+ utilities.remove(i);
}
}
@@ -161,15 +161,15 @@
* Returns the set of interfaces implemented by the given class and its
* ancestors or a blank set if none
*/
- private static Set<Class> getAllInterfaces(Class clazz) {
- Set<Class> implemented = new HashSet<Class>();
+ private static Set<Class<?>> getAllInterfaces(Class<?> clazz) {
+ Set<Class<?>> implemented = new HashSet<Class<?>>();
getAllInterfaces(clazz, implemented);
return implemented;
}
- private static void getAllInterfaces(Class clazz, Set<Class> implemented) {
- Class[] interfaces = clazz.getInterfaces();
- for (Class interfaze : interfaces) {
+ private static void getAllInterfaces(Class<?> clazz, Set<Class<?>> implemented) {
+ Class<?>[] interfaces = clazz.getInterfaces();
+ for (Class<?> interfaze : interfaces) {
if (Modifier.isPublic(interfaze.getModifiers())) {
implemented.add(interfaze);
}
Modified: incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java?rev=650769&r1=650768&r2=650769&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java (original)
+++ incubator/tuscany/java/sca/modules/extensibility/src/main/java/org/apache/tuscany/sca/core/UtilityExtensionPoint.java Wed Apr 23 00:18:39 2008
@@ -21,34 +21,34 @@
/**
- * The extension point for the Tuscany core utility service extensions.
+ * The extension point for the Tuscany core utility extensions.
*
* @version $Rev$ $Date$
*/
public interface UtilityExtensionPoint {
/**
- * Add a service to the registry
- * @param service The instance of the service
+ * Add a utility to the extension point
+ * @param utility The instance of the utility
*
- * @throws IllegalArgumentException if service is null
+ * @throws IllegalArgumentException if utility is null
*/
- void addService(Object service);
+ void addUtility(Object utility);
/**
- * Get the service by the interface
- * @param serviceType The lookup key (service interface)
- * @return The instance of the service
+ * Get the utility by the interface
+ * @param utilityType The lookup key (utility interface)
+ * @return The instance of the utility
*
- * @throws IllegalArgumentException if serviceType is null
+ * @throws IllegalArgumentException if utilityType is null
*/
- <T> T getService(Class<T> serviceType);
+ <T> T getUtility(Class<T> utilityType);
/**
- * Remove a service
- * @param service The service to remove
+ * Remove a utility
+ * @param utility The utility to remove
*
- * @throws IllegalArgumentException if service is null
+ * @throws IllegalArgumentException if utility is null
*/
- void removeService(Object service);
+ void removeUtility(Object utility);
}