You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by ms...@apache.org on 2016/01/18 13:41:32 UTC

[30/35] portals-pluto git commit: Adapted the portlet container ServletContainerInitializer to integrate the bean configuration before launching the portlet servlets. Added default portlet class instantiation to support portlets that have declared portle

Adapted the portlet container ServletContainerInitializer to integrate
the bean configuration before launching the portlet servlets. Added default
portlet class instantiation to support portlets that have declared portlet
classes, but are not in a valid bean archive.


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

Branch: refs/heads/V3Prototype
Commit: afb1a42f791456bcb3794878b41502e144ea6a48
Parents: 2e60a31
Author: Scott Nicklous <ms...@apache.org>
Authored: Thu Jan 14 17:15:05 2016 +0100
Committer: Scott Nicklous <ms...@apache.org>
Committed: Thu Jan 14 17:15:05 2016 +0100

----------------------------------------------------------------------
 .../driver/PortletContainerInitializer.java     | 157 +++++----
 .../bean/processor/AnnotationRecognizer.java    |   3 -
 .../bean/processor/PortletCDIExtension.java     |   6 +-
 .../processor/PortletSessionScopedConfig.java   |   8 +-
 .../processor/PortletStateScopedConfig.java     |   8 +-
 .../om/portlet/impl/ConfigurationProcessor.java | 334 +++++++++++++++++--
 .../impl/JSR286ConfigurationProcessor.java      |   4 +-
 .../impl/JSR362ConfigurationProcessor.java      | 263 ---------------
 .../src/main/resources/META-INF/beans.xml       |   5 +
 9 files changed, 425 insertions(+), 363 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container-driver-api/src/main/java/org/apache/pluto/container/driver/PortletContainerInitializer.java
----------------------------------------------------------------------
diff --git a/pluto-container-driver-api/src/main/java/org/apache/pluto/container/driver/PortletContainerInitializer.java b/pluto-container-driver-api/src/main/java/org/apache/pluto/container/driver/PortletContainerInitializer.java
index afc574c..e48566f 100644
--- a/pluto-container-driver-api/src/main/java/org/apache/pluto/container/driver/PortletContainerInitializer.java
+++ b/pluto-container-driver-api/src/main/java/org/apache/pluto/container/driver/PortletContainerInitializer.java
@@ -32,6 +32,8 @@ import javax.servlet.ServletRegistration;
 import javax.servlet.annotation.HandlesTypes;
 
 import org.apache.pluto.container.PortletInvokerService;
+import org.apache.pluto.container.bean.processor.AnnotatedConfigBean;
+import org.apache.pluto.container.bean.processor.PortletCDIExtension;
 import org.apache.pluto.container.om.portlet.PortletDefinition;
 import org.apache.pluto.container.om.portlet.impl.ConfigurationHolder;
 import org.slf4j.Logger;
