diff --git a/include/dynamic-graph/entity.h b/include/dynamic-graph/entity.h
index dde3226b5264389fae469030ec1b17b3e40f84f4..a461cdccba32cbb9ad103582419e819656a4bf25 100644
--- a/include/dynamic-graph/entity.h
+++ b/include/dynamic-graph/entity.h
@@ -71,7 +71,6 @@ namespace dynamicgraph
   /// customize the command-line by overriding commandLine ().
   class DYNAMIC_GRAPH_DLLAPI Entity : private boost::noncopyable
   {
-    DYNAMIC_GRAPH_ENTITY_DECL ();
   public:
     typedef std::map< std::string,SignalBase<int>* > SignalMap;
     typedef std::map<const std::string, command::Command*> CommandMap_t;
@@ -83,6 +82,7 @@ namespace dynamicgraph
     {
       return name;
     }
+    virtual const std::string& getClassName  () const = 0;
 
     SignalBase<int>& getSignal (const std::string& signalName);
     const SignalBase<int>& getSignal (const std::string& signalName) const;
diff --git a/src/dgraph/entity.cpp b/src/dgraph/entity.cpp
index 407b1bcece033896e8bbbaaa3018e70960fbc5fb..8831af40e24f68737f1b811d03708f1cb113aa70 100644
--- a/src/dgraph/entity.cpp
+++ b/src/dgraph/entity.cpp
@@ -34,9 +34,6 @@ using namespace std;
 using namespace dynamicgraph;
 using dynamicgraph::command::Command;
 
-const std::string Entity::CLASS_NAME = "Entity";
-
-
 void Entity::
 entityRegistration  ()
 {
@@ -58,7 +55,7 @@ Entity( const string& name__ )
   if( name.length ()==0 )
     {
       stringstream oss; oss << rand ();
-      name = this->getClassName();
+      //name = this->getClassName(); Cannot call a virtual function from the constructor
       name+="::";
       name+=oss.str ();
     }
diff --git a/tests/entity.cpp b/tests/entity.cpp
index 520b8d4ccb59cbb425f8d08a0fff7bf696952e27..19d398ea50ed3f47378b1d79c02bdc94f5c91f8a 100644
--- a/tests/entity.cpp
+++ b/tests/entity.cpp
@@ -26,33 +26,43 @@
 
 using boost::test_tools::output_test_stream;
 
-extern "C" {
-  dynamicgraph::Entity* EntityMaker_Entity(const std::string& objname)
+namespace dynamicgraph
+{
+  class CustomEntity : public Entity
   {
-    return new dynamicgraph::Entity (objname);
-  }
+  public:
+    static const std::string CLASS_NAME;
+    virtual const std::string& getClassName () const
+    {
+      return CLASS_NAME;
+    }
+    CustomEntity (const std::string n)
+      : Entity (n)
+    {
+    }
+  };
+  DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN (CustomEntity,"CustomEntity");
 }
 
+
 BOOST_AUTO_TEST_CASE (constructor)
 {
-  dynamicgraph::FactoryStorage::getInstance()->registerEntity
-    (dynamicgraph::Entity::CLASS_NAME, &EntityMaker_Entity);
-
-  BOOST_CHECK_EQUAL (dynamicgraph::Entity::CLASS_NAME, "Entity");
+  BOOST_CHECK_EQUAL (dynamicgraph::CustomEntity::CLASS_NAME, "CustomEntity");
 
   dynamicgraph::Entity& entity =
-    *dynamicgraph::FactoryStorage::getInstance()->newEntity("Entity",
+    *dynamicgraph::FactoryStorage::getInstance()->newEntity("CustomEntity",
 							    "my-entity");
   BOOST_CHECK_EQUAL (entity.getName (), "my-entity");
-  BOOST_CHECK_EQUAL (entity.getClassName (), dynamicgraph::Entity::CLASS_NAME);
+  BOOST_CHECK_EQUAL (entity.getClassName (),
+		     dynamicgraph::CustomEntity::CLASS_NAME);
 
-  dynamicgraph::Entity entity2 ("");
+   dynamicgraph::CustomEntity entity2 ("");
 }
 
 BOOST_AUTO_TEST_CASE (signal)
 {
   dynamicgraph::Entity& entity =
-    *dynamicgraph::FactoryStorage::getInstance()->newEntity("Entity", "");
+    dynamicgraph::PoolStorage::getInstance()->getEntity("my-entity");
 
   // Non const getter.
   try
@@ -99,7 +109,7 @@ BOOST_AUTO_TEST_CASE (display)
   output_test_stream output;
 
   entity.display(output);
-  BOOST_CHECK (output.is_equal ("Entity: my-entity"));
+  BOOST_CHECK (output.is_equal ("CustomEntity: my-entity"));
 }
 
 BOOST_AUTO_TEST_CASE (getCommandList)
@@ -140,7 +150,7 @@ BOOST_AUTO_TEST_CASE (commandLine_print)
   std::istringstream args;
 
   entity.commandLine("print", args, output);
-  BOOST_CHECK (output.is_equal ("Entity: my-entity\n"));
+  BOOST_CHECK (output.is_equal ("CustomEntity: my-entity\n"));
 }
 
 BOOST_AUTO_TEST_CASE (commandLine_signals)
diff --git a/tests/factory.cpp b/tests/factory.cpp
index 23a52f1745b86116fccaf0ec1437f251b88136d3..fbc5683be2e9f5e5588a1a7ea669bca2b6650f7a 100644
--- a/tests/factory.cpp
+++ b/tests/factory.cpp
@@ -26,9 +26,29 @@
 using boost::test_tools::output_test_stream;
 
 
+
+namespace dynamicgraph
+{
+  class CustomEntity : public Entity
+  {
+  public:
+    static const std::string CLASS_NAME;
+    virtual const std::string& getClassName () const
+    {
+      return CLASS_NAME;
+    }
+    CustomEntity (const std::string n)
+      : Entity (n)
+    {
+    }
+  };
+  const std::string CustomEntity::CLASS_NAME = "CustomEntity";
+}
+
+
 dynamicgraph::Entity* makeEntity(const std::string& objectName)
 {
-  return new dynamicgraph::Entity (objectName);
+  return new dynamicgraph::CustomEntity (objectName);
 }