# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/oleksiys/Projects/glassfish/v3.trunk.bak/appserver # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: extras/grizzly-container/pom.xml --- extras/grizzly-container/pom.xml Base (BASE) +++ extras/grizzly-container/pom.xml Locally Deleted @@ -1,85 +0,0 @@ - - - - 4.0.0 - - org.glassfish.extras - extras - 3.2-SNAPSHOT - ../pom.xml - - - grizzly-container - hk2-jar - GlassFish Grizzly adapter container implementation - - - - dochez - Jerome Dochez - http://blogs.sun.com/dochez - Oracle, Inc. - - lead - developer - - - - - - org.glassfish.hk2 - hk2 - - - org.glassfish.common - glassfish-api - ${project.version} - - - org.glassfish.common - internal-api - ${project.version} - - - Index: extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java --- extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java Base (BASE) +++ extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java Locally Deleted @@ -1,64 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ - -package org.glassfish.extras.grizzly; - -import org.jvnet.hk2.annotations.Service; -import org.glassfish.api.container.Sniffer; -import org.glassfish.internal.deployment.GenericSniffer; - -/** - * Sniffs raw grizzly adapters in jar files - * - * @author Jerome Dochez - */ -@Service(name="grizzly") -public class GrizzlyAdapterSniffer extends GenericSniffer { - - final static private String[] containerNames = { "org.glassfish.extras.grizzly.GrizzlyContainer" }; - - public GrizzlyAdapterSniffer() { - super("grizzly", GrizzlyModuleDescriptor.DescriptorPath ,null); - } - - public String[] getContainersNames() { - return containerNames; - } -} Index: extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java --- extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java Base (BASE) +++ extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java Locally Deleted @@ -1,116 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ - -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 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 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; - } -} Index: extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java --- extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java Base (BASE) +++ extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java Locally Deleted @@ -1,58 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2010 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ - -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 getDeployer() { - return GrizzlyDeployer.class; - } - - public String getName() { - return "grizzly"; - } -} Index: extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java --- extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java Base (BASE) +++ extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java Locally Deleted @@ -1,122 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ - -package org.glassfish.extras.grizzly; - -import org.glassfish.grizzly.http.server.util.IntrospectionUtils; -import org.jvnet.hk2.annotations.Service; -import org.jvnet.hk2.annotations.Inject; -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 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 { - - @Inject - RequestDispatcher dispatcher; - - public MetaData getMetaData() { - return new MetaData(false, new Class[] { GrizzlyModuleDescriptor.class}, null); - } - - public V loadMetaData(Class 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 modules = new LinkedList(); - - - Map> - properties = configs.getProperties(); - for (Map.Entry config : configs.getAdapters().entrySet()) { - HttpHandler httpHandler; - try { - Class adapterClass = context.getClassLoader().loadClass(config.getValue()); - httpHandler = HttpHandler.class.cast(adapterClass.newInstance()); - ArrayList 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) { - } -} Index: extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java --- extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java Base (BASE) +++ extras/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java Locally Deleted @@ -1,139 +0,0 @@ -/* - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - * - * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. - * - * The contents of this file are subject to the terms of either the GNU - * General Public License Version 2 only ("GPL") or the Common Development - * and Distribution License("CDDL") (collectively, the "License"). You - * may not use this file except in compliance with the License. You can - * obtain a copy of the License at - * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html - * or packager/legal/LICENSE.txt. See the License for the specific - * language governing permissions and limitations under the License. - * - * When distributing the software, include this License Header Notice in each - * file and include the License file at packager/legal/LICENSE.txt. - * - * GPL Classpath Exception: - * Oracle designates this particular file as subject to the "Classpath" - * exception as provided by Oracle in the GPL Version 2 section of the License - * file that accompanied this code. - * - * Modifications: - * If applicable, add the following below the License Header, with the fields - * enclosed by brackets [] replaced by your own identifying information: - * "Portions Copyright [year] [name of copyright owner]" - * - * Contributor(s): - * If you wish your version of this file to be governed by only the CDDL or - * only the GPL Version 2, indicate your decision by adding "[Contributor] - * elects to include this software in this distribution under the [CDDL or GPL - * Version 2] license." If you don't indicate a single choice of license, a - * recipient has the option to distribute your version of this file under - * either the CDDL, the GPL Version 2 or to extend the choice of license to - * its licensees as provided above. However, if you add GPL Version 2 code - * and therefore, elected the GPL Version 2 license, then the option applies - * only if the new code is made subject to such option by the copyright - * holder. - */ - -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 { - - final static String DescriptorPath = "META-INF/grizzly-glassfish.xml"; - final Map tuples = new HashMap(); - final Map> adapterProperties = new HashMap>(); - - 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(); - NodeList adapters = element.getElementsByTagName("service"); - for (int i=0;i list = new ArrayList(); - - // 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); - if (attrs != null){ - 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 getAdapters() { - return tuples; - } - - 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> getProperties(){ - return adapterProperties; - } -} Index: extras/pom.xml --- extras/pom.xml Base (BASE) +++ extras/pom.xml Locally Modified (Based On LOCAL) @@ -55,7 +55,7 @@ pom GlassFish Extras modules - grizzly-container + osgi-container javaee Index: grizzly/glassfish-grizzly-extra-all/pom.xml --- grizzly/glassfish-grizzly-extra-all/pom.xml Locally New +++ grizzly/glassfish-grizzly-extra-all/pom.xml Locally New @@ -0,0 +1,146 @@ + + + + + + org.glassfish.grizzly + glassfish-grizzly + 3.2-SNAPSHOT + ../pom.xml + + 4.0.0 + glassfish-grizzly-extra-all + jar + Glassfish Grizzly extra jars Combining + combining of all glassfish grizzly extra jars + + + + oleksiys + Oleksiy Stashok + http://blogs.oracle.com/oleksiys + Oracle, Inc. + + developer + + + + + + + + com.sun.enterprise + consolidatedbundle-maven-plugin + + + processhk2headers + process-classes + + hk2-generate + + + + + + + + org.apache.felix + maven-bundle-plugin + + + + + 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.extras.grizzly.*;version=${project.version} + + * + META-INF/inhabitants/=target/classes/META-INF/inhabitants/ + * + + + + jar + + + true + + + + bundle + + bundle + + + + + + + + + + org.glassfish.grizzly + grizzly-comet + + + org.glassfish.grizzly + grizzly-websockets + + + org.glassfish.grizzly + grizzly-http-servlet + + + org.glassfish.grizzly + grizzly-http-ajp + + + org.glassfish.grizzly + glassfish-grizzly-container + ${project.version} + + + Index: grizzly/grizzly-container/pom.xml --- grizzly/grizzly-container/pom.xml Locally New +++ grizzly/grizzly-container/pom.xml Locally New @@ -0,0 +1,85 @@ + + + + 4.0.0 + + org.glassfish.grizzly + glassfish-grizzly + 3.2-SNAPSHOT + ../pom.xml + + + glassfish-grizzly-container + hk2-jar + GlassFish Grizzly adapter container implementation + + + + dochez + Jerome Dochez + http://blogs.sun.com/dochez + Oracle, Inc. + + lead + developer + + + + + + org.glassfish.hk2 + hk2 + + + org.glassfish.common + glassfish-api + ${project.version} + + + org.glassfish.common + internal-api + ${project.version} + + + Index: grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java --- grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java Locally New +++ grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyAdapterSniffer.java Locally New @@ -0,0 +1,64 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +package org.glassfish.extras.grizzly; + +import org.jvnet.hk2.annotations.Service; +import org.glassfish.api.container.Sniffer; +import org.glassfish.internal.deployment.GenericSniffer; + +/** + * Sniffs raw grizzly adapters in jar files + * + * @author Jerome Dochez + */ +@Service(name="grizzly") +public class GrizzlyAdapterSniffer extends GenericSniffer { + + final static private String[] containerNames = { "org.glassfish.extras.grizzly.GrizzlyContainer" }; + + public GrizzlyAdapterSniffer() { + super("grizzly", GrizzlyModuleDescriptor.DescriptorPath ,null); + } + + public String[] getContainersNames() { + return containerNames; + } +} Index: grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java --- grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java Locally New +++ grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyApp.java Locally New @@ -0,0 +1,116 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +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 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 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; + } +} Index: grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java --- grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java Locally New +++ grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyContainer.java Locally New @@ -0,0 +1,58 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2007-2010 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +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 getDeployer() { + return GrizzlyDeployer.class; + } + + public String getName() { + return "grizzly"; + } +} Index: grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java --- grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java Locally New +++ grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyDeployer.java Locally New @@ -0,0 +1,122 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +package org.glassfish.extras.grizzly; + +import org.glassfish.grizzly.http.server.util.IntrospectionUtils; +import org.jvnet.hk2.annotations.Service; +import org.jvnet.hk2.annotations.Inject; +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 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 { + + @Inject + RequestDispatcher dispatcher; + + public MetaData getMetaData() { + return new MetaData(false, new Class[] { GrizzlyModuleDescriptor.class}, null); + } + + public V loadMetaData(Class 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 modules = new LinkedList(); + + + Map> + properties = configs.getProperties(); + for (Map.Entry config : configs.getAdapters().entrySet()) { + HttpHandler httpHandler; + try { + Class adapterClass = context.getClassLoader().loadClass(config.getValue()); + httpHandler = HttpHandler.class.cast(adapterClass.newInstance()); + ArrayList 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) { + } +} Index: grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java --- grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java Locally New +++ grizzly/grizzly-container/src/main/java/org/glassfish/extras/grizzly/GrizzlyModuleDescriptor.java Locally New @@ -0,0 +1,139 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright (c) 2007-2011 Oracle and/or its affiliates. All rights reserved. + * + * The contents of this file are subject to the terms of either the GNU + * General Public License Version 2 only ("GPL") or the Common Development + * and Distribution License("CDDL") (collectively, the "License"). You + * may not use this file except in compliance with the License. You can + * obtain a copy of the License at + * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html + * or packager/legal/LICENSE.txt. See the License for the specific + * language governing permissions and limitations under the License. + * + * When distributing the software, include this License Header Notice in each + * file and include the License file at packager/legal/LICENSE.txt. + * + * GPL Classpath Exception: + * Oracle designates this particular file as subject to the "Classpath" + * exception as provided by Oracle in the GPL Version 2 section of the License + * file that accompanied this code. + * + * Modifications: + * If applicable, add the following below the License Header, with the fields + * enclosed by brackets [] replaced by your own identifying information: + * "Portions Copyright [year] [name of copyright owner]" + * + * Contributor(s): + * If you wish your version of this file to be governed by only the CDDL or + * only the GPL Version 2, indicate your decision by adding "[Contributor] + * elects to include this software in this distribution under the [CDDL or GPL + * Version 2] license." If you don't indicate a single choice of license, a + * recipient has the option to distribute your version of this file under + * either the CDDL, the GPL Version 2 or to extend the choice of license to + * its licensees as provided above. However, if you add GPL Version 2 code + * and therefore, elected the GPL Version 2 license, then the option applies + * only if the new code is made subject to such option by the copyright + * holder. + */ + +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 { + + final static String DescriptorPath = "META-INF/grizzly-glassfish.xml"; + final Map tuples = new HashMap(); + final Map> adapterProperties = new HashMap>(); + + 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(); + NodeList adapters = element.getElementsByTagName("service"); + for (int i=0;i list = new ArrayList(); + + // 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); + if (attrs != null){ + 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 getAdapters() { + return tuples; + } + + 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> getProperties(){ + return adapterProperties; + } +} Index: grizzly/pom.xml --- grizzly/pom.xml Locally New +++ grizzly/pom.xml Locally New @@ -0,0 +1,61 @@ + + + + + 4.0.0 + + org.glassfish + glassfish-parent + 3.2-SNAPSHOT + ../pom.xml + + org.glassfish.grizzly + glassfish-grizzly + pom + Grizzly Glassfish Extra modules + + grizzly-container + glassfish-grizzly-extra-all + + Index: packager/glassfish-common-tmp/pom.xml --- packager/glassfish-common-tmp/pom.xml Base (BASE) +++ packager/glassfish-common-tmp/pom.xml Locally Modified (Based On LOCAL) @@ -131,8 +131,8 @@ ${project.version} - org.glassfish.extras - grizzly-container + org.glassfish.grizzly + glassfish-grizzly-container ${project.version} Index: pom.xml --- pom.xml Base (BASE) +++ pom.xml Locally Modified (Based On LOCAL) @@ -141,6 +141,7 @@ tests osgi-platforms flashlight + grizzly webservices orb appclient @@ -203,6 +204,7 @@ tests osgi-platforms flashlight + grizzly webservices @@ -259,6 +261,7 @@ tests osgi-platforms flashlight + grizzly webservices virtualization paas @@ -314,6 +317,7 @@ tests osgi-platforms flashlight + grizzly webservices orb installer