Class Utils
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddEndpointsToService(AxisService axisService) static voidaddEndpointsToService(AxisService axisService, AxisConfiguration axisConfiguration) static voidaddExcludeMethods(ArrayList<String> excludeList) Add the Axis2 lifecycle / session methods to a pre-existing list of names that will be excluded when generating schemas.static voidaddFlowHandlers(Flow flow, ClassLoader clsLoader) static voidaddHttpEndpoint(AxisService axisService, String url) static voidaddHttpEndpoint(AxisService axisService, String protocol, String endpointName) static voidaddSoap11Endpoint(AxisService axisService, String url) static voidaddSoap11Endpoint(AxisService axisService, String protocol, String endpointName) static voidaddSoap12Endpoint(AxisService axisService, String url) static voidaddSoap12Endpoint(AxisService axisService, String protocol, String endpointName) static DeploymentClassLoadercreateClassLoader(File serviceFile, boolean isChildFirstClassLoading) static ClassLoadercreateClassLoader(URL[] urls, ClassLoader serviceClassLoader, boolean extractJars, File tmpDir, boolean isChildFirstClassLoading) static ClassLoadercreateClassLoader(ArrayList urls, ClassLoader serviceClassLoader, boolean extractJars, File tmpDir, boolean isChildFirstClassLoading) static FilecreateTempFile(String suffix, InputStream in, File tmpDir) static voiddeployModuleServices(AxisModule module, ConfigurationContext configCtx) Modules can contain services in some cases.static voidfillAxisService(AxisService axisService, AxisConfiguration axisConfig, ArrayList<String> excludeOperations, ArrayList<String> nonRpcMethods) This guy will create a AxisService using java reflectionstatic ListfindLibJars(URL url) Get names of all *.jar files inside the lib/ directory of a given jar URLstatic StringformatPath(String path) Format the string paths to match any platform..static StringgetAnnotatedServiceName(Class serviceClass, WebServiceAnnotation serviceAnnotation) The util method to prepare the JSR 181 annotated service name from given annotation or for defaults JSR 181 specifies that the in javax.jws.WebService the parameter serviceName contains the wsdl:service name to mapp.static AxisOperationgetAxisOperationForJmethod(Method method) static AxisOperationgetAxisOperationForJmethod(Method method, boolean isHttpSCOKforVoidMethod) This method returns Axis operation with IN and OUT message exchange pattern for a service method which has void as the return type.static AxisBindingMessagegetBindingMessage(AxisBindingOperation bindingOperation, AxisMessage message) static AxisBindingOperationgetBindingOperation(AxisBinding binding, AxisOperation operation) static ClassLoadergetClassLoader(ClassLoader parent, File file, boolean isChildFirstClassLoading) Get a ClassLoader which contains a classpath of a) the passed directory and b) any jar files inside the "lib/" or "Lib/" subdirectory of the passed directory.static ClassLoadergetClassLoader(ClassLoader parent, String path, boolean isChildFirstClassLoading) static StringgetClassNameFromResourceName(String resourceName) Get the class name from a resource name referring to a class file.static AxisBindinggetHttpBinding(AxisService service) static Stringget http input mime type from the services xmlstatic StringgetHTTPLoacationFromServicesXML(AxisOperation operation) extract the http location from services xml related to given operationstatic StringgetHTTPMethodFromServicesXML(AxisOperation operation) extract the http method from services xml related to given operationstatic Stringget http output mime type from the services xmlgetListOfClasses(DeploymentFileData deploymentFileData) Scan a JAR file and return the list of classes contained in the JAR.static org.apache.axiom.om.OMElementgetParameter(String name, String value, boolean locked) static Stringstatic StringgetServiceHierarchy(String filePath, String serviceDir) Computes the hierarchical part of the service name if this is such a service path.static StringgetShortFileName(String filename) static AxisBindinggetSoap11Binding(AxisService service) static AxisBindinggetSoap12Binding(AxisService service) static URL[]getURLsForAllJars(URL url, File tmpDir) static booleanThis method checks whether a given CApp file is a fat CApp or not by reading the descriptor.static booleanisHttpBinding(AxisBinding binding) static booleanisSoap11Binding(AxisBinding binding) static booleanisSoap12Binding(AxisBinding binding) static booleanloadHandler(ClassLoader loader1, HandlerDescription desc) static voidlogFaultyServiceInfo(AxisConfiguration axisConfig) Log faulty services info due to unavailability of modules and transportsstatic StringNormalize a uri containing ../ and ./ paths.static voidprocessBeanPropertyExclude(AxisService service) This method is to process bean exclude parameter and the XML format of that would be+ static voidprocessPolicyAttachments(Iterator attachmentElements, AxisService service) static StringreplaceSystemProperty(String text) Replace the ${ref}, $sys{ref} and $env{ref} pattern OMText node values with env or system property values.static voidresolveOMElementChildValues(org.apache.axiom.om.OMElement element) Resolves env or system property values in OMElement nodes.static voidsetEndpointsToAllUsedBindings(AxisService axisService) static File
-
Field Details
-
defaultEncoding
-
-
Constructor Details
-
Utils
public Utils()
-
-
Method Details
-
addFlowHandlers
- Throws:
AxisFault
-
loadHandler
public static boolean loadHandler(ClassLoader loader1, HandlerDescription desc) throws DeploymentException - Throws:
DeploymentException
-
getURLsForAllJars
-
createTempFile
- Throws:
IOException
-
getClassLoader
public static ClassLoader getClassLoader(ClassLoader parent, String path, boolean isChildFirstClassLoading) throws DeploymentException - Throws:
DeploymentException
-
getClassLoader
public static ClassLoader getClassLoader(ClassLoader parent, File file, boolean isChildFirstClassLoading) throws DeploymentException Get a ClassLoader which contains a classpath of a) the passed directory and b) any jar files inside the "lib/" or "Lib/" subdirectory of the passed directory.- Parameters:
parent- parent ClassLoader which will be the parent of the result of this methodfile- a File which must be a directory for this to be useful- Returns:
- a new ClassLoader pointing to both the passed dir and jar files under lib/
- Throws:
DeploymentException- if problems occur
-
fillAxisService
public static void fillAxisService(AxisService axisService, AxisConfiguration axisConfig, ArrayList<String> excludeOperations, ArrayList<String> nonRpcMethods) throws Exception This guy will create a AxisService using java reflection- Parameters:
axisService- the target AxisServiceaxisConfig- the in-scope AxisConfigurationexcludeOperations- a List of Strings (or null), each containing a method to excludenonRpcMethods- a List of Strings (or null), each containing a non-rpc method name- Throws:
Exception- if a problem occurs
-
getAxisOperationForJmethod
- Throws:
AxisFault
-
getAxisOperationForJmethod
public static AxisOperation getAxisOperationForJmethod(Method method, boolean isHttpSCOKforVoidMethod) throws AxisFault This method returns Axis operation with IN and OUT message exchange pattern for a service method which has void as the return type.Axis services can contain methods throws an exception and void as the return type, Normally in such case the returned Axis operation has IN only message exchange pattern. So that the http status code for the response is 202. This overloaded method added to fix that issue. This will return Axis operation with IN and OUT message exchange pattern for a service method which has void as the return type and the method must throw an checked exception. Then the response http status code will be 200 OK. To get 200 http status code you must set the mepinandout parameter to true in the axis2.xml
- Parameters:
method- method object which represents the service methodisHttpSCOKforVoidMethod- is httpSCOKforVoidServiceMethod parameter true or false in the axis2.xml- Throws:
AxisFault
-
getParameter
-
deployModuleServices
public static void deployModuleServices(AxisModule module, ConfigurationContext configCtx) throws AxisFault Modules can contain services in some cases. This method will deploy all the services for a given AxisModule into the current AxisConfiguration.The code looks for an "aars/" directory inside the module (either .mar or exploded), and an "aars.list" file inside that to figure out which services to deploy. Note that all services deployed this way will have access to the Module's classes.
- Parameters:
module- the AxisModule to search for servicesconfigCtx- ConfigurationContext in which to deploy- Throws:
AxisFault
-
normalize
Normalize a uri containing ../ and ./ paths.- Parameters:
uri- The uri path to normalize- Returns:
- The normalized uri
-
getPath
-
findLibJars
Get names of all *.jar files inside the lib/ directory of a given jar URL- Parameters:
url- base URL of a JAR to search- Returns:
- a List containing file names (Strings) of all files matching "[lL]ib/*.jar"
-
addExcludeMethods
Add the Axis2 lifecycle / session methods to a pre-existing list of names that will be excluded when generating schemas.- Parameters:
excludeList- an ArrayList containing method names - we'll add ours to this.
-
createClassLoader
public static DeploymentClassLoader createClassLoader(File serviceFile, boolean isChildFirstClassLoading) throws MalformedURLException - Throws:
MalformedURLException
-
createClassLoader
public static ClassLoader createClassLoader(ArrayList urls, ClassLoader serviceClassLoader, boolean extractJars, File tmpDir, boolean isChildFirstClassLoading) -
toFile
- Throws:
UnsupportedEncodingException
-
createClassLoader
public static ClassLoader createClassLoader(URL[] urls, ClassLoader serviceClassLoader, boolean extractJars, File tmpDir, boolean isChildFirstClassLoading) -
processBeanPropertyExclude
This method is to process bean exclude parameter and the XML format of that would be+ - Parameters:
service- , AxisService object
-
getShortFileName
-
getAnnotatedServiceName
public static String getAnnotatedServiceName(Class serviceClass, WebServiceAnnotation serviceAnnotation) The util method to prepare the JSR 181 annotated service name from given annotation or for defaults JSR 181 specifies that the in javax.jws.WebService the parameter serviceName contains the wsdl:service name to mapp. If its not available then the default will be Simple name of the class + "Service"- Parameters:
serviceClass- the service ClassserviceAnnotation- a WebService annotation, or null- Returns:
- String version of the ServiceName according to the JSR 181 spec
-
addEndpointsToService
- Throws:
AxisFault
-
setEndpointsToAllUsedBindings
-
addEndpointsToService
public static void addEndpointsToService(AxisService axisService, AxisConfiguration axisConfiguration) throws AxisFault - Throws:
AxisFault
-
addSoap11Endpoint
- Throws:
Exception
-
addSoap11Endpoint
public static void addSoap11Endpoint(AxisService axisService, String protocol, String endpointName) throws Exception - Throws:
Exception
-
addSoap12Endpoint
- Throws:
Exception
-
addSoap12Endpoint
public static void addSoap12Endpoint(AxisService axisService, String protocol, String endpointName) throws Exception - Throws:
Exception
-
addHttpEndpoint
-
addHttpEndpoint
-
processPolicyAttachments
public static void processPolicyAttachments(Iterator attachmentElements, AxisService service) throws XMLStreamException, FactoryConfigurationError -
isSoap11Binding
-
isSoap12Binding
-
isHttpBinding
-
getSoap11Binding
-
getSoap12Binding
-
getHttpBinding
-
getBindingOperation
public static AxisBindingOperation getBindingOperation(AxisBinding binding, AxisOperation operation) -
getBindingMessage
public static AxisBindingMessage getBindingMessage(AxisBindingOperation bindingOperation, AxisMessage message) -
getHTTPLoacationFromServicesXML
extract the http location from services xml related to given operation- Parameters:
operation-- Returns:
-
getHTTPMethodFromServicesXML
extract the http method from services xml related to given operation- Parameters:
operation-- Returns:
-
getHTTPInputSerializationFromServicesXML
get http input mime type from the services xml- Parameters:
operation-- Returns:
-
getHTTPOutputSerializationFromservicesXML
get http output mime type from the services xml- Parameters:
operation-- Returns:
-
logFaultyServiceInfo
Log faulty services info due to unavailability of modules and transports- Parameters:
axisConfig-
-
getServiceHierarchy
Computes the hierarchical part of the service name if this is such a service path. Ex: filePath = .../repository/services/foo/1.0.0/version.aar -> "foo/1.0.0/" filePath = .../repository/services/version.aar -> ""- Parameters:
filePath- - input file path of the deploying fileserviceDir- - 'services', 'pojo', 'servicejars' etc..- Returns:
- hierarchical path. either "" or a '/' separated string (Ex: foo/1.0.0/)
-
formatPath
Format the string paths to match any platform.. windows, linux etc..- Parameters:
path- - input file path- Returns:
- formatted file path
-
getClassNameFromResourceName
Get the class name from a resource name referring to a class file.- Parameters:
resourceName- the resource name- Returns:
- the class name
-
getListOfClasses
public static List<String> getListOfClasses(DeploymentFileData deploymentFileData) throws DeploymentException Scan a JAR file and return the list of classes contained in the JAR.- Parameters:
deploymentFileData- the JAR to scan- Returns:
- a list of Java class names
- Throws:
DeploymentException- if an error occurs while scanning the file
-
resolveOMElementChildValues
public static void resolveOMElementChildValues(org.apache.axiom.om.OMElement element) Resolves env or system property values in OMElement nodes.- Parameters:
element- OMElement which need to resolve
-
replaceSystemProperty
Replace the ${ref}, $sys{ref} and $env{ref} pattern OMText node values with env or system property values.- Parameters:
text- OMText node value- Returns:
- resolved node value
-
isFatCAR
This method checks whether a given CApp file is a fat CApp or not by reading the descriptor.- Parameters:
cAppFilePath- CApp file path- Returns:
- true if the CApp is a fat CApp, false otherwise
-