当前位置: 动力学知识库 > 问答 > 编程问答 >

Java factory method call from Scala

问题描述:

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.

分享给朋友:
您可能感兴趣的文章:
随机阅读: