Index: src/main/java/org/glassfish/kernel/embedded/PortImpl.java =================================================================== --- src/main/java/org/glassfish/kernel/embedded/PortImpl.java (revision 31262) +++ src/main/java/org/glassfish/kernel/embedded/PortImpl.java (working copy) @@ -1,28 +1,30 @@ package org.glassfish.kernel.embedded; -import org.jvnet.hk2.annotations.Service; +import com.sun.enterprise.config.serverbeans.HttpService; +import com.sun.enterprise.config.serverbeans.VirtualServer; +import com.sun.grizzly.config.dom.Http; +import com.sun.grizzly.config.dom.NetworkConfig; +import com.sun.grizzly.config.dom.NetworkListener; +import com.sun.grizzly.config.dom.NetworkListeners; +import com.sun.grizzly.config.dom.Protocol; +import com.sun.grizzly.config.dom.Protocols; +import com.sun.grizzly.config.dom.ThreadPool; +import com.sun.grizzly.config.dom.Transport; +import org.glassfish.api.ActionReport; +import org.glassfish.api.admin.CommandRunner; +import org.glassfish.api.embedded.Port; import org.jvnet.hk2.annotations.Inject; import org.jvnet.hk2.annotations.Scoped; +import org.jvnet.hk2.annotations.Service; import org.jvnet.hk2.component.PerLookup; -import org.jvnet.hk2.config.TransactionFailure; import org.jvnet.hk2.config.ConfigSupport; import org.jvnet.hk2.config.SingleConfigCode; -import org.glassfish.api.embedded.Port; -import org.glassfish.api.admin.CommandRunner; -import org.glassfish.api.ActionReport; +import org.jvnet.hk2.config.TransactionFailure; -import java.util.Properties; +import java.io.IOException; import java.util.List; +import java.beans.PropertyVetoException; -import com.sun.grizzly.config.dom.NetworkConfig; -import com.sun.grizzly.config.dom.NetworkListener; -import com.sun.grizzly.config.dom.Protocol; -import com.sun.grizzly.config.dom.Http; -import com.sun.grizzly.config.dom.ThreadPool; -import com.sun.grizzly.config.dom.Transport; -import com.sun.grizzly.config.dom.Protocols; -import com.sun.grizzly.config.dom.NetworkListeners; - /** * Abstract to port creation and destruction */ @@ -37,6 +39,9 @@ PortsImpl ports; @Inject NetworkConfig config; + @Inject + HttpService httpService; + String listenerName; int number; @@ -44,6 +49,26 @@ number = portNumber; listenerName = getListenerName(); try { + + //Add the listner to virtual server + VirtualServer vs = httpService.getVirtualServerByName("server"); + if(vs == null){ + throw new IOException("Invalid configuration! There must be virtual server named 'server'"); + } + + ConfigSupport.apply(new SingleConfigCode() { + public Object run(VirtualServer param) throws TransactionFailure, PropertyVetoException { + String nls = param.getNetworkListeners(); + if(nls==null){ + nls = listenerName; + }else if(nls.length() > 0){ + nls += ","+listenerName; + } + param.setNetworkListeners(nls); + return param; + } + }, httpService.getVirtualServerByName("server")); + ConfigSupport.apply(new SingleConfigCode() { public Object run(Protocols param) throws TransactionFailure { final Protocol protocol = param.createChild(Protocol.class);