Welcome to the new Gigaspaces XAP forum. To recover your account, please follow these instructions.

Ask Your Question
0

Wiring up stuff from a main() method

We're using @ExecutorProxy annotation to get access to our space-side services, but I was wondering how to programmatically inject these fields when not running inside a PU but when you have a little utility that's called from a main() class or, say, a servlet deployed someplace else than in a GS servlet container?

{quote}This thread was imported from the previous forum. For your reference, the original is [available here|http://forum.openspaces.org/thread.jspa?threadID=3080]{quote}

asked 2009-05-12 02:40:34 -0500

cdegroot gravatar image

updated 2013-08-08 09:52:00 -0500

jaissefsfex gravatar image
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

Hi Cees

Here's an example:

IJSpace space = new UrlSpaceConfigurer("jini:////space").space();
GigaSpace gigaSpace = new GigaSpaceConfigurer(space).gigaSpace();
IDataProcessor dataProcessor = new ExecutorRemotingProxyConfigurer<IDataProcessor>(gigaSpace, IDataProcessor.class).proxy();

Note that most documentation pages for OpenSpaces components have a "Code" tab that shows how to configure them in plain Java.
You may also find this post helpful: http://uri-cohen.blogspot.com/2008/01/to-spring-or-not-to-spring.html

Uri

answered 2009-05-12 03:06:24 -0500

uri gravatar image
edit flag offensive delete link more

Comments

Thanks Uri - but I was aware of that snippet (and your blog post ;-)).

However, if I'm doing this and then start using classes that have @ExecutorProxy annotations, will they be properly be injected with the respective proxies?

(might be a stupid question, but consider me a Spring n00b...)

cdegroot gravatar imagecdegroot ( 2009-05-12 03:30:55 -0500 )edit

For the annotation to be processed, you need to start a Spring context (or process it manually which doesn't make a lot of sense).
If you start a Spring context from your main method you can retrieve the bean which uses the proxy based on its ID, e.g.:
ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/pu.xml");
MyBean bean = (MyBean)context.getBean("myBean");

If you use a web application you can automatically start the context from within the web application - http://static.springframework.org/spring/docs/2.5.x/reference/beans.html#context-create
I'd recommend using Spring MVC controllers you can inject proxies to your web component.
You can see how this is done in our petclinic port: http://www.openspaces.org/display/DAE/GigaSpacesPetClinic

Uri

uri gravatar imageuri ( 2009-05-12 03:59:45 -0500 )edit

Thanks, Uri - that'll help me get going :)

cdegroot gravatar imagecdegroot ( 2009-05-12 04:27:01 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2009-05-12 02:40:34 -0500

Seen: 64 times

Last updated: May 12 '09