You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Miguel Angel Hernández <mi...@gmail.com> on 2007/03/14 20:22:09 UTC

Hivemind Registry and Spring

Hi all,

How can I expose the Hivemind Registry in a spring bean?

thanks

Miguel

Re: Hivemind Registry and Spring

Posted by Miguel Angel Hernández <mi...@gmail.com>.
Hi,

I managed to expose the Registry to Spring via a custom
ApplicationInitializer instead of the SpringApplicationInitializer:

<service-point id="SpringApplicationInitializer"
    interface="org.apache.tapestry.services.ApplicationInitializer"
    visibility="private">
    <invoke-factory>
      <construct
        class="tapestry.services.CustomSpringApplicatonInitializer">
        <set-object property="beanFactoryHolder"
          value="service:hivemind.lib.DefaultSpringBeanFactoryHolder" />
        <set-service property="appGlobals" service-id="
tapestry.globals.ApplicationGlobals" />
      </construct>
    </invoke-factory>
  </service-point>

And then inject the tapestry globals to it.

Then in the Custom initializer. I obtain the registry from the globals with
this name "org.apache.tapestry.Registry:" + <ApplictationName>
I obtain the application name from the Sepecification, but really Hivemind
uses the name of the servlet, which is'nt always the same as the
Application, so this isn't always a safe call, here is the code:

public void initialize(HttpServlet servlet) {
        ServletContext context = servlet.getServletContext();
        WebApplicationContext webappctx = (WebApplicationContext) context
                .getAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        if (webappctx == null) {
            throw new ApplicationRuntimeException("Spring Context is NULL");
        }
        RegistryBeanFactory rbf = new RegistryBeanFactory(webappctx);

        String regAttrName = "org.apache.tapestry.Registry:" +
appGlobals.getSpecification().getName();;
        rbf.setRegistry((Registry)
getAppGlobals().getWebContext().getAttribute(
                regAttrName));
        beanFactoryHolder.setBeanFactory(rbf);
    }

Then as the RegistryBeanFactory, which now holds a reference to the
registry, builds a bean I can inject the right service onto it.

But what I really want to inject into the Spring Bean is an StateObject...
but when I look for it into the Registry, like this
getRegistry().getConfigurationAsMap("tapestry.state.ApplicationObjects
").get("object-name"))
I get an instance of StateObjectContribution :(, instead of an object of my
StateObject's class.

I there anyway of stripping the StateObjectContribution to obtain the right
object?

please help me I'm really puzzled with this one.

cheers,

miguel



On 3/15/07, Jesse Kuhnert <jk...@gmail.com> wrote:
>
> You can't, unless you control it through your own ApplicationServlet
> implementation. (or know the context parameter it is stored in, which
> I don't remember off hand as I've never used it )
>
> On 3/14/07, Miguel Angel Hernández <mi...@gmail.com> wrote:
> > Hi all,
> >
> > How can I expose the Hivemind Registry in a spring bean?
> >
> > thanks
> >
> > Miguel
> >
>
>
> --
> Jesse Kuhnert
> Tapestry/Dojo team member/developer
>
> Open source based consulting work centered around
> dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Hivemind Registry and Spring

Posted by Jesse Kuhnert <jk...@gmail.com>.
You can't, unless you control it through your own ApplicationServlet
implementation. (or know the context parameter it is stored in, which
I don't remember off hand as I've never used it )

On 3/14/07, Miguel Angel Hernández <mi...@gmail.com> wrote:
> Hi all,
>
> How can I expose the Hivemind Registry in a spring bean?
>
> thanks
>
> Miguel
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org