Package com.sun.enterprise.config.serverbeans

Examples of com.sun.enterprise.config.serverbeans.HttpListener


            HttpService service = ServerBeansFactory.getHttpServiceBean(context);
            if(service !=null){
                HttpListener[] hlArray = service.getHttpListener();
                //check not needed since there should always be atleast 1 httplistener
                //if you don't find one, use first one.
                HttpListener ls = null;
                if(hlArray != null && hlArray.length > 0){
                    ls=hlArray[0];
                    //default is the first one that is enabled.
                    for(int i = 0;i<hlArray.length;i++) {
                        if(hlArray[i].isEnabled()) {
                            ls = hlArray[i];
                            break;
                        }
                    }
                }
                if(ls!=null)
                    virtualServer = ls.getDefaultVirtualServer();
            }
        } catch(ConfigException e){
            String msg = localStrings.getString("enterprise.deployment.autodeploy.unable_to_get_virtualserver");
            sLogger.log(Level.WARNING, msg+e.getMessage());
        } catch(Exception e){String msg = localStrings.getString("enterprise.deployment.autodeploy.unable_to_get_virtualserver");
View Full Code Here


            }
        }
   
        WebServerInfo wsi = new WebServerInfo();
        for (int i=0;i<httpListeners.size();i++) {
            HttpListener hl = (HttpListener) httpListeners.get(i);
            if (!hl.isEnabled())
                continue;
           
            if(targetHostName == null) {
                targetHostName = hl.getServerName();
                if (targetHostName==null || targetHostName.length()==0) {
                    targetHostName = getDefaultHostName();
                }
            }
            try {
                targetHostName = InetAddress.getByName(targetHostName).getCanonicalHostName();
            } catch (java.net.UnknownHostException unex) {
                throw new ConfigException(unex.getMessage(), unex);
            }
            String redirectPortNb = hl.getRedirectPort();
            String portNb;
            if (redirectPortNb!=null) {
                portNb = redirectPortNb;
            } else {
                portNb = hl.getPort();
            }
            if(targetName == null) {
                targetName = ApplicationServer.getServerContext().getInstanceName();
            }
            PropertyResolver pr = new PropertyResolver(cc, targetName);
            String resolvedPort = pr.resolve(portNb);
           
            int port = Integer.parseInt(resolvedPort);
            if (hl.isSecurityEnabled()) {
                wsi.setHttpsVS(new VirtualServerInfo("https", targetHostName, port));               
            } else {
                wsi.setHttpVS(new VirtualServerInfo("http", targetHostName, port));
            }
View Full Code Here

    public static String getSynchronizationURL(ConfigContext ctx,
            DASPropertyReader dpr) throws ConfigException, IOException {

        String url = null;

        HttpListener listener = ServerHelper.getHttpListener(ctx,
                SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME,
                ServerHelper.ADMIN_HTTP_LISTNER_ID);

        String host = dpr.getHost();
        String port = listener.getPort();

        if ((host == null) || (port == null)) {
            String msg =
                _localStrMgr.getString("synchronizationUrlError", host, port);
            throw new IllegalArgumentException(msg);
        }
           
        if (listener.isSecurityEnabled()) {
            url = "https://"+host+":"+port+SYNCHRONIZATION_URI;
        } else {
            url = "http://"+host+":"+port+SYNCHRONIZATION_URI;
        }
View Full Code Here

            msg = lsm.getString("start.debug.msg", dopt);
        }
        return ( msg );
    }
    private String getAdminConsoleMessage() throws ConfigException {
        final HttpListener admin = ServerHelper.getHttpListener(cc, sn, ServerHelper.ADMIN_HTTP_LISTNER_ID);
        String url = "", port = null;
        if (admin != null) {
            url = ServerHelper.getUrlString(admin);
            port = admin.getPort();
        }
        return ( lsm.getString("admin.console.msg", url, port) );
    }
