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;
... 
 
    @Override
    public void loadBus(ServletConfig servletConfig) throws ServletException {
        super.loadBus(servletConfig);       
       
        // You could add the endpoint publish codes here
        Bus bus = cxf.getBus();
        BusFactory.setDefaultBus(bus);
        Endpoint.publish("/Greeter", new GreeterImpl());
       
        // You can als use the simple frontend API to do this
        ServerFactoryBean factroy = new ServerFactoryBean();
        factory.setBus(bus);
        factory.setServiceClass(GreeterImpl.class);
        factory.setAddress("/Greeter");

        factory.create();

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");
name;
manu.get_name(); //Danger 1 :only run time error here;Crackford's reason

var adi =  new Person("Adi");
adi.get_name();

//Okay let us try Iheritance with new 

var Employee = function (name,company){
  this.name = name;
  this.company=company;
  Person.call(this,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;
naresh.get_name();
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");
palani;
//perfect
palani.get_company();
palani.get_name();

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

function Manager(name,company){

  Employee.call(this,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_name();
 guru.get_company() ;
 guru.getTeamSize();

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...