/*
 * Copyright 2008-2011 Red Hat, Inc, and individual contributors.
 * 
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */

package org.torquebox.rack.deployers;

import org.jboss.deployers.spi.DeploymentException;
import org.jboss.deployers.spi.deployer.DeploymentStages;
import org.jboss.deployers.spi.deployer.helpers.AbstractDeployer;
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.torquebox.rack.metadata.RackApplicationMetaData;

public class RackApplicationDefaultsDeployer extends AbstractDeployer {

    public static final String DEFAULT_HOST = "localhost";
    public static final String DEFAULT_CONTEXT_PATH = "/";

    public RackApplicationDefaultsDeployer() {
        setStage( DeploymentStages.PRE_REAL );
        setInput( RackApplicationMetaData.class );
        addOutput( RackApplicationMetaData.class );
    }

    public void deploy(DeploymentUnit unit) throws DeploymentException {
        RackApplicationMetaData metadata = unit.getAttachment( RackApplicationMetaData.class );
        if (metadata.getHosts().isEmpty()) {
            metadata.addHost( DEFAULT_HOST );
        }

        if ((metadata.getContextPath() == null) || (metadata.getContextPath().trim().equals( "" ))) {
            metadata.setContextPath( DEFAULT_CONTEXT_PATH );
        }
    }
}

@@ -1369,16 +1369,87 @@
 H = %22/%22;
+%0A    public static final String DEFAULT_STATIC_PATH_PREFIX = %22public/%22;
 %0A%0A    pu
@@ -2090,16 +2090,219 @@
       %7D%0A
+        %0A        if ((metadata.getStaticPathPrefix() == null) %7C%7C (metadata.getStaticPathPrefix().trim().equals( %22%22 ))) %7B%0A            metadata.setStaticPathPrefix( DEFAULT_STATIC_PATH_PREFIX );%0A        %7D%0A
     %7D%0A%7D%0A

Set ye olde static path prefixxe.