PDA

View Full Version : Configuration Context from another locations...



iguana
Aug 16th, 2004, 03:34 AM
Hi All,

I am in need of retrieving configuration contexts from a network node so I can configure for example ... menu items on the fly...

Can I do it in current version of RCP?

Thanks

Indra

Cybernet Sauvignon
Aug 16th, 2004, 05:03 AM
Indra,

try to use org.springframework.context.access.ContextSingleto nBeanFactoryLocator, or DefaultLocatorFactory in the same package.
This singletons are intended to instantiate AppCtx using beanRefContext.xml file, where you can specify the real appCtx sources (e.g. http://org.foo/myAppCtx.xml).

But I think that just for dynamic menu loading is better other solution.
Use the mentioned ContextSingletonBeanFactoryLocator (or DefaultLocatorFactory) and specify there local appCtx files.

Create a bean like


pubilc interface MenuSource {
MenuItem getMenu();
MenuItem getMenu(MenuItem item);
MenuItem getMenu(Principal user);
...
}

public class RemoteMenuSource {
public MenuItem getMenu() {
// call the server to get the menu
// using specified remoting service
}
}


Then let the UI code, which builds the menu, use the MenuSource bean (of course configured by Spring :-). E.g.


public class ApplicationFrame {
private MenuSource menuSource;
public setMenuSource(MenuSource menuSource) {
thie.menuSource = menuSource;
}

...

public init(...) {
MenuItem mainMenu = menuSource.getMenu();
...
}
}


and config it by


<bean name="menuSource" class="RemoteMenuSource"/>
<bean name="applicationFrame" class="ApplicationFrame">
<property name="menuSource"><ref bean="menuSource"/></property>
</bean>


Hope this help