You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2007/03/29 18:43:55 UTC

svn commit: r523764 - in /incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common: ./ tools/wsdl/ xbean/

Author: gnodet
Date: Thu Mar 29 09:43:53 2007
New Revision: 523764

URL: http://svn.apache.org/viewvc?view=rev&rev=523764
Log:
SM-903: use generics

Modified:
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/Schema.java
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalyzer.java
    incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/AsyncBaseLifeCycle.java Thu Mar 29 09:43:53 2007
@@ -81,17 +81,17 @@
 
     protected boolean workManagerCreated;
 
-    protected Map processors;
+    protected Map<String, ExchangeProcessor> processors;
     
-    protected ThreadLocal correlationId;
+    protected ThreadLocal<String> correlationId;
     
     protected String currentState = LifeCycleMBean.UNKNOWN;
 
     public AsyncBaseLifeCycle() {
         this.running = new AtomicBoolean(false);
         this.polling = new AtomicBoolean(false);
-        this.processors = new ConcurrentHashMap();
-        this.correlationId = new ThreadLocal();
+        this.processors = new ConcurrentHashMap<String, ExchangeProcessor>();
+        this.correlationId = new ThreadLocal<String>();
     }
 
     public AsyncBaseLifeCycle(ServiceMixComponent component) {
@@ -504,7 +504,7 @@
                     processor = ep.getProcessor();
                 }
             } else {
-                processor = (ExchangeProcessor) processors.remove(exchange.getExchangeId());
+                processor = processors.remove(exchange.getExchangeId());
             }
             if (processor == null) {
                 throw new IllegalStateException("No processor found for: " + exchange.getExchangeId());
@@ -577,7 +577,7 @@
         String correlationIDValue = (String) exchange.getProperty(JbiConstants.CORRELATION_ID);
         if (correlationIDValue == null) {
             // Retrieve correlation id from thread local variable, if exist
-            correlationIDValue = (String) correlationId.get();
+            correlationIDValue = correlationId.get();
             if (correlationIDValue == null) {
                 // Set a correlation id property that have to be propagated in all components
                 // to trace the process instance

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/Registry.java Thu Mar 29 09:43:53 2007
@@ -24,17 +24,17 @@
 public class Registry {
 
     protected ServiceMixComponent component;
-    protected Map endpoints;
-    protected Map serviceUnits;
+    protected Map<String, Endpoint> endpoints;
+    protected Map<String, ServiceUnit> serviceUnits;
     
     public Registry(ServiceMixComponent component) {
         this.component = component;
-        this.endpoints = new HashMap();
-        this.serviceUnits = new HashMap();
+        this.endpoints = new HashMap<String, Endpoint>();
+        this.serviceUnits = new HashMap<String, ServiceUnit>();
     }
 
     public Endpoint getEndpoint(String key) {
-        return (Endpoint) this.endpoints.get(key);
+        return this.endpoints.get(key);
     }
     
     public boolean isRegistered(ServiceUnit su) {
@@ -46,7 +46,7 @@
     }
     
     public ServiceUnit getServiceUnit(String name) {
-        return (ServiceUnit) this.serviceUnits.get(name);
+        return this.serviceUnits.get(name);
     }
     
     public void registerEndpoint(Endpoint ep) {

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/ServiceUnit.java Thu Mar 29 09:43:53 2007
@@ -18,7 +18,6 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -37,7 +36,7 @@
 
     protected String status = LifeCycleMBean.SHUTDOWN;
 
-    protected Map endpoints = new LinkedHashMap();
+    protected Map<String, Endpoint> endpoints = new LinkedHashMap<String, Endpoint>();
 
     public ServiceUnit() {
     }
@@ -48,19 +47,17 @@
 
     public void start() throws Exception {
         // Activate endpoints
-        List activated = new ArrayList();
+        List<Endpoint> activated = new ArrayList<Endpoint>();
         try {
-            for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
-                Endpoint endpoint = (Endpoint) iter.next();
+            for (Endpoint endpoint : getEndpoints()) {
                 endpoint.activate();
                 activated.add(endpoint);
             }
             this.status = LifeCycleMBean.STARTED;
         } catch (Exception e) {
             // Deactivate activated endpoints
-            for (Iterator iter = activated.iterator(); iter.hasNext();) {
+            for (Endpoint endpoint : activated) {
                 try {
-                    Endpoint endpoint = (Endpoint) iter.next();
                     endpoint.deactivate();
                 } catch (Exception e2) {
                     // do nothing
@@ -74,8 +71,7 @@
         this.status = LifeCycleMBean.STOPPED;
         // Deactivate endpoints
         Exception exception = null;
-        for (Iterator iter = getEndpoints().iterator(); iter.hasNext();) {
-            Endpoint endpoint = (Endpoint) iter.next();
+        for (Endpoint endpoint : getEndpoints()) {
             try {
                 endpoint.deactivate();
             } catch (Exception e) {
@@ -126,7 +122,7 @@
         this.component = component;
     }
 
-    public Collection getEndpoints() {
+    public Collection<Endpoint> getEndpoints() {
         return this.endpoints.values();
     }
 
@@ -146,7 +142,7 @@
     }
 
     public Endpoint getEndpoint(String key) {
-        return (Endpoint) this.endpoints.get(key);
+        return this.endpoints.get(key);
     }
 
     public ClassLoader getConfigurationClassLoader() {

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/Schema.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/Schema.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/Schema.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/Schema.java Thu Mar 29 09:43:53 2007
@@ -31,8 +31,8 @@
 
     private Element root;
     private String namespace;
-    private List imports;
-    private List sourceUris;
+    private List<String> imports;
+    private List<URI> sourceUris;
     
     /**
      * Add a reference to an imported namespace.
@@ -40,7 +40,7 @@
      */
     public void addImport(String namespace) {
         if (imports == null) {
-            imports = new ArrayList();
+            imports = new ArrayList<String>();
         }
         imports.add(namespace);
     }
@@ -48,14 +48,14 @@
     /**
      * @return Returns the imports.
      */
-    public List getImports() {
+    public List<String> getImports() {
         return imports;
     }
 
     /**
      * @param imports The imports to set.
      */
-    public void setImports(List imports) {
+    public void setImports(List<String> imports) {
         this.imports = imports;
     }
 
@@ -90,7 +90,7 @@
     /**
      * @return Returns the sourceUri.
      */
-    public List getSourceUris() {
+    public List<URI> getSourceUris() {
         return sourceUris;
     }
 
@@ -99,7 +99,7 @@
      */
     public void addSourceUri(URI sourceUri) {
     	if (sourceUris == null) {
-    		sourceUris = new ArrayList();
+    		sourceUris = new ArrayList<URI>();
     	}
         sourceUris.add(sourceUri);
     }

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/SchemaCollection.java Thu Mar 29 09:43:53 2007
@@ -19,6 +19,7 @@
 import java.net.URI;
 import java.util.Collection;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -44,7 +45,7 @@
 
     private static Log log = LogFactory.getLog(SchemaCollection.class);
     
-    private Map schemas;
+    private Map<String, Schema> schemas;
     private URI baseUri;
     
     public SchemaCollection() {
@@ -56,16 +57,16 @@
             log.debug("Initializing schema collection with baseUri: " + baseUri);
         }
         this.baseUri = baseUri;
-        this.schemas = new HashMap();
+        this.schemas = new HashMap<String, Schema>();
     }
     
     public Schema getSchema(String namespaceURI) {
-        return (Schema) schemas.get(namespaceURI);
+        return schemas.get(namespaceURI);
     }
     
     public void read(Element elem, URI sourceUri) throws Exception {
     	String namespace = elem.getAttribute("targetNamespace");
-    	Schema schema = (Schema) schemas.get(namespace);
+    	Schema schema = schemas.get(namespace);
     	if (schema == null) {
 	        schema = new Schema();
 	        schema.addSourceUri(sourceUri);
@@ -118,8 +119,8 @@
     
     protected void handleImports(Schema schema, URI baseUri) throws Exception {
         NodeList children = schema.getRoot().getChildNodes();
-        List imports = new ArrayList();
-        List includes = new ArrayList();
+        List<Element> imports = new ArrayList<Element>();
+        List<Element> includes = new ArrayList<Element>();
         for (int i = 0; i < children.getLength(); i++) {
             Node child = children.item(i);
             if (child instanceof Element) {
@@ -133,8 +134,8 @@
                 }
             }
         }
-        for (Iterator iter = imports.iterator(); iter.hasNext();) {
-            Element ce = (Element) iter.next();
+        for (Iterator<Element> iter = imports.iterator(); iter.hasNext();) {
+            Element ce = iter.next();
             String namespace = ce.getAttribute("namespace");
             String location = ce.getAttribute("schemaLocation");
             schema.addImport(namespace);
@@ -143,8 +144,8 @@
             	read(location, baseUri);
             }
         }
-        for (Iterator iter = includes.iterator(); iter.hasNext();) {
-            Element ce = (Element) iter.next();
+        for (Iterator<Element> iter = includes.iterator(); iter.hasNext();) {
+            Element ce = iter.next();
 	        String location = ce.getAttribute("schemaLocation");
             schema.getRoot().removeChild(ce);
 	        if (location != null && !"".equals(location)) {
@@ -171,11 +172,11 @@
         }
      }
      
-     public Collection getSchemas() {
+     public Collection<Schema> getSchemas() {
         if (schemas != null) {
            return schemas.values();
         } else {
-           return java.util.Collections.EMPTY_SET;
+           return Collections.emptySet();
         }
      }
 }

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/tools/wsdl/WSDLFlattener.java Thu Mar 29 09:43:53 2007
@@ -38,18 +38,13 @@
 import javax.wsdl.factory.WSDLFactory;
 import javax.xml.namespace.QName;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
 import com.ibm.wsdl.extensions.schema.SchemaImpl;
 
 public class WSDLFlattener {
 
-    private static Log log = LogFactory.getLog(WSDLFlattener.class);
-    
     private Definition definition;
     private SchemaCollection schemas;
-    private Map flattened;
+    private Map<QName, Definition> flattened;
     private boolean initialized;
     
     public WSDLFlattener() {
@@ -62,7 +57,7 @@
         
     public WSDLFlattener(Definition definition, SchemaCollection schemas) {
         this.definition = definition;
-        this.flattened = new HashMap();
+        this.flattened = new HashMap<QName, Definition>();
         this.schemas = schemas;
     }
     
@@ -87,7 +82,7 @@
      * @throws Exception if an error occurs
      */
     public Definition getDefinition(QName portType) throws Exception {
-        Definition def = (Definition) flattened.get(portType);
+        Definition def = flattened.get(portType);
         if (def == null) {
             def = flattenDefinition(portType);
             flattened.put(portType, def);

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalyzer.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalyzer.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalyzer.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/AbstractXBeanServiceUnitAnalyzer.java Thu Mar 29 09:43:53 2007
@@ -25,6 +25,7 @@
 import javax.jbi.messaging.MessageExchange;
 
 import org.apache.servicemix.common.Endpoint;
+import org.apache.servicemix.common.packaging.Consumes;
 import org.apache.servicemix.common.packaging.Provides;
 import org.apache.servicemix.common.packaging.ServiceUnitAnalyzer;
 import org.apache.xbean.spring.context.FileSystemXmlApplicationContext;
@@ -33,32 +34,32 @@
 public abstract class AbstractXBeanServiceUnitAnalyzer implements
 		ServiceUnitAnalyzer {
 
-	List consumes = new ArrayList();
+	List<Consumes> consumes = new ArrayList<Consumes>();
 
-	List provides = new ArrayList();
+	List<Provides> provides = new ArrayList<Provides>();
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see org.apache.servicemix.common.packaging.ServiceUnitAnalyzer#getConsumes()
 	 */
-	public List getConsumes() {
+	public List<Consumes> getConsumes() {
 		return consumes;
 	}
 
-	protected abstract List getConsumes(Endpoint endpoint);
+	protected abstract List<Consumes> getConsumes(Endpoint endpoint);
 
 	/*
 	 * (non-Javadoc)
 	 * 
 	 * @see org.apache.servicemix.common.packaging.ServiceUnitAnalyzer#getProvides()
 	 */
-	public List getProvides() {
+	public List<Provides> getProvides() {
 		return provides;
 	}
 
-	protected List getProvides(Endpoint endpoint) {
-		List providesList = new ArrayList();
+	protected List<Provides> getProvides(Endpoint endpoint) {
+		List<Provides> providesList = new ArrayList<Provides>();
 		if (endpoint.getRole().equals(MessageExchange.Role.PROVIDER)) {
 			Provides newProvide = new Provides();
 			newProvide.setEndpointName(endpoint.getEndpoint());

Modified: incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java?view=diff&rev=523764&r1=523763&r2=523764
==============================================================================
--- incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java (original)
+++ incubator/servicemix/trunk/common/servicemix-common/src/main/java/org/apache/servicemix/common/xbean/ClassLoaderXmlPreprocessor.java Thu Mar 29 09:43:53 2007
@@ -135,7 +135,7 @@
             }
 
             // build hidden classes
-            List hidden = new ArrayList();
+            List<String> hidden = new ArrayList<String>();
             NodeList hiddenElems = classpathElement.getElementsByTagName("hidden");
             for (int i = 0; i < hiddenElems.getLength(); i++) {
                 Element hiddenElement = (Element) hiddenElems.item(i);
@@ -144,7 +144,7 @@
             }
 
             // build non overridable classes
-            List nonOverridable = new ArrayList();
+            List<String> nonOverridable = new ArrayList<String>();
             NodeList nonOverridableElems = classpathElement.getElementsByTagName("nonOverridable");
             for (int i = 0; i < nonOverridableElems.getLength(); i++) {
                 Element nonOverridableElement = (Element) nonOverridableElems.item(i);
@@ -153,7 +153,7 @@
             }
 
             // build the classpath
-            List classpath = new ArrayList();
+            List<String> classpath = new ArrayList<String>();
             NodeList locations = classpathElement.getElementsByTagName("location");
             for (int i = 0; i < locations.getLength(); i++) {
                 Element locationElement = (Element) locations.item(i);
@@ -165,8 +165,8 @@
             URL[] urls;
             if (classpath.size() != 0) {
                 urls = new URL[classpath.size()];
-                for (ListIterator iterator = classpath.listIterator(); iterator.hasNext();) {
-                    String location = (String) iterator.next();
+                for (ListIterator<String> iterator = classpath.listIterator(); iterator.hasNext();) {
+                    String location = iterator.next();
                     URL url = repository.getResource(location);
                     if (url == null) {
                         throw new FatalBeanException("Unable to resolve classpath location " + location);
@@ -183,8 +183,8 @@
                                                  urls, 
                                                  parentLoader,
                                                  inverse,
-                                                 (String[]) hidden.toArray(new String[hidden.size()]),
-                                                 (String[]) nonOverridable.toArray(new String[nonOverridable.size()]));
+                                                 hidden.toArray(new String[hidden.size()]),
+                                                 nonOverridable.toArray(new String[nonOverridable.size()]));
 
             // remove the classpath element so Spring doesn't get confused
             document.getDocumentElement().removeChild(classpathElement);