You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hivemind.apache.org by Colin Taylor <co...@gmail.com> on 2005/12/06 04:44:09 UTC

setting properties on an interceptor

Hopefully this is pretty straightfoward but proven frustratingly opaque to
me so far...

Can someone explain why cant I set a property on an interceptor?


    <service-point id="DomainServices" interface="my.DomainServices">
        <invoke-factory>
            <construct class="my.DomainServicesImpl">
            </construct>
        </invoke-factory>

        <interceptor service-id="opensme.entityext.TransactionInterceptor">
            <set-property name="timeout" value="600"/>  // DONT WORK
        </interceptor>
    </service-point>

Likewise set, set-object generates errors. Whats the Hivemind way of doing
this simple bean config?

cheers
CT.

RE: setting properties on an interceptor

Posted by James Carman <ja...@carmanconsulting.com>.
Colin,

It looks like you should do:

<interceptor service-id="TransactionInterceptor"> 
  <timeout value=”1000 (or whatever you want it to be)” />
</interceptor>

But, I'm not convinced that you're schema is set up correctly.  You're not
adding the timeout value to the parameters.  You might try something like
this:

<parameters-schema> 
  <element name="timeout">
    <attribute name="value" translator="int"/>
  </element>
  <rules>
    <push-attribute attribute="value"/>
    <invoke-parent method="addElement"/>
  </rules>
</parameters-schema>

Now, this is off the top of my head, so it might not work as is.  I'm just
trying to nudge you in the right direction.  But, based on what I see, this
seems like it will work.  Good luck.  Let us know if we can be of any more
help.

James

________________________________________
From: Colin Taylor [mailto:colin.taylor@gmail.com] 
Sent: Saturday, December 10, 2005 8:48 PM
To: hivemind-user@jakarta.apache.org
Subject: Re: setting properties on an interceptor

Thanks for you answer, Knut.

Unforunately still havent reached nirvana on this issue or on Hivemind
service configuration in general.
Having looked at the well, complexity of schemas and contributions, I cant
help but wonder is that really necessary for this use case? I just want to
have a default timeout set up from my Transaction Interceptor and have the
ability to override on a per service basis. I started mapping this out with
schemas and contributions and was starting to clock up the lines of xml.
Futhermore I felt like I was programming in xml, which is never a good
feeling as its verbosity and magic mappings start to obscure intent. 

My [still incomplete] attempt follows. If anyone can shed further light I'd
appreciate it, I truly hope I must be missing something. 
  

  <service-point id="TransactionInterceptor" interface="
org.apache.hivemind.ServiceInterceptorFactory">
        <invoke-factory model="primitive">
            <construct class=TransactionInterceptorFactory">
                <set-service property="factory" service-id="
hivemind.ClassFactory"/>
                <set-configuration configuration-id="TransactionDefaults" />
            </construct>
        </invoke-factory>
        <parameters-schema> 

            <element name="timeout">
                <attribute name="value" translator="int"/>
            </element>
        </parameters-schema>
    </service-point>

    <configuration-point id="TransactionDefaults" occurs="1">
        Configuration that defines default behavior of the
TransactionService.
        It must be contributed exactly once in the whole application. 

        <schema>
            <element name="defaults">
                <element name="timeout">
                    <attribute name="value"/>
                </element> 
            </element>
        </schema>
    </configuration-point>


    <contribution configuration-id="TransactionDefaults">
        <defaults>
            <timeout value="300"/> 
        </defaults>
    </contribution>

    <service-point id="MyServices" interface="com.MyServices">
        <invoke-factory>
            <construct class=" com.MyServicesImpl">
            </construct>
        </invoke-factory>
        <interceptor service-id="hivemind.LoggingInterceptor"/>
        <interceptor service-id="TransactionInterceptor"> 
?? what goes here???
        </interceptor>
    </service-point>



---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org


Re: setting properties on an interceptor

Posted by Colin Taylor <co...@gmail.com>.
Thanks for you answer, Knut.

Unforunately still havent reached nirvana on this issue or on Hivemind
service configuration in general.
Having looked at the well, complexity of schemas and contributions, I cant
help but wonder is that really necessary for this use case? I just want to
have a default timeout set up from my Transaction Interceptor and have the
ability to override on a per service basis. I started mapping this out with
schemas and contributions and was starting to clock up the lines of xml.
Futhermore I felt like I was programming in xml, which is never a good
feeling as its verbosity and magic mappings start to obscure intent.

My [still incomplete] attempt follows. If anyone can shed further light I'd
appreciate it, I truly hope I must be missing something.


  <service-point id="TransactionInterceptor" interface="
org.apache.hivemind.ServiceInterceptorFactory">
        <invoke-factory model="primitive">
            <construct class=TransactionInterceptorFactory">
                <set-service property="factory" service-id="
hivemind.ClassFactory"/>
                <set-configuration configuration-id="TransactionDefaults" />
            </construct>
        </invoke-factory>
        <parameters-schema>

            <element name="timeout">
                <attribute name="value" translator="int"/>
            </element>
        </parameters-schema>
    </service-point>

    <configuration-point id="TransactionDefaults" occurs="1">
        Configuration that defines default behavior of the
TransactionService.
        It must be contributed exactly once in the whole application.

        <schema>
            <element name="defaults">
                <element name="timeout">
                    <attribute name="value"/>
                </element>
            </element>
        </schema>
    </configuration-point>


    <contribution configuration-id="TransactionDefaults">
        <defaults>
            <timeout value="300"/>
        </defaults>
    </contribution>

    <service-point id="MyServices" interface="com.MyServices">
        <invoke-factory>
            <construct class="com.MyServicesImpl">
            </construct>
        </invoke-factory>
        <interceptor service-id="hivemind.LoggingInterceptor"/>
        <interceptor service-id="TransactionInterceptor">
?? what goes here???
        </interceptor>
    </service-point>

Re: setting properties on an interceptor

Posted by Knut Wannheden <kn...@gmail.com>.
Colin,

I don't know if that's just a typo in your message but the
"service-id" attribute of your <interceptor> element has a leading
blank.

For the <set-property> (or <set-object>) elements to work inside the
<interceptor> element, they must be accepted by your interceptor
factory "opensme.entityext.TransactionInterceptor". IOW, the
interceptor factory needs to specify these elements in its schema.

If you don't want to implement your own interceptor factory you can
take a look at the general MethodInterceptorFactory in the
"hivemind.lib" module (see
http://jakarta.apache.org/hivemind/hivemind-lib/MethodInterceptorFactory.html).
It lets you provide the implementation of the intercepter as any
object (e.g. a service).

HTH,

--knut

On 12/6/05, Colin Taylor <co...@gmail.com> wrote:
> Hopefully this is pretty straightfoward but proven frustratingly opaque to
> me so far...
>
> Can someone explain why cant I set a property on an interceptor?
>
>
>     <service-point id="DomainServices" interface=" my.DomainServices">
>         <invoke-factory>
>             <construct class="my.DomainServicesImpl">
>             </construct>
>         </invoke-factory>
>
>         <interceptor service-id="
> opensme.entityext.TransactionInterceptor">
>             <set-property name="timeout" value="600"/>  // DONT WORK
>         </interceptor>
>     </service-point>
>
> Likewise set, set-object generates errors. Whats the Hivemind way of doing
> this simple bean config?
>
> cheers
> CT.
>
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-user-help@jakarta.apache.org