103928aee4356845252ac6b662d5c72c29903813eJake Slack//
203928aee4356845252ac6b662d5c72c29903813eJake Slack//  ========================================================================
303928aee4356845252ac6b662d5c72c29903813eJake Slack//  Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd.
403928aee4356845252ac6b662d5c72c29903813eJake Slack//  ------------------------------------------------------------------------
503928aee4356845252ac6b662d5c72c29903813eJake Slack//  All rights reserved. This program and the accompanying materials
603928aee4356845252ac6b662d5c72c29903813eJake Slack//  are made available under the terms of the Eclipse Public License v1.0
703928aee4356845252ac6b662d5c72c29903813eJake Slack//  and Apache License v2.0 which accompanies this distribution.
803928aee4356845252ac6b662d5c72c29903813eJake Slack//
903928aee4356845252ac6b662d5c72c29903813eJake Slack//      The Eclipse Public License is available at
1003928aee4356845252ac6b662d5c72c29903813eJake Slack//      http://www.eclipse.org/legal/epl-v10.html
1103928aee4356845252ac6b662d5c72c29903813eJake Slack//
1203928aee4356845252ac6b662d5c72c29903813eJake Slack//      The Apache License v2.0 is available at
1303928aee4356845252ac6b662d5c72c29903813eJake Slack//      http://www.opensource.org/licenses/apache2.0.php
1403928aee4356845252ac6b662d5c72c29903813eJake Slack//
1503928aee4356845252ac6b662d5c72c29903813eJake Slack//  You may elect to redistribute this code under either of these licenses.
1603928aee4356845252ac6b662d5c72c29903813eJake Slack//  ========================================================================
1703928aee4356845252ac6b662d5c72c29903813eJake Slack//
1803928aee4356845252ac6b662d5c72c29903813eJake Slack
1903928aee4356845252ac6b662d5c72c29903813eJake Slackpackage org.eclipse.jetty.webapp;
2003928aee4356845252ac6b662d5c72c29903813eJake Slack
2103928aee4356845252ac6b662d5c72c29903813eJake Slackpublic class CloneConfiguration extends AbstractConfiguration
2203928aee4356845252ac6b662d5c72c29903813eJake Slack{
2303928aee4356845252ac6b662d5c72c29903813eJake Slack    final WebAppContext _template;
2403928aee4356845252ac6b662d5c72c29903813eJake Slack
2503928aee4356845252ac6b662d5c72c29903813eJake Slack    CloneConfiguration(WebAppContext template)
2603928aee4356845252ac6b662d5c72c29903813eJake Slack    {
2703928aee4356845252ac6b662d5c72c29903813eJake Slack        _template=template;
2803928aee4356845252ac6b662d5c72c29903813eJake Slack    }
2903928aee4356845252ac6b662d5c72c29903813eJake Slack
3003928aee4356845252ac6b662d5c72c29903813eJake Slack    @Override
3103928aee4356845252ac6b662d5c72c29903813eJake Slack    public void configure(WebAppContext context) throws Exception
3203928aee4356845252ac6b662d5c72c29903813eJake Slack    {
3303928aee4356845252ac6b662d5c72c29903813eJake Slack        for (Configuration configuration : _template.getConfigurations())
3403928aee4356845252ac6b662d5c72c29903813eJake Slack            configuration.cloneConfigure(_template,context);
3503928aee4356845252ac6b662d5c72c29903813eJake Slack    }
3603928aee4356845252ac6b662d5c72c29903813eJake Slack
3703928aee4356845252ac6b662d5c72c29903813eJake Slack
3803928aee4356845252ac6b662d5c72c29903813eJake Slack    @Override
3903928aee4356845252ac6b662d5c72c29903813eJake Slack    public void deconfigure(WebAppContext context) throws Exception
4003928aee4356845252ac6b662d5c72c29903813eJake Slack    {
4103928aee4356845252ac6b662d5c72c29903813eJake Slack        for (Configuration configuration : _template.getConfigurations())
4203928aee4356845252ac6b662d5c72c29903813eJake Slack            configuration.deconfigure(context);
4303928aee4356845252ac6b662d5c72c29903813eJake Slack    }
4403928aee4356845252ac6b662d5c72c29903813eJake Slack}
45