Author: cwiklik
Date: Thu Feb 10 18:47:21 2011
New Revision: 1069521

URL: http://svn.apache.org/viewvc?rev=1069521&view=rev
Log:
UIMA-2044 Modified getComponentName() to handle missing name in the AE 
descriptor

Modified:
    
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java

Modified: 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
URL: 
http://svn.apache.org/viewvc/uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java?rev=1069521&r1=1069520&r2=1069521&view=diff
==============================================================================
--- 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
 (original)
+++ 
uima/uima-as/trunk/uimaj-as-core/src/main/java/org/apache/uima/aae/controller/BaseAnalysisEngineController.java
 Thu Feb 10 18:47:21 2011
@@ -248,6 +248,8 @@ public abstract class BaseAnalysisEngine
   // Holds destination names of clients known to be dead
   protected ConcurrentHashMap<String,String> deadClientDestinationMap = new 
ConcurrentHashMap<String, String>();
   
+  private String serviceName=null;
+  
   public BaseAnalysisEngineController() {
 
   }
@@ -308,7 +310,6 @@ public abstract class BaseAnalysisEngine
 
     endpointName = anEndpointName;
     delegateKey = anEndpointName;
-
     if (this instanceof AggregateAnalysisEngineController) {
       ConcurrentHashMap endpoints = new ConcurrentHashMap();
       endpoints.putAll(aDestinationMap);
@@ -930,12 +931,48 @@ public abstract class BaseAnalysisEngine
   public boolean isTopLevelComponent() {
     return (parentController == null);
   }
-
+  private String setupName() {
+    //return ((ResourceCreationSpecifier) 
resourceSpecifier).getMetaData().getName();
+    String serviceName = ((ResourceCreationSpecifier) 
resourceSpecifier).getMetaData().getName();
+    if ( serviceName == null || serviceName.trim().length() == 0 ) {
+      if ( isTopLevelComponent() ) {
+        if ( isPrimitive() ) {
+          String implementationName = ((ResourceCreationSpecifier) 
resourceSpecifier).getImplementationName();
+          if ( implementationName.indexOf(".") > 0) {
+            implementationName = 
implementationName.substring(implementationName.lastIndexOf(".")+1);
+          }
+          return implementationName;
+        } else {
+          return "Top Level Aggregate Service";
+        }
+      } else {
+        try {
+          UimaContext childContext = 
parentController.getChildUimaContext(endpointName);
+          String qualifiedName = 
((UimaContextAdmin)childContext).getQualifiedContextName();
+          if ( qualifiedName != null ) {
+            if ( qualifiedName.startsWith("/")) {
+              qualifiedName = qualifiedName.substring(1);
+              qualifiedName = qualifiedName.replaceAll("/", "_"); // normalize
+              if ( qualifiedName.endsWith("_")) {
+                qualifiedName = qualifiedName.substring(0, 
qualifiedName.length()-1);
+              }
+            }
+          }
+        } catch( Exception e){}
+        return delegateKey;
+      }
+    } else {
+      return serviceName;
+    }
+  }
   /**
    * Returns the name of the component. The name comes from the analysis 
engine descriptor
    */
   public String getComponentName() {
-    return ((ResourceCreationSpecifier) 
resourceSpecifier).getMetaData().getName();
+    if ( serviceName == null ) {
+      serviceName = setupName();
+    }
+    return serviceName;
   }
 
   /**


Reply via email to