Tuesday, August 6, 2013

Data Source create on WSO2 products in remote manner




In WSO2 products , we can configured DataSources with lot of features. We can do it using Admin Console in those products.

But sometimes we want to do it remotely like in automated deployment enlivenment. Then we can use a service to that provided by the Admin Services.

Using curl command.


curl -k -u admin:admin -d @datasourceconfig.xml -H "Content-Type: application/xml action=addDataSource" https://hostname:9443/services/NDataSourceAdmin


datasourceconfig.xml


 <xsd:addDataSource xmlns:xsd="http://org.apache.axis2/xsd"
    xmlns:xsd1="http://services.core.ndatasource.carbon.wso2.org/xsd"
    xmlns:xsd2="http://core.ndatasource.carbon.wso2.org/xsd">
    <xsd:dsmInfo>
        <xsd1:definition>
            <xsd1:dsXMLConfiguration>
                   <![CDATA[<configuration>
                  <url>jdbc:mysql://localhost:3306/dbname</url>
                  <username>root</username>
                  <password>root</password>
                  <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                  <maxActive>50</maxActive>
                  <maxWait>60000</maxWait>
                  <testOnBorrow>true</testOnBorrow>
                  <validationQuery>SELECT 1</validationQuery>
                  <validationInterval>30000</validationInterval>
                  </configuration>]]>
            </xsd1:dsXMLConfiguration>
            <xsd1:type>RDBMS</xsd1:type>
        </xsd1:definition>
        <xsd1:description>description</xsd1:description>
        <xsd1:jndiConfig>
            <xsd2:name>... JNDI Name here ..</xsd2:name>
            <xsd2:useDataSourceFactory>false</xsd2:useDataSourceFactory>
        </xsd1:jndiConfig>
        <xsd1:name>... DataSourceName Here ..</xsd1:name>
        <xsd1:system>false</xsd1:system>
    </xsd:dsmInfo>
</xsd:addDataSource> 


Monday, August 5, 2013

Generic Queue & Consumer Implementation using Java


Here I have implemented a generic queue and consumer using Java.

Java Implementation Source Code
https://github.com/harsha1979/lightweightqueue.git


 //Create an ExecutionEngine and start.

boolean isAutoStart = false ;
boolean isAutoRestart = false ;


//Time Delay in Millisecond
int timeDelay = 100 ;
int queueLength - 100 ;

//ExecutorImpl is an implementation of the Executor to do the task when the executor do execute.

Executor executor = new ExecutorImpl();

ExecutionEngine executionEngine =  new ExecutionEngine<CustomBean>(executor,isAutoStart,        isAutoRestart,timeDelay,queueLength);

executionEngine.startEngine();

//Put an element to the queue
CustomBean customBean = new CustomBean();
executionEngine.getSynchQueue().put(customBean);

VI Editor

Few commands.

vi file Invoke vi on file
vi file1 file2 Invoke vi on files sequentially
view file Invoke vi on file in read-only mode
vi -R file Invoke vi on file in read-only mode
vi -r file Recover file and recent edits after a
          crash
vi -t tag Look up tag and start editing at its
         definition
vi -w n Set the window size to n; useful over a
       slow connection
vi + file Open file at last line
vi +n file Open file directly at line number n
vi -c command file Open file, execute command, which is
                  usually a search command or line num-
                 ber (POSIX)
vi +/pattern file Open file directly at pattern
ex file Invoke ex on file
ex - file < script Invoke ex on file, taking commands
                  from script; suppress informative mes-
                 sages and prompts
ex -s file < script Invoke ex on file, taking commands
                   from script; suppress informative mes-
                  sages and prompts (POSIX)