Re: [jira] Commented: (SLING-957) JCR EventListeners are not easy to create or write
Hi, Ian Boston schrieb: On 6 May 2009, at 20:23, Felix Meschberger wrote: I have to admit, that I have my issues with this patch, too. First it introduces new API and second it exposes a Jackrabbit internal feature (SynchronousEventListener) which is AFAICT not intended for general use. May I ask you, what your use case for the SynchronousEventListener is ? We need to get access to items before they are saved to a) set additional node properties b) apply some rules on node properties. Hmm, not knowing the exact details, I would assume that in your synchronous listener you have a JCR session, which you use to update the content. So it would be something like: User Session US modifies content Synchronous Listener gets notified Synchronous Listener Session SLS modifies content again Correct. Now, I don't completely understand what the advantage of using a synchronous listener really is - or is it for the Transaction Context you are referring to below ? So I would also prefer a solution, which the standard OSGi Event Admin service: Using service registration properties EventHandler services may limit the events they receive. To support Jackrabbit SynchronousEventListeners, the OSGi EventAdmin bridge (bridging JCR events to OSGi events) may use synchronous event delivery (EventAdmin.sendEvent). For normal EventListeners, the regular asynchronous event delivery (EventAdmin.postEvent) is used. WDYT ? yes, that might work for us, I assume by synchronous they are on the same thread No, you cannot assume that you are running in the same thread, the save assumption as per the OSGi EventAdmin spüec is, that it may be the same thread must is not required to be. But you may assume that the listener is called synchronously. and share the same Transaction context ? I am not sure, what exactly you mean here. Is the listeners session associated with the Transaction context while updating more properties ? Now, the question is of course, how the listener session gets to the Transaction context to associate with. If it is a ThreadLocal property, you may be lost with EventAdmin. Maybe Jackrabbit SynchronouseEventListener is so special, that we expose special API from the jackrabbit-server bundle to support such synchronous listeners. Regards Felix
Re: Registering Servlets and Filters
Hi, Andreas Kollegger schrieb: With the current Servlet Resolution wiki page out-of-sync, does anyone have a bare-bones example of registering a servlet and/or filter with the Sling framework? It looks like a bundle just has to register a javax.servlet.Servlet service with the proper sling properties for it to get picked up. I've tried a simple OSGi Activator, but can't seem to get it to work. Example BundleActivator.start... public void start( BundleContext bc ) throws Exception { Dictionary props = new Properties(); props.put(sling.servlet.paths, /myservlet/html, /myservlet/txt); bc.registerService( javax.servlet.Servlet.class.getName(), new MyServlet(), props ); } This is almost correct. The property value is either a single string or an array of strings. So your example should really be: props.put(sling.servlet.paths, new String[]{ /myservlet/html, /myservlet/txt }); But since you registered with absolute paths, the resource types must also be absolute. Thus your example (with the fix for the property value) should work for .html and .txt requests to resources whose resource type /myservlet. If your resource types are relative -- e.g. myservlet -- you should register with relative paths as in : props.put(sling.servlet.paths, new String[]{ myservlet/html, myservlet/txt }); or better yet to register with two properties, one for the resource type and for the extensions supported: props.put(sling.servlet.resourceTypes, myservlet); props.put(sling.servlet.extensions, new String[]{html,txt}); HTH Regards Felix Thanks for any guidance, Andreas
Re: Use cases for bundle-based Jackrabbit customizations?
2009/5/6 Bertrand Delacretaz bdelacre...@apache.org: In an ideal world, I think it should be possible to use separate bundles to provide classes for all elements of the repository.xml configuration that have a class attribute. Hear, hear! [...] Could people give a quick description of their use cases that require customizing these things? Please also briefly indicate if/how that works now. I need some custom AccessManager logic, therefore I created the PluggableAccessManager, see SLING-880 [1]. This patch provides an interface that can be implemented by custom bundles. The interface is really a simplified version of AccessManager. This again was inspired by a tip from Rory Douglas [2], who pointed me to PluggableDefaultLoginModule. The PluggableAccessManager works for me, but being able to plugin a real Jackrabbit AccessManager, would sure be nice. It would also be useful if DefaultAccessManager could be exported, as it is much easier to override certain methods in that, than to implement the interface from scratch. [1] https://issues.apache.org/jira/browse/SLING-880 [2] http://markmail.org/thread/wlqm3yjpbyokwcvy -- Vidar S. Ramdal vi...@idium.no - http://www.idium.no Akersgata 16, N-0158 Oslo, Norway +47 21 531941, ext 2070
Re: [Vote] Release Apache Sling 5
+1 Carsten -- Carsten Ziegeler cziege...@apache.org
Re: [jira] Commented: (SLING-957) JCR EventListeners are not easy to create or write
On 7 May 2009, at 07:55, Felix Meschberger wrote: Hi, Ian Boston schrieb: On 6 May 2009, at 20:23, Felix Meschberger wrote: I have to admit, that I have my issues with this patch, too. First it introduces new API and second it exposes a Jackrabbit internal feature (SynchronousEventListener) which is AFAICT not intended for general use. May I ask you, what your use case for the SynchronousEventListener is ? We need to get access to items before they are saved to a) set additional node properties b) apply some rules on node properties. Hmm, not knowing the exact details, I would assume that in your synchronous listener you have a JCR session, which you use to update the content. So it would be something like: User Session US modifies content Synchronous Listener gets notified Synchronous Listener Session SLS modifies content again yes, but in some cases there is more. Correct. Now, I don't completely understand what the advantage of using a synchronous listener really is - or is it for the Transaction Context you are referring to below ? I'll add a some context. We have bound a JTA transaction to the JCR session (using the XASession methods) That transaction is committed at the end of the request cycle. The JTA transaction is also bound to a JPA Entity Manager so that all modifications are committed at once... or rolled back at once. Some, not all, of the Synchronous listeners update relational indexes stored in a traditional RDBMS via JPA and used for reporting type queries that are not possible through the JCR Query mechanism. Important, but not directly relevant We run in a cluster and with the JTA transaction bound to the session the volume of journal entries flowing through the cluster node is greatly reduces. In short we see one large journal entry per request cycle and a number of lock-unlock events. This was observed pre-sling on JR14 after patching the Journal writers to filter out blank events. For us... this had a large impact on back end database load. I haven't re-tested on Sling with JR15 (yet), I believe there is an alternative fix already in place for the empty event issue, but AFAICT binding the a transaction to the request will have the same effect (as well as mitigating failures part way through the request cycle) To recap: 1. We events because we want to monitor all nodes for modifications to certain properties, potentially changing those properties and vetoing them. 2. We also generate relational indexes of node properties in JPA managed tables so that views with multi table joins can be generated. 3. We use synchronous events because we need to bind into a single transaction over both JCR and JPA, and potentially roll back the entire transaction. Now, the approach is a hack that works with what is possible, if there is a more mainstream way of achieving the same results then I am open to anything. Ian So I would also prefer a solution, which the standard OSGi Event Admin service: Using service registration properties EventHandler services may limit the events they receive. To support Jackrabbit SynchronousEventListeners, the OSGi EventAdmin bridge (bridging JCR events to OSGi events) may use synchronous event delivery (EventAdmin.sendEvent). For normal EventListeners, the regular asynchronous event delivery (EventAdmin.postEvent) is used. WDYT ? yes, that might work for us, I assume by synchronous they are on the same thread No, you cannot assume that you are running in the same thread, the save assumption as per the OSGi EventAdmin spüec is, that it may be the same thread must is not required to be. But you may assume that the listener is called synchronously. and share the same Transaction context ? I am not sure, what exactly you mean here. Is the listeners session associated with the Transaction context while updating more properties ? Now, the question is of course, how the listener session gets to the Transaction context to associate with. If it is a ThreadLocal property, you may be lost with EventAdmin. Maybe Jackrabbit SynchronouseEventListener is so special, that we expose special API from the jackrabbit-server bundle to support such synchronous listeners. Regards Felix
Re: Use cases for bundle-based Jackrabbit customizations?
On Wed, May 6, 2009 at 2:49 PM, Ian Boston i...@tfd.co.uk wrote: At the moment we (Sakai) would might want to customze LoginModule and WorkspaceAccessmanager and need to customize SecurityManager so that we can get a custom DefaultAccessManager. ...At the moment, we have a big patch on the jackrabbit-server bundle, which IMHO is not sustainable. I think this might really be an issue for Jackrabbit rather than Sling. Happy to create a patch if it would help explain the detail I agree that this is more an issue for Jackrabbit in the end, but as several people seemed to have issues with that in Sling I thought here might be a good place to collect requirements. Creating a patch might be a good idea - even if it's supposed to go into Jackrabbit eventually, I think clarifying the issues here would be good. -Bertrand
Re: Use cases for bundle-based Jackrabbit customizations?
Ok will do, For Sling I need to do it against JR15, we have done this already in the jackrabbit-server bundle, ideally the extension mechanism should go into JR so that will patches against the 1.x branch and trunk. I haven't had a chance to see where trunk has gone with 20, but will do. Ian On 7 May 2009, at 10:49, Bertrand Delacretaz wrote: Creating a patch might be a good idea - even if it's supposed to go into Jackrabbit eventually, I think clarifying the issues here would be good.
Re: Use cases for bundle-based Jackrabbit customizations?
Hi, On Wed, May 6, 2009 at 11:33 AM, Bertrand Delacretaz bdelacre...@apache.org wrote: I'm trying to get an overview of the current issues related to customizing an embedded Jackrabbit repository using Sling bundles. Note that the current Jackrabbit configuration mechanism requires direct access to all the *implementation* classes configured in the repository.xml file. I'm not sure how this could best be made to work with the cross-bundle class loading restrictions in an OSGi environment. There's an ongoing effort in Jackrabbit to make the configuration handling more flexible (JCR-1438), with the ultimate goal of being able to configure Jackrabbit using OSGi services or an IoC container. I've already been able to implement parts of the issue (see the related commits in Jackrabbit), but there's still quite a lot of work remaining with the more complex configuration entries. BR, Jukka Zitting
Building trunk
Hi, I am trying to build trunk after the recent release and version increment. Before doing this I zapped ~/.m2/repository/org/apache/sling as a precaution, but I am seeing quite a variety of missing artifacts versions eg 2.0.4-incubator 5-incubator etc I suspect, if no one is seeing the same problems they might have the old artifacts in their local maven repo. Should these all be 6-incubator-SNAPSHOT and 2.0.5-incubator-SNAPSHOT everywhere or should there be a mixture ? I have a half a patch done but thought I should check. Ian
Re: Building trunk
:), Ignore me, I need to pull the appropriate tag and build locally while waiting for the release. Ian On 7 May 2009, at 12:07, Ian Boston wrote: Hi, I am trying to build trunk after the recent release and version increment. Before doing this I zapped ~/.m2/repository/org/apache/sling as a precaution, but I am seeing quite a variety of missing artifacts versions eg 2.0.4-incubator 5-incubator etc I suspect, if no one is seeing the same problems they might have the old artifacts in their local maven repo. Should these all be 6-incubator-SNAPSHOT and 2.0.5-incubator- SNAPSHOT everywhere or should there be a mixture ? I have a half a patch done but thought I should check. Ian
Re: Use cases for bundle-based Jackrabbit customizations?
On Thu, May 7, 2009 at 12:46 PM, Jukka Zitting jukka.zitt...@gmail.com wrote: ...On Wed, May 6, 2009 at 11:33 AM, Bertrand Delacretaz bdelacre...@apache.org wrote: I'm trying to get an overview of the current issues related to customizing an embedded Jackrabbit repository using Sling bundles. Note that the current Jackrabbit configuration mechanism requires direct access to all the *implementation* classes configured in the repository.xml file. I'm not sure how this could best be made to work with the cross-bundle class loading restrictions in an OSGi environment... One way that should work (didn't work before the recent upgrade of the Felix framework) is to provide the customization classes in fragment bundles that are attached to the jackrabbit server bundles. This makes those classes available to that bundle exactly as if they were part of the bundle. Another option is to use dynamic imports in the jackrabbit server bundle, and have the customization bundles export the implementation classes. Both the above solutions are suboptimal, but should allow Jackrabbit extensions to come from different bundles. I've had a look at https://issues.apache.org/jira/browse/JCR-1438 which is about using factories to instantiate the pluggable Jackrabbit components, and I'm wondering if a central customizing method would help, something like: interface Customizer { T getCustomizableComponentInstance( Class T componentType, MapString, String options } Where standard Jackrabbit would use Class.forName() based on a property in the options, and in an OSGi environment you'd plugin a Customizer that grabs the appropriate OSGi service based on the type T and options. Not sure if Jackrabbit requires Java 1.5 already, but it not the idea can also work without generics. -Bertrand
Re: Building trunk
Ian Boston wrote: :), Ignore me, I need to pull the appropriate tag and build locally while waiting for the release. Actually this was a good hint as I forgot to commit the updated poms yesterday evening :) Everything should point now to the next parent pom snapshot and allow a build without locally building something before again. Thanks Carsten Ian On 7 May 2009, at 12:07, Ian Boston wrote: Hi, I am trying to build trunk after the recent release and version increment. Before doing this I zapped ~/.m2/repository/org/apache/sling as a precaution, but I am seeing quite a variety of missing artifacts versions eg 2.0.4-incubator 5-incubator etc I suspect, if no one is seeing the same problems they might have the old artifacts in their local maven repo. Should these all be 6-incubator-SNAPSHOT and 2.0.5-incubator-SNAPSHOT everywhere or should there be a mixture ? I have a half a patch done but thought I should check. Ian -- Carsten Ziegeler cziege...@apache.org
Re: Building trunk
Obviously I was wrong of course, trunk is not buildable - this will be the case until we can make the release available in a public repository (and this will take at least another 4 days - but with the weekend inbetween this might be a little bit longer). Carsten -- Carsten Ziegeler cziege...@apache.org
Re: Building trunk
At the moment I am doing svn co http://svn.apache.org/repos/asf/incubator/sling/tags/sling-5-incubator-source-release cd sling-5-incubator-source-release mvn clean install Which places the necessary artifacts into the local repo so trunk still builds. HTH, anyone who zapped their repo like me. Ian On 7 May 2009, at 15:10, Carsten Ziegeler wrote: Obviously I was wrong of course, trunk is not buildable - this will be the case until we can make the release available in a public repository (and this will take at least another 4 days - but with the weekend inbetween this might be a little bit longer). Carsten -- Carsten Ziegeler cziege...@apache.org
Re: Desactivate header authorization in POSTS
hi Daniel, You might want to login first by going to /system/sling/login.html (IIRC). If you want to allow anonymous POST requests, you might want to change the user name of the anonymous user in the repository configuration. Goto to /system/sling/configMgr and select the Repository Configuration with the UUID-like part in the name and change the anonymous user name to something else (value does not matter as long as it is not anonymous). Alternatively you may change the value of the anonymousId parameter of the LoginModule configuration in the ${sling.home}/jackrabbit/repository.xml file to something else. The reason for this is, that by default Jackrabbit allows anyone to write to the repository except the user designated as the anonymous user in the repository.xml configuration file. Hope this helps. Regards Felix Daniel, de la Cuesta Navarrete schrieb: Hi, By default, if you want to create a resource in Sling you have to include the authorization headers in the POST request: http://admin:ad...@localhost:/content/mycontent/* How can desactivate this? I have my own authorization filter and I want to allow anonimous POSTs. Thank you.
file upload question
hi all, Re the file upload example at http://dev.day.com/microsling/content/blogs/main/fileuploadsinsling.html, code snippet # 3: how would you extract the original filename there? I tried it to parse it with commons fileupload, but this throws an IllegalStateException Request Data has already been read . Thanks, Juerg
Re: file upload question
Hi Juerg, I think SlingPostServlet has already parsed the file. For that reason you get that exception. That manner Sling allow you to handle the file like a simple request parameter. So, if you want to do something diferent with it, like save it in a other location in your file system, you could make: byte [] data = request.getParameter(data).getBytes(ISO-8859-1); if(data.length0){ File file = new File(fileFolder, fileName); FileOutputStream fout = new FileOutputStream(file); fout.write(data); } Sorry if I'm wrong. Good luck! 2009/5/7 Juerg Meier j...@proxymit.net hi all, Re the file upload example at http://dev.day.com/microsling/content/blogs/main/fileuploadsinsling.html, code snippet # 3: how would you extract the original filename there? I tried it to parse it with commons fileupload, but this throws an IllegalStateException Request Data has already been read . Thanks, Juerg
Re: Registering Servlets and Filters
Thanks to both Felix and Bertrand, servlets and filters are both now working. Now, I'm moving on to deploying sitemesh as a filter. An initial challenge is that SiteMesh attempts to load configuration files using the ServletContext, which doesn't seem to search the bundle that loaded the filter. Is there a way to register search paths for the shared ServletContext? Otherwise I'll look into hacking SiteMesh to use alternative configuration methods. Thanks, Andreas On May 7, 2009, at 3:02 AM, Felix Meschberger wrote: Hi, Andreas Kollegger schrieb: With the current Servlet Resolution wiki page out-of-sync, does anyone have a bare-bones example of registering a servlet and/or filter with the Sling framework? It looks like a bundle just has to register a javax.servlet.Servlet service with the proper sling properties for it to get picked up. I've tried a simple OSGi Activator, but can't seem to get it to work. Example BundleActivator.start... public void start( BundleContext bc ) throws Exception { Dictionary props = new Properties(); props.put(sling.servlet.paths, /myservlet/html, /myservlet/ txt); bc.registerService( javax.servlet.Servlet.class.getName(), new MyServlet(), props ); } This is almost correct. The property value is either a single string or an array of strings. So your example should really be: props.put(sling.servlet.paths, new String[]{ /myservlet/html, /myservlet/txt }); But since you registered with absolute paths, the resource types must also be absolute. Thus your example (with the fix for the property value) should work for .html and .txt requests to resources whose resource type /myservlet. If your resource types are relative -- e.g. myservlet -- you should register with relative paths as in : props.put(sling.servlet.paths, new String[]{ myservlet/html, myservlet/txt }); or better yet to register with two properties, one for the resource type and for the extensions supported: props.put(sling.servlet.resourceTypes, myservlet); props.put(sling.servlet.extensions, new String[]{html,txt}); HTH Regards Felix Thanks for any guidance, Andreas