Sunday, October 29, 2017

How to create http proxy service in Wso2 ESB

Now we are going to explain about how to create http proxy service and call it to with client side.


Configuring Wso2 ESB to route messages through a proxy server


Edit the <ESB_HOME>/repository/conf/axis2/axis2.xml file, and add the following parameters in the <transportSender> configuration of the http transport:
  • http.proxyHost - The host name of the proxy server.
  • http.proxyPort - The port number of the proxy server.

You can see like this code when you set above parameters. 

<transportSender name="http" 
   class="org.apache.synapse.transport.passthru.PassThroughHttpSender">    
    <parameter name="non-blocking" locked="false">true</parameter>
    <parameter name="http.proxyHost" locked="false">localhost</parameter>
    <parameter name="http.proxyPort" locked="false">8080</parameter>
</transportSender>


Create proxy service using Wso2 Developer Studio.




Friday, October 27, 2017

How to create proxy service using WSO2 ESB (Call Using Soap UI)

If you don't have idea about how to install wso2 esb for your PC follow this link.

I'm going to explain how to create proxy service using wso2 developer tool.

Here is I only  added log mediator inside the proxy service. Now expose the car app

Lets go to the admin console panel. Here you can see bellow things.

  1. Proxy URL
  2. wsdl file

Click this wsdl link. You can see wsdl file inside the another tab. Copy that wsdl link.

Now we need to create SOAP project. Open soap UI.
Create new soap project using copied link.


Tuesday, October 24, 2017

How to includeHTML page into another HTML page

I'm going to include content.html file inside main.html,

content.html file


<html> 
  <body>
    <div id="new-projects">
    <a href="howto_google_maps.asp">Google Maps</a><br>
    <a href="howto_css_animate_buttons.asp">Animated Buttons</a><br>
    <a href="howto_css_modals.asp">Modal Boxes</a><br>
    <a href="howto_js_animate.asp">Animations</a><br>
    <a href="howto_js_progressbar.asp">Progress Bars</a><br>
    <a href="howto_css_dropdown.asp">Hover Dropdowns</a><br>
    <a href="howto_js_dropdown.asp">Click Dropdowns</a><br>
    <a href="howto_css_table_responsive.asp">ResponsiveTab</a><br>
    </div>
</body>
</html>



main.html file


<html lang="en">
<head>
 <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
 <script>
$(document).ready(function() {
$('#result').load('content.html #new-projects', function() {
//alert("loaded");
});
});
 </script>
</head>

<body>
   <b>Projects:</b>
<div id="result"></div>
</body>

</html>





You need to include both file in same folder. Otherwise you have to change inside the load() method.


Run this as localhost/path/main.html

Friday, October 20, 2017

How to debug java class inside the class mediator in Wso2 Enterprise Integrator(EI)

Before I do this I created API including class mediator.


Deployee car file including all file(Here I only included Esb Solution project).


Go to integrator.bat file location(<ESB_HOME>/bin) in command prompt and run bellow line.


integrator.bat -debug 5005     (Here you can enter any port what you need).


After this go to java class.


Select Run in menu bar -> Debug Configuration.. ->Right click on Remote Java Application in the left side

     ->New ->Enter  5005 popup window port location ->click Debug

Description Images



Image_01
sdwad




















Image_02


When Finished command prompt run statement you will able to see like this line 
as usually
 INFO - CarbonUIServiceComponent Mgt Console URL  : https://192.168.120.160:9443/carbon/ 

After this send request your API. Then You can see debug mode in the java class.
Thank you

















Wednesday, October 18, 2017

Creating a .jar Deployment Package Using Maven and Eclipse IDE (Java)

In this tutorial, we will show you how to use Maven build tool, to create a single executable Jar.

Right click maven project,

choose Run As-> Maven Build .... 

Type package in the Goals box.

Click Run.

Friday, September 15, 2017

How to find something on your computer in second

To day I'm going to explain about most important thing for computer users. How to search anything on your computer in just second. I used for this everything software. You can download it from this http://filehippo.com/download_everything/ link or other any sites. After install you can play with it.




Monday, August 21, 2017

Creating APIs - Enterprise Service Bus

This page describes how you can create an API that allows URL parameters to be sent directly into the ESB. 

Goto wso2 developer Studio. 

01 . Create ESB Solution Project 
Click Developer Studio -> Open Dashboard -> Click ESB Solution Project 

ESB Project Name is  TestAPI


Remove Create Registry Resources Project and Create Connector Exporter Project. Only tick Create Composite Application Project. Then click Finish.

 02. Create REST API 

Right click on created project(Left side)

New =>REST API =>Create A New API Artifact 


Enter bellow parameters to text fields 









You can see created API in leftside





















Select Source code

<?xml version="1.0" encoding="UTF-8"?>
<api context="/service" hostname="localhost" name="urlParameterAPI" port="8280" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET">
        <inSequence/>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>


Then Change it like bellow code

<?xml version="1.0" encoding="UTF-8"?>
<api context="/service" hostname="localhost" name="urlParameterAPI" port="8280" xmlns="http://ws.apache.org/ns/synapse">
    <resource methods="GET">
        <inSequence>
             <log level="full">
                <property expression="get-property('username')"                  name="====USERNAME===="/>
            </log>
        </inSequence/>
        <outSequence/>
        <faultSequence/>
    </resource>
