Friday, February 14, 2014

Apache CXF and Spring

 Follwing maven settings in  jroller

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" ? >

< 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.:
    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){ string;
  //if ( !(this instanceof Person) ) //part soln to danger 1
    //  return new Person(name);

Person.prototype.get_name = function(){

//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){ = 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(){


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

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

function Manager(name,company){,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() ;

Total Pageviews