Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 2008-2012 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 com.sun.enterprise.web.reconfig;
 
 
 import java.util.List;
Web container dynamic configuration handler

Author(s):
amyroh
 
 public class WebConfigListener implements ConfigListenerMapperUpdateListener {
 
     @LogMessageInfo(
             message = "Web container config changed {0} {1} {2}",
             level = "FINE")
     public static final String CHANGE_INVOKED = "AS-WEB-00299";
 
     @LogMessageInfo(
             message = "Exception processing HttpService configuration change",
             level = "SEVERE",
             cause = "An exception occurred during configuration change ",
             action = "Check the exception for error")
     public static final String EXCEPTION_WEB_CONFIG = "AS-WEB-00300";
 
     public HttpService httpService;
     
     @Inject @Optional
 
     @Inject @Optional
     public List<Propertyproperty;
    
    private WebContainer container;
    private Logger logger;
    private NetworkConfig networkConfig;
    
    
Set the Web Container for this ConfigListener. Must be set in order to perform dynamic configuration

Parameters:
container the container to be set
    public void setContainer(WebContainer container) {
        this. = container;
    }
    public void setLogger(Logger logger) {
        synchronized (this) {
            this. = logger;
        }
    }
    public void setNetworkConfig(NetworkConfig config) {
        this. = config;
    }

    
Handles HttpService change events

Parameters:
events the PropertyChangeEvent
    @Override
    public synchronized UnprocessedChangeEvents changed(PropertyChangeEvent[] events) {
        return ConfigSupport.sortAndDispatch(eventsnew Changed() {         
            @Override
            public <T extends ConfigBeanProxyNotProcessed changed(TYPE typeClass<T> tClass, T t) {
                if (.isLoggable(.)) {
                    .log(.new Object[] {typetClasst});
                }
                try {
                    if (tClass == HttpService.class) {
                        .updateHttpService((HttpServicet);
                    } else if (tClass == NetworkListener.class) {
                        if (type==.) {
                            .addConnector((NetworkListenerttrue);
                        } else if (type==.) {
                            .deleteConnector((NetworkListenert);
                        } else if (type==.) {
                            .updateConnector((NetworkListenert);
                        }
                    } else if (tClass == VirtualServer.class) {
                        if (type==.) {
                            .createHost((VirtualServertnull);
                            .loadDefaultWebModule((VirtualServert);
                        } else if (type==.) {
                            .deleteHost();
                        } else if (type==.) {
                            .updateHost((VirtualServer)t);
                        }
                    } else if (tClass == AccessLog.class) {
                        .updateAccessLog();
                    } else if (tClass == ManagerProperties.class) {
                        return new NotProcessed("ManagerProperties requires restart");
                    } else if (tClass == WebContainerAvailability.class ||
                            tClass == AvailabilityService.class) {
                        // container.updateHttpService handles SingleSignOn valve configuration
                        .updateHttpService();
                    } else if (tClass == NetworkListeners.class) {
                        // skip updates
                    } else if (tClass == Property.class) {
                        ConfigBeanProxy config = ((Property)t).getParent();
                        if (config instanceof HttpService) {
                            .updateHttpService((HttpService)config);
                        } else if (config instanceof VirtualServer) {
                            .updateHost((VirtualServer)config);
                        } else if (config instanceof NetworkListener) {
                            .updateConnector((NetworkListener)config);
                        } else {
                            .updateHttpService();
                        }
                    } else if (tClass == SystemProperty.class) {
                        if (((SystemProperty)t).getName().endsWith("LISTENER_PORT")) {
                            for (NetworkListener listener : .getNetworkListeners().getNetworkListener()) {
                                if (listener.getPort().equals(((SystemProperty)t).getValue())) {
                                    .updateConnector(listener);
                                }
                            }
                        }
                    } else if (tClass == JavaConfig.class) {
                        JavaConfig jc = (JavaConfigt;
                        final List<StringjvmOptions = new ArrayList<String>(jc.getJvmOptions());
                        for (String jvmOption : jvmOptions) {
                            if (jvmOption.startsWith("-DjvmRoute=")) {
                                .updateJvmRoute(jvmOption);
                            }
                        }
                    } else {
                        // Ignore other unrelated events
                    }
                } catch (LifecycleException le) {
                    .log(.le);
                }
                return null;
            }
        }
        , );
    }
    @Override
    public void update(HttpService httpServiceNetworkListener httpListener,
            Mapper mapper) {
        .updateMapper(httpServicehttpListenermapper);
    }
New to GrepCode? Check out our FAQ X