Brief Introduction to Rest full Web Services

Rest full Web Services
Representational State Transfer (REST) is an architectural style for building distributed systems. The Web is an example for such a system. REST-style applications can be built using a wide variety of technologies. REST's main principles are those of resource-oriented states and functionalities, the idea of a unique way of identifying resources, and the idea of how operations on these resources are defined in terms of a single protocol for interacting with resources. REST-oriented system design leads to systems which are open, scalable, extensible, and easy to understand.

REST Definition
REST is an acronym standing for Representational State Transfer.

Motivation for REST
The motivation for REST was to capture the characteristics of the Web which made the Web successful. Subsequently these characteristics are being used to guide the evolution of the Web.

REST Concepts
Resources are defined by URIs
Resources are manipulated through their representations
Messages are self-descriptive and stateless
There can be multiple representations for a resource
Application state is driven by resource manipulations

REST is built around the idea of simplifying agreement
nouns are required to name the resources that can be talked about
verbs are the operations that can be applied to named resources
content types define which information representations are available


For most applications, HTTP's basic methods are sufficient
GET: Fetching a resource (there must be no side-effects)
PUT: Transfers a resource to a server (overwriting if there already is one)
POST: Adds to an existing resource on the server
DELETE: Discards a resource (its name cannot be used anymore)
Expose directory structure-like URIs
From the standpoint of client applications addressing resources, the URIs determine how intuitive the REST Web service is going to be and whether the service is going to be used in ways that the designers can anticipate

 Stateless nature of restfull web services
REST Web services need to scale to meet increasingly high performance demands. Clusters of servers with load-balancing and failover capabilities, proxies, and gateways are typically arranged in a way that forms a service topology, which allows requests to be forwarded from one server to the other as needed to decrease the overall response time of a Web service call. Using intermediary servers to improve scale requires REST Web service clients to send complete, independent requests; that is, to send requests that include all data needed to be fulfilled so that the components in the intermediary servers may forward, route, and load-balance without any state being held locally in between requests.

How to generate Axiom OMElement Using input Stream

The method showed below is generate   Axiom OMElement  from input stream
  
   /**
     * @param inputStream Reads input stream that use to build OMElement
     * @return  OMElement that generated from input stream
     * @throws Exception at error in generating parser
     */
    public static OMElement buildOMElement(InputStream inputStream) throws Exception {
        XMLStreamReader parser;
        try {
            parser = XMLInputFactory.newInstance().createXMLStreamReader(inputStream);
        }
        catch (XMLStreamException e) {
            String msg = "Error in initializing the parser to build the OMElement.";
            log.error(msg, e);
            throw new Exception(msg, e);
        }
        finally {
           log.info("Reading data from configuration file");
        }
        StAXOMBuilder builder = new StAXOMBuilder(parser);
        return builder.getDocumentElement();
    }


we can call this method as follows

OMElement  element=buildOMElement(new FileInputStream("File path String"));

If you need more information go to this link

How to read user input at command line -Java


    public String readUserInput(String printMessage) throws IOException{
        System.out.println(printMessage);
        InputStreamReader isr = new InputStreamReader ( System.in );
        BufferedReader br = new BufferedReader (isr);
        String returnString;
        try {
            returnString=br.readLine();
        } catch (IOException e) {
           String message="error while reading user input";
           log.error(message,e);
           throw new IOException(e);
        }
        finally {
            br.close();
            isr.close()
        }
        return returnString;
    }

Get Present Working Directory in Java Code

Most of projects we don't use absolute path instead we use relative path thats best practice. in this discussion we will see how to get string name of current working folder so after that we can get relative path corresponding to that base location . so simple just few lines :)
   public static String getCurrentDirectory(){
        String cwd = null;
        try{
            cwd = new java.io.File( "." ).getCanonicalPath();

        } catch (java.io.IOException e)
        {
            log.error("Error in getting present working Directory");
        }
        return cwd;
    }

Empowering the Future of API Management: Unveiling the Journey of WSO2 API Platform for Kubernetes (APK) Project and the Anticipated Alpha Release

  Introduction In the ever-evolving realm of API management, our journey embarked on the APK project eight months ago, and now, with great a...