Java factory method call from Scala

92 Views Asked by At

In a Scala project I am working on I am using a library that provides a factory method to instantiate instance of crypto-currencies exchanges interfaces. in java it is like this :

Exchange bitstamp = ExchangeFactory.INSTANCE.createExchange(BitstampExchange.class.getName());

and it works, in scala I tried to call it like this :

 val exchange = ExchangeFactory.INSTANCE.createExchange(classOf[BitstampExchange].toString);

but I get an exception and it doesn't work.

[ExchangeException: Problem creating Exchange (class not found)]

now, I don't really know the best way to deal with. Should I write my own factory method in scala ? or is there some workaround to make it work ?

Thanks in advance.

0

There are 0 best solutions below