</api>


Now its ok.

http://localhost:8280/service?username=Priyantha_Samaraweera



Wednesday, August 16, 2017

Deadlock, livelock

deadlock, livelock

Threads


Abstract Class in Java

A class that is declared using “abstract” keyword is known as abstract class.

Abstract is a process of hiding the data implementation details and showing only functionality to the user.Abstraction lets you focus on what the object does instead of how it does it.

Main things of abstract class

  • Abstraction class may or may not contain abstraction method.(There can be non abstract method) Point : An abstract method is method that declare that is declared without an implementation (without braces, and followed by a semicolon), like this:      Ex : abstract void moveTo(double deltaX, double deltaY);
  • But, If a class has at least one abstract method then class must be abstract
  • If a class is declared abstract, it cannot be instantiated (Abstract classes may not be instantiated) {You are not allowed to create object of Abstract class}
  • To use abstract class you have to inherit it from another class. Provide implementation to all the abstract method in it.
  • If you inherit abstract class, You have to provide implementation to all the abstract method in it.

Declare abstract class

Specifying abstract keyword before the class during declaration, make it abstract. Have look below code:
abstract class AbstractDemo{ }

Declare abstract method

Specifying abstract keyword before the method during declaration, make it abstract. Have look below code
abstract void moveTo();//no body

Why we need to abstraction class

In an object-oriented drawing application, you can draw circles, rectangles, lines, Bezier curves, and many other graphic object. These object all have certain states(for ex -: position, orientation, line color, fill color) and behaviors(for ex -: moveTo, rotate, resize, draw) in common. Some of these states and behaviors are the same for all graphic objects (for ex : fill color,position, and moveTo). Others require different implementation(for ex: resize or drow). All GraphicObject must be able to draw or resize themselves; they just differ in how they do it. This is a perfect situation for abstract superclass. You can take advantage of the similarities and declare all the graphic object to inherit from the same abstract parent object(for ex : GraphicObject) as shown in the following figure.


First, you declare an abstract class, GraphicObject, to provide member variables and method that are wholly shared by all subclasses, such as the current position and the move to method.GraphicObject also declared abstract methods for abstract methods, such as drow or resize, that need to be a implemented by all subclasses but must  be implemented in different ways. The GraphicObject class can look something like this:

abstract class GraphicObject {

   void moveTo(int x, int y) {
       //Inside  this method we have to do change position of the graphic object
// according to x,y .This changes same to every graphic object.
//Then we can implement here.
   }
   abstract void draw(); //But every graphic object drawing case is unique.
// Not common. Then we have to create that case
// inside each class . Then create these method as abstract
    abstract void resize();
}


Usage of abstract method in sub classes

Each non abstract subclasses of GraphicObject, such as Circle and Rectangle, must provide implementations for the draw and resize method.

class Circle extends GraphicObject {
   void draw() {
       //Add to some implementation here
   }
   void resize() {
       //Add to some implementation here   
   }
}
class Rectangle extends GraphicObject {
   void draw() {
       //Add to some implementation here
   }
   void resize() {
       //Add to some implementation here
   }
}

Inside the main method you can call all methods like this

Public static void main(String args[]){
GraphicObject c = new Circle();
c.drow();
c.resize();
c.moveTo(4,5);
}

Ways to achieve abstraction in java

There are two ways to achieve abstraction in java
  • Abstract class(0 to 100%)
  • Interface(100%)

Abstraction class having construction, data member, method etc

abstract class GraphicObject {
  
   GraphicObject (){
       System.out.println("GraphicObject  is created");
   }
   void moveTo(int y, int x) {
          System.out.println("Change position according to "+ x+ " and " + y);
   }
   abstract void draw();
}

class Circle extends GraphicObject {
   void draw() {
       System.out.println("Draw the Circle");
   }
}
class TestAbstract
{  
   
   public static void main(String args[]){
      
       GraphicObject  grObj = new Circle ();
       grObj.draw();
       grObj.moveTo(4,6);
   }
}

Output:
GraphicObject  is created
Draw the Circle
Change position according to 6 and 4


Remember two rules:

  • If the class is having few abstract methods and few concrete methods: declare it as abstract class.
  • If the class is having only abstract methods: declare it as interface.


Tuesday, August 15, 2017

WSO2 Enterprise Service Bus Quick Start Guide

Before you working start with wso2 esb tool you have to download two different tool.

Enterprise Service Bus Tool
Developer Studio Tool

Download wso2 esb tool

  • Go to this link
  • Select binary type of 5.0.0 version
  • Enter your details and select and Select submit. It will download esb tool
When downloaded it you can extract and ready to use it


Download Developer studio tool(Current best version)

  • This developed on the eclipse mars version. 
  • Go to this link
  • Click download button
  • Enter your email and click Download Tooling
  • Select your operating system(OS) then it will start download 

Congratulation! Now you are ready to work with wso2 esb product.

Friday, August 4, 2017

What is the Compiler, JVM in java

When we type code using some IDE like eclipse,  netbeans  it's only can understand us. But computer can't understand it. There for compiler and JVM help to machine to understand this code. How ever compiler , compile the code to the bite code. And java virtual machine(JVM) convert that byte code to the ascii value using Just in Time (JIT). That's why java slow compatibility.