Code Search for Developers
 
 
  

WebApplicationHelper.java from SmartFrog at Krugle


Show WebApplicationHelper.java syntax highlighted

/** (C) Copyright 2006 Hewlett-Packard Development Company, LP

 This library 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 library 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 library; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 For more information: www.smartfrog.org

 */
package org.smartfrog.services.www;

import org.smartfrog.sfcore.utils.ComponentHelper;
import org.smartfrog.sfcore.prim.Prim;

import java.rmi.RemoteException;
import java.net.InetAddress;

/**
 * Things to help web applications.
 * Factored out of JettyHelper.
 * created 05-Apr-2006 15:13:52
 */

public class WebApplicationHelper extends ComponentHelper {

    public WebApplicationHelper(Prim owner) {
        super(owner);
    }

    /**
     * Concatenate two paths together, inserting a '/' if needed, and ensuring
     * that there is no '//' at the join.
     *
     * @param path1
     * @param path2
     * @return concatenated paths
     */
    public static String concatPaths(String path1, String path2) {
        StringBuffer buffer = new StringBuffer(path1.length() +
                path2.length() +
                1);
        boolean endsWithSlash = path1.endsWith("/");
        boolean beginsWithSlash = path2.startsWith("/");
        buffer.append(path1);
        if (!endsWithSlash) {
            buffer.append('/');
        }
        if (beginsWithSlash) {
            buffer.append(path2.substring(1));
        } else {
            buffer.append(path2);
        }
        return buffer.toString();
    }

    /**
     * Get the ipaddrs of the local machine
     *
     * @return the IP address that we are deployed on
     */
    public String getIpAddress() throws RemoteException {
        InetAddress deployedHost = getOwner().sfDeployedHost();
        String hostAddress = deployedHost.getHostAddress();
        return hostAddress;
    }

    /**
     * strip any trailing * from a path and give the base bit up to where that
     * began.
     *
     * @param path
     * @return the stripped path
     */
    public static String deregexpPath(String path) {
        String result;
        int star = path.indexOf('*');
        if (star < 0) {
            return path;
        }
        if (star == 0) {
            return "/";
        }
        result = path.substring(0, star - 1);
        return result;
    }
}




See more files for this project here

SmartFrog

SmartFrog (Smart Framework for Object Groups) is a framework for configuring and automatically activating distributed applications. \r\nThe SmartFrog framework is released under LGPL license.\r\nMore info at: www.smartfrog.org

Project homepage: http://sourceforge.net/projects/smartfrog
Programming language(s): Java,XML
License: other

  context/
    ApplicationServerContextImpl.java
    EarApplicationImpl.java
    MimeTypeImpl.java
    ServletComponentImpl.java
    ServletContextComponentImpl.java
    ServletContextImpl.java
    WebApplicationImpl.java
  dbc/
    AbstractDbcDelegate.java
    DbcEarDelegate.java
    DbcWarDelegate.java
    DeployByCopyServer.java
    DeployByCopyServerImpl.java
    EndOfQueue.java
    QueuedFile.java
    components.sf
  diagnostics/
    HostExists.java
    HostExistsFunction.java
    HostExistsImpl.java
    components.sf
  servers/
    jboss4.sf
    serverbase.sf
    testwar.sf
    tomcat5.sf
  ApplicationServerContext.java
  JavaEnterpriseApplication.java
  JavaWebApplication.java
  JavaWebApplicationServer.java
  LivenessPage.java
  LivenessPageChecker.java
  LivenessPageComponent.java
  LivenessPageValidator.java
  MimeType.java
  ServletComponent.java
  ServletContextComponent.java
  ServletContextComponentDelegate.java
  ServletContextIntf.java
  WaitForPage.java
  WaitForPageImpl.java
  WebApplicationHelper.java
  components.sf
  jasper.sf
  livenessPage.sf
  package.html
  testwar-m2.sf
  webapplication.sf
  webserver.sf