Tuesday, September 02, 2014

JBoss AS 7.1.1 and HornetQ Clustering in two nodes

Fist follow

Check the  domain.xml configuration in the Master node  ( for profile - full-ha part) for the things marked yellow

Code as well as the domain.xml configuration  and the ports to be open is in GitHub https://github.com/alexcpn/jboss_hornetq_clustering

(Tested with AS 7.1.1)



Will create a message/messages and send to MROQueue ; The MROExecutorMDB will receive it and post a message to MROTopic which will be received by MROControllerMDB in both the master and slave nodes

(Deploy MROController.ear and MROExecuotor.ear to only other-server-group (jboss-cli.sh , connect to master and deploy)

Thursday, August 07, 2014

Exposing REST interface from a Session Bean

Here is a working example  at https://github.com/alexcpn/rest_in_sessionbean Tested with JBOSS AS 7.1.1. Note that a war file is needed in the ear, with a web.xml . This is using JBOSS inbuilt RESTEasy.

Idea from Adam Bein's  blog - www.adam-bien.com/roller/abien/entry/ejb_3_1_and_rest

Friday, February 14, 2014

Apache CXF and Spring

 Follwing maven settings in  jroller http://www.jroller.com/gmazza/entry/web_service_tutorial

Reading a little from Spring I understood that this is actually the applicationcontext.xml and cxf is somehow cooking its beans with Spring

< bean id="cxf" class="org.apache.cxf.bus.spring.SpringBus" destroy-method="shutdown" / >
    < bean id="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor"
                class="org.apache.cxf.bus.spring.BusWiringBeanFactoryPostProcessor" / >
    < bean id="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor"
                class="org.apache.cxf.bus.spring.Jsr250BeanPostProcessor" / >   
    < bean id="org.apache.cxf.bus.spring.BusExtensionPostProcessor"
                class="org.apache.cxf.bus.spring.BusExtensionPostProcessor" / >

Two of the most fundamental and important packages in Spring are the org.springframework.beans and org.springframework.context packages. Code in these packages provides the basis for Spring's Inversion of Control (alternately called Dependency Injection) features. The BeanFactory provides an advanced configuration mechanism capable of managing beans (objects) of any nature, using potentially any kind of storage facility. The ApplicationContext builds on top of the BeanFactory (it's a subclass) and adds other functionality such as easier integration with Springs AOP features, message resource handling (for use in internationalization), event propagation, declarative mechanisms to create the ApplicationContext and optional parent contexts, and application-layer specific contexts such as the WebApplicationContext, among other enhancements.

A BeanFactory configuration consists of, at its most basic level, definitions of one or more beans that the BeanFactory must manage. In an XmlBeanFactory, these are configured as one or morebean elements inside a top-level beans element.

< ? xml version="1.0" encoding="UTF-8" ? >
< !DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >

< beans >
  < bean id="..." class="..." >

  < / bean >

Using the servlet transport without Spring
A user who doesn't want to touch any Spring stuff could also publish the endpoint with CXF servlet transport. First you should extend the CXFNonSpringServlet and then override the method loadBus, e.g.:
import javax.xml.ws.Endpoint;
    public void loadBus(ServletConfig servletConfig) throws ServletException {
        // You could add the endpoint publish codes here
        Bus bus = cxf.getBus();
        Endpoint.publish("/Greeter", new GreeterImpl());
        // You can als use the simple frontend API to do this
        ServerFactoryBean factroy = new ServerFactoryBean();


Wednesday, February 05, 2014

JavaScript (Prototypal) Inheritance with new and Object.create

//Inheritance in JavaScript

var Person = function (string){
 this.name= string;
  //if ( !(this instanceof Person) ) //part soln to danger 1
    //  return new Person(name);

Person.prototype.get_name = function(){
 return this.name;

//Danger 1 : No compile errors here if new is skipped
//Also inside the function would now be the global this object,
//not the new instance! The constructor would be overriding all sorts
//of global variables inadvertently
var manu = Person("Manu");
manu.get_name(); //Danger 1 :only run time error here;Crackford's reason

var adi =  new Person("Adi");

//Okay let us try Iheritance with new 

var Employee = function (name,company){
  this.name = name;

Employee.prototype.get_company = function(){

 return this.comany;

//How to inherit from Person ?
//Step 1 - Link the prototypes //very similar to Object.create see below
Employee.prototype = new Person();

var naresh =  new Employee("Naresh","NSN");
naresh.get_company(); // oops, inheritance not complete

//Need to set the prototype after step 1
//Step 2
Employee.prototype.get_company = function(){

 return this.company;

var palani =  new Employee("Palani","NSN");

//---------------Another way with Obect.create--------------------------

function Manager(name,company){


Manager.prototype = Object.create(Employee.prototype);
Manager.prototype.constructor = Manager; //correct the ctor
Manager.prototype.getTeamSize = function(){
   return 5;

var guru = new Manager("Guru","NSN");

 guru.get_company() ;

Install/Upgrade NVIDI Driver in Ubuntu for CUDA SDK

Most linux distribution comes with the Nouveau https://nouveau.freedesktop.org/wiki/ display driver configured. If you need to use NVIDIA...