View Full Code Here

    public Result validate(ConfigContextEvent cce) {
        Result result = super.validate(cce); // Before doing custom validation do basic validation
        String choice = cce.getChoice();
       
        if(choice.equals(StaticTest.ADD) || choice.equals(StaticTest.VALIDATE)) {
            final HttpListener h = (HttpListener)cce.getObject();
            String vsId = h.getDefaultVirtualServer();
            try {
                Config config = (Config) ((HttpService) cce.getClassObject()).parent();
                if( config!=null ) {
                    boolean exists = checkVSExists(vsId, config);
                    if(!exists) {
                        result.failed(smh.getLocalString(getClass().getName() + ".virtualserverNotFound",
                                                         "Attribute(default-virtual-server={0}) : Virtual Server not found", new Object[]{vsId}));
                    } else if (h.isEnabled()){
                            // When the listener is enabled then the virtual
                            // server must be on.
                        if (! isVirtualServerOn(h, config, result)){
                            result.failed(smh.getLocalString(getClass().getName() + ".cannotAddVsNotOn",
                                                             "Cannot add this HttpListener \"{0}\" because it is enabled but its virtual server \"{1}\" has a state other than \"on\" ({2})",
                                                             new Object[]{h.getId(), vsId, getDefaultVirtualServer(vsId, config).getState()}));
                        }
                    }
                }
               
            }
            catch(Exception e){
                _logger.log(Level.FINE, "domainxmlverifier.error", e);
               
            }
        } else if (choice.equals(StaticTest.UPDATE)) {
            if (cce.getName().equals("enabled") && ConfigBean.toBoolean((String) cce.getObject())){
                final HttpListener h = (HttpListener) cce.getClassObject();
                final Config c = (Config) ((HttpService) h.parent()).parent();
                final VirtualServer vs = getDefaultVirtualServer(h.getDefaultVirtualServer(), c);
                if (null != vs && !vs.getState().equals("on")){
                    result.failed(smh.getLocalString(getClass().getName() + ".cannotUpdateVSNotOn",
                                                     "Cannot enable this HttpListener \"{0}\" because its virtual server \"{1}\" has a state other than \"on\" ({2})",
                                                     new Object[]{h.getId(), vs.getId(), vs.getState()}));
                                                    
                }
            } else if (ServerTags.ENABLED.equals(cce.getName()) && ! ConfigBean.toBoolean((String) cce.getObject())) {
                final HttpListener h = (HttpListener) cce.getClassObject();
                if (com.sun.enterprise.config.serverbeans.ServerHelper.ADMIN_HTTP_LISTNER_ID.equals(h.getId())) {
                    //this is rather stupid
                    final String locmsg = this.getClass().getName() + ".cantDisableAdminVS";
                    final String enmsg = "ADMVAL1076: The http-listener reserved for administrative purposes can not be disabled.";
                    final String msg = smh.getLocalString(locmsg, enmsg);
                    result.failed(msg);                   
                }
            }
        } else if (StaticTest.DELETE.equals(choice)) {
            //the admin-listener cannot be deleted
            if (cce.getObject() instanceof HttpListener) {
                final HttpListener h = (HttpListener) cce.getObject();
                // this assumes that "admin-listener" is reserved in any config, although it makes sense only for DAS
                // so, I am not making any checks if this is DAS's config
                if (com.sun.enterprise.config.serverbeans.ServerHelper.ADMIN_HTTP_LISTNER_ID.equals(h.getId())) {
                    //this is rather stupid
                    final String locmsg = this.getClass().getName() + ".cantDeleteAdminListener";
                    final String enmsg = "ADMVAL1075: The http-listener reserved for administrative purposes can not be deleted.";
                    final String msg = smh.getLocalString(locmsg, enmsg);
                    result.failed(msg);
View Full Code Here

        final Set listeners = getPeerListeners(vs);
        if (listeners.isEmpty()) { return Collections.EMPTY_SET; }

        final Set result = new HashSet();
        for (final Iterator it = listeners.iterator(); it.hasNext(); ){
            final HttpListener l = (HttpListener) it.next();
            if (l.getDefaultVirtualServer().equals(vs.getId())){
                result.add(l);
            }
        }
        return result;
    }
View Full Code Here

        return test;
    }

    private final void checkAllRelatedHttpListenersAreDisabled(final VirtualServer vs, final Result result) throws ConfigException {
        for (final Iterator it = getReferers(vs).iterator(); it.hasNext(); ){
            final HttpListener l = (HttpListener) it.next();
            if (l.isEnabled()){
                result.failed(smh.getLocalString(getClass().getName()+".listenerEnabled",
                                                "Cannot disable the virtual server \"{0}\" because this is the default virtual server for the http listener \"{1}\".",
                                                new Object[]{vs.getId(), l.getId()}));
            }
        }
    }
View Full Code Here

        this.cc = ConfigFactory.
            createConfigContext(xmlPath);

       
            //get port from ConfigFactory
        final HttpListener admin = ServerHelper.getHttpListener(cc,
                                   SystemPropertyConstants.DEFAULT_SERVER_INSTANCE_NAME,
                                   ServerHelper.ADMIN_HTTP_LISTNER_ID);
        if (admin != null) {
            final String port = admin.getPort();
                //set port and host options so that password can be retrieved from .asadminpass
            setOption("port", port);
            setOption("host", "localhost");           
        }
    }
View Full Code Here

        getVirtualServer(vsID).setHttpListeners(setToStr(httpListeners));
    }

    protected HttpListener getHttpListener(String id) throws ConfigException
    {
        HttpListener listener = config.getHttpService().getHttpListenerById(id);
        checkArg(listener, strMgr.getString("http_listener_vs_assoc_mgr.no_such_element", id));
        return listener;
    }
View Full Code Here

    public static String getAdminPort() {
        String sn = ApplicationServer.getServerContext().getInstanceName();
        ConfigContext cc = ApplicationServer.getServerContext()
        .getConfigContext();
        HttpListener admin = null;

        try {
            admin = ServerHelper.getHttpListener(cc, sn,
                    ServerHelper.ADMIN_HTTP_LISTNER_ID);
        } catch (ConfigException ex) {
            ex.printStackTrace();
        }

        String port = null;

        if (admin != null) {
            port = admin.getPort();
        }

        return port;
    }
View Full Code Here

TOP

Related Classes of com.sun.enterprise.config.serverbeans.HttpListener

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.