Package org.apache.axis2.util
Class Utils
- java.lang.Object
-
- org.apache.axis2.util.Utils
-
public class Utils extends Object
-
-
Constructor Summary
Constructors Constructor Description Utils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
addHandler(Flow flow, Handler handler, String phaseName)
static void
calculateDefaultModuleVersion(HashMap modules, AxisConfiguration axisConfig)
static boolean
checkVersion(Version module1version, Version module2version)
- if he trying to engage the same module then method will returen false - else it will return truestatic Object
createServiceObject(AxisService service)
Create a service object for a given service.static AxisService
createSimpleInOnlyService(QName serviceName, MessageReceiver messageReceiver, QName opName)
static AxisService
createSimpleService(QName serviceName, String className, QName opName)
static AxisService
createSimpleService(QName serviceName, MessageReceiver messageReceiver, String className, QName opName)
static AxisService
createSimpleServiceforClient(QName serviceName, String className, QName opName)
static AxisService
createSimpleServiceforClient(QName serviceName, MessageReceiver messageReceiver, String className, QName opName)
static ServiceContext
fillContextInformation(AxisService axisService, ConfigurationContext configurationContext)
static int
getAxisSpecifMEPConstant(String messageExchangePattern)
Maps the String URI of the Message exchange pattern to a integer.static String
getHostname(AxisConfiguration axisConfiguration)
First check whether the hostname parameter is there in AxisConfiguration (axis2.xml) , if it is there then this will return that as the host name , o.w will return the IP address.static AxisFault
getInboundFaultFromMessageContext(MessageContext messageContext)
Get an AxisFault object to represent the SOAPFault in the SOAPEnvelope attached to the provided MessageContext.static String
getIpAddress()
Returns the ip address to be used for the replyto epr CAUTION: This will go through all the available network interfaces and will try to return an ip address.static String
getIpAddress(AxisConfiguration axisConfiguration)
First check whether the hostname parameter is there in AxisConfiguration (axis2.xml) , if it is there then this will retun that as the host name , o.w will return the IP address.static String
getModuleName(String moduleName, String moduleVersion)
static int
getMtomThreshold(MessageContext msgCtxt)
static ConfigurationContext
getNewConfigurationContext(String repositry)
static ClassLoader
getObjectClassLoader(Object object)
This method will provide the logic needed to retrieve an Object's classloader in a Java 2 Security compliant manner.static String
getOperationName(String path, String serviceName)
Compute the operation path from request URI using the servince name.static String
getParameterValue(Parameter param)
static String
getServiceAndOperationPart(String path, String servicePath)
Gives the service/operation part from the incoming EPR Ex: ..services/foo/bar/Version/getVersion -> foo/bar/Version/getVersionstatic Class<?>
getServiceClass(AxisService service)
Get the service class for a given service.static String
getURIScheme(String uri)
Get the scheme part from a URI (or URL).static boolean
isClientThreadNonBlockingPropertySet(MessageContext messageContext)
this is to make is backward compatible.static boolean
isHiddenService(AxisService axisService)
This method is used to find whether an axis2service is declared as hidden using the "hiddenService" paramstatic boolean
isValidModuleName(String moduleName)
static String[]
parseRequestURLForServiceAndOperation(String path, String servicePath)
Break a full path into piecesstatic String
sanitizeWebOutput(String text)
-
-
-
Method Detail
-
createSimpleService
public static AxisService createSimpleService(QName serviceName, String className, QName opName) throws AxisFault
- Throws:
AxisFault
-
createSimpleServiceforClient
public static AxisService createSimpleServiceforClient(QName serviceName, String className, QName opName) throws AxisFault
- Throws:
AxisFault
-
createSimpleInOnlyService
public static AxisService createSimpleInOnlyService(QName serviceName, MessageReceiver messageReceiver, QName opName) throws AxisFault
- Throws:
AxisFault
-
createSimpleService
public static AxisService createSimpleService(QName serviceName, MessageReceiver messageReceiver, String className, QName opName) throws AxisFault
- Throws:
AxisFault
-
createSimpleServiceforClient
public static AxisService createSimpleServiceforClient(QName serviceName, MessageReceiver messageReceiver, String className, QName opName) throws AxisFault
- Throws:
AxisFault
-
fillContextInformation
public static ServiceContext fillContextInformation(AxisService axisService, ConfigurationContext configurationContext) throws AxisFault
- Throws:
AxisFault
-
parseRequestURLForServiceAndOperation
public static String[] parseRequestURLForServiceAndOperation(String path, String servicePath)
Break a full path into pieces- Returns:
- an array where element [0] always contains the service, and element 1, if not null, contains the path after the first element. all ? parameters are discarded.
-
getServiceAndOperationPart
public static String getServiceAndOperationPart(String path, String servicePath)
Gives the service/operation part from the incoming EPR Ex: ..services/foo/bar/Version/getVersion -> foo/bar/Version/getVersion- Parameters:
path
- - incoming EPRservicePath
- - Ex: 'services'- Returns:
- - service/operation part
-
getOperationName
public static String getOperationName(String path, String serviceName)
Compute the operation path from request URI using the servince name. Service name can be a normal one or a hierarchical one. Ex: ../services/Echo/echoString -> echoString ../services/foo/1.0.0/Echo/echoString -> echoString ../services/Echo/ -> null- Parameters:
path
- - request URIserviceName
- - service name- Returns:
- - operation name if any, else null
-
getNewConfigurationContext
public static ConfigurationContext getNewConfigurationContext(String repositry) throws Exception
- Throws:
Exception
-
isValidModuleName
public static boolean isValidModuleName(String moduleName)
-
checkVersion
public static boolean checkVersion(Version module1version, Version module2version) throws AxisFault
- if he trying to engage the same module then method will returen false - else it will return true- Throws:
AxisFault
-
calculateDefaultModuleVersion
public static void calculateDefaultModuleVersion(HashMap modules, AxisConfiguration axisConfig)
-
getAxisSpecifMEPConstant
public static int getAxisSpecifMEPConstant(String messageExchangePattern)
Maps the String URI of the Message exchange pattern to a integer. Further, in the first lookup, it will cache the looked up value so that the subsequent method calls are extremely efficient.
-
getInboundFaultFromMessageContext
public static AxisFault getInboundFaultFromMessageContext(MessageContext messageContext)
Get an AxisFault object to represent the SOAPFault in the SOAPEnvelope attached to the provided MessageContext. This first check for an already extracted AxisFault and otherwise does a simple extract. MUST NOT be passed a MessageContext which does not contain a SOAPFault- Parameters:
messageContext
-- Returns:
-
getObjectClassLoader
public static ClassLoader getObjectClassLoader(Object object)
This method will provide the logic needed to retrieve an Object's classloader in a Java 2 Security compliant manner.
-
getMtomThreshold
public static int getMtomThreshold(MessageContext msgCtxt)
-
getIpAddress
public static String getIpAddress() throws SocketException
Returns the ip address to be used for the replyto epr CAUTION: This will go through all the available network interfaces and will try to return an ip address. First this will try to get the first IP which is not loopback address (127.0.0.1). If none is found then this will return this will return 127.0.0.1. This will not consider IPv6 addresses. TODO: - Improve this logic to genaralize it a bit more - Obtain the ip to be used here from the Call API- Returns:
- Returns String.
- Throws:
SocketException
-
getIpAddress
public static String getIpAddress(AxisConfiguration axisConfiguration) throws SocketException
First check whether the hostname parameter is there in AxisConfiguration (axis2.xml) , if it is there then this will retun that as the host name , o.w will return the IP address.- Throws:
SocketException
-
getHostname
public static String getHostname(AxisConfiguration axisConfiguration)
First check whether the hostname parameter is there in AxisConfiguration (axis2.xml) , if it is there then this will return that as the host name , o.w will return the IP address.- Parameters:
axisConfiguration
-- Returns:
- hostname
-
getURIScheme
public static String getURIScheme(String uri)
Get the scheme part from a URI (or URL).- Parameters:
uri
- the URI- Returns:
- the scheme of the URI
-
createServiceObject
public static Object createServiceObject(AxisService service) throws AxisFault
Create a service object for a given service. The method first looks for theConstants.SERVICE_OBJECT_SUPPLIER
service parameter and if this parameter is present, it will use the specified class to create the service object. If the parameter is not present, it will create an instance of the class specified by theConstants.SERVICE_CLASS
parameter.- Parameters:
service
- the service- Returns:
- The service object or
null
if neither theConstants.SERVICE_OBJECT_SUPPLIER
nor theConstants.SERVICE_CLASS
parameter was found on the service, i.e. if the service doesn't specify how to create a service object. If the return value is non null, it will always be a newly created instance. - Throws:
AxisFault
- if an error occurred while attempting to instantiate the service object
-
getServiceClass
public static Class<?> getServiceClass(AxisService service) throws AxisFault
Get the service class for a given service. This method will first check theConstants.SERVICE_CLASS
service parameter and if that parameter is not present, inspect the instance returned by the service object supplier specified byConstants.SERVICE_OBJECT_SUPPLIER
.- Parameters:
service
- the service- Returns:
- The service class or
null
if neither theConstants.SERVICE_CLASS
nor theConstants.SERVICE_OBJECT_SUPPLIER
parameter was found on the service, i.e. if the service doesn't specify a service class. - Throws:
AxisFault
- if an error occurred while attempting to load the service class or to instantiate the service object
-
isClientThreadNonBlockingPropertySet
public static boolean isClientThreadNonBlockingPropertySet(MessageContext messageContext)
this is to make is backward compatible. Get rid of this at the next major release.- Parameters:
messageContext
-- Returns:
-
isHiddenService
public static boolean isHiddenService(AxisService axisService)
This method is used to find whether an axis2service is declared as hidden using the "hiddenService" param- Parameters:
axisService
- - the service of interest- Returns:
- true if is declared as hidden, false if not
-
-