This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.scalatest.mock.EasyMockSugar | |
trait RepositoryComponentMock | |
extends RepositoryComponent | |
with EasyMockSugar { | |
val projectRepository = mock[ProjectRepository] | |
val userRepository = mock[UserRepository] | |
} | |
trait ServiceComponentMock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ChartViewFactoryComponent { | |
val chartViewFactory: ChartViewFactory | |
trait ChartViewFactory { | |
def create(chart: Chart): ChartView | |
} | |
} | |
trait ChartViewFactoryComponentImpl extends ChartViewFactoryComponent { | |
self: HistogramViewFactoryComponent with ScatterPlotViewFactoryComponent => | |
override val chartViewFactory: ChartViewFactory = new ChartViewFactoryImpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ChartViewComponent | |
extends ChartViewFactoryComponent | |
trait ChartViewComponentImpl | |
extends ChartViewComponent | |
with ChartViewFactoryComponentImpl | |
with HistogramViewFactoryComponentImpl | |
with ScatterPlotViewFactoryComponentImpl | |
trait ViewComponent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component @Scope("prototype") | |
public class StatefulService { | |
// ... | |
} | |
@Component | |
public class ReferencingService { | |
// every referencing component will get its own instance of the service | |
@Autowired |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait StatefulServiceComponent { | |
def statefulService: StatefulService | |
trait StatefulService { | |
// ... | |
} | |
} | |
trait StatefulServiceComponentImpl extends StatefulServiceComponent { | |
override def statefulService: StatefulService = new StatefulServiceImpl | |
private class StatefulServiceImpl extends StatefulService { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait ReferencingServiceComponent { | |
def referencingService: ReferencingService | |
trait ReferencingService { | |
// ... | |
} | |
} | |
trait ReferencingServiceComponentImpl extends ReferencingServiceComponent { | |
self: StatefulServiceComponent => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class MyApplication extends TopComponent { | |
def start = { | |
// ... | |
} | |
// ... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object MyApplication { | |
def main(args: Array[String]) = | |
(new MyApplication with TopComponentImpl).start | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object MyApplication { | |
def main(args: Array[String]) = { | |
val app = | |
if (testMode) | |
(new MyApplication with TopComponentTestImpl) | |
else | |
(new MyApplication with TopComponentImpl) | |
app.start | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait TopComponent | |
extends RepositoryComponent | |
with ServiceComponent | |
object TopComponentImpl extends TopComponentImpl | |
trait TopComponentImpl | |
extends TopComponent | |
with RepositoryComponentImpl | |
with ServiceComponentImpl |