blob: 881575d8b2c7eb4b572b3d2152561417df658af9 [file] [log] [blame]
/*******************************************************************************
* Copyright © 2013 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*
*******************************************************************************/
package server;
import common.ServiceInfoRecord;
import common.ServiceLocation;
import common.constants;
// service
service ServerInfo
function getServerAddress()returns(ServiceInfoRecord)
info ServiceInfoRecord;
request javax.servlet.http.HttpServletRequest? = eglx.http.ServletContext.getHttpServletRequest();
if(request != null)
Syslib.writestdout("request.getRequestURL():" + request.getRequestURL().toString());
Syslib.writestdout("request.getServletPath():" + request.getServletPath());
Syslib.writestdout("request.getRequestURI():" + request.getRequestURI());
host string = request.getRequestURL().toString();
host = host.replaceStr(request.getServletPath(), "");
//if you just want the request up to the context remove the Request URI from the Request URL
// host = host.replaceStr(request.getRequestURI(), "");
Syslib.writestdout("host:" + host);
info.serverAddress = host;
end
value string? = SysLib.getProperty(Constants.ServiceTypePropertyKey);
Syslib.writestdout(Constants.ServiceTypePropertyKey + ":" + value);
case(value.toLowerCase())
when(Constants.ServiceTypeRESTValue.toLowerCase())
info.serviceType = ServiceLocation.rest;
when(Constants.ServiceTypeJettyRESTValue.toLowerCase())
info.serviceType = ServiceLocation.jetty;
otherwise
info.serviceType = ServiceLocation.dedicated;
end
return(info);
end
end