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

Ask Your Question

Embeded PU?

Doing simple data write read from a space I've done with code that uses a local space url (/./MySpaceName) with the SpaceFinder and that works great. I can run my code in Eclipse and the space just starts like majic. Very cool.

Is there anyway to do the same thing with a PU? Is there way to start a PU Instance from within code? If I use a local space url in pu.xml would the finder find that in the same JVM if passed the local url or would it need to have the Jini URL with the MySpaceName?

Is there an example of using a service defined in a PU from just plain Java Code?

  • Peace

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

asked 2007-11-15 22:46:01 -0500

djking gravatar image

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

jaissefsfex gravatar image
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted


You can use the integrated processing unit container which was designed to be executed within IDEs.

The simplest way to get started is to import the OpenSpaces hello world eclipse project into your Eclipse. You'll have a launch definition already set up for what you're looking for.


answered 2007-11-16 02:43:00 -0500

nirpaz gravatar image
edit flag offensive delete link more

You can setup your space beans and start them as part of a Spring application.

See an example attached.


answered 2007-11-16 02:35:02 -0500

guy sayar gravatar image
edit flag offensive delete link more


OK Guys we each approach only seems to answer 50% of my question.

For the IntegratedProcessingUnitContainer, are you saying I should invoke it's main method from code and then use the space finder to get a handle on that space? See my question about what URL to use in the case of starting and embed space. Does the main method return?

From the spring side how do I deploy a PU to an embedded space started that way?

I'll experiment but I'd like to see the docs draw out a more complete example from one direction or the other or both. I think the docs assume previous space knowledge and that it would be obvious that you'd just do X, but as a newb I can guess experiment but I'd rather have it drawn out.

Both ideas move me forward in my understanding, thank you.

- Peace

djking gravatar imagedjking ( 2007-11-16 09:58:05 -0500 )edit

OK so I started a PU Container by calling


in a separate thread. As main does not return.

IJSpace space = (IJSpace) SpaceFinder.find("/./space"); Where "/./space" is the same URL as in the PU.xml returns the PU space. I can then take the Message written in the HellowWorld bean. I had commented out the take in the bean.

I'd feel more comfortable if I had a way to wait for the IntegratedProcessingUnitContainer to finish starting up, cause it feels like I'm setting up a race condition.

  • Peace
djking gravatar imagedjking ( 2007-11-16 10:37:04 -0500 )edit


I guess I'm missing something in what you're trying to achieve so I'll try to guess...

When you start the IntegratedContainer you get access to IJSpace by getting first the GigaSpace interface. For most cases working with the GigaSpace API is enough. If you need additional functionality of IJspace, you get it from the GigaSpace instance.

When working with pu.xml you are encouraged to rely on Spring's dependency injection mechanism. So, in order to get a GigaSpace instance, you should have your bean, lets call it myBean, defined in the pu.xml and have a method ready to inject the GigaSpace interface.

The hello world example of OpenSpaces under ${XAP_installation_dir}/examples/openspaces/ is such an example.

All the initialization is done synchronously in a single sequence where the space is instantiated first and than it's proxy is injected into your bean.

Is this what you were looking for?


nirpaz gravatar imagenirpaz ( 2007-11-16 13:21:00 -0500 )edit

Dave and I have been chatting off forum - his interest was to see how he could using the IntegratedContainer in his java code, and to understand how he could take a Spring app (in this case, already developed and running in an app server) and inject into it the necessary bits so he could talk to a pu running somewhere else. (And he wanted to try to run that PU in code where he controlled the main() )

I had a code sample that did the second thing, and talked him through the first bit ...


toby gravatar imagetoby ( 2007-11-16 14:11:04 -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


Asked: 2007-11-15 22:46:01 -0500

Seen: 9 times

Last updated: Nov 16 '07