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
Hi,

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
ComponentLocator
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:

*TapestryConstants.java*
static final Collection<String> TAPESTRY_PAGES_CLASSES = new
ArrayList<String>(3);
 static final Collection<String> TAPESTRY_COMPONENTS_CLASSES = new
ArrayList<String>(44);
 static final Collection<String> TAPESTRY_MIXINS_CLASSES = new
ArrayList<String>(70);

 static final String ROOT_PACKAGE = "org.apache.tapestry5.corelib";
 static final String PATH_PREFIX= "core";
 static {
  // Pages
  TAPESTRY_PAGES_CLASSES.add("org.apache.tapestry5.corelib.pages.ExceptionReport");
   .............. and more

*2. controlledPackageNames*

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

 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(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM,
"org.extwind.osgi.tapestry");
dic.put("filter-name", "app");

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

Get source code of tapestry-osgi from
http://extwind.googlecode.com/svn/trunk/Tapestry-OSGi/

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.


Regards,

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

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