来自受限层的Java调用方法 [英] Java calling methods from restricted layer

查看:127
本文介绍了来自受限层的Java调用方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我甚至不确定这是否可行,但我想询问社群的一般意见。

I'm not even sure if this is doable but I want to ask the community for their general opinion.

我必须解决以下问题:

我的项目有2个图层,一个核心图层和一个业务图层。
此核心层提供业务层。此时,Business类可以导入Core类并执行他们想要的任何操作。核心类只能导入核心类并使用它们的方法,禁止访问Business类及其各自的方法。

My Project has 2 Layers, a Core layer and a Business layer. This Core layer is providing the Business layer. At this moment Business classes can import Core classes and do whatever they want. Core classes can only import core classes and use their methods, the access to Business classes and their respective methods is forbidden.

我想添加一个特定的功能:
我不想让Core对Business层有任何正常访问权限,但是我想创建类似于界面或类似东西的东西(我不知道如何在这里表达自己因为我不知道它是否可能),这为Core类提供了一些Business类使用的特定方法。

I want to add a specific feature: I don't want to give Core any normal access to the Business layer, but I want to create something like an interface or anything similar (I don't know how to express myself here cause I have no idea if its possible), that provides the Core classes some specific methods from Business classes to use.

任何人都可以帮助我,或者至少给我一些指导原则,或者在哪里搜索。

Can anyone help me out, or at least give me some guidelines what to read, or where to search.

预先感谢任何支持。

编辑:
我使用带有Seam的Spring Framework和JBoss

I use Spring Framework with Seam and JBoss

推荐答案

你可能面临的是模块依赖和循环依赖的设计。简而言之,Core需要的Business方法可能必须重新考虑到utils模块或Business-Core模块中,然后两者都可以访问。我只是在这里猜测。

What you are probably facing is the design of module dependency and circular dependency. In short, the Business methods that Core needs may have to be re-factored into a 'utils' module or a 'Business-Core' module that is then accessible by both. I am only guessing here.

除了自动构建之外,像Maven这样的构建工具也鼓励这种模块化和依赖。从一个模块开始的项目在完成时分成3-4个模块并不罕见。

In addition to automating builds, a build tool like Maven also encourages such modularization and dependency. It is not unusual for a project that started off as one module to be split into 3-4 modules by the time it is done.

这篇关于来自受限层的Java调用方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