@@ -66,82 +68,107 @@ public class PortletContainerInitializer implements ServletContainerInitializer
    public void onStartup(Set<Class<?>> classes, ServletContext ctx)
          throws ServletException {
 
-      InputStream win = ctx.getResourceAsStream(WEB_XML);
-      InputStream pin = ctx.getResourceAsStream(PORTLET_XML);
+      try {
 
-      if (isDebug) {
-         StringBuilder txt = new StringBuilder(128);
-         txt.append("§§§ ServletContainerInitializer. ctx path: ").append(
-               ctx.getContextPath());
-         txt.append(", servlet ctx name: ").append(ctx.getServletContextName());
-         txt.append(", # portlet annotations: ").append(
-               (classes != null) ? classes.size() : "null");
-         txt.append(", found web.xml: ").append(win != null);
-         txt.append(", found portlet.xml: ").append(pin != null);
-         LOG.debug(txt.toString());
-      }
+         // Get the bean configuration from the CDI extension
 
-      // If portlet configuration is available, parse it and launch the portlet
-      // servlets
-      if ((classes != null && classes.size() > 0) || pin != null) {
+         AnnotatedConfigBean acb = PortletCDIExtension.getConfig();
+         if (acb == null) {
+            StringBuilder txt = new StringBuilder();
+            txt.append("The managed bean configuration could not be obtained. \n\nMake sure Tomcat is configured correctly.");
+            txt.append("\nVerify that the CDI implementation is available and configured to run before the Pluto portlet container initializer.");
+            txt.append("\nVerify that the file 'weld-servlet-2.3.1.Final.jar' is in the ${catalina.base}/lib directory.");
+            txt.append("\nVerify that the catalina.properties file contains a line similar to:.");
+            txt.append("\n   common.loader=\"${catalina.home}/lib/weld-servlet-2.3.1.Final.jar\",\"${catalina.base}/lib\",\"${catalina.base}/lib/*.jar\",\"${catalina.home}/lib\",\"${catalina.home}/lib/*.jar\"");
+            txt.append("\n");
+            LOG.warn(txt.toString());
+         }
 
-         try {
-            ConfigurationHolder holder = new ConfigurationHolder();
+         // Read the annotated configuration
 
-            if (classes != null) {
-               holder.processConfigAnnotations(classes);
-            }
+         ConfigurationHolder holder = new ConfigurationHolder();
 
-            if (pin != null) {
-               // parse the portlet deployment descriptor
-               holder.processPortletDD(pin);
-            }
+         if (classes != null) {
+            holder.processConfigAnnotations(classes);
+         }
 
-            if (win != null) {
-               // parse the web app deployment descriptor
-               holder.processWebDD(win);
-            }
-            
-            holder.validate();
-
-            if (holder.getPad().getPortlets().size() > 0) {
-
-               ctx.setAttribute(ConfigurationHolder.ATTRIB_NAME, holder);
-               
-               // dynamically deploy the portlet servlets
-               for (PortletDefinition pd : holder.getPad().getPortlets()) {
-                  String pn = pd.getPortletName();
-                  String mapping = PortletInvokerService.URIPREFIX + pn;
-                  String servletName = pn + "_PS3";
-
-                  if (isDebug) {
-                     StringBuilder txt = new StringBuilder();
-                     txt.append("Adding PortletServlet3. Portlet name: ");
-                     txt.append(pn);
-                     txt.append(", servlet name: ").append(servletName);
-                     txt.append(", mapping: ").append(mapping);
-                     LOG.debug(txt.toString());
-                  }
-                  
-                  ServletRegistration.Dynamic sr = ctx.addServlet(servletName, PortletServlet3.class);
-                  sr.addMapping(mapping);
-                  sr.setInitParameter(PortletServlet3.PORTLET_NAME, pn);
-                  sr.setLoadOnStartup(100);
+         // set up for reading the XML files
+
+         InputStream win = ctx.getResourceAsStream(WEB_XML);
+         InputStream pin = ctx.getResourceAsStream(PORTLET_XML);
+
+         if (isDebug) {
+            StringBuilder txt = new StringBuilder(128);
+            txt.append("§§§ ServletContainerInitializer. ctx path: ").append(
+                  ctx.getContextPath());
+            txt.append(", servlet ctx name: ").append(ctx.getServletContextName());
+            txt.append(", # portlet annotations: ").append(
+                  (classes != null) ? classes.size() : "null");
+            txt.append(", found web.xml: ").append(win != null);
+            txt.append(", found portlet.xml: ").append(pin != null);
+            LOG.debug(txt.toString());
+         }
 
+         // Now read the XML configuration and validate the resulting explicit config
+
+         if (pin != null) {
+            // parse the portlet deployment descriptor
+            holder.processPortletDD(pin);
+         }
+
+         if (win != null) {
+            // parse the web app deployment descriptor
+            holder.processWebDD(win);
+         }
+
+         holder.validate();
+         
+         // If we were able to obtain a bean config, reconcile the bean config with the
+         // explicitly declared portlet configuration.
+         
+         if (acb != null) {
+            holder.reconcileBeanConfig(acb.getMethodStore());
+         }
+         
+         // If portlets have been found in this servlet context, launch the portlet servlets
+
+         if (holder.getPad().getPortlets().size() > 0) {
+
+            ctx.setAttribute(ConfigurationHolder.ATTRIB_NAME, holder);
+
+            // dynamically deploy the portlet servlets
+            for (PortletDefinition pd : holder.getPad().getPortlets()) {
+               String pn = pd.getPortletName();
+               String mapping = PortletInvokerService.URIPREFIX + pn;
+               String servletName = pn + "_PS3";
+
+               if (isDebug) {
+                  StringBuilder txt = new StringBuilder();
+                  txt.append("Adding PortletServlet3. Portlet name: ");
+                  txt.append(pn);
+                  txt.append(", servlet name: ").append(servletName);
+                  txt.append(", mapping: ").append(mapping);
+                  LOG.debug(txt.toString());
                }
-               
-            } else {
-               LOG.debug("No portlet definitions for context: " + ctx.getServletContextName());
+
+               ServletRegistration.Dynamic sr = ctx.addServlet(servletName, PortletServlet3.class);
+               sr.addMapping(mapping);
+               sr.setInitParameter(PortletServlet3.PORTLET_NAME, pn);
+               sr.setLoadOnStartup(100);
+
             }
 
-         } catch (Exception e) {
-            StringBuilder txt = new StringBuilder(128);
-            txt.append("Exception processing portlet application configuration");
-            txt.append(", Servlet ctx name: ").append(
-                  ctx.getServletContextName());
-            txt.append(", Exception: ").append(e.toString());
-            LOG.info(txt.toString());
+         } else {
+            LOG.debug("No portlet definitions for context: " + ctx.getServletContextName());
          }
+
+      } catch (Exception e) {
+         StringBuilder txt = new StringBuilder(128);
+         txt.append("Exception processing portlet application configuration");
+         txt.append(", Servlet ctx name: ").append(
+               ctx.getServletContextName());
+         txt.append(", Exception: ").append(e.toString());
+         LOG.info(txt.toString());
       }
 
    }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/AnnotationRecognizer.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/AnnotationRecognizer.java b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/AnnotationRecognizer.java
index 5530f04..83dcee2 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/AnnotationRecognizer.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/AnnotationRecognizer.java
@@ -95,9 +95,6 @@ public abstract class AnnotationRecognizer {
    public void checkAnnotatedType(ProcessAnnotatedType pat) throws InvalidAnnotationException {
       AnnotatedType<?> aType = pat.getAnnotatedType();
       String typeName = aType.getJavaClass().getCanonicalName();
-      if (isDebug) {
-         LOG.debug("Checking for annotations on: " + typeName);
-      }
       try {
          
          // Process the class annotations

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletCDIExtension.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletCDIExtension.java b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletCDIExtension.java
index 35d79c0..1bc695e 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletCDIExtension.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletCDIExtension.java
@@ -100,16 +100,16 @@ public class PortletCDIExtension implements Extension {
       // Done processing the annotations, so put the resulting configuration in an
       // application scoped bean to pass it to the servlet
       
-      LOG.debug("Now attempting to get the AnnotatedConfigBean ...");
+      LOG.trace("Now attempting to get the AnnotatedConfigBean ...");
       Set<Bean<?>> beans = bm.getBeans(AnnotatedConfigBean.class);
       @SuppressWarnings("unchecked")
       Bean<AnnotatedConfigBean> bean = (Bean<AnnotatedConfigBean>) bm.resolve(beans);
       if (bean != null) {
-         LOG.debug("Got AnnotatedConfigBean bean: " + bean.getBeanClass().getCanonicalName());
+         LOG.trace("Got AnnotatedConfigBean bean: " + bean.getBeanClass().getCanonicalName());
          try {
             CreationalContext<AnnotatedConfigBean> cc = bm.createCreationalContext(bean);
             acb = (AnnotatedConfigBean) bm.getReference(bean, AnnotatedConfigBean.class, cc);
-            LOG.debug("Got AnnotatedConfigBean instance.");
+            LOG.trace("Got AnnotatedConfigBean instance.");
             acb.setMethodStore(ams);
             acb.setSummary(summary);
             acb.setStateScopedConfig(par.getStateScopedConfig());

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletSessionScopedConfig.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletSessionScopedConfig.java b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletSessionScopedConfig.java
index 5295a6d..c4353a5 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletSessionScopedConfig.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletSessionScopedConfig.java
@@ -46,7 +46,7 @@ import org.slf4j.LoggerFactory;
 public class PortletSessionScopedConfig  implements Serializable {
    private static final long serialVersionUID = -5333145344722804837L;
    private final Logger LOG = LoggerFactory.getLogger(PortletSessionScopedConfig.class);
-   private final boolean isDebug = LOG.isDebugEnabled();
+   private final boolean isTrace = LOG.isTraceEnabled();
    
    
    // Maps the bean contextual to the annotation. The bean contextual is obtained
@@ -94,10 +94,10 @@ public class PortletSessionScopedConfig  implements Serializable {
       
       // dump configuration data to trace
       
-      if (isDebug) {
+      if (isTrace) {
          StringBuilder txt = new StringBuilder(128);
-         txt.append("PortletSessionScopedBeanHolder configuration: \n");
-         txt.append("\nAnnotatedBeans: ");
+         txt.append("PortletSessionScopedBeanHolder configuration. ");
+         txt.append(" AnnotatedBeans: ");
          txt.append(getConfigAsString());
          LOG.debug(txt.toString());
       }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletStateScopedConfig.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletStateScopedConfig.java b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletStateScopedConfig.java
index b92b2cf..735f1a3 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletStateScopedConfig.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/bean/processor/PortletStateScopedConfig.java
@@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory;
 public class PortletStateScopedConfig  implements Serializable {
    private static final long serialVersionUID = -5333145344722804837L;
    private final Logger LOG = LoggerFactory.getLogger(PortletStateScopedConfig.class);
-   private final boolean isDebug = LOG.isDebugEnabled();
+   private final boolean isTrace = LOG.isTraceEnabled();
    
    
    // Contains a sorted list of PortletStateScoped annotated class names. The sorted list
@@ -131,10 +131,10 @@ public class PortletStateScopedConfig  implements Serializable {
       
       // dump configuration data to trace
       
-      if (isDebug) {
+      if (isTrace) {
          StringBuilder txt = new StringBuilder(128);
-         txt.append("PortletStateScopedBeanHolder configuration: \n");
-         txt.append("\nAnnotatedBeans: ");
+         txt.append("PortletStateScopedBeanHolder configuration.");
+         txt.append(" Annotated Beans: ");
          txt.append(getConfigAsString());
          LOG.debug(txt.toString());
       }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
index 5460a10..7f368e4 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/ConfigurationProcessor.java
@@ -1,14 +1,30 @@
 package org.apache.pluto.container.om.portlet.impl;
 
+import static org.apache.pluto.container.bean.processor.MethodDescription.METH_ACT;
+import static org.apache.pluto.container.bean.processor.MethodDescription.METH_DES;
+import static org.apache.pluto.container.bean.processor.MethodDescription.METH_EVT;
+import static org.apache.pluto.container.bean.processor.MethodDescription.METH_HDR;
+import static org.apache.pluto.container.bean.processor.MethodDescription.METH_INI;
+import static org.apache.pluto.container.bean.processor.MethodDescription.METH_REN;
+import static org.apache.pluto.container.bean.processor.MethodDescription.METH_RES;
+
 import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Locale;
 import java.util.Random;
 import java.util.ResourceBundle;
+import java.util.Set;
 
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.portlet.Portlet;
 import javax.portlet.annotations.PortletApplication;
 import javax.portlet.annotations.PortletConfiguration;
 import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.xpath.XPath;
@@ -16,8 +32,15 @@ import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathFactory;
 
+import org.apache.pluto.container.bean.processor.AnnotatedMethod;
 import org.apache.pluto.container.bean.processor.AnnotatedMethodStore;
+import org.apache.pluto.container.bean.processor.MethodDescription;
+import org.apache.pluto.container.bean.processor.MethodIdentifier;
+import org.apache.pluto.container.bean.processor.MethodType;
+import org.apache.pluto.container.om.portlet.EventDefinition;
+import org.apache.pluto.container.om.portlet.EventDefinitionReference;
 import org.apache.pluto.container.om.portlet.PortletApplicationDefinition;
+import org.apache.pluto.container.om.portlet.PortletDefinition;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.w3c.dom.Document;
@@ -29,8 +52,8 @@ public abstract class ConfigurationProcessor {
    
    
    /** Logger. */
-   private static final Logger LOG = LoggerFactory
-         .getLogger(ConfigurationProcessor.class);
+   private static final Logger LOG = LoggerFactory.getLogger(ConfigurationProcessor.class);
+   private static final boolean isDebug = LOG.isDebugEnabled();
 
 
    protected PortletApplicationDefinition pad;
@@ -72,23 +95,6 @@ public abstract class ConfigurationProcessor {
     */
    public abstract void validate() throws IllegalArgumentException;
    
-   /**
-    * reconciles the given annotated method store containing the bean configuration
-    * with the configuration as read from the portlet deployment descriptor and 
-    * the corresponding type annotations.
-    * <p>
-    * Portlets that are defined in the bean config are added to the portlet application
-    * definition if not already present. Event reference information from the 
-    * annotations is verified and added to the corresponding portlet definition.
-    * <p>
-    * Methods from portlet classes definied in the portlet definitions are
-    * added to the annotated method store.
-    * 
-    * @param ams
-    */
-   public void reconcileBeanConfig(AnnotatedMethodStore ams) {
-      // do nothing for JSR 168 & JSR 286 portlets
-   }
 
    /**
     * Handle the locale the old-fashioned way (v1 & v2)
@@ -340,4 +346,294 @@ public abstract class ConfigurationProcessor {
    public void processValidatorAnnotation(Class<?> cls) {
    }
 
+   /**
+    * reconciles the given annotated method store containing the bean configuration
+    * with the configuration as read from the portlet deployment descriptor and 
+    * the corresponding type annotations.
+    * <p>
+    * Portlets that are defined in the bean config are added to the portlet application
+    * definition if not already present. Event reference information from the 
+    * annotations is verified and added to the corresponding portlet definition.
+    * <p>
+    * Methods from portlet classes definied in the portlet definitions are
+    * added to the annotated method store.
+    * 
+    * @param ams
+    */
+   public void reconcileBeanConfig(AnnotatedMethodStore ams) {
+      
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder();
+         txt.append("Beginning reconciliation. Annotated portlets: ").append(ams.getPortletNames().toString());
+         LOG.debug(txt.toString());
+      }
+
+      ams.setDefaultNamespace(pad.getDefaultNamespace());
+      
+      for (String pn : ams.getPortletNames()) {
+         
+         PortletDefinition pd = pad.getPortlet(pn);
+         if (pd == null) {
+            pd = new PortletDefinitionImpl(pn, pad);
+         }
+         
+         List<EventDefinitionReference> edrs = pd.getSupportedProcessingEvents();
+         for (QName qn : ams.getProcessingEventRefs(pn)) {
+            EventDefinition ed = pad.getEventDefinition(qn);
+            if (ed == null) {
+               StringBuilder txt = new StringBuilder(128);
+               txt.append("No event definition found for annotated processing event reference.");
+               txt.append(" Portlet name: ").append(pn);
+               txt.append(", QName: ").append(qn);
+               LOG.warn(txt.toString());
+               
+               // remove the defective method from the store
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), qn, MethodType.EVENT);
+               ams.removeMethod(mi);
+               
+               continue;
+            }
+            EventDefinitionReference newedr = new EventDefinitionReferenceImpl(qn);
+            if (!edrs.contains(newedr)) {
+               pd.addSupportedProcessingEvent(newedr);
+            }
+         }
+         
+         edrs = pd.getSupportedPublishingEvents();
+         for (QName qn : ams.getPublishingEventRefs(pn)) {
+            EventDefinition ed = pad.getEventDefinition(qn);
+            if (ed == null) {
+               StringBuilder txt = new StringBuilder(128);
+               txt.append("No event definition found for annotated publishing event reference.");
+               txt.append(" Portlet name: ").append(pn);
+               txt.append(", QName: ").append(qn);
+               LOG.warn(txt.toString());
+               continue;
+            }
+            EventDefinitionReference newedr = new EventDefinitionReferenceImpl(qn);
+            if (!edrs.contains(newedr)) {
+               pd.addSupportedPublishingEvent(newedr);
+            }
+         }
+         
+         pad.addPortlet(pd);
+      }
+      
+      // Now add the declared portlet class methods to the store
+      
+      List<PortletDefinition> badPortlets = new ArrayList<PortletDefinition>();
+      for (PortletDefinition pd : pad.getPortlets()) {
+         Class<?> cls = null;
+
+         String clsName = pd.getPortletClass();
+         if (isValidIdentifier(clsName)) {
+            
+            // Make sure the class can be loaded
+            Class<?> valClass = null;
+            StringBuilder txt = new StringBuilder(128);
+            try {
+               ClassLoader cl = Thread.currentThread().getContextClassLoader();
+               if (cl == null) {
+                  cl = this.getClass().getClassLoader();
+               }
+               valClass = cl.loadClass(clsName);
+               if (Portlet.class.isAssignableFrom(valClass)) {
+                  cls = valClass;
+               } else {
+                  txt.append("Specified portlet class does not implement the Portlet interface.");
+               }
+            } catch (Exception e) {
+               txt.append("Specified portlet class could not be loaded.");
+            } finally {
+               if (cls == null) {
+                  txt.append(" Portlet name: ").append(pd.getPortletName());
+                  txt.append(", Portlet class: ").append(clsName);
+                  LOG.warn(txt.toString());
+               }
+            }
+         }
+         
+         Object instance = null;
+         if (cls != null) {
+            
+            // Let CDI instantiate the portlet to allow for injection. 
+            // Get the single bean instance for the portlet class.
+            
+            StringBuilder txt = new StringBuilder(128);
+            BeanManager bm = ams.getBeanMgr();
+            if (bm == null) {
+               txt.append("Could not instantiate portlet class. Bean manager is null.");
+            } else {
+               Set<Bean<?>> beans = bm.getBeans(cls);
+               if (beans == null || beans.size() == 0) {
+                  txt.append("Could not instantiate portlet class. No beans found.");
+               } else {
+                  Bean<?> bean = bm.resolve(beans);
+                  if (bean == null) {
+                     txt.append("Could not instantiate portlet class. Could not resolve bean.");
+                  } else {
+                     instance = bm.getReference(bean, bean.getBeanClass(), bm.createCreationalContext(bean));
+                     if (instance == null) {
+                        txt.append("Could not instantiate portlet class. Could not get bean instance.");
+                     }
+                  }
+               }
+            }
+            
+            // If the instance is still null, the portlet class might not be in a valid bean 
+            // archive, as a JSR 286 portlet might be. Try to get a regular old instance.
+            
+            if (instance == null) {
+               LOG.debug("Could not create bean (possibly not in a valid bean archive). Now directly instantiating class: " + cls.getCanonicalName());
+               try {
+                  instance = cls.newInstance();
+               } catch(Exception e) {
+                  txt.append(" Exception creating instance of class: ").append(e.toString());
+               }
+            }
+            
+            
+            if ((instance == null) && (txt.length() > 0)) {
+               txt.append(" Portlet name: ").append(pd.getPortletName());
+               txt.append(", portlet class: ").append(cls);
+               LOG.warn(txt.toString());
+            }
+         }
+
+         if (instance != null) {
+            
+            // The annotated method store might contain methods from the configured
+            // portlet class being processed. For example, this may occur when an action
+            // or event method in the portlet class is annotated to specify processing or
+            // publishing event references. Such annotated methods must use the same bean
+            // instance, so fix up the method store.
+            
+            ams.setPortletClassInstance(cls, instance);
+
+            // extract the methods from the portlet class and add them to the method store
+            // as long there is no corresponding annotated method already present.
+            // (annotated methods take precedence over portlet class methods). 
+            
+            AnnotatedMethod am;
+            am = getMethod(instance, "init", METH_INI);
+            if (am != null) {
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.INIT);
+               if (ams.getMethods(mi).size() == 0) {
+                  ams.addMethod(mi, am);
+               }
+            }
+            
+            am = getMethod(instance, "destroy", METH_DES);
+            if (am != null) {
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.DESTROY);
+               if (ams.getMethods(mi).size() == 0) {
+                  ams.addMethod(mi, am);
+               }
+            }
+            
+            am = getMethod(instance, "processAction", METH_ACT);
+            if (am != null) {
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.ACTION);
+               if (ams.getMethods(mi).size() == 0) {
+                  ams.addMethod(mi, am);
+               }
+            }
+            
+            am = getMethod(instance, "processEvent", METH_EVT);
+            if (am != null) {
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.EVENT);
+               if (ams.getMethods(mi).size() == 0) {
+                  ams.addMethod(mi, am);
+               }
+            }
+            
+            am = getMethod(instance, "render", METH_REN);
+            if (am != null) {
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.RENDER);
+               if (ams.getMethods(mi).size() == 0) {
+                  ams.addMethod(mi, am);
+               }
+            }
+            
+            am = getMethod(instance, "renderHeaders", METH_HDR);
+            if (am != null) {
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.HEADER);
+               if (ams.getMethods(mi).size() == 0) {
+                  ams.addMethod(mi, am);
+               }
+            }
+            
+            am = getMethod(instance, "serveResource", METH_RES);
+            if (am != null) {
+               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.RESOURCE);
+               if (ams.getMethods(mi).size() == 0) {
+                  ams.addMethod(mi, am);
+               }
+            }
+
+         }
+         
+         // and finally make sure that the portlet has at least one render, header, or serveResource
+         // method. If not, delete it.
+         
+         boolean methodsOK = false;
+         for (MethodIdentifier mi : ams.getMethodIDsForPortlet(pd.getPortletName())) {
+            if ((mi.getType() == MethodType.RENDER) || (mi.getType() == MethodType.RESOURCE) ||
+                  (mi.getType() == MethodType.HEADER)) {
+               methodsOK = true;
+               break;
+            }
+         }
+         if (!methodsOK) {
+            
+            ams.removeMethodsForPortlet(pd.getPortletName());
+            badPortlets.add(pd);
+            
+            StringBuilder txt = new StringBuilder();
+            txt.append("Portlet does not have a render, resource, or header method, so cannot be taken into service. ");
+            txt.append("Portlet name: ").append(pd.getPortletName());
+            LOG.warn(txt.toString());
+         }
+      }
+      
+      // if there are bad portlets, delete them from the config
+      for (PortletDefinition pd : badPortlets) {
+         pad.removePortlet(pd);
+      }
+      
+      if (isDebug) {
+         StringBuilder txt = new StringBuilder();
+         txt.append("Finished reconciling bean config. ");
+         txt.append("Resulting portlet list: ").append(ams.getPortletNames().toString());
+         LOG.debug(txt.toString());
+      }
+      
+   }
+   
+   /**
+    * helper method for extracting the portlet methods from the portlet class.
+    * @param cls
+    * @param name
+    * @param md
+    * @return
+    */
+   private AnnotatedMethod getMethod(Object instance, String name, MethodDescription md) {
+      AnnotatedMethod am = null;
+      Class<?> cls = instance.getClass();
+      try {
+         Method meth = cls.getMethod(name, md.getArgTypes());
+         am = new AnnotatedMethod(cls, instance, meth, md);
+      } catch (Exception e) {
+         if (isDebug) {
+            StringBuilder txt = new StringBuilder();
+            txt.append("Could not retrieve method from portlet class.");
+            txt.append(" Method name: ").append(name);
+            txt.append(", Class: ").append(cls.getCanonicalName());
+            txt.append(", Argument types: ").append(md.getArgTypes());
+            LOG.debug(txt.toString());
+         }
+      }
+      return am;
+   }
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR286ConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR286ConfigurationProcessor.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR286ConfigurationProcessor.java
index c48c429..7cbb18f 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR286ConfigurationProcessor.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR286ConfigurationProcessor.java
@@ -478,12 +478,12 @@ public class JSR286ConfigurationProcessor extends JSR168ConfigurationProcessor {
          List<PortletModeType> pmlist = st.getPortletMode();
          if (pmlist.size() == 0) {
             String info = "No portlet modes found in Supports block.";
-            LOG.debug(info);
+            LOG.trace(info);
          }
          List<WindowStateType> wslist = st.getWindowState();
          if (wslist.size() == 0) {
             String info = "No window states found in Supports block.";
-            LOG.debug(info);
+            LOG.trace(info);
          }
 
          // set up Supports

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR362ConfigurationProcessor.java
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR362ConfigurationProcessor.java b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR362ConfigurationProcessor.java
index 891259b..9b97417 100644
--- a/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR362ConfigurationProcessor.java
+++ b/pluto-container/src/main/java/org/apache/pluto/container/om/portlet/impl/JSR362ConfigurationProcessor.java
@@ -18,17 +18,13 @@
 
 package org.apache.pluto.container.om.portlet.impl;
 
-import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Set;
 
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
 import javax.portlet.Portlet;
 import javax.portlet.PortletRequest;
 import javax.portlet.PortletURLGenerationListener;
@@ -51,14 +47,6 @@ import javax.portlet.filter.ResourceFilter;
 import javax.xml.bind.JAXBElement;
 import javax.xml.namespace.QName;
 
-import org.apache.pluto.container.bean.processor.AnnotatedMethod;
-import org.apache.pluto.container.bean.processor.AnnotatedMethodStore;
-import org.apache.pluto.container.bean.processor.MethodIdentifier;
-import org.apache.pluto.container.bean.processor.MethodType;
-
-import static org.apache.pluto.container.bean.processor.MethodDescription.*;
-
-import org.apache.pluto.container.bean.processor.MethodDescription;
 import org.apache.pluto.container.om.portlet.ContainerRuntimeOption;
 import org.apache.pluto.container.om.portlet.CustomPortletMode;
 import org.apache.pluto.container.om.portlet.CustomWindowState;
@@ -122,7 +110,6 @@ public class JSR362ConfigurationProcessor extends JSR286ConfigurationProcessor {
 
    /** Logger. */
    private static final Logger  LOG     = LoggerFactory.getLogger(JSR362ConfigurationProcessor.class);
-   private static final boolean isDebug = LOG.isDebugEnabled();
    private static final boolean isTrace = LOG.isTraceEnabled();
    
    // For holding the preference validators while the portlet configuration
@@ -1391,254 +1378,4 @@ public class JSR362ConfigurationProcessor extends JSR286ConfigurationProcessor {
       }
    }
 
-   @Override
-   public void reconcileBeanConfig(AnnotatedMethodStore ams) {
-
-      ams.setDefaultNamespace(pad.getDefaultNamespace());
-      
-      for (String pn : ams.getPortletNames()) {
-         
-         PortletDefinition pd = pad.getPortlet(pn);
-         if (pd == null) {
-            pd = new PortletDefinitionImpl(pn, pad);
-         }
-         
-         List<EventDefinitionReference> edrs = pd.getSupportedProcessingEvents();
-         for (QName qn : ams.getProcessingEventRefs(pn)) {
-            EventDefinition ed = pad.getEventDefinition(qn);
-            if (ed == null) {
-               StringBuilder txt = new StringBuilder(128);
-               txt.append("No event definition found for annotated processing event reference.");
-               txt.append(" Portlet name: ").append(pn);
-               txt.append(", QName: ").append(qn);
-               LOG.warn(txt.toString());
-               
-               // remove the defective method from the store
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), qn, MethodType.EVENT);
-               ams.removeMethod(mi);
-               
-               continue;
-            }
-            EventDefinitionReference newedr = new EventDefinitionReferenceImpl(qn);
-            if (!edrs.contains(newedr)) {
-               pd.addSupportedProcessingEvent(newedr);
-            }
-         }
-         
-         edrs = pd.getSupportedPublishingEvents();
-         for (QName qn : ams.getPublishingEventRefs(pn)) {
-            EventDefinition ed = pad.getEventDefinition(qn);
-            if (ed == null) {
-               StringBuilder txt = new StringBuilder(128);
-               txt.append("No event definition found for annotated publishing event reference.");
-               txt.append(" Portlet name: ").append(pn);
-               txt.append(", QName: ").append(qn);
-               LOG.warn(txt.toString());
-               continue;
-            }
-            EventDefinitionReference newedr = new EventDefinitionReferenceImpl(qn);
-            if (!edrs.contains(newedr)) {
-               pd.addSupportedPublishingEvent(newedr);
-            }
-         }
-         
-         pad.addPortlet(pd);
-      }
-      
-      // Now add the declared portlet class methods to the store
-      
-      List<PortletDefinition> badPortlets = new ArrayList<PortletDefinition>();
-      for (PortletDefinition pd : pad.getPortlets()) {
-         Class<?> cls = null;
-
-         String clsName = pd.getPortletClass();
-         if (isValidIdentifier(clsName)) {
-            
-            // Make sure the class can be loaded
-            Class<?> valClass = null;
-            StringBuilder txt = new StringBuilder(128);
-            try {
-               ClassLoader cl = Thread.currentThread().getContextClassLoader();
-               if (cl == null) {
-                  cl = this.getClass().getClassLoader();
-               }
-               valClass = cl.loadClass(clsName);
-               if (Portlet.class.isAssignableFrom(valClass)) {
-                  cls = valClass;
-               } else {
-                  txt.append("Specified portlet class does not implement the Portlet interface.");
-               }
-            } catch (Exception e) {
-               txt.append("Specified portlet class could not be loaded.");
-            } finally {
-               if (cls == null) {
-                  txt.append(" Portlet name: ").append(pd.getPortletName());
-                  txt.append(", Portlet class: ").append(clsName);
-                  LOG.warn(txt.toString());
-               }
-            }
-         }
-         
-         Object instance = null;
-         if (cls != null) {
-            
-            // Let CDI instantiate the portlet to allow for injection. 
-            // Get the single bean instance for the portlet class.
-            
-            StringBuilder txt = new StringBuilder(128);
-            BeanManager bm = ams.getBeanMgr();
-            if (bm == null) {
-               txt.append("Could not instantiate portlet class. Bean manager is null.");
-            } else {
-               Set<Bean<?>> beans = bm.getBeans(cls);
-               if (beans == null || beans.size() == 0) {
-                  txt.append("Could not instantiate portlet class. No beans found.");
-               } else {
-                  Bean<?> bean = bm.resolve(beans);
-                  if (bean == null) {
-                     txt.append("Could not instantiate portlet class. Could not resolve bean.");
-                  } else {
-                     instance = bm.getReference(bean, bean.getBeanClass(), bm.createCreationalContext(bean));
-                     if (instance == null) {
-                        txt.append("Could not instantiate portlet class. Could not get bean instance.");
-                     }
-                  }
-               }
-            }
-            
-            if (txt.length() > 0) {
-               txt.append(" Portlet name: ").append(pd.getPortletName());
-               txt.append(", portlet class: ").append(cls);
-               LOG.warn(txt.toString());
-            }
-         }
-
-         if (instance != null) {
-            
-            // The annotated method store might contain methods from the configured
-            // portlet class being processed. For example, this may occur when an action
-            // or event method in the portlet class is annotated to specify processing or
-            // publishing event references. Such annotated methods must use the same bean
-            // instance, so fix up the method store.
-            
-            ams.setPortletClassInstance(cls, instance);
-
-            // extract the methods from the portlet class and add them to the method store
-            // as long there is no corresponding annotated method already present.
-            // (annotated methods take precedence over portlet class methods). 
-            
-            AnnotatedMethod am;
-            am = getMethod(instance, "init", METH_INI);
-            if (am != null) {
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.INIT);
-               if (ams.getMethods(mi).size() == 0) {
-                  ams.addMethod(mi, am);
-               }
-            }
-            
-            am = getMethod(instance, "destroy", METH_DES);
-            if (am != null) {
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.DESTROY);
-               if (ams.getMethods(mi).size() == 0) {
-                  ams.addMethod(mi, am);
-               }
-            }
-            
-            am = getMethod(instance, "processAction", METH_ACT);
-            if (am != null) {
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.ACTION);
-               if (ams.getMethods(mi).size() == 0) {
-                  ams.addMethod(mi, am);
-               }
-            }
-            
-            am = getMethod(instance, "processEvent", METH_EVT);
-            if (am != null) {
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.EVENT);
-               if (ams.getMethods(mi).size() == 0) {
-                  ams.addMethod(mi, am);
-               }
-            }
-            
-            am = getMethod(instance, "render", METH_REN);
-            if (am != null) {
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.RENDER);
-               if (ams.getMethods(mi).size() == 0) {
-                  ams.addMethod(mi, am);
-               }
-            }
-            
-            am = getMethod(instance, "renderHeaders", METH_HDR);
-            if (am != null) {
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.HEADER);
-               if (ams.getMethods(mi).size() == 0) {
-                  ams.addMethod(mi, am);
-               }
-            }
-            
-            am = getMethod(instance, "serveResource", METH_RES);
-            if (am != null) {
-               MethodIdentifier mi = new MethodIdentifier(pd.getPortletName(), "", MethodType.RESOURCE);
-               if (ams.getMethods(mi).size() == 0) {
-                  ams.addMethod(mi, am);
-               }
-            }
-
-         }
-         
-         // and finally make sure that the portlet has at least one render, header, or serveResource
-         // method. If not, delete it.
-         
-         boolean methodsOK = false;
-         for (MethodIdentifier mi : ams.getMethodIDsForPortlet(pd.getPortletName())) {
-            if ((mi.getType() == MethodType.RENDER) || (mi.getType() == MethodType.RESOURCE) ||
-                  (mi.getType() == MethodType.HEADER)) {
-               methodsOK = true;
-               break;
-            }
-         }
-         if (!methodsOK) {
-            
-            ams.removeMethodsForPortlet(pd.getPortletName());
-            badPortlets.add(pd);
-            
-            StringBuilder txt = new StringBuilder();
-            txt.append("Portlet does not have a render, resource, or header method, so cannot be taken into service. ");
-            txt.append("Portlet name: ").append(pd.getPortletName());
-            LOG.warn(txt.toString());
-         }
-      }
-      
-      // if there are bad portlets, delete them from the config
-      for (PortletDefinition pd : badPortlets) {
-         pad.removePortlet(pd);
-      }
-      
-   }
-   
-   /**
-    * helper method for extracting the portlet methods from the portlet class.
-    * @param cls
-    * @param name
-    * @param md
-    * @return
-    */
-   private AnnotatedMethod getMethod(Object instance, String name, MethodDescription md) {
-      AnnotatedMethod am = null;
-      Class<?> cls = instance.getClass();
-      try {
-         Method meth = cls.getMethod(name, md.getArgTypes());
-         am = new AnnotatedMethod(cls, instance, meth, md);
-      } catch (Exception e) {
-         if (isDebug) {
-            StringBuilder txt = new StringBuilder();
-            txt.append("Could not retrieve method from portlet class.");
-            txt.append(" Method name: ").append(name);
-            txt.append(", Class: ").append(cls.getCanonicalName());
-            txt.append(", Argument types: ").append(md.getArgTypes());
-            LOG.debug(txt.toString());
-         }
-      }
-      return am;
-   }
 }

http://git-wip-us.apache.org/repos/asf/portals-pluto/blob/afb1a42f/pluto-container/src/main/resources/META-INF/beans.xml
----------------------------------------------------------------------
diff --git a/pluto-container/src/main/resources/META-INF/beans.xml b/pluto-container/src/main/resources/META-INF/beans.xml
new file mode 100644
index 0000000..115420e
--- /dev/null
+++ b/pluto-container/src/main/resources/META-INF/beans.xml
@@ -0,0 +1,5 @@
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="
+http://java.sun.com/xml/ns/javaee
+http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
\ No newline at end of file