Skip to content

Commit

Permalink
javadocs/comments/toStrings
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@380 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
nickarls committed Nov 28, 2008
1 parent 7c30296 commit a76e8c4
Show file tree
Hide file tree
Showing 6 changed files with 255 additions and 16 deletions.
@@ -1,3 +1,20 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jboss.webbeans.servlet;

import java.lang.reflect.Constructor;
Expand All @@ -17,47 +34,94 @@
import org.jboss.webbeans.util.JNDI;
import org.jboss.webbeans.util.Reflections;

/**
* Reacts to phases of the servlet life cycles
*
* @author Pete Muir
* @author Nicklas Karlsson
*/
public class ServletLifecycle
{

private static LogProvider log = Logging.getLogProvider(ServletLifecycle.class);

// Where to find the manager in JNDI
private static final String MANAGER_JNDI_KEY = "java:comp/Manager";

// The servlet context
private static ServletContext servletContext;

/**
* Starts the application
*
* Runs the bootstrapper for bean discover and initialization
*
* @param context The servlet context
*/
public static void beginApplication(ServletContext context)
{
servletContext = context;
Bootstrap bootstrap = new Bootstrap();
bootstrap.boot(getWebBeanDiscovery());
}

/**
* Ends the application
*/
public static void endApplication() {
servletContext = null;
}

/**
* Begins a session
*
* @param session The HTTP session
*/
public static void beginSession(HttpSession session)
{
}

/**
* Ends a session
*
* @param session The HTTP session
*/
public static void endSession(HttpSession session) {
}

/**
* Begins a HTTP request
*
* Sets the session into the session context
*
* @param request The request
*/
public static void beginRequest(HttpServletRequest request) {
ManagerImpl manager = (ManagerImpl) JNDI.lookup(MANAGER_JNDI_KEY);
SessionContext sessionContext = (SessionContext) manager.getContext(SessionScoped.class);
sessionContext.setSession(request.getSession(true));
}

/**
* Ends a HTTP request
*
* @param request The request
*/
public static void endRequest(HttpServletRequest request) {
}

/**
* Gets the servlet context
*
* @return The servlet context
*/
public static ServletContext getServletContext()
{
return servletContext;
}

/**
* Gets the Web Beans discovery class
*
* @return The discoverer
*/
// TODO move some of this bootstrap for reuse outside Servlet
private static WebBeanDiscovery getWebBeanDiscovery()
{
Expand Down
@@ -1,3 +1,20 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jboss.webbeans.servlet;

import java.io.IOException;
Expand All @@ -11,17 +28,35 @@
import javax.servlet.http.HttpServletRequest;

/**
* Filter for handling request-level events
*
* @author Shane Bryzak
* Delegates work to the ServletLifecycle
*
* @author Pete Muir
* @author Nicklas Karlsson
*/
public class WebBeansFilter implements Filter
{
/**
* Called when the filter is initializes
*
* @param filterConfig The filter configuration
* @throws ServletException When things go Wrong(tm)
*/
public void init(FilterConfig filterConfig) throws ServletException
{

}

/**
* Executes the filter
*
* @param request The request
* @param response The response
* @param chain The filter chain
*
* @throws IOException When things go Wrong(tm)
* @throws ServletException When things go Wrong(tm)
*/
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
{
try
Expand All @@ -35,6 +70,9 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
}
}

/**
* Called when the filter is destroyed
*/
public void destroy()
{
}
Expand Down
@@ -1,28 +1,75 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jboss.webbeans.servlet;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

/**
* The Web Beans listener
*
* Listens for context/session creation/destruction.
*
* Delegates work to the ServletLifeCycle.
*
* @author Nicklas Karlsson
*
*/
public class WebBeansListener implements ServletContextListener, HttpSessionListener
{

/**
* Called when the context is initialized (application started)
*
* @param event The context event
*/
public void contextInitialized(ServletContextEvent event)
{
ServletLifecycle.beginApplication(event.getServletContext());
}

/**
* Called when the session is created
*
* @param event The session event
*/
public void sessionCreated(HttpSessionEvent event)
{
ServletLifecycle.beginSession(event.getSession());
}

/**
* Called when the session is destroyed
*
* @param event The session event
*/
public void sessionDestroyed(HttpSessionEvent event)
{
ServletLifecycle.endSession(event.getSession());
}

/**
* Called when the context is destroyed (application sopped)
*
* @param event The context event
*/
public void contextDestroyed(ServletContextEvent event)
{
ServletLifecycle.endApplication();
Expand Down
@@ -1,9 +1,35 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2008, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.jboss.webbeans.transaction;

import javax.ejb.Local;

/**
* The local EJB interface for the TransactionListener
*
* @author Nicklas Karlsson
*
*/
@Local
public interface LocalTransactionListener
public interface LocalTransactionListener
{
/**
* The destroy method
*/
public void destroy();
}

0 comments on commit a76e8c4

Please sign in to comment.