cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Poetz <reinh...@apache.org>
Subject Re: [RT] OSGi based blocks
Date Wed, 15 Mar 2006 23:41:52 GMT
Daniel Fagerstrom wrote:

<snip/>

> Inter Block Communication
> =========================
> 
> The servlets (sitemaps) in the different blocks need to be able to call 
> each other. Also it simplifies reuse of blocks if one block can extend 
> another one (or rather that a servlets in one block can extend a servlet 
> in another one). This is achieved with the block protocol.
> 
> One way of thinking about the inter block communication is to consider 
> the servlet in the block to be embedded in an own container where the 
> the servlets of the other blocks are available through the servlet 
> context. This is the way I have implemented it, so other servlets can be 
> called through the getNamedDispatcher method of the servlet context, 
> with the block name as argument.
> 
> The implementation of calls to super blocks and polymorphism requires 
> the use of a call stack, see [8] for details.
> 
> Block properties are accessed as servlet config (and context) init 
> parameters.
> 
> In the OSGi implementation there is a BlockServlet that sets up the the 
> communication with other blocks and creates the context that the servlet 
> of the own block is executed within. A declaration of a BlockServlet 
> might look like:
> 
>   <scr:component name="cocoon.blockServlet2">
>     <scr:implementation 
> class="org.apache.cocoon.blocks.osgi.BlockServlet"/>
>     <scr:service>
>       <scr:provide interface="javax.servlet.Servlet"/>
>     </scr:service>
>     <scr:property name="path" value="/test2"/>
>     <scr:property name="attr" value="bar"/>
>     <scr:reference name="blockServlet"
>                    interface="javax.servlet.Servlet"
>                    target="(component.name=cocoon.servlet2)"/>
>     <scr:reference name="block1"
>                    interface="javax.servlet.Servlet"
>                    target="(component.name=cocoon.blockServlet1)"/>
>   </scr:component>

Do I understand correctly that every bundle can have such a component declaration?

A second question: The bundle provides the interface javax.servlet.Servlet. One 
of our goals is polymorphism. What's the plan to achieve this? My idea was 
having a declaration like

    <scr:component name="fancy-skin">
      <scr:implementation class="myCompany.FancySkinServlet"/>
      <scr:service>
        <scr:provide interface="myCompany.Skin"/>
      </scr:service>
      <scr:property name="path" value="/test3"/>
    </scr:component>

package myCompany;
public interface Skin extends javax.servlet.Servlet {
  ...
}

A block/bundle that requires my skin could have following declaration:

    <scr:component name="myApp">
      <scr:implementation
         class="org.apache.cocoon.blocks.osgi.BlockServlet"/>
      <scr:service>
        <scr:provide interface="javax.servlet.Servlet"/>
      </scr:service>
      <scr:property name="path" value="/test2"/>
      <scr:property name="attr" value="bar"/>
      <scr:reference name="blockServlet"
                     interface="javax.servlet.Servlet"
                     target="(component.name=cocoon.servlet2)"/>
      <scr:reference name="skin"
                     interface="myCompany.FancySkinServlet"
                     target="(component.name=fancy-skin)"/>
   </scr:component>


The target could be overriden by the configuration service. Do we get 
polymorphism this way based on the interface of references?


-- 
Reinhard Pötz           Independent Consultant, Trainer & (IT)-Coach 

{Software Engineering, Open Source, Web Applications, Apache Cocoon}

                                        web(log): http://www.poetz.cc
--------------------------------------------------------------------

	
		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de

Mime
View raw message