Package com.sun.grizzly.config.dom

Examples of com.sun.grizzly.config.dom.Protocol


        Config newConfig = targetUtil.getConfig(target);
        if (newConfig!=null) {
            config = newConfig;
        }
        final ActionReport report = context.getActionReport();
        Protocol protocol = config.getNetworkConfig().getProtocols().findProtocol(protocolName);
        if (protocol!=null) {
            final PortUnification pu = protocol.getPortUnification();
            if (pu!=null) {
                for (ProtocolFinder finder : pu.getProtocolFinder()) {
                    report.getTopMessagePart().addChild().setMessage(finder.getName());
                }
            }
View Full Code Here


            config = newConfig;
        }
        final ActionReport report = context.getActionReport();
        // check for duplicates
        Protocols protocols = config.getNetworkConfig().getProtocols();
        Protocol protocol = null;
        for (Protocol p : protocols.getProtocol()) {
            if(protocolName.equals(p.getName())) {
                protocol = p;
            }
        }
        if (protocol == null) {
            report.setMessage(localStrings.getLocalString("create.http.redirect.fail.protocolnotfound",
                "The specified protocol {0} is not yet configured. Please create one", protocolName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
        if (protocol.getHttpRedirect() != null) {
            report.setMessage(localStrings.getLocalString("create.http.redirect.fail.duplicate",
                "An http-redirect element for {0} already exists. Cannot add duplicate http-redirect", protocolName));
            report.setActionExitCode(ActionReport.ExitCode.FAILURE);
            return;
        }
View Full Code Here

            config = newConfig;
        }
        report = context.getActionReport();
        try {
            final Protocols protocols = config.getNetworkConfig().getProtocols();
            final Protocol protocol = protocols.findProtocol(protocolName);
            validate(protocol, "create.http.fail.protocolnotfound",
                "The specified protocol {0} is not yet configured", protocolName);
            PortUnification pu = getPortUnification(protocol);
            ConfigSupport.apply(new ConfigCode() {
                @Override
                public Object run(ConfigBeanProxy... params) {
                    final Protocol prot = (Protocol) params[0];
                    final PortUnification portUnification = (PortUnification) params[1];

                    final List<ProtocolFinder> oldList = portUnification.getProtocolFinder();
                    List<ProtocolFinder> newList = new ArrayList<ProtocolFinder>();
                    for (final ProtocolFinder finder : oldList) {
                        if (!name.equals(finder.getName())) {
                            newList.add(finder);
                        }
                    }
                    if (oldList.size() == newList.size()) {
                        throw new RuntimeException(
                            String.format("No finder named %s found for protocol %s", name, protocolName));
                    }
                    if(newList.isEmpty()) {
                        prot.setPortUnification(null);
                    } else {
                        portUnification.setProtocolFinder(newList);
                    }
                    return null;
                }
View Full Code Here

    @Produces({"text/html;qs=2",MediaType.APPLICATION_JSON,MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED})
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.APPLICATION_FORM_URLENCODED})
    public ActionReportResult get() {
        Dom dom = getEntity();
        NetworkListener nl = dom.createProxy(NetworkListener.class);
        Protocol p = nl.findHttpProtocol();
        RestActionReporter ar = new RestActionReporter();
        ar.setActionExitCode(ActionReport.ExitCode.SUCCESS);
        ar.getTopMessagePart().getProps().put("protocol", p.getName());

        ActionReportResult result = new ActionReportResult("find-http-protocol", ar, new OptionsResult());

        return result;
    }
View Full Code Here

        }

        grizzlyListener = new GrizzlyListener(grizzlyService.getMonitoring(), new Controller(){
            public void logVersion(){}  
        }, networkListener.getName());
        final Protocol httpProtocol = networkListener.findHttpProtocol();
        V3Mapper mapper = null;
        // mapper initialization now happens *before* the GrizzlyListener
        // is configured.  This is necessary for WebSocket support (if enabled).
        if (httpProtocol != null) {
            mapper = new V3Mapper(logger);
            mapper.setPort(portNumber);
            mapper.setId(networkListener.getName());
            Inhabitant<Mapper> onePortMapper = new ExistingSingletonInhabitant<Mapper>(mapper);
            grizzlyService.getHabitat().addIndex(onePortMapper,
                                                 Mapper.class.getName(),
                                                 (networkListener.getAddress() + networkListener.getPort()));
        }

        grizzlyListener.configure(networkListener, grizzlyService.habitat);

        if(!grizzlyListener.isGenericListener()) {
            final GrizzlyEmbeddedHttp embeddedHttp = grizzlyListener.getEmbeddedHttp();

            if (httpProtocol != null) {
                final ContainerMapper adapter = new ContainerMapper(grizzlyService, embeddedHttp);
                adapter.setMapper(mapper);
                adapter.setDefaultHost(grizzlyListener.getDefaultVirtualServer());
                adapter.configureMapper();
                embeddedHttp.setAdapter(adapter);

                String ct = httpProtocol.getHttp().getDefaultResponseType();
                adapter.setDefaultContentType(ct);
                final Collection<VirtualServer> list = grizzlyService.getHabitat().getAllByContract(VirtualServer.class);
                final String vsName = httpProtocol.getHttp().getDefaultVirtualServer();
                for (VirtualServer virtualServer : list) {
                    if (virtualServer.getId().equals(vsName)) {
                        vs = virtualServer;
                        embeddedHttp.setWebAppRootPath(vs.getDocroot());

View Full Code Here

            }
            addChangeListener(listener);
            addChangeListener(listener.findThreadPool());
            addChangeListener(listener.findTransport());

            final Protocol protocol = listener.findHttpProtocol();
            if (protocol != null) {
                addChangeListener(protocol);
                addChangeListener(protocol.getHttp());
                addChangeListener(protocol.getHttp().getFileCache());
                addChangeListener(protocol.getSsl());
            }
        }

        final Future<Result<Thread>> future =  proxy.start();
View Full Code Here

                        "HTTP Listener named {0} not found", listenerId));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
                }

                Protocol protocol = networkListener.findHttpProtocol();
                if (protocol.getSsl() == null) {
                    report.setMessage(localStrings.getLocalString(
                        "delete.ssl.element.doesnotexist", "Ssl element does " +
                        "not exist for Listener named {0}", listenerId));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
                    return;
View Full Code Here

    private void addSslToNetworkListener(Config config, ActionReport report) {
        NetworkConfig netConfig = config.getNetworkConfig();
        // ensure we have the specified listener
        NetworkListener listener = netConfig.getNetworkListener(listenerId);
        Protocol httpProtocol;
        try {
            if (listener == null) {
                report.setMessage(
                    localStrings.getLocalString("create.ssl.http.notfound",
                        "Network Listener named {0} does not exist.  Creating or using the named protocol element instead.",
                        listenerId));
                httpProtocol = findOrCreateProtocol(listenerId);
            } else {
                httpProtocol = listener.findHttpProtocol();
                Ssl ssl = httpProtocol.getSsl();
                if (ssl != null) {
                    report.setMessage(localStrings.getLocalString("create.ssl.http.alreadyExists",
                        "Network Listener named {0} to which this ssl element is being added already has an ssl element.",
                        listenerId));
                    report.setActionExitCode(ActionReport.ExitCode.FAILURE);
View Full Code Here

        newSsl.setTlsRollbackEnabled(tlsrollbackenabled.toString());
    }

    private Protocol findOrCreateProtocol(final String name) throws TransactionFailure {
        NetworkConfig networkConfig = config.getNetworkConfig();
        Protocol protocol = networkConfig.findProtocol(name);
        if (protocol == null) {
            protocol = (Protocol) ConfigSupport.apply(new SingleConfigCode<Protocols>() {
                public Object run(Protocols param) throws TransactionFailure {
                    Protocol newProtocol = param.createChild(Protocol.class);
                    newProtocol.setName(name);
                    newProtocol.setSecurityEnabled("true");
                    param.getProtocol().add(newProtocol);
                    return newProtocol;
                }
            }, habitat.getComponent(Protocols.class));
        }
View Full Code Here

    }

    private void addAsadminProtocol(NetworkConfig config) throws TransactionFailure {
        ensureAdminThreadPool();
        final Protocols protocols = getProtocols(config);
        Protocol adminProtocol = protocols.findProtocol(ASADMIN_LISTENER);
        if (adminProtocol == null) {
            adminProtocol = (Protocol) ConfigSupport.apply(new SingleConfigCode<Protocols>() {
                public Object run(Protocols param) throws TransactionFailure {
                    final Protocol protocol = param.createChild(Protocol.class);
                    param.getProtocol().add(protocol);
                    protocol.setName(ASADMIN_LISTENER);
                    Http http = protocol.createChild(Http.class);
                    http.setFileCache(http.createChild(FileCache.class));
                    protocol.setHttp(http);
                    http.setDefaultVirtualServer(ASADMIN_VIRTUAL_SERVER);
                    http.setMaxConnections("250");
                    return protocol;
                }
            }, protocols);
View Full Code Here

TOP

Related Classes of com.sun.grizzly.config.dom.Protocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.