You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwebbeans.apache.org by ge...@apache.org on 2012/11/07 15:06:14 UTC

svn commit: r1406640 - in /openwebbeans/trunk/webbeans-clustering: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/webbeans/ src/main/java/org/apache/webbeans/web/ src/main/java/org/apache/webbeans...

Author: gerdogdu
Date: Wed Nov  7 14:06:13 2012
New Revision: 1406640

URL: http://svn.apache.org/viewvc?rev=1406640&view=rev
Log:
OWB-717 Remove Failover implementation from Web to Own Project

Added:
    openwebbeans/trunk/webbeans-clustering/
    openwebbeans/trunk/webbeans-clustering/pom.xml
    openwebbeans/trunk/webbeans-clustering/src/
    openwebbeans/trunk/webbeans-clustering/src/main/
    openwebbeans/trunk/webbeans-clustering/src/main/java/
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/DefaultOwbFailOverService.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverFilter.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverSessionActivationListener.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/OwbProxyObjectInputStream.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/SerializationHandlerV10.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/main/resources/
    openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/
    openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/openwebbeans/
    openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/openwebbeans/openwebbeans.properties   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/
    openwebbeans/trunk/webbeans-clustering/src/test/java/
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/AbstractUnitTest.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/ConversationScopedBean.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/DefaultOwbFailOverServiceTest.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockConversationService.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockHttpSession.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletContext.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletRequest.java   (with props)
    openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/SessionScopedBean.java   (with props)

Added: openwebbeans/trunk/webbeans-clustering/pom.xml
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/pom.xml?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/pom.xml (added)
+++ openwebbeans/trunk/webbeans-clustering/pom.xml Wed Nov  7 14:06:13 2012
@@ -0,0 +1,91 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements. See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.openwebbeans</groupId>
+        <artifactId>openwebbeans</artifactId>
+        <version>1.1.7-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>openwebbeans-clustering</artifactId>
+    <name>Clustering Plugin</name>
+    <description>Clustering plugin</description>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-impl</artifactId>
+        </dependency>
+
+
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-spi</artifactId>
+            <optional>true</optional>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.openwebbeans</groupId>
+            <artifactId>openwebbeans-web</artifactId>
+        </dependency>        
+        
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-atinject_1.0_spec</artifactId>
+            <optional>true</optional>
+        </dependency>
+        
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-el_2.2_spec</artifactId>
+            <optional>true</optional>
+            <scope>test</scope>
+        </dependency>        
+        
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+            <optional>true</optional>
+            <scope>test</scope>
+        </dependency>        
+        
+        
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        
+
+    </dependencies>
+    
+</project>

Added: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/DefaultOwbFailOverService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/DefaultOwbFailOverService.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/DefaultOwbFailOverService.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/DefaultOwbFailOverService.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,380 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.UUID;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javassist.util.proxy.ProxyObjectOutputStream;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.inject.spi.Bean;
+import javax.servlet.http.HttpSession;
+
+import org.apache.webbeans.config.OpenWebBeansConfiguration;
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.context.ConversationContext;
+import org.apache.webbeans.context.SessionContext;
+import org.apache.webbeans.conversation.ConversationManager;
+import org.apache.webbeans.exception.WebBeansException;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.proxy.javassist.OpenWebBeansClassLoaderProvider;
+import org.apache.webbeans.spi.FailOverService;
+import org.apache.webbeans.web.context.SessionContextManager;
+import org.apache.webbeans.web.context.WebContextsService;
+
+/**
+ * Default implementation of the {@link FailOverService}.
+ */
+public class DefaultOwbFailOverService implements FailOverService
+{
+    private static final Logger LOGGER = WebBeansLoggerFacade.getLogger(DefaultOwbFailOverService.class);
+
+    public static final String CONFIG_IS_SUPPORT_FAILOVER = "org.apache.webbeans.web.failover.issupportfailover";
+    public static final String CONFIG_IS_SUPPORT_PASSIVATE = "org.apache.webbeans.web.failover.issupportpassivation";
+    public static final String CONFIG_RESOURCES_SERIALIZATION_HANDLER = "org.apache.webbeans.web.failover.resources.serialization.handler.v10";
+
+    public static final String ATTRIBUTE_SESSION_CONTEXT = "sessionContext";
+    public static final String ATTRIBUTE_CONVERSATION_CONTEXT_MAP = "conversatzionContextMap";
+
+    private static final String JVM_ID = UUID.randomUUID().toString() + "_" + System.currentTimeMillis();
+
+    private final WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+
+    private ThreadLocal<Boolean> passivation = new ThreadLocal<Boolean>();
+    private boolean supportFailOver;
+    private boolean supportPassivation;
+    private SerializationHandlerV10 handler;
+
+    public DefaultOwbFailOverService()
+    {
+        OpenWebBeansConfiguration config = webBeansContext.getOpenWebBeansConfiguration();
+
+        String value;
+
+        value = config.getProperty(CONFIG_IS_SUPPORT_FAILOVER);
+        if (value != null && value.equalsIgnoreCase("true"))
+        {
+            supportFailOver = true;
+        }
+
+        value = config.getProperty(CONFIG_IS_SUPPORT_PASSIVATE);
+        if (value != null && value.equalsIgnoreCase("true"))
+        {
+            supportPassivation = true;
+        }
+
+        if (supportFailOver || supportPassivation)
+        {
+            OpenWebBeansClassLoaderProvider.initProxyFactoryClassLoaderProvider();
+            value = config.getProperty(CONFIG_RESOURCES_SERIALIZATION_HANDLER);
+
+            if (value != null)
+            {
+                try
+                {
+                    handler = (SerializationHandlerV10) Class.forName(value).newInstance();
+                }
+                catch (Exception e)
+                {
+                    LOGGER.log(Level.SEVERE, "DefaultOwbFailOverService could not instanciate: [" + value + "]", e);
+                }
+            }
+        }
+
+        if (LOGGER.isLoggable(Level.FINE))
+        {
+            LOGGER.log(Level.FINE, "IsSupportFailOver: [{0}]", String.valueOf(supportFailOver));
+            LOGGER.log(Level.FINE, "IsSupportPassivation: [{0}]", String.valueOf(supportPassivation));
+        }
+    }
+
+    public void sessionIsIdle(HttpSession session)
+    {
+        if (session != null)
+        {
+            FailOverBag bag = (FailOverBag) session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
+
+            if (bag == null)
+            {
+                bag = new FailOverBag(session.getId(), getJvmId());
+            }
+
+            bag.setSessionInUse(false);
+
+            storeBeansInFailOverBag(bag, session);
+
+            addFailOverBagToSession(bag, session);
+            addActivationListenerToSession(session);
+        }
+
+        passivation.remove();
+        passivation.set(null);
+    }
+
+    public void sessionIsInUse(HttpSession session)
+    {
+        if (session != null)
+        {
+            FailOverBag bag = (FailOverBag) session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
+
+            if (bag != null)
+            {
+                bag.setSessionInUse(true);
+            }
+
+            addActivationListenerToSession(session);
+        }
+    }
+
+    public void sessionDidActivate(HttpSession session)
+    {
+        FailOverBag bag = (FailOverBag) session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
+
+        if (bag != null)
+        {
+            if (bag.isSessionInUse())
+            {
+                if (LOGGER.isLoggable(Level.FINE))
+                {
+                    LOGGER.log(Level.FINE, "Skip restore beans for session [" + bag.getSessionId() + "] because session is in use.");
+                }
+            }
+            else
+            {
+                if (LOGGER.isLoggable(Level.FINE))
+                {
+                    LOGGER.log(Level.FINE, "Restore beans for session [{0}]", session.getId());
+                }
+
+                restoreBeansFromFailOverBag(bag, session);
+            }
+        }
+    }
+
+    public void sessionWillPassivate(HttpSession session)
+    {
+        sessionIsIdle(session);
+
+        passivation.set(true);
+    }
+
+    /**
+     * Adds the {@link FailOverSessionActivationListener} to the current {@link HttpSession}.
+     * It must not be manually registered when we store it as session attribute.
+     * 
+     * @param session The current {@link HttpSession}.
+     */
+    protected void addActivationListenerToSession(HttpSession session)
+    {
+        if (session.getAttribute(FailOverSessionActivationListener.SESSION_ATTRIBUTE_NAME) == null)
+        {
+            session.setAttribute(FailOverSessionActivationListener.SESSION_ATTRIBUTE_NAME, new FailOverSessionActivationListener());
+        }
+    }
+
+    /**
+     * Store the {@link FailOverBag} as attribute to the current {@link HttpSession}.
+     * So when the session is fail over to other JVM or local disk, the
+     * attribute could also be serialized.
+     * 
+     * @param bag The {@link FailOverBag}.
+     * @param session The current {@link HttpSession}.
+     */
+    protected void addFailOverBagToSession(FailOverBag bag, HttpSession session)
+    {
+        try
+        {
+            session.setAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME, bag);
+
+            if (LOGGER.isLoggable(Level.FINE))
+            {
+                LOGGER.log(Level.FINE, "Successfully added FailOverBag to session [" + bag.getSessionId() + "].");
+            }
+        }
+        catch (Exception e)
+        {
+            String message = "Could not add FailOverBag to session [" + bag.getSessionId() + "].";
+            LOGGER.log(Level.SEVERE, message, e);
+
+            throw new WebBeansException(message, e);
+        }
+    }
+
+    /**
+     * Stores the session and conversation contexts in the {@link FailOverBag}.
+     * 
+     * @param bag The {@link FailOverBag}.
+     * @param session The current {@link HttpSession}.
+     */
+    protected void storeBeansInFailOverBag(FailOverBag bag, HttpSession session)
+    {
+        // store the session context
+        SessionContextManager sessionManager =
+                ((WebContextsService) webBeansContext.getContextsService()).getSessionContextManager();
+        SessionContext sessionContext = sessionManager.getSessionContextWithSessionId(session.getId());
+        bag.put(ATTRIBUTE_SESSION_CONTEXT, sessionContext);
+
+        // store all conversation contexts
+        ConversationManager conversationManager = webBeansContext.getConversationManager();
+        bag.put(ATTRIBUTE_CONVERSATION_CONTEXT_MAP, conversationManager.getConversationMapWithSessionId(session.getId()));
+
+        if (LOGGER.isLoggable(Level.FINE))
+        {
+            LOGGER.log(Level.FINE, "Beans for session [" + bag.getSessionId() + "] successfully stored in FailOverBag.");
+        }
+    }
+
+    /**
+     * Restores the session and conversation contexts from the given {@link FailOverBag}.
+     * 
+     * @param bag The {@link FailOverBag}.
+     * @param session The current {@link HttpSession}.
+     */
+    @SuppressWarnings("unchecked")
+    protected void restoreBeansFromFailOverBag(FailOverBag bag, HttpSession session)
+    {
+        try
+        {
+            // restore session context
+            SessionContext sessionContext = (SessionContext) bag.get(ATTRIBUTE_SESSION_CONTEXT);
+
+            if (sessionContext != null)
+            {
+                SessionContextManager sessionManager =
+                        ((WebContextsService) webBeansContext.getContextsService()).getSessionContextManager();
+
+                sessionManager.addNewSessionContext(session.getId(), sessionContext);
+                sessionContext.setActive(true);
+            }
+
+            // restore conversation contexts
+            Map<Conversation, ConversationContext> conversationContextMap =
+                    (Map<Conversation, ConversationContext>) bag.get(ATTRIBUTE_CONVERSATION_CONTEXT_MAP);
+
+            if (conversationContextMap != null && !conversationContextMap.isEmpty())
+            {
+                ConversationManager conversationManager = webBeansContext.getConversationManager();
+                Iterator<Conversation> iterator = conversationContextMap.keySet().iterator();
+
+                while (iterator.hasNext())
+                {
+                    Conversation conversation = iterator.next();
+                    ConversationContext context = conversationContextMap.get(conversation);
+                    conversationManager.addConversationContext(conversation, context);
+                }
+            }
+
+            if (LOGGER.isLoggable(Level.FINE))
+            {
+                LOGGER.log(Level.FINE, "Beans for session [" + bag.getSessionId() + "] from [" + bag.getJvmId() + "] successfully restored.");
+            }
+        }
+        catch (Exception e)
+        {
+            String message = "Could not restore beans for session [" + bag.getSessionId()
+                    + "] from [" + bag.getJvmId() + "]";
+            LOGGER.log(Level.SEVERE, message, e);
+
+            throw new WebBeansException(message, e);
+        }
+    }
+
+    /**
+     * Except the EJB remote stub, it is hard to handle other types of
+     * resources. Here we delegate serialization/deserialization to the
+     * application provided SerializationHandler.
+     */
+    public Object handleResource(Bean<?> bean, Object resourceObject, ObjectInput in, ObjectOutput out)
+    {
+        if (handler != null)
+        {
+            return handler.handleResource(bean, resourceObject, in, out,
+                    (isPassivation()) ? SerializationHandlerV10.TYPE_PASSIVATION : SerializationHandlerV10.TYPE_FAILOVER);
+        }
+        return NOT_HANDLED;
+    }
+
+    /**
+     * Get object input stream. Note, the stream should support deserialize
+     * javassist objects.
+     * 
+     * @return custom object input stream.
+     */
+    public ObjectInputStream getObjectInputStream(InputStream in) throws IOException
+    {
+        return new OwbProxyObjectInputStream(in);
+    }
+
+    /**
+     * Get object output stream. Note, the stream should support deserialize
+     * javassist objects.
+     * 
+     * @return custom object output stream.
+     */
+    public ObjectOutputStream getObjectOutputStream(OutputStream out) throws IOException
+    {
+        return new ProxyObjectOutputStream(out);
+    }
+
+    public String getJvmId()
+    {
+        return JVM_ID;
+    }
+
+    public boolean isSupportFailOver()
+    {
+        return supportFailOver;
+    }
+
+    public void enableFailOverSupport(boolean supportFailOver)
+    {
+        this.supportFailOver = supportFailOver;
+    }
+
+    public boolean isSupportPassivation()
+    {
+        return supportPassivation;
+    }
+
+    public void enablePassivationSupport(boolean supportPassivation)
+    {
+        this.supportPassivation = supportPassivation;
+    }
+
+    public boolean isPassivation()
+    {
+        if (passivation.get() == null)
+        {
+            passivation.set(false);
+        }
+
+        return passivation.get();
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/DefaultOwbFailOverService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,171 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.logger.WebBeansLoggerFacade;
+import org.apache.webbeans.spi.FailOverService;
+
+/**
+ * Bag which holds all required informations for the fail over.
+ */
+public class FailOverBag implements Serializable, Externalizable
+{
+    public static final String SESSION_ATTRIBUTE_NAME = "o.a.owb.FAIL_OVER_BAG";
+
+    private static final Logger LOGGER = WebBeansLoggerFacade.getLogger(FailOverBag.class);
+    private static final long serialVersionUID = -6314819837009653190L;
+
+    private transient FailOverService failOverService;
+
+    private Map<String, Object> items;
+    private boolean sessionInUse;
+    private String sessionId;
+    private String jvmId;
+
+    /**
+     * Used by serialization.
+     */
+    public FailOverBag()
+    {
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+
+        this.failOverService = webBeansContext.getService(FailOverService.class);
+        this.items = new HashMap<String, Object>();
+    }
+
+    public FailOverBag(String sessionId, String jvmId)
+    {
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+
+        this.failOverService = webBeansContext.getService(FailOverService.class);
+        this.items = new HashMap<String, Object>();
+        this.sessionId = sessionId;
+        this.jvmId = jvmId;
+    }
+
+    public void put(String name, Object item)
+    {
+        items.put(name, item);
+    }
+
+    public Object get(String name)
+    {
+        return items.get(name);
+    }
+
+    @SuppressWarnings("unchecked")
+    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
+    {
+        sessionInUse = in.readBoolean();
+        sessionId = (String) in.readObject();
+        jvmId = (String) in.readObject();
+
+        if (sessionInUse)
+        {
+            if (LOGGER.isLoggable(Level.FINE))
+            {
+                LOGGER.log(Level.FINE, "Skip bean de-serialization because session with id [" + sessionId + "] is in use.");
+            }
+
+            return;
+        }
+
+        byte[] buffer = (byte[]) in.readObject();
+        ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
+        ObjectInputStream ois = failOverService.getObjectInputStream(bais);
+
+        items = (Map<String, Object>) ois.readObject();
+
+        ois.close();
+    }
+
+    public void writeExternal(ObjectOutput out) throws IOException
+    {
+        out.writeBoolean(sessionInUse);
+        out.writeObject(sessionId);
+        out.writeObject(jvmId);
+
+        if (sessionInUse)
+        {
+            if (LOGGER.isLoggable(Level.FINE))
+            {
+                LOGGER.log(Level.FINE, "Skip bean serialization because session with id [" + sessionId + "] is in use.");
+            }
+
+            return;
+        }
+
+        // We could not directly use java object stream since we are using javassist.
+        // Serialize the bag by use javassist object stream.
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = failOverService.getObjectOutputStream(baos);
+        oos.writeObject(items);
+        oos.flush();
+
+        out.writeObject(baos.toByteArray());
+
+        oos.close();
+        baos.close();
+    }
+
+    public boolean isSessionInUse()
+    {
+        return sessionInUse;
+    }
+
+    public void setSessionInUse(boolean sessionInUse)
+    {
+        this.sessionInUse = sessionInUse;
+    }
+
+    public String getSessionId()
+    {
+        return sessionId;
+    }
+
+    public void setSessionId(String sessionId)
+    {
+        this.sessionId = sessionId;
+    }
+
+    public String getJvmId()
+    {
+        return jvmId;
+    }
+
+    public void setJvmId(String jvmId)
+    {
+        this.jvmId = jvmId;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverBag.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverFilter.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverFilter.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverFilter.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverFilter.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover;
+
+import java.io.IOException;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.FailOverService;
+
+/**
+ * {@link Filter} which handles the bean fail over.
+ * This extra {@link Filter} is required because
+ * {@link javax.servlet.ServletRequestListener#requestDestroyed(javax.servlet.ServletRequestEvent)}
+ * will be called after Tomcats session replication and is not in sync with the specs.
+ */
+public class FailOverFilter implements Filter
+{
+    protected FailOverService failoverService;
+
+    /**
+     * Default constructor.
+     */
+    public FailOverFilter()
+    {
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+        failoverService = webBeansContext.getService(FailOverService.class);
+    }
+
+    public void destroy()
+    {
+        //do nothing
+    }
+
+    public void doFilter(ServletRequest request, ServletResponse response,
+                         FilterChain chain) throws IOException, ServletException
+    {
+        try
+        {
+            chain.doFilter(request, response);
+        }
+        finally
+        {
+            if (failoverService != null
+                && failoverService.isSupportFailOver()
+                && request instanceof HttpServletRequest)
+            {
+                HttpServletRequest httpRequest = (HttpServletRequest) request;
+                HttpSession session = httpRequest.getSession(false);
+
+                if (session != null)
+                {
+                    failoverService.sessionIsIdle(session);
+                }
+            }
+        }
+    }
+
+    public void init(FilterConfig config) throws ServletException
+    {
+        //do nothing
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverFilter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverSessionActivationListener.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverSessionActivationListener.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverSessionActivationListener.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverSessionActivationListener.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover;
+
+import java.io.Serializable;
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionActivationListener;
+import javax.servlet.http.HttpSessionEvent;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.spi.FailOverService;
+
+/**
+ * {@link HttpSessionActivationListener} which informs the {@link FailOverService}
+ * about session activation and passivation.
+ * 
+ * It must NOT be manually registered because the {@link FailOverService}
+ * store it as session attribute and therefore it will be executed automatically.
+ */
+public class FailOverSessionActivationListener implements HttpSessionActivationListener, Serializable
+{
+    public static final String SESSION_ATTRIBUTE_NAME = "o.a.owb.SESSION_ACTIVATION_LISTENER";
+
+    private static final long serialVersionUID = -5690043082210295824L;
+
+    public void sessionWillPassivate(HttpSessionEvent event)
+    {
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+        FailOverService failOverService = webBeansContext.getService(FailOverService.class);
+
+        if (failOverService != null && failOverService.isSupportPassivation())
+        {
+            HttpSession session = event.getSession();
+            failOverService.sessionWillPassivate(session);
+        }
+    }
+
+    public void sessionDidActivate(HttpSessionEvent event)
+    {
+        WebBeansContext webBeansContext = WebBeansContext.currentInstance();
+        FailOverService failOverService = webBeansContext.getService(FailOverService.class);
+
+        if (failOverService != null && (failOverService.isSupportFailOver() || failOverService.isSupportPassivation()))
+        {
+            HttpSession session = event.getSession();
+            failOverService.sessionDidActivate(session);
+        }
+    }
+}
\ No newline at end of file

Propchange: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/FailOverSessionActivationListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/OwbProxyObjectInputStream.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/OwbProxyObjectInputStream.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/OwbProxyObjectInputStream.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/OwbProxyObjectInputStream.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectStreamClass;
+
+import javassist.util.proxy.ProxyObjectInputStream;
+
+public class OwbProxyObjectInputStream extends ProxyObjectInputStream
+{
+    public OwbProxyObjectInputStream(InputStream in) throws IOException
+    {
+        super(in);
+    }
+
+    @Override
+    protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException
+    {
+        try
+        {
+            String name = desc.getName();
+
+            return Class.forName(name, false, Thread.currentThread().getContextClassLoader());
+        }
+        catch (ClassNotFoundException ex)
+        {
+            return super.resolveClass(desc);
+        }
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/OwbProxyObjectInputStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/SerializationHandlerV10.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/SerializationHandlerV10.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/SerializationHandlerV10.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/SerializationHandlerV10.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover;
+
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+
+import javax.enterprise.inject.spi.Bean;
+
+/**
+ * Application could implement this interface and register with failover service to handle 
+ * serialization/deserialization of resource beans. Failover serivce will invoke this
+ * handleResource Method then.
+ * 
+ */
+public interface SerializationHandlerV10 
+{
+    /**
+     * failover case.
+     */
+    public final static int TYPE_FAILOVER = 0;
+
+    /**
+     * passivation case.
+     */
+    public final static int TYPE_PASSIVATION = 1;
+        
+    /**
+     * Application provided custom handler for serialize 
+     * and deserialize resource beans.
+     *  
+     * @param bean                The resource bean.
+     * @param resourceObject    The resource bean instance
+     * @param in                The input object stream
+     * @param out                The output object stream
+     * @param type                TYPE_FAILOVER or TYPE_PASSIVATION
+     * 
+     * @return NOT_HANDLED if not handled by handler.
+     */
+    public Object handleResource(
+            Bean<?> bean,
+            Object resourceObject,
+            ObjectInput in,
+            ObjectOutput out,
+            int type
+            );
+
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/main/java/org/apache/webbeans/web/failover/SerializationHandlerV10.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/openwebbeans/openwebbeans.properties?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/openwebbeans/openwebbeans.properties (added)
+++ openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/openwebbeans/openwebbeans.properties Wed Nov  7 14:06:13 2012
@@ -0,0 +1,27 @@
+#Licensed to the Apache Software Foundation (ASF) under one
+#or more contributor license agreements.  See the NOTICE file
+#distributed with this work for additional information
+#regarding copyright ownership.  The ASF licenses this file
+#to you 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.
+#---------------------------------------------------------------
+# The Clustering configuration for OpenWebBeans
+#
+#---------------------------------------------------------------
+configuration.ordinal=20
+
+################################ Failover Service #############################################
+org.apache.webbeans.spi.FailOverService=org.apache.webbeans.web.failover.DefaultOwbFailOverService
+org.apache.webbeans.web.failover.issupportfailover=false
+org.apache.webbeans.web.failover.issupportpassivation=false
+##############################################################################################

Propchange: openwebbeans/trunk/webbeans-clustering/src/main/resources/META-INF/openwebbeans/openwebbeans.properties
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/AbstractUnitTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/AbstractUnitTest.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/AbstractUnitTest.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/AbstractUnitTest.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,145 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import java.lang.annotation.Annotation;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+
+import org.apache.webbeans.config.WebBeansContext;
+import org.apache.webbeans.config.WebBeansFinder;
+import org.apache.webbeans.exception.WebBeansConfigurationException;
+import org.apache.webbeans.lifecycle.test.OpenWebBeansTestLifeCycle;
+import org.apache.webbeans.lifecycle.test.OpenWebBeansTestMetaDataDiscoveryService;
+import org.apache.webbeans.spi.ContainerLifecycle;
+import org.apache.webbeans.util.WebBeansUtil;
+import org.junit.Assert;
+
+
+public abstract class AbstractUnitTest
+{
+    private OpenWebBeansTestLifeCycle testLifecycle;
+    private List<Extension>  extensions = new ArrayList<Extension>();
+    private WebBeansContext webBeansContext;
+
+    protected AbstractUnitTest()
+    {
+
+    }
+    
+    protected void startContainer(Collection<Class<?>> beanClasses)
+    {
+        startContainer(beanClasses, null);
+    }
+    
+    protected void startContainer(Collection<Class<?>> beanClasses, Collection<String> beanXmls)
+    {
+        WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());
+        //Creates a new container
+        testLifecycle = new OpenWebBeansTestLifeCycle();
+        
+        webBeansContext = WebBeansContext.getInstance();
+        for (Extension ext : extensions)
+        {
+            webBeansContext.getExtensionLoader().addExtension(ext);
+        }
+        
+        //Deploy bean classes
+        OpenWebBeansTestMetaDataDiscoveryService discoveryService = (OpenWebBeansTestMetaDataDiscoveryService)webBeansContext.getScannerService();
+        discoveryService.deployClasses(beanClasses);
+        if (beanXmls != null)
+        {
+            discoveryService.deployXMLs(beanXmls);
+        }
+
+        //Start application
+        try
+        {
+            testLifecycle.startApplication(null);
+        }
+        catch (Exception e)
+        {
+            throw new WebBeansConfigurationException(e);
+        }
+        
+    }
+
+    protected ContainerLifecycle getLifecycle()
+    {
+        return testLifecycle;
+    }
+    
+    protected void shutDownContainer()
+    {
+        //Shwtdown application
+        if(this.testLifecycle != null)
+        {
+            this.testLifecycle.stopApplication(null);
+        }        
+    }
+        
+    protected WebBeansContext getWebBeansContext()
+    {
+        return this.webBeansContext;
+    }
+    
+    protected BeanManager getBeanManager()
+    {
+        return this.webBeansContext.getBeanManagerImpl();
+    }
+
+    @SuppressWarnings("unchecked")
+    protected <T> T getInstance(Class<T> type, Annotation... qualifiers)
+    {
+        Set<Bean<?>> beans = getBeanManager().getBeans(type, qualifiers);
+        Assert.assertNotNull(beans);
+
+        Bean<?> bean = getBeanManager().resolve(beans);
+        
+        return (T) getBeanManager().getReference(bean, type, getBeanManager().createCreationalContext(bean));
+    }
+    
+    protected String getXmlPath(String packageName, String fileName)
+    {
+        StringBuilder prefix = new StringBuilder(packageName.replace('.', '/'));
+        prefix.append("/");
+        prefix.append(fileName);
+        prefix.append(".xml");
+        
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        return loader.getResource(prefix.toString()).toExternalForm();
+    }
+    
+    /**
+     * Add a CDI Extension which should get used in the test case.
+     * Use this function instead of defining test Extensions via the usual
+     * META-INF/services/javax.enterprise.inject.spi.Extension file!
+     * 
+     * @param ext the {@link Extension} which should get loaded
+     */
+    public void addExtension(Extension ext) {
+        this.extensions.add(ext);
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/AbstractUnitTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/ConversationScopedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/ConversationScopedBean.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/ConversationScopedBean.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/ConversationScopedBean.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.inject.Inject;
+
+@ConversationScoped
+public class ConversationScopedBean implements Serializable
+{
+    private static final long serialVersionUID = -1494676081508377549L;
+
+    @Inject private BeanManager beanManager;
+    @Inject private Conversation conversation;
+
+    private String text;
+
+    public void beginConversation()
+    {
+        if (conversation.isTransient())
+        {
+            conversation.begin();
+        }
+    }
+
+    public void endConversation()
+    {
+        if (!conversation.isTransient())
+        {
+            conversation.end();
+        }
+    }
+
+    public boolean isBeanManagerNotNull()
+    {
+        return beanManager != null;
+    }
+
+    public String getText()
+    {
+        return text;
+    }
+
+    public void setText(String text)
+    {
+        this.text = text;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/ConversationScopedBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/DefaultOwbFailOverServiceTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/DefaultOwbFailOverServiceTest.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/DefaultOwbFailOverServiceTest.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/DefaultOwbFailOverServiceTest.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,341 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.spi.Bean;
+import javax.servlet.http.HttpSession;
+
+import org.apache.webbeans.context.ConversationContext;
+import org.apache.webbeans.conversation.ConversationImpl;
+import org.apache.webbeans.conversation.ConversationManager;
+import org.apache.webbeans.spi.ConversationService;
+import org.apache.webbeans.spi.FailOverService;
+import org.apache.webbeans.web.failover.DefaultOwbFailOverService;
+import org.apache.webbeans.web.failover.FailOverBag;
+import org.apache.webbeans.web.failover.FailOverSessionActivationListener;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class DefaultOwbFailOverServiceTest extends AbstractUnitTest
+{
+    private static final String SESSION_SCOPED_SAMPLE_TEXT = "session_sample";
+    private static final String CONVERSATION_SCOPED_SAMPLE_TEXT = "conversatzion_sample";
+
+    @Before
+    public void before()
+    {
+        Collection<Class<?>> classes = new ArrayList<Class<?>>();
+        classes.add(ConversationScopedBean.class);
+        classes.add(SessionScopedBean.class);
+
+        startContainer(classes);
+    }
+
+    @After
+    public void after()
+    {
+        shutDownContainer();
+    }
+
+    /**
+     * Tests that the {@link FailOverBag} and {@link FailOverSessionActivationListener} will be added to the session.
+     */
+    @Test
+    public void sessionIsIdle()
+    {
+        // ----- setup
+        HttpSession session = new MockHttpSession();
+
+        DefaultOwbFailOverService failoverService =
+                (DefaultOwbFailOverService) getWebBeansContext().getService(FailOverService.class);
+
+        failoverService.enableFailOverSupport(true);
+        failoverService.enablePassivationSupport(true);
+
+
+
+        // ----- execute
+        failoverService.sessionIsIdle(session);
+
+
+
+        // ----- assert
+        FailOverSessionActivationListener listener = (FailOverSessionActivationListener)
+                session.getAttribute(FailOverSessionActivationListener.SESSION_ATTRIBUTE_NAME);
+        FailOverBag failOverBag = (FailOverBag)
+                session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
+
+        Assert.assertNotNull(listener);
+        Assert.assertNotNull(failOverBag);
+        Assert.assertFalse(failOverBag.isSessionInUse());
+        Assert.assertFalse(failoverService.isPassivation());
+    }
+
+    /**
+     * Tests that <code>sessionInUse</code> will be set and that the
+     * {@link FailOverSessionActivationListener} will be added to the session.
+     */
+    @Test
+    public void sessionIsInUse()
+    {
+        // ----- setup
+        HttpSession session = new MockHttpSession();
+
+        // put bag manually to session
+        FailOverBag failOverBag = new FailOverBag(session.getId(), "");
+        session.setAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME, failOverBag);
+
+        DefaultOwbFailOverService failoverService =
+                (DefaultOwbFailOverService) getWebBeansContext().getService(FailOverService.class);
+
+        failoverService.enableFailOverSupport(true);
+        failoverService.enablePassivationSupport(true);
+
+
+
+        // ----- execute
+        failoverService.sessionIsInUse(session);
+
+
+
+        // ----- assert
+        FailOverSessionActivationListener listener = (FailOverSessionActivationListener)
+                session.getAttribute(FailOverSessionActivationListener.SESSION_ATTRIBUTE_NAME);
+
+        Assert.assertNotNull(listener);
+        Assert.assertTrue(failOverBag.isSessionInUse());
+        Assert.assertFalse(failoverService.isPassivation());
+    }
+
+    /**
+     * Tests that the {@link FailOverBag} and {@link FailOverSessionActivationListener} will be added to the session.
+     */
+    @Test
+    public void sessionWillPassivate()
+    {
+        // ----- setup
+        HttpSession session = new MockHttpSession();
+
+        DefaultOwbFailOverService failoverService =
+                (DefaultOwbFailOverService) getWebBeansContext().getService(FailOverService.class);
+
+        failoverService.enableFailOverSupport(true);
+        failoverService.enablePassivationSupport(true);
+
+
+
+        // ----- execute
+        failoverService.sessionWillPassivate(session);
+
+
+
+        // ----- assert
+        FailOverSessionActivationListener listener = (FailOverSessionActivationListener)
+                session.getAttribute(FailOverSessionActivationListener.SESSION_ATTRIBUTE_NAME);
+        FailOverBag failOverBag = (FailOverBag)
+                session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
+
+        Assert.assertNotNull(listener);
+        Assert.assertNotNull(failOverBag);
+        Assert.assertFalse(failOverBag.isSessionInUse());
+        Assert.assertTrue(failoverService.isPassivation());
+    }
+
+    /**
+     * Tests that the session context will be stored and restored
+     * successfully from the {@link FailOverBag}.
+     * 
+     * @throws Exception When store/restore the session context fails.
+     */
+    @Test
+    public void restoreSessionContext() throws Exception
+    {
+        // ----- setup
+        HttpSession session = new MockHttpSession();
+
+        DefaultOwbFailOverService failoverService =
+                (DefaultOwbFailOverService) getWebBeansContext().getService(FailOverService.class);
+
+        failoverService.enableFailOverSupport(true);
+        failoverService.enablePassivationSupport(true);
+
+
+
+        // ----- execute
+        getWebBeansContext().getContextsService().startContext(SessionScoped.class, session);
+
+        // set sample text
+        getInstance(SessionScopedBean.class).setText(SESSION_SCOPED_SAMPLE_TEXT);
+
+        // store beans in session
+        failoverService.sessionIsIdle(session);
+
+        // serialize / deserialize and store deserialized bag back to session
+        FailOverBag failOverBag;
+        failOverBag = (FailOverBag) session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
+        failOverBag = (FailOverBag) serialize(failOverBag);
+
+        session.setAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME, failOverBag);
+
+        // remove sample text
+        getInstance(SessionScopedBean.class).setText(null);
+
+        getWebBeansContext().getContextsService().endContext(SessionScoped.class, session);
+
+        // restore beans from session
+        failoverService.sessionDidActivate(session);
+
+        getWebBeansContext().getContextsService().startContext(SessionScoped.class, session);
+
+
+
+        // ----- assert
+        Assert.assertEquals(SESSION_SCOPED_SAMPLE_TEXT, getInstance(SessionScopedBean.class).getText());
+    }
+
+    /**
+     * Tests that the conversation contexts will be stored and restored
+     * successfully from the {@link FailOverBag}.
+     * 
+     * @throws Exception When store/restore the session context fails.
+     */
+    @Test
+    public void restoreConversationContexts() throws Exception
+    {
+        // ----- setup
+        HttpSession session = new MockHttpSession();
+
+        DefaultOwbFailOverService failoverService =
+                (DefaultOwbFailOverService) getWebBeansContext().getService(FailOverService.class);
+
+        failoverService.enableFailOverSupport(true);
+        failoverService.enablePassivationSupport(true);
+
+
+
+        // ----- execute
+        // create conversation
+        ConversationContext conversationContext = new ConversationContext();
+        conversationContext.setActive(true);
+
+        Conversation conversation = new ConversationImpl(session.getId(), getWebBeansContext());
+        conversation.begin();
+
+        ConversationManager conversationManager = getWebBeansContext().getConversationManager();
+        conversationManager.addConversationContext(conversation, conversationContext);
+
+        getWebBeansContext().registerService(ConversationService.class, new MockConversationService(session, conversation));
+
+        // set sample text
+        getInstance(ConversationScopedBean.class, conversationContext).setText(CONVERSATION_SCOPED_SAMPLE_TEXT);
+
+        // store beans in session
+        failoverService.sessionIsIdle(session);
+
+        // serialize / deserialize and store deserialized bag back to session
+        FailOverBag failOverBag;
+        failOverBag = (FailOverBag) session.getAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME);
+        failOverBag = (FailOverBag) serialize(failOverBag);
+
+        session.setAttribute(FailOverBag.SESSION_ATTRIBUTE_NAME, failOverBag);
+
+        // remove sample text
+        getInstance(ConversationScopedBean.class, conversationContext).setText(null);
+
+        getWebBeansContext().getContextsService().endContext(ConversationScoped.class, conversationContext);
+
+        // restore beans from session
+        failoverService.sessionDidActivate(session);
+
+
+
+        // ----- assert
+        // get and activate conversation
+        Map<Conversation, ConversationContext> conversationMap =
+                conversationManager.getConversationMapWithSessionId(session.getId());
+
+        Conversation propogatedConversation =
+                conversationManager.getPropogatedConversation(conversation.getId(), session.getId());
+
+        ConversationContext propogatedConversationContext =  conversationMap.get(propogatedConversation);
+        propogatedConversationContext.setActive(true);
+
+        ConversationScopedBean beanInstance = getInstance(ConversationScopedBean.class, propogatedConversationContext);
+
+        Assert.assertEquals(CONVERSATION_SCOPED_SAMPLE_TEXT, beanInstance.getText());
+        Assert.assertTrue(beanInstance.isBeanManagerNotNull());
+    }
+
+    /**
+     * Tests that the {@link FailOverSessionActivationListener} is serializable.
+     *
+     * @throws Exception If serialization fails.
+     */
+    @Test
+    public void serializeSessionActivationListener() throws Exception
+    {
+        serialize(new FailOverSessionActivationListener());
+    }
+
+    private Serializable serialize(Serializable serializable) throws IOException, ClassNotFoundException
+    {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ObjectOutputStream oos = new ObjectOutputStream(baos);
+
+        oos.writeObject(serializable);
+        oos.close();
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+        ObjectInputStream ois = new ObjectInputStream(bais);
+
+        Object deserializedObject = ois.readObject();
+
+        ois.close();
+
+        return (Serializable) deserializedObject;
+    }
+
+    public <T> T getInstance(Class<T> type, Context context)
+    {
+        Set<Bean<?>> beans = getBeanManager().getBeans(type);
+        @SuppressWarnings("unchecked")
+        Bean<T> bean = (Bean<T>) getBeanManager().resolve(beans);
+        CreationalContext<T> creationalContext = getBeanManager().createCreationalContext(bean);
+
+        return context.get(bean, creationalContext);
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/DefaultOwbFailOverServiceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockConversationService.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockConversationService.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockConversationService.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockConversationService.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import javax.enterprise.context.Conversation;
+import javax.servlet.http.HttpSession;
+
+import org.apache.webbeans.spi.ConversationService;
+
+public class MockConversationService implements ConversationService
+{
+    private String conversationId;
+    private String sessionId;
+
+    public MockConversationService(HttpSession session, Conversation conversation)
+    {
+        this.sessionId = session.getId();
+        this.conversationId = conversation.getId();
+    }
+
+    public String getConversationId()
+    {
+        return conversationId;
+    }
+
+    public String getConversationSessionId()
+    {
+        return sessionId;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockConversationService.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockHttpSession.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockHttpSession.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockHttpSession.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockHttpSession.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+import javax.servlet.http.HttpSessionContext;
+
+public class MockHttpSession implements HttpSession
+{
+    public static final String SESSION_ID = "testSessionId";
+
+    private Map<String, Object> attributes = new HashMap<String, Object>();
+
+    public Object getAttribute(String key)
+    {
+        return attributes.get(key);
+    }
+
+    public Enumeration getAttributeNames()
+    {
+        return null;
+    }
+
+    public long getCreationTime()
+    {
+        return 0;
+    }
+
+    public String getId()
+    {
+        return SESSION_ID;
+    }
+
+    public long getLastAccessedTime()
+    {
+        return 0;
+    }
+
+    public int getMaxInactiveInterval()
+    {
+        return 0;
+    }
+
+    public ServletContext getServletContext()
+    {
+        return null;
+    }
+
+    public HttpSessionContext getSessionContext()
+    {
+        return null;
+    }
+
+    public Object getValue(String arg0)
+    {
+        return null;
+    }
+
+    public String[] getValueNames()
+    {
+        return null;
+    }
+
+    public void invalidate()
+    {
+
+    }
+
+    public boolean isNew()
+    {
+        return false;
+    }
+
+    public void putValue(String arg0, Object arg1)
+    {
+
+    }
+
+    public void removeAttribute(String key)
+    {
+        attributes.remove(key);
+    }
+
+    public void removeValue(String arg0)
+    {
+
+    }
+
+    public void setAttribute(String key, Object value)
+    {
+        attributes.put(key, value);
+    }
+
+    public void setMaxInactiveInterval(int arg0)
+    {
+
+    }
+}
\ No newline at end of file

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockHttpSession.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletContext.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletContext.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletContext.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletContext.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.Servlet;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
+ */
+public class MockServletContext implements ServletContext
+{
+    public Object getAttribute(String name)
+    {
+        return null;
+    }
+
+    public ServletContext getContext(String uripath)
+    {
+        return null;
+    }
+
+    public String getContextPath()
+    {
+        return null;
+    }
+
+    public int getMajorVersion()
+    {
+        return 0;
+    }
+
+    public int getMinorVersion()
+    {
+        return 0;
+    }
+
+    public String getMimeType(String file)
+    {
+        return null;
+    }
+
+    public Set getResourcePaths(String path)
+    {
+        return null;
+    }
+
+    public URL getResource(String path) throws MalformedURLException
+    {
+        return null;
+    }
+
+    public InputStream getResourceAsStream(String path)
+    {
+        return null;
+    }
+
+    public RequestDispatcher getRequestDispatcher(String path)
+    {
+        return null;
+    }
+
+    public RequestDispatcher getNamedDispatcher(String name)
+    {
+        return null;
+    }
+
+    public Servlet getServlet(String name) throws ServletException
+    {
+        return null;
+    }
+
+    public Enumeration getServlets()
+    {
+        return null;
+    }
+
+    public Enumeration getServletNames()
+    {
+        return null;
+    }
+
+    public void log(String msg)
+    {
+    }
+
+    public void log(Exception exception, String msg)
+    {
+    }
+
+    public void log(String message, Throwable throwable)
+    {
+    }
+
+    public String getRealPath(String path)
+    {
+        return null;
+    }
+
+    public String getServerInfo()
+    {
+        return null;
+    }
+
+    public String getInitParameter(String name)
+    {
+        return null;
+    }
+
+    public Enumeration getInitParameterNames()
+    {
+        return null;
+    }
+
+    public Enumeration getAttributeNames()
+    {
+        return null;
+    }
+
+    public void setAttribute(String name, Object object)
+    {
+    }
+
+    public void removeAttribute(String name)
+    {
+    }
+
+    public String getServletContextName()
+    {
+        return null;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletRequest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletRequest.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletRequest.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletRequest.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:struberg@yahoo.de">Mark Struberg</a>
+ */
+public class MockServletRequest implements HttpServletRequest
+{
+
+    public Object getAttribute(String name)
+    {
+        return null;
+    }
+
+    public Enumeration getAttributeNames()
+    {
+        return null;
+    }
+
+    public String getCharacterEncoding()
+    {
+        return null;
+    }
+
+    public void setCharacterEncoding(String env) throws UnsupportedEncodingException
+    {
+    }
+
+    public int getContentLength()
+    {
+        return 0;
+    }
+
+    public String getContentType()
+    {
+        return null;
+    }
+
+    public ServletInputStream getInputStream() throws IOException
+    {
+        return null;
+    }
+
+    public String getParameter(String name)
+    {
+        return null;
+    }
+
+    public Enumeration getParameterNames()
+    {
+        return null;
+    }
+
+    public String[] getParameterValues(String name)
+    {
+        return new String[0];
+    }
+
+    public Map getParameterMap()
+    {
+        return null;
+    }
+
+    public String getProtocol()
+    {
+        return null;
+    }
+
+    public String getScheme()
+    {
+        return null;
+    }
+
+    public String getServerName()
+    {
+        return null;
+    }
+
+    public int getServerPort()
+    {
+        return 0;
+    }
+
+    public BufferedReader getReader() throws IOException
+    {
+        return null;
+    }
+
+    public String getRemoteAddr()
+    {
+        return null;
+    }
+
+    public String getRemoteHost()
+    {
+        return null;
+    }
+
+    public void setAttribute(String name, Object o)
+    {
+    }
+
+    public void removeAttribute(String name)
+    {
+    }
+
+    public Locale getLocale()
+    {
+        return null;
+    }
+
+    public Enumeration getLocales()
+    {
+        return null;
+    }
+
+    public boolean isSecure()
+    {
+        return false;
+    }
+
+    public RequestDispatcher getRequestDispatcher(String path)
+    {
+        return null;
+    }
+
+    public String getRealPath(String path)
+    {
+        return null;
+    }
+
+    public int getRemotePort()
+    {
+        return 0;
+    }
+
+    public String getLocalName()
+    {
+        return null;
+    }
+
+    public String getLocalAddr()
+    {
+        return null;
+    }
+
+    public int getLocalPort()
+    {
+        return 0;
+    }
+
+    public String getAuthType()
+    {
+        return null;
+    }
+
+    public Cookie[] getCookies()
+    {
+        return new Cookie[0];
+    }
+
+    public long getDateHeader(String name)
+    {
+        return 0;
+    }
+
+    public String getHeader(String name)
+    {
+        return null;
+    }
+
+    public Enumeration getHeaders(String name)
+    {
+        return null;
+    }
+
+    public Enumeration getHeaderNames()
+    {
+        return null;
+    }
+
+    public int getIntHeader(String name)
+    {
+        return 0;
+    }
+
+    public String getMethod()
+    {
+        return null;
+    }
+
+    public String getPathInfo()
+    {
+        return null;
+    }
+
+    public String getPathTranslated()
+    {
+        return null; 
+    }
+
+    public String getContextPath()
+    {
+        return null;
+    }
+
+    public String getQueryString()
+    {
+        return null;
+    }
+
+    public String getRemoteUser()
+    {
+        return null;
+    }
+
+    public boolean isUserInRole(String role)
+    {
+        return false;
+    }
+
+    public Principal getUserPrincipal()
+    {
+        return null;
+    }
+
+    public String getRequestedSessionId()
+    {
+        return null;
+    }
+
+    public String getRequestURI()
+    {
+        return null;
+    }
+
+    public StringBuffer getRequestURL()
+    {
+        return null;
+    }
+
+    public String getServletPath()
+    {
+        return null;
+    }
+
+    public HttpSession getSession(boolean create)
+    {
+        return null;
+    }
+
+    public HttpSession getSession()
+    {
+        return null;
+    }
+
+    public boolean isRequestedSessionIdValid()
+    {
+        return false;
+    }
+
+    public boolean isRequestedSessionIdFromCookie()
+    {
+        return false;
+    }
+
+    public boolean isRequestedSessionIdFromURL()
+    {
+        return false;
+    }
+
+    public boolean isRequestedSessionIdFromUrl()
+    {
+        return false;
+    }
+}

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/MockServletRequest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/SessionScopedBean.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/SessionScopedBean.java?rev=1406640&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/SessionScopedBean.java (added)
+++ openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/SessionScopedBean.java Wed Nov  7 14:06:13 2012
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.webbeans.web.failover.tests;
+
+import java.io.Serializable;
+
+import javax.enterprise.context.SessionScoped;
+
+@SessionScoped
+public class SessionScopedBean implements Serializable
+{
+    private static final long serialVersionUID = -448758698909502562L;
+
+    private String text;
+
+    public String getText()
+    {
+        return text;
+    }
+
+    public void setText(String text)
+    {
+        this.text = text;
+    }
+}
\ No newline at end of file

Propchange: openwebbeans/trunk/webbeans-clustering/src/test/java/org/apache/webbeans/web/failover/tests/SessionScopedBean.java
------------------------------------------------------------------------------
    svn:eol-style = native