English 中文(简体)
利用春天制作的电网
原标题:Wicket WebApplication/WebPage circular dependency using spring

在我的“区域”春季应用中,我有这一方法将春季管理人员引入<>代码>WebApplication类别:

private void initManager() {
    ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(getServletContext());
    this.manager = (MyManager) applicationContext.getBean("manager");
}

我通常在<代码>in内设置内部错误网页。 我的<代码>WebApplication等方法。 有时 我也用一些可读页:

public class MyApplication extends WebApplication {

    @Override
    protected void init() {
        IApplicationSettings applicationSettings = getApplicationSettings();
        applicationSettings.setInternalErrorPage(ErrorPage.class);
        mountBookmarkablePage("privacy", PrivacyPage.class);
    }

    //............
}

My WebPage classes usually depend on my manager class, for instance:

public class ErrorPage extends WebPage {

    public ErrorPage() {
        MyApplication application = (MyApplication) getApplication();
        add(new EmailLink(application.getManager().getMailSupport()));
    }
}

因此,我的<代码>WebApplication类别系指一个或多个网页,我的网页指的是WebApplication。 这是一种循环依赖吗? 如果是,我如何能够避免?

最佳回答

我要说的是,这不是循环依赖,而是组合。

然而,我认为你总是能够向网页班级和汽车线路注入你的经理。

EDIT:

You may also need to enable spring annotations in applicationContext.xml as well and add some new dependencies if not already in classpath

see applicationContext.xml sample at this address and your will be pretty much similar except the scan package name. Update those values accordingly.

public class ErrorPage extends WebPage {

@Autowired
private MyManager myManager;

//setter getter methods as well
}
问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签