How do I get a handle to the UVM factory?

I want to use method “find_by_name()” of uvm_factory in my base_test class which is extended from uvm_test.

class base_test extends uvm_test;
   `uvm_component_utils(base_test) 
     ....
     ....
endclass

class basic_test1 extends base_test;
    `uvm_component_utils(basic_test1) 
     
     function void build_phase(uvm_phase phase);
      super.build_phase(phase);
     uvm_config_wrapper::set(this,"vsequencer.main_phase","default_sequence", factory.find_by_name("basic_write_seq"));

     endfunction
endclass

This code gives the following error : 
 Hierarchical name component lookup failed at 'factory'


Then i tried following code :

class base_test extends uvm_test;
   `uvm_component_utils(base_test)
    uvm_factory factory;
     ....
     ....
    function void build_phase(uvm_phase phase);
        super.build_phase(phase);
        factory = uvm_factory::get(); 
    endfunction
endclass

class basic_test1 extends base_test;
    `uvm_component_utils(basic_test1) 
     
     function void build_phase(uvm_phase phase);
      super.build_phase(phase);
     uvm_config_wrapper::set(this,"vsequencer.main_phase","default_sequence", factory.find_by_name("basic_write_seq"));

     endfunction
endclass

This code gives following error : find_by_name is not a class item.

So How can i get handle to uvm_factory??

In reply to rushank27:

From the UVM 1.2 release notes:

The undocumented uvm_pkg::factory variable has been removed, as it was unsafe during static initialization, and incompatible with the uvm_coreservice_t class. References to this variable need to be upgraded to retrieve the factory via uvm_factory::get.

In the second example , as you mentioned , i got the handle by using uvm_factory::get() , but i am still not able to use method find_by_name(). It gives error that " find_by_name is not a class item "

Example :
class base_test extends uvm_test;
`uvm_component_utils(base_test)
uvm_factory factory;


function void build_phase(uvm_phase phase);
super.build_phase(phase);
factory = uvm_factory::get();
endfunction
endclass

class basic_test1 extends base_test;
`uvm_component_utils(basic_test1)

 function void build_phase(uvm_phase phase);
  super.build_phase(phase);
 uvm_config_wrapper::set(this,"vsequencer.main_phase","default_sequence", factory.find_by_name("basic_write_seq"));

 endfunction

endclass

In reply to rushank27:

Sorry, your question did not match your problem. You are getting a handle to the factory correctly. The problem is you are trying to use an early version of the UVM and umm_factory::find_by_name was renamed find_wrapper_by_name.

Use

umm_config_db#(umm_wrapper_object)::set(this,"vsequencer.main_phase","default_sequence", factory.find_wrapper_by_name("basic_write_seq"));