Initial Contribution

Signed-off-by: Vinay Vishal <vinay.vishal@oracle.com>
diff --git a/appserver/grizzly/glassfish-grizzly-extra-all/exclude.xml b/appserver/grizzly/glassfish-grizzly-extra-all/exclude.xml
new file mode 100644
index 0000000..cbdb2c7
--- /dev/null
+++ b/appserver/grizzly/glassfish-grizzly-extra-all/exclude.xml
@@ -0,0 +1,40 @@
+<!--
+
+    Copyright (c) 2012, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<FindBugsFilter>
+    <!--
+        Exclude these classes that are imported as binaries from Grizzly.
+    -->
+    <Match>
+        <Or>
+            <Class name="~org\.glassfish\.grizzly\.servlet\..*"/>
+            <Class name="~org\.glassfish\.grizzly\.websockets\..*"/>
+            <Class name="~org\.glassfish\.grizzly\.comet\..*"/>
+            <Class name="~org\.glassfish\.extras\.grizzly\..*"/>
+        </Or>
+    </Match>
+
+    <!--
+        The Logger in this class is only used to log messages at FINEST level,
+        so no resource bundle is needed.
+    -->
+    <Match>
+        <Class name="org.glassfish.grizzly.extras.addons.AjpAddOnProvider"/>
+        <Bug pattern="GF_MISSING_LOGMESSAGES_RB_ANNOTATION"/>
+    </Match>
+</FindBugsFilter>
diff --git a/appserver/grizzly/glassfish-grizzly-extra-all/pom.xml b/appserver/grizzly/glassfish-grizzly-extra-all/pom.xml
new file mode 100644
index 0000000..97c3c91
--- /dev/null
+++ b/appserver/grizzly/glassfish-grizzly-extra-all/pom.xml
@@ -0,0 +1,149 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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">
+    <parent>
+        <groupId>org.glassfish.main.grizzly</groupId>
+        <artifactId>glassfish-grizzly</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>glassfish-grizzly-extra-all</artifactId>
+    <packaging>jar</packaging>
+    <name>Glassfish Grizzly extra jars Combining</name>
+    <description>combining of all glassfish grizzly extra jars</description>
+
+    <developers>
+        <developer>
+            <id>oleksiys</id>
+            <name>Oleksiy Stashok</name>
+            <url>http://blogs.oracle.com/oleksiys</url>
+            <organization>Oracle, Inc.</organization>
+            <roles>
+                <role>developer</role>
+            </roles>
+        </developer>
+    </developers>
+
+    <properties>
+        <findbugs.exclude>${project.basedir}/exclude.xml</findbugs.exclude>
+    </properties>
+
+    <build>       
+        <plugins>
+            <plugin>
+                <groupId>org.glassfish.hk2</groupId>
+                 <artifactId>hk2-inhabitant-generator</artifactId>
+                <executions>
+                    <execution>
+                        <id>generate-inhabitants</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>generate-inhabitants</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.glassfish.hk2</groupId>
+                <artifactId>consolidatedbundle-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>processhk2headers</id>
+                        <phase>process-classes</phase>
+                        <goals>
+                            <goal>hk2-generate</goal>
+                        </goals>
+                    </execution>
+                </executions>
+
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.glassfish.grizzly.comet.*;version=${grizzly.version},
+                            org.glassfish.grizzly.websockets.*;version=${grizzly.version},
+                            org.glassfish.grizzly.http.ajp.*;version=${grizzly.version},
+                            org.glassfish.grizzly.servlet.*;version=${grizzly.version},
+                            org.glassfish.grizzly.extras.*;version=${project.version},
+                            org.glassfish.extras.grizzly.*;version=${project.version}
+                        </Export-Package>
+                        <Import-Package>*</Import-Package>
+                        <Include-Resource>META-INF/hk2-locator/=target/classes/META-INF/hk2-locator/</Include-Resource>
+                        <DynamicImport-Package>*</DynamicImport-Package>
+                    </instructions>
+                    
+                    <supportedProjectTypes>
+                        <supportedProjectType>jar</supportedProjectType>
+                    </supportedProjectTypes>
+                    
+                    <unpackBundle>true</unpackBundle>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>bundle</id>
+                        <goals>
+                            <goal>bundle</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-comet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-websockets</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-http-servlet</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.grizzly</groupId>
+            <artifactId>grizzly-http-ajp</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.main.grizzly</groupId>
+            <artifactId>glassfish-grizzly-container</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+           <groupId>org.glassfish.hk2</groupId>
+           <artifactId>hk2</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>javax.servlet-api</artifactId>
+            <version>${servlet-api.version}</version>
+	    <scope>provided</scope>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/AjpAddOnProvider.java b/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/AjpAddOnProvider.java
new file mode 100644
index 0000000..0810450
--- /dev/null
+++ b/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/AjpAddOnProvider.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.grizzly.extras.addons;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.glassfish.grizzly.config.ConfigAwareElement;
+import org.glassfish.grizzly.config.dom.Http;
+import org.glassfish.grizzly.config.dom.NetworkListener;
+import org.glassfish.grizzly.http.ajp.AjpAddOn;
+import org.glassfish.grizzly.http.server.AddOn;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.jvnet.hk2.annotations.ContractsProvided;
+import org.jvnet.hk2.annotations.Service;
+
+/**
+ * Ajp service.
+ *
+ * @author Alexey Stashok
+ */
+@Service(name = "ajp")
+@ContractsProvided({AjpAddOnProvider.class, AddOn.class})
+public class AjpAddOnProvider extends AjpAddOn implements ConfigAwareElement<Http> {
+
+    protected static final Logger _logger = Logger.getLogger("javax.enterprise.web");
+
+    @Override
+    public void configure(final ServiceLocator habitat,
+            final NetworkListener networkListener, final Http http) {
+
+        final boolean jkSupportEnabled = http.getJkEnabled() != null
+                ? Boolean.parseBoolean(http.getJkEnabled())
+                : Boolean.parseBoolean(networkListener.getJkEnabled());
+        if (jkSupportEnabled) {
+            final String jkPropertiesFilename =
+                    Boolean.parseBoolean(http.getJkEnabled())
+                    ? http.getJkConfigurationFile()
+                    : networkListener.getJkConfigurationFile();
+
+            File propertiesFile = null;
+
+            if (jkPropertiesFilename != null) {
+                propertiesFile = new File(jkPropertiesFilename);
+            }
+
+
+            final String systemPropertyFilename =
+                    System.getProperty("com.sun.enterprise.web.connector.enableJK.propertyFile");
+
+            if ((propertiesFile == null || !propertiesFile.exists())
+                    && systemPropertyFilename != null) {
+                propertiesFile = new File(systemPropertyFilename);
+            }
+
+            if (propertiesFile == null) {
+                if (_logger.isLoggable(Level.FINEST)) {
+                    _logger.finest("jk properties configuration file not defined");
+                }
+                return;
+            }
+
+            if (!propertiesFile.exists()) {
+                if (_logger.isLoggable(Level.FINEST)) {
+                    _logger.log(Level.FINEST,
+                            "jk properties configuration file ''{0}'' doesn't exist",
+                            propertiesFile.getAbsoluteFile());
+                }
+                return;
+            }
+
+            if (_logger.isLoggable(Level.FINEST)) {
+                _logger.log(Level.FINEST, "Loading glassfish-jk.properties from {0}",
+                        propertiesFile.getAbsolutePath());
+            }
+
+            Properties properties = null;
+
+            InputStream is = null;
+            try {
+                is = new BufferedInputStream(new FileInputStream(propertiesFile));
+                properties = new Properties();
+                properties.load(is);
+
+            } catch (Exception ex) {
+                throw new IllegalStateException(ex);
+            } finally {
+                if (is != null) {
+                    try {
+                        is.close();
+                    } catch (IOException ignored) {
+                    }
+                }
+            }
+
+            configure(properties);
+        }
+    }
+}
diff --git a/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/CometAddOnProvider.java b/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/CometAddOnProvider.java
new file mode 100644
index 0000000..c81626e
--- /dev/null
+++ b/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/CometAddOnProvider.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.grizzly.extras.addons;
+
+import org.glassfish.grizzly.comet.CometAddOn;
+import org.glassfish.grizzly.http.server.AddOn;
+import org.jvnet.hk2.annotations.ContractsProvided;
+import org.jvnet.hk2.annotations.Service;
+
+/**
+ * Comet service.
+ *
+ * @author Alexey Stashok
+ */
+@Service(name="comet")
+@ContractsProvided({CometAddOnProvider.class, AddOn.class})
+public class CometAddOnProvider extends CometAddOn {
+}
diff --git a/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/WebSocketAddOnProvider.java b/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/WebSocketAddOnProvider.java
new file mode 100644
index 0000000..699837c
--- /dev/null
+++ b/appserver/grizzly/glassfish-grizzly-extra-all/src/main/java/org/glassfish/grizzly/extras/addons/WebSocketAddOnProvider.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2009, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.grizzly.extras.addons;
+
+import java.io.IOException;
+import org.glassfish.grizzly.config.ConfigAwareElement;
+import org.glassfish.grizzly.config.dom.Http;
+import org.glassfish.grizzly.config.dom.NetworkListener;
+import org.glassfish.grizzly.filterchain.FilterChainContext;
+import org.glassfish.grizzly.http.HttpContent;
+import org.glassfish.grizzly.http.server.AddOn;
+import org.glassfish.grizzly.http.server.util.Mapper;
+import org.glassfish.grizzly.websockets.WebSocketAddOn;
+import org.glassfish.grizzly.websockets.WebSocketEngine;
+import org.glassfish.grizzly.websockets.WebSocketFilter;
+import org.glassfish.hk2.api.ServiceLocator;
+import org.glassfish.internal.grizzly.ContextMapper;
+import org.jvnet.hk2.annotations.ContractsProvided;
+import org.jvnet.hk2.annotations.Service;
+
+/**
+ * Websocket service.
+ *
+ * @author Alexey Stashok
+ */
+@Service(name="websocket")
+@ContractsProvided({WebSocketAddOnProvider.class, AddOn.class})
+public class WebSocketAddOnProvider extends WebSocketAddOn implements ConfigAwareElement<Http> {
+
+    private Mapper mapper;
+    
+    @Override
+    public void configure(ServiceLocator habitat,
+            NetworkListener networkListener, Http configuration) {
+        mapper = getMapper(habitat, networkListener);
+        
+        setTimeoutInSeconds(Long.parseLong(configuration.getWebsocketsTimeoutSeconds()));
+    }
+
+    @Override
+    protected WebSocketFilter createWebSocketFilter() {
+        return new GlassfishWebSocketFilter(mapper, getTimeoutInSeconds());
+    }
+
+    private static Mapper getMapper(final ServiceLocator habitat,
+            final NetworkListener listener) {
+        
+        final int port;
+        try {
+            port = Integer.parseInt(listener.getPort());
+        } catch (NumberFormatException e) {
+            throw new IllegalStateException("Port number is not integer");
+        }
+        
+        for (Mapper m : habitat.<Mapper>getAllServices(Mapper.class)) {
+            if (m.getPort() == port &&
+                    m instanceof ContextMapper) {
+                ContextMapper cm = (ContextMapper) m;
+                if (listener.getName().equals(cm.getId())) {
+                    return m;
+                }
+            }
+        }
+        
+        return null;
+    }
+    
+    private static class GlassfishWebSocketFilter extends WebSocketFilter {
+        private final Mapper mapper;
+        
+        public GlassfishWebSocketFilter(final Mapper mapper,
+                long wsTimeoutInSeconds) {
+            super(wsTimeoutInSeconds);
+            this.mapper = mapper;
+        }
+
+        @Override
+        protected boolean doServerUpgrade(final FilterChainContext ctx,
+                final HttpContent requestContent) throws IOException {
+            return !WebSocketEngine.getEngine().upgrade(
+                    ctx, requestContent, mapper);
+        }
+    }
+}
diff --git a/appserver/grizzly/grizzly-container/pom.xml b/appserver/grizzly/grizzly-container/pom.xml
new file mode 100755
index 0000000..32f49dd
--- /dev/null
+++ b/appserver/grizzly/grizzly-container/pom.xml
@@ -0,0 +1,65 @@
+<!--
+
+    Copyright (c) 2010, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.main.grizzly</groupId>
+        <artifactId>glassfish-grizzly</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>glassfish-grizzly-container</artifactId>
+    <packaging>glassfish-jar</packaging>
+    
+    <name>GlassFish Grizzly adapter container implementation</name>
+
+    <developers>
+        <developer>
+            <id>dochez</id>
+            <name>Jerome Dochez</name>
+            <url>http://blogs.sun.com/dochez</url>
+            <organization>Oracle, Inc.</organization>
+            <roles>
+                <role>lead</role>
+                <role>developer</role>
+            </roles>
+        </developer>
+    </developers>
+    <dependencies>
+        <dependency>
+            <groupId>org.glassfish.hk2</groupId>
+            <artifactId>hk2-core</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.main.common</groupId>
+            <artifactId>glassfish-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.glassfish.main.common</groupId>
+            <artifactId>internal-api</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.enterprise.deploy</groupId>
+            <artifactId>javax.enterprise.deploy-api</artifactId>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java
new file mode 100644
index 0000000..85803b3
--- /dev/null
+++ b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.extras.grizzly;
+
+import javax.enterprise.deploy.shared.ModuleType;
+import org.glassfish.api.deployment.archive.ArchiveType;
+import org.glassfish.internal.deployment.GenericSniffer;
+import org.jvnet.hk2.annotations.Service;
+
+/**
+ * Sniffs raw grizzly adapters in jar files
+ *
+ * @author Jerome Dochez
+ */
+@Service(name="grizzly")
+public class GrizzlyAdapterSniffer extends GenericSniffer {
+    
+    final static private String[] containerNames = { "grizzly" };
+
+    public GrizzlyAdapterSniffer() {
+        super("grizzly", GrizzlyModuleDescriptor.DescriptorPath ,null);
+    }
+
+    @Override
+    public String[] getContainersNames() {
+        return containerNames;
+    }
+
+    /**
+     *
+     * This API is used to help determine if the sniffer should recognize
+     * the current archive.
+     * If the sniffer does not support the archive type associated with
+     * the current deployment, the sniffer should not recognize the archive.
+     *
+     * @param archiveType the archive type to check
+     * @return whether the sniffer supports the archive type
+     *
+     */
+    @Override
+    public boolean supportsArchiveType(ArchiveType archiveType) {
+        if (archiveType.toString().equals(ModuleType.WAR.toString()) ||
+            archiveType.toString().equals(ModuleType.EJB.toString())) {
+            return true;
+        }
+        return false;
+    }
+}
diff --git a/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java
new file mode 100644
index 0000000..c7c624a
--- /dev/null
+++ b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.extras.grizzly;
+
+import org.glassfish.api.deployment.ApplicationContainer;
+import org.glassfish.api.deployment.ApplicationContext;
+import org.glassfish.api.container.RequestDispatcher;
+import org.glassfish.api.container.EndpointRegistrationException;
+
+import com.sun.logging.LogDomains;
+import org.glassfish.grizzly.http.server.HttpHandler;
+
+import java.util.Collection;
+import java.util.logging.Level;
+
+/**
+ * Deployed grizzly application.
+ *
+ * @author Jerome Dochez
+ */
+public class GrizzlyApp implements ApplicationContainer {
+
+    final ClassLoader cl;
+    final Collection<Adapter> modules;
+    final RequestDispatcher dispatcher;
+
+    public static final class Adapter {
+        final HttpHandler service;
+        final String contextRoot;        
+        public Adapter(String contextRoot, HttpHandler adapter) {
+            this.service = adapter;
+            this.contextRoot = contextRoot;
+        }
+    }
+
+    public GrizzlyApp(Collection<Adapter> adapters, RequestDispatcher dispatcher, ClassLoader cl) {
+        this.modules = adapters;
+        this.dispatcher = dispatcher;
+        this.cl = cl;
+    }
+
+    public Object getDescriptor() {
+        return null;
+    }
+
+    public boolean start(ApplicationContext startupContext) throws Exception {
+        for (Adapter module : modules) {
+            dispatcher.registerEndpoint(module.contextRoot, module.service, this);
+        }
+        return true;
+    }
+
+    public boolean stop(ApplicationContext stopContext) {
+        boolean success = true;
+        for (Adapter module : modules) {
+            try {
+                dispatcher.unregisterEndpoint(module.contextRoot);
+            } catch (EndpointRegistrationException e) {
+                LogDomains.getLogger(getClass(), LogDomains.DPL_LOGGER).log(
+                        Level.SEVERE, "Exception while unregistering adapter at " + module.contextRoot, e);
+                success = false;
+            }
+        }
+        return success;
+    }
+
+    public boolean suspend() {
+        return false;
+    }
+
+    public boolean resume() throws Exception {
+        return false;
+    }
+
+    public ClassLoader getClassLoader() {
+        return cl;
+    }
+}
diff --git a/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java
new file mode 100644
index 0000000..5755de2
--- /dev/null
+++ b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.extras.grizzly;
+
+import org.jvnet.hk2.annotations.Service;
+import org.glassfish.api.container.Container;
+import org.glassfish.api.deployment.Deployer;
+
+
+@Service(name="grizzly")
+public class GrizzlyContainer implements Container {
+
+    public Class<? extends Deployer> getDeployer() {
+        return GrizzlyDeployer.class;
+    }
+
+    public String getName() {
+        return "grizzly";
+    }
+}
diff --git a/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java
new file mode 100644
index 0000000..e520bd1
--- /dev/null
+++ b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.extras.grizzly;
+
+import org.jvnet.hk2.annotations.Service;
+import org.glassfish.api.deployment.Deployer;
+import org.glassfish.api.deployment.MetaData;
+import org.glassfish.api.deployment.DeploymentContext;
+import org.glassfish.api.container.RequestDispatcher;
+import org.glassfish.extras.grizzly.GrizzlyModuleDescriptor.GrizzlyProperty;
+
+import java.util.Map;
+import java.util.LinkedList;
+import java.util.logging.Level;
+
+import javax.inject.Inject;
+
+import com.sun.logging.LogDomains;
+import java.util.ArrayList;
+import org.glassfish.grizzly.http.server.HttpHandler;
+
+/**
+ * @author Jerome Dochez
+ */
+@Service(name="grizzly")
+public class GrizzlyDeployer implements Deployer<GrizzlyContainer, GrizzlyApp> {
+
+    @Inject
+    RequestDispatcher dispatcher;
+    
+    public MetaData getMetaData() {
+        return new MetaData(false, new Class[] { GrizzlyModuleDescriptor.class}, null);
+    }
+
+    public <V> V loadMetaData(Class<V> type, DeploymentContext context) {
+        return type.cast(new GrizzlyModuleDescriptor(context.getSource(), context.getLogger()));
+    }
+
+    public boolean prepare(DeploymentContext context) {
+        return true;
+    }
+
+    /**
+     * Deploy a {@link Adapter} pr {@link GrizzlyAdapter}.
+     * @param container
+     * @param context
+     * @return
+     */
+    public GrizzlyApp load(GrizzlyContainer container, DeploymentContext context) {
+
+        GrizzlyModuleDescriptor configs = context.getModuleMetaData(GrizzlyModuleDescriptor.class);
+
+        LinkedList<GrizzlyApp.Adapter> modules = new LinkedList<GrizzlyApp.Adapter>();
+
+
+        Map<String,ArrayList<GrizzlyProperty>>
+                        properties = configs.getProperties();
+        for (Map.Entry<String, String> config : configs.getAdapters().entrySet()) {
+            HttpHandler httpHandler;
+            try {
+                Class adapterClass = context.getClassLoader().loadClass(config.getValue());
+                httpHandler = HttpHandler.class.cast(adapterClass.newInstance());
+                ArrayList<GrizzlyProperty> list =
+                        properties.get(config.getValue());
+                for (GrizzlyProperty p: list){
+                    IntrospectionUtils.setProperty(httpHandler, p.name, p.value);
+                }
+                httpHandler.start();
+            } catch(Exception e) {
+                context.getLogger().log(Level.SEVERE, e.getMessage(),e);
+                return null;
+            }
+            modules.add(new GrizzlyApp.Adapter(config.getKey(), httpHandler));
+        }
+        return new GrizzlyApp(modules, dispatcher, context.getClassLoader());
+
+    }
+
+    public void unload(GrizzlyApp appContainer, DeploymentContext context) {
+    }
+
+    public void clean(DeploymentContext context) {
+    }
+}
diff --git a/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java
new file mode 100644
index 0000000..845c5f2
--- /dev/null
+++ b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v. 2.0, which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * This Source Code may also be made available under the following Secondary
+ * Licenses when the conditions for such availability set forth in the
+ * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+ * version 2 with the GNU Classpath Exception, which is available at
+ * https://www.gnu.org/software/classpath/license.html.
+ *
+ * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+ */
+
+package org.glassfish.extras.grizzly;
+
+import org.glassfish.api.deployment.archive.ReadableArchive;
+import org.xml.sax.SAXException;
+import org.w3c.dom.*;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.logging.Logger;
+import java.util.logging.Level;
+import java.io.IOException;
+import java.util.ArrayList;
+
+/**
+ * Descriptor for a grizzly application.
+ *
+ * @author Jerome Dochez
+ */
+public class GrizzlyModuleDescriptor {
+
+    private final static String[] HANDLER_ELEMENTS = {"adapter", "http-handler"};
+    final static String DescriptorPath = "META-INF/grizzly-glassfish.xml";
+    final Map<String, String> tuples = new HashMap<String, String>();
+    final Map<String, ArrayList<GrizzlyProperty>> adapterProperties = new HashMap<String,  ArrayList<GrizzlyProperty>>();
+
+    GrizzlyModuleDescriptor(ReadableArchive source, Logger logger) {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        try {
+            parse(factory.newDocumentBuilder().parse(source.getEntry(DescriptorPath)));
+        } catch (SAXException e) {
+            logger.log(Level.SEVERE, e.getMessage(),e);
+            throw new RuntimeException(e);
+        } catch (IOException e) {
+            logger.log(Level.SEVERE, e.getMessage(),e);
+            throw new RuntimeException(e);
+        } catch (ParserConfigurationException e) {
+            logger.log(Level.SEVERE, e.getMessage(),e);
+            throw new RuntimeException(e);
+        }
+    }
+
+    private void parse(Document document) {
+        Element element = document.getDocumentElement();
+        for (String handlerElement : HANDLER_ELEMENTS) {
+            NodeList adapters = element.getElementsByTagName(handlerElement);
+            for (int i=0;i<adapters.getLength();i++) {
+                Node adapter = adapters.item(i);
+                NamedNodeMap attrs = adapter.getAttributes();
+                NodeList properties = adapter.getChildNodes();
+                ArrayList<GrizzlyProperty> list = new ArrayList<GrizzlyProperty>();
+
+                // Read the properties to be set on a GrizzlyAdapter
+                for (int j=0; j < properties.getLength(); j++){
+                    Node property = properties.item(j);
+                    NamedNodeMap values = property.getAttributes();
+                   if (values != null){
+                        list.add(new GrizzlyProperty(values.getNamedItem("name").getNodeValue(),
+                                              values.getNamedItem("value").getNodeValue()));
+                    }
+                }
+
+                adapterProperties.put(attrs.getNamedItem("class-name").getNodeValue(), list);
+                addAdapter(attrs.getNamedItem("context-root").getNodeValue(),
+                        attrs.getNamedItem("class-name").getNodeValue());
+            }
+        }
+    }
+
+    public void addAdapter(String contextRoot, String className) {
+        if (tuples.containsKey(contextRoot)) {
+            throw new RuntimeException("duplicate context root in configuration :" + contextRoot);
+        }
+        tuples.put(contextRoot, className);
+    }
+        
+    public Map<String, String> getAdapters() {
+        return tuples;
+    }
+
+    static class GrizzlyProperty{
+
+        String name ="";
+        String value = "";
+
+        public GrizzlyProperty(String name, String value) {
+            this.name = name;
+            this.value = value;
+        }
+
+    }
+
+    /**
+     * Return the properties to be set on {@link Adapter}
+     */
+    Map<String,ArrayList<GrizzlyProperty>> getProperties(){
+        return adapterProperties;
+    }
+}
diff --git a/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/IntrospectionUtils.java b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/IntrospectionUtils.java
new file mode 100644
index 0000000..401c93d
--- /dev/null
+++ b/appserver/grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/IntrospectionUtils.java
@@ -0,0 +1,227 @@
+/*
+ * Copyright (c) 2012-2018 Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2004 The Apache Software Foundation
+ *
+ * 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.glassfish.extras.grizzly;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.util.HashMap;
+import java.util.Map;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.glassfish.grizzly.Grizzly;
+
+/**
+ * Utils for introspection and reflection
+ */
+public final class IntrospectionUtils {
+
+    private static final Logger LOGGER = Grizzly.logger(IntrospectionUtils.class);
+
+    /**
+     * Find a method with the right name If found, call the method ( if param is
+     * int or boolean we'll convert value to the right type before) - that means
+     * you can have setDebug(1).
+     */
+    public static boolean setProperty(Object o, String name, String value) {
+        if (dbg > 1) {
+            d("setProperty(" + o.getClass() + " " + name + "=" + value + ")");
+        }
+
+        String setter = "set" + capitalize(name);
+
+        try {
+            Method methods[] = findMethods(o.getClass());
+            Method setPropertyMethodVoid = null;
+            Method setPropertyMethodBool = null;
+
+            // First, the ideal case - a setFoo( String ) method
+            for (int i = 0; i < methods.length; i++) {
+                Class<?> paramT[] = methods[i].getParameterTypes();
+                if (setter.equals(methods[i].getName()) && paramT.length == 1
+                        && "java.lang.String".equals(paramT[0].getName())) {
+
+                    methods[i].invoke(o, value);
+                    return true;
+                }
+            }
+
+            // Try a setFoo ( int ) or ( boolean )
+            for (int i = 0; i < methods.length; i++) {
+                boolean ok = true;
+                if (setter.equals(methods[i].getName())
+                        && methods[i].getParameterTypes().length == 1) {
+
+                    // match - find the type and invoke it
+                    Class<?> paramType = methods[i].getParameterTypes()[0];
+                    Object params[] = new Object[1];
+
+                    // Try a setFoo ( int )
+                    if ("java.lang.Integer".equals(paramType.getName())
+                            || "int".equals(paramType.getName())) {
+                        try {
+                            params[0] = Integer.valueOf(value);
+                        } catch (NumberFormatException ex) {
+                            ok = false;
+                        }
+                        // Try a setFoo ( long )
+                    } else if ("java.lang.Long".equals(paramType.getName())
+                            || "long".equals(paramType.getName())) {
+                        try {
+                            params[0] = Long.valueOf(value);
+                        } catch (NumberFormatException ex) {
+                            ok = false;
+                        }
+
+                        // Try a setFoo ( boolean )
+                    } else if ("java.lang.Boolean".equals(paramType.getName())
+                            || "boolean".equals(paramType.getName())) {
+                        params[0] = Boolean.valueOf(value);
+
+                        // Try a setFoo ( InetAddress )
+                    } else if ("java.net.InetAddress".equals(paramType.getName())) {
+                        try {
+                            params[0] = InetAddress.getByName(value);
+                        } catch (UnknownHostException exc) {
+                            d("Unable to resolve host name:" + value);
+                            ok = false;
+                        }
+
+                        // Unknown type
+                    } else {
+                        d("Unknown type " + paramType.getName());
+                    }
+
+                    if (ok) {
+                        methods[i].invoke(o, params);
+                        return true;
+                    }
+                }
+
+                // save "setProperty" for later
+                if ("setProperty".equals(methods[i].getName())) {
+                    if (methods[i].getReturnType() == Boolean.TYPE) {
+                        setPropertyMethodBool = methods[i];
+                    } else {
+                        setPropertyMethodVoid = methods[i];
+                    }
+
+                }
+            }
+
+            // Ok, no setXXX found, try a setProperty("name", "value")
+            if (setPropertyMethodBool != null || setPropertyMethodVoid != null) {
+                Object params[] = new Object[2];
+                params[0] = name;
+                params[1] = value;
+                if (setPropertyMethodBool != null) {
+                    try {
+                        return (Boolean) setPropertyMethodBool.invoke(o, params);
+                    } catch (IllegalArgumentException biae) {
+                        //the boolean method had the wrong
+                        //parameter types. lets try the other
+                        if (setPropertyMethodVoid != null) {
+                            setPropertyMethodVoid.invoke(o, params);
+                            return true;
+                        } else {
+                            throw biae;
+                        }
+                    }
+                } else {
+                    setPropertyMethodVoid.invoke(o, params);
+                    return true;
+                }
+            }
+
+        } catch (IllegalArgumentException ex2) {
+            LOGGER.log(Level.INFO, "IAE " + o + " " + name + " " + value, ex2);
+        } catch (SecurityException ex1) {
+            if (dbg > 0) {
+                d("SecurityException for " + o.getClass() + " " + name + "="
+                        + value + ")");
+            }
+            if (dbg > 1) {
+                LOGGER.log(Level.WARNING, "", ex1);
+            }
+        } catch (IllegalAccessException iae) {
+            if (dbg > 0) {
+                d("IllegalAccessException for " + o.getClass() + " " + name
+                        + "=" + value + ")");
+            }
+            if (dbg > 1) {
+                LOGGER.log(Level.WARNING, "", iae);
+            }
+        } catch (InvocationTargetException ie) {
+            if (dbg > 0) {
+                d("InvocationTargetException for " + o.getClass() + " " + name
+                        + "=" + value + ")");
+            }
+            if (dbg > 1) {
+                LOGGER.log(Level.WARNING, "", ie);
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Reverse of Introspector.decapitalize
+     */
+    public static String capitalize(String name) {
+        if (name == null || name.length() == 0) {
+            return name;
+        }
+        char chars[] = name.toCharArray();
+        chars[0] = Character.toUpperCase(chars[0]);
+        return new String(chars);
+    }
+
+
+
+    // -------------------- other utils --------------------
+
+    @SuppressWarnings("UnusedDeclaration")
+    public static void clear() {
+        objectMethods.clear();
+    }
+
+    static Map<Class<?>, Method[]> objectMethods =
+            new HashMap<Class<?>, Method[]>();
+
+    @SuppressWarnings("unchecked")
+    public static Method[] findMethods(Class<?> c) {
+        Method methods[] = objectMethods.get(c);
+        if (methods != null) {
+            return methods;
+        }
+
+        methods = c.getMethods();
+        objectMethods.put(c, methods);
+        return methods;
+    }
+
+    // debug --------------------
+    static final int dbg = 0;
+
+    static void d(String s) {
+        if (LOGGER.isLoggable(Level.FINE)) {
+            LOGGER.log(Level.FINE, "IntrospectionUtils: {0}", s);
+        }
+    }
+}
diff --git a/appserver/grizzly/pom.xml b/appserver/grizzly/pom.xml
new file mode 100755
index 0000000..edcbe71
--- /dev/null
+++ b/appserver/grizzly/pom.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Copyright (c) 1997, 2018 Oracle and/or its affiliates. All rights reserved.
+
+    This program and the accompanying materials are made available under the
+    terms of the Eclipse Public License v. 2.0, which is available at
+    http://www.eclipse.org/legal/epl-2.0.
+
+    This Source Code may also be made available under the following Secondary
+    Licenses when the conditions for such availability set forth in the
+    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
+    version 2 with the GNU Classpath Exception, which is available at
+    https://www.gnu.org/software/classpath/license.html.
+
+    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
+
+-->
+
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.glassfish.main</groupId>
+        <artifactId>glassfish-parent</artifactId>
+        <version>5.0.1-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+    <groupId>org.glassfish.main.grizzly</groupId>
+    <artifactId>glassfish-grizzly</artifactId>
+    <packaging>pom</packaging>
+    <name>Grizzly Glassfish Extra modules</name>  
+    <modules>
+        <module>grizzly-container</module>
+        <module>glassfish-grizzly-extra-all</module>
+    </modules>
+</project>