tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From 蓝天白云 <donf.y...@gmail.com>
Subject Problems with developing Tapestry 5 on osgi environment
Date Mon, 04 May 2009 17:09:27 GMT

I'm developing Tapestry 5 base on osgi environment recently and it's almost
done at this time but 3 problems:

First, I have to show you how tapestry-osgi works in shortly:
tapestry-osgi is suported by 2 bundles:
*org.extwind.osgi.http.filter*  - Register FilterService as osgi service,
like HttpService
*org.extwind.osgi.tapestry*  -  Register TapestryFilter by FilterService,
and register ComponentService as osgi service.

The ComponentService is used to register/unregister a root package of module
(bundle) into Tapestry dynamically
public interface ComponentService {
    public void registerPackage(String packageName);
    public void unregisterPackage(String packageName);

Override ComponentClassResolver to finding page/component/minix class and
mapping page/component/minix name, to locate class and resources, need a
public interface ComponentLocatorRegistry {
    public void register(String packageName, ComponentLocator pageLocator);
    public void unregister(String packageName);
Every component bundles which would like to register a package into tapestry
will be associated to a ComponentLocator, so tapestry can find resources
from them.

 The global AppModule is located in bundle org.extwind.osgi.tapestry to
override services.

*1. case-insensitive*

As we know, java is a case-sensitive world,, I really can't make sense why
tapestry built with case-insensitive.
But it's not a major problem with osgi, I just per-loading tapestry's
componets at the time when bundle startup, like following:

static final Collection<String> TAPESTRY_PAGES_CLASSES = new
 static final Collection<String> TAPESTRY_COMPONENTS_CLASSES = new
 static final Collection<String> TAPESTRY_MIXINS_CLASSES = new

 static final String ROOT_PACKAGE = "org.apache.tapestry5.corelib";
 static final String PATH_PREFIX= "core";
 static {
  // Pages
   .............. and more

*2. controlledPackageNames*

I can't remove packages from controlledPackageNames when component bundles
stop until get any supported method from ComponentInstantiatorSource such

 void removePackage(String packageName);

*3. Service binding*
 This is a major problem with osgi.
I just researched how tapestry's service binding, if any chance to provide a
way to add modules in Registry or something else like following:

addModules(Collection<ModuleDef> moduleDefs, ...)

Registry can be hold in *org.extwind.osgi.tapestry* to accept modules
registered by components bundles dynamically, through override
TapestryFilter.init(Registry) like following:

FilterService filterService = (FilterService) context.getService(reference);
Dictionary<String, String> dic = new Hashtable<String, String>();
dic.put("filter-name", "app");

filterService.registerFilter("/*", new TapestryFilter() {
    protected void init(Registry registry) throws ServletException {
     ComponentLocatorRegistry componentLocatorRegistry =
     pageServiceRegistration =
       new ComponentServiceListener(componentLocatorRegistry, registry),
   }, dic, null);
   ...... and more

Get source code of tapestry-osgi from

And also Tomcat-OSGi is on programming if any interestings to you,
documents are all in Chinese and translating to English.

Appreciates for any suggestions.


Donf Yang
To be surprised,to wonder,is to begin to understand.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message