[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openejb-cvs
Subject:    [1/2] tomee git commit: Adding lots of debug logging for container matching in AutoConfig
From:       jgallimore () apache ! org
Date:       2018-02-28 12:45:35
Message-ID: 5670178f66c24cc791a994c3b2e3c5a0 () git ! apache ! org
[Download RAW message or body]

Repository: tomee
Updated Branches:
  refs/heads/tomee-1.7.x a96992c58 -> ed3584cc9


Adding lots of debug logging for container matching in AutoConfig


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/99896796
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/99896796
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/99896796

Branch: refs/heads/tomee-1.7.x
Commit: 998967968a50aa5b5d28a5e45adf8afa6cad649b
Parents: a96992c
Author: Jonathan Gallimore <jon@jrg.me.uk>
Authored: Wed Feb 28 11:38:40 2018 +0000
Committer: Jonathan Gallimore <jon@jrg.me.uk>
Committed: Wed Feb 28 11:38:40 2018 +0000

----------------------------------------------------------------------
 .../org/apache/openejb/config/AutoConfig.java   | 76 +++++++++++++++++++-
 1 file changed, 73 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/99896796/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
                
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java \
b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java \
                index 0c73a5d..99bdf30 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AutoConfig.java
@@ -838,12 +838,20 @@ public class AutoConfig implements DynamicDeployer, \
                JndiConstants {
                 throw new OpenEJBException("No ejb deployment found for ejb " + \
bean.getEjbName());  }
 
-            final Class<? extends ContainerInfo> containerInfoType = \
ConfigurationFactory.getContainerInfoType(getType(bean)); +            final String \
beanType = getType(bean); +            final Class<? extends ContainerInfo> \
containerInfoType = ConfigurationFactory.getContainerInfoType(beanType); +            \
logger.debug("Bean type of bean {0} is {1}", bean.getId(), beanType); +
             if (ejbDeployment.getContainerId() == null && !skipMdb(bean)) {
+                logger.debug("Container for bean {0} is not set, looking for a \
suitable container", bean.getId()); +
                 String containerId = getUsableContainer(containerInfoType, bean, \
appResources);  if (containerId == null) {
+                    logger.debug("Suitable container for bean {0} not found, \
                creating one", bean.getId());
                     containerId = createContainer(containerInfoType, ejbDeployment, \
bean);  }
+
+                logger.debug("Setting container ID {0} for bean {0}", containerId, \
bean.getId());  ejbDeployment.setContainerId(containerId);
             }
 
@@ -2195,42 +2203,104 @@ public class AutoConfig implements DynamicDeployer, \
JndiConstants {  return installResource(beanName, resourceInfo);
     }
 
-    private String getUsableContainer(final Class<? extends ContainerInfo> \
containerInfoType, final Object bean, final AppResources appResources) { +    private \
String getUsableContainer(final Class<? extends ContainerInfo> containerInfoType, \
final EnterpriseBean bean, final AppResources appResources) { +        \
logger.debug("Searching for usable container for bean: {0}. Available application \
containers: {1}, available system containers {2}", +                bean.getId(),
+                getContainerIds(appResources.getContainerInfos()),
+                getContainerIds(configFactory.getContainerInfos())
+        );
+
         if (MessageDrivenBean.class.isInstance(bean)) {
             final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) bean;
             final String messagingType = messageDrivenBean.getMessagingType();
+
             final List<String> containerIds = \
appResources.containerIdsByType.get(messagingType); +            \
logger.debug("Searching for usable container for bean: {0} by messaging type: {1}. \
Potential application containers: {2}", +                    bean.getId(),
+                    messagingType,
+                    Join.join(",", containerIds));
+
             if (containerIds != null && !containerIds.isEmpty()) {
+                logger.debug("Returning first application container matching by \
type: {0} - {1}", +                        messagingType,
+                        containerIds.get(0));
+
                 return containerIds.get(0);
             }
         }
 
+        logger.debug("Attempting to find a matching container for bean: {0} from \
application containers {1}", +                bean.getId(),
+                getContainerIds(appResources.getContainerInfos()));
+
         String containerInfo = matchContainer(containerInfoType, bean, \
                appResources.getContainerInfos());
         if (containerInfo == null) { // avoid to build \
configFactory.getContainerInfos() if not needed +
+            logger.debug("Matching application container not found. Attempting to \
find a matching container for bean: {0} from system containers {1}", +                \
bean.getId(), +                    \
getContainerIds(appResources.getContainerInfos())); +
             containerInfo = matchContainer(containerInfoType, bean, \
configFactory.getContainerInfos());  }
+
         if (containerInfo != null) {
+            logger.debug("Using container {0} for bean {1}", containerInfo, \
bean.getId());  return containerInfo;
         }
 
+        logger.debug("No suitable existing container found for bean {0}", \
bean.getId());  return null;
     }
 
-    private String matchContainer(final Class<? extends ContainerInfo> \
containerInfoType, final Object bean, final Collection<ContainerInfo> list) { +    \
private String getContainerIds(final Collection<ContainerInfo> containerInfos) { +    \
final Set<String> containerIds = new HashSet<String>(); +
+        for (final ContainerInfo containerInfo : containerInfos) {
+            containerIds.add(containerInfo.id);
+        }
+
+        return Join.join(", ", containerIds);
+    }
+
+    private String matchContainer(final Class<? extends ContainerInfo> \
containerInfoType, final EnterpriseBean bean, final Collection<ContainerInfo> list) { \
for (final ContainerInfo containerInfo : list) {  if \
(containerInfo.getClass().equals(containerInfoType)) {  // MDBs must match message \
listener interface type  if (MessageDrivenBean.class.isInstance(bean)) {
                     final MessageDrivenBean messageDrivenBean = (MessageDrivenBean) \
                bean;
                     final String messagingType = \
messageDrivenBean.getMessagingType(); +
                     if \
(containerInfo.properties.get("MessageListenerInterface").equals(messagingType)) { +  \
logger.debug("Container {0} matches container type {1} and MessageListenerInterface \
{2} for bean {3}, this container will be used.", +                                \
containerInfo.id, +                                containerInfoType.getName(),
+                                messagingType,
+                                bean.getId());
+
                         return containerInfo.id;
+                    } else {
+                        logger.debug("Container {0} of type {1} does not have the \
matching MessageListenerInterface. Bean listener interface is {2}, " + +              \
"container listener interface is {3} for bean {4}. Skipping.", +                      \
containerInfo.id, +                                containerInfoType.getName(),
+                                messagingType,
+                                \
containerInfo.properties.get("MessageListenerInterface"), +                           \
bean.getId()); +
                     }
                 } else {
+                    logger.debug("Container {0} matches container type {1} for bean \
{2}, this container will be used.", +                            containerInfo.id,
+                            containerInfoType.getName(),
+                            bean.getId());
+
                     return containerInfo.id;
                 }
             }
+
+            logger.debug("Skipping container {0} of type {1}", containerInfo.id, \
containerInfoType.getName());  }
+
         return null;
     }
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic