Skip to content

Commit

Permalink
fix and oops, log the servlet int not starting, not an exception
Browse files Browse the repository at this point in the history
  • Loading branch information
pmuir committed Nov 3, 2009
1 parent 5f92bcf commit fc9e53a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions impl/pom.xml
Expand Up @@ -136,6 +136,7 @@
<enumType>org.jboss.weld.messages.JsfMessage</enumType>
<enumType>org.jboss.weld.messages.ReflectionMessage</enumType>
<enumType>org.jboss.weld.messages.UtilMessage</enumType>
<enumType>org.jboss.weld.messages.ServletMessage</enumType>
</enumTypes>
</configuration>
</execution>
Expand Down
Expand Up @@ -111,11 +111,6 @@ public boolean isProxyable()
return true;
}

public boolean isProxyRequired()
{
return true;
}

@Override
public String getDescription()
{
Expand Down
16 changes: 16 additions & 0 deletions impl/src/main/java/org/jboss/weld/messages/ServletMessage.java
@@ -0,0 +1,16 @@
package org.jboss.weld.messages;

import ch.qos.cal10n.BaseName;
import ch.qos.cal10n.Locale;
import ch.qos.cal10n.LocaleData;

@BaseName("org.jboss.weld.messages.servlet")
@LocaleData({
@Locale("en")
})
public enum ServletMessage
{

NOT_STARTING

}
12 changes: 10 additions & 2 deletions impl/src/main/java/org/jboss/weld/servlet/WeldListener.java
Expand Up @@ -22,6 +22,10 @@
*/
package org.jboss.weld.servlet;

import static org.jboss.weld.messages.ServletMessage.NOT_STARTING;
import static org.jboss.weld.util.log.Category.SERVLET;
import static org.jboss.weld.util.log.LoggerFactory.loggerFactory;

import javax.enterprise.inject.spi.BeanManager;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
Expand All @@ -35,6 +39,7 @@
import org.jboss.weld.context.ContextLifecycle;
import org.jboss.weld.servlet.api.ServletServices;
import org.jboss.weld.servlet.api.helpers.AbstractServletListener;
import org.slf4j.cal10n.LocLogger;

/**
* The Weld listener
Expand All @@ -49,6 +54,8 @@
public class WeldListener extends AbstractServletListener
{

private static final LocLogger log = loggerFactory().getLogger(SERVLET);

private ServletLifecycle lifecycle;

private ServletLifecycle getLifecycle()
Expand Down Expand Up @@ -78,15 +85,16 @@ private static BeanManagerImpl getBeanManager(ServletContext ctx)
@Override
public void contextInitialized(ServletContextEvent sce)
{
super.contextInitialized(sce);
if (!Container.instance().isInitialized())
{
throw new IllegalStateException("Weld bootstrap must be complete before contextInitialized event");
log.warn(NOT_STARTING);
return;
}
if (!Container.instance().deploymentServices().contains(ServletServices.class))
{
throw new IllegalStateException("Cannot use WeldListener without ServletServices");
}
super.contextInitialized(sce);
sce.getServletContext().setAttribute(BeanManager.class.getName(), getBeanManager(sce.getServletContext()));
}

Expand Down
@@ -0,0 +1 @@
NOT_STARTING=Not starting Weld/Servlet integration as Weld failed to initialize

0 comments on commit fc9e53a

Please sign in to comment.