You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by Christopher Cheng <ch...@gmail.com> on 2011/07/17 19:32:04 UTC
how to make SessionFactory spring friendly?
This is the normal procedure to obtain a session with opencmis api
SessionFactory f = SessionFactoryImpl.newInstance();
Map<String, String> params = new HashMap<String, String>();
params.put(SessionParameter.USER, "admin");
params.put(SessionParameter.PASSWORD, "admin");
params.put(SessionParameter.ATOMPUB_URL, "
http://localhost:8080/alfresco/service/cmis");
params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
params.put(SessionParameter.REPOSITORY_ID,
f.getRepositories(params).get(0).getId());
Session s = f.createSession(params);
Is there any component in chemistry to make this more spring friendly and
poolable like Hibernate or ActiveMQ session factories?
Re: how to make SessionFactory spring friendly?
Posted by Florian Müller <fl...@alfresco.com>.
You need a session object per user. Session objects are bound to a
repository AND a user.
If all session parameters are fixed (URL, username/password, repository
id, etc.) then you can create a session object with Spring and a
SessionFactory bean. (Look for "factory-bean" and "factory-method" in
the Spring documentation.)
If there is anything dynamic (for example the username/password or the
repository id) then you have to create your own small bean that handles
those details for you.
- Florian
On 17/07/2011 19:05, Christopher Cheng wrote:
> so you mean one single session could be used to serve all requests for a
> single webapp?
>
> I am using Struts2 as the frontend, Alfresco as the backend for content
> repository, chemistry opencmis to get documents from one of the spaces
> (folders)
>
> To simplify development, I am trying to get opencmis session directly from
> spring with WebApplicationContext in freemarker/struts2 actions/jsp, just
> want to make sure that I can simply get an opencmis session instead of
> sessionFactory from spring for all requests and for all users
>
> On Mon, Jul 18, 2011 at 1:51 AM, Florian Müller <
> florian.mueller@alfresco.com> wrote:
>
>> Hi,
>>
>> See [1] how to create a SessionFactory object with Spring.
>> Session objects shouldn't be pooled. One session object should serve all
>> requests for a specific user.
>> OpenCMIS is thread-safe. So just create one object and reuse it wherever
>> possible. In this way all threads share one cache which much more efficient
>> than pooling.
>>
>>
>> - Florian
>>
>>
>>
>> [1]
>> http://static.springsource.org/spring/docs/2.0.x/reference/beans.html#beans-factory-class-static-factory-method
>>
>>
>> On 17/07/2011 18:32, Christopher Cheng wrote:
>>> This is the normal procedure to obtain a session with opencmis api
>>>
>>> SessionFactory f = SessionFactoryImpl.newInstance();
>>> Map<String, String> params = new HashMap<String, String>();
>>> params.put(SessionParameter.USER, "admin");
>>> params.put(SessionParameter.PASSWORD, "admin");
>>> params.put(SessionParameter.ATOMPUB_URL, "
>>> http://localhost:8080/alfresco/service/cmis");
>>> params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
>>> params.put(SessionParameter.REPOSITORY_ID,
>>> f.getRepositories(params).get(0).getId());
>>> Session s = f.createSession(params);
>>>
>>> Is there any component in chemistry to make this more spring friendly and
>>> poolable like Hibernate or ActiveMQ session factories?
>>>
>>
>>
>
Re: how to make SessionFactory spring friendly?
Posted by Christopher Cheng <ch...@gmail.com>.
so you mean one single session could be used to serve all requests for a
single webapp?
I am using Struts2 as the frontend, Alfresco as the backend for content
repository, chemistry opencmis to get documents from one of the spaces
(folders)
To simplify development, I am trying to get opencmis session directly from
spring with WebApplicationContext in freemarker/struts2 actions/jsp, just
want to make sure that I can simply get an opencmis session instead of
sessionFactory from spring for all requests and for all users
On Mon, Jul 18, 2011 at 1:51 AM, Florian Müller <
florian.mueller@alfresco.com> wrote:
> Hi,
>
> See [1] how to create a SessionFactory object with Spring.
> Session objects shouldn't be pooled. One session object should serve all
> requests for a specific user.
> OpenCMIS is thread-safe. So just create one object and reuse it wherever
> possible. In this way all threads share one cache which much more efficient
> than pooling.
>
>
> - Florian
>
>
>
> [1]
> http://static.springsource.org/spring/docs/2.0.x/reference/beans.html#beans-factory-class-static-factory-method
>
>
> On 17/07/2011 18:32, Christopher Cheng wrote:
> > This is the normal procedure to obtain a session with opencmis api
> >
> > SessionFactory f = SessionFactoryImpl.newInstance();
> > Map<String, String> params = new HashMap<String, String>();
> > params.put(SessionParameter.USER, "admin");
> > params.put(SessionParameter.PASSWORD, "admin");
> > params.put(SessionParameter.ATOMPUB_URL, "
> > http://localhost:8080/alfresco/service/cmis");
> > params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
> > params.put(SessionParameter.REPOSITORY_ID,
> > f.getRepositories(params).get(0).getId());
> > Session s = f.createSession(params);
> >
> > Is there any component in chemistry to make this more spring friendly and
> > poolable like Hibernate or ActiveMQ session factories?
> >
>
>
Re: how to make SessionFactory spring friendly?
Posted by Florian Müller <fl...@alfresco.com>.
Hi,
See [1] how to create a SessionFactory object with Spring.
Session objects shouldn't be pooled. One session object should serve all requests for a specific user.
OpenCMIS is thread-safe. So just create one object and reuse it wherever possible. In this way all threads share one cache which much more efficient than pooling.
- Florian
[1] http://static.springsource.org/spring/docs/2.0.x/reference/beans.html#beans-factory-class-static-factory-method
On 17/07/2011 18:32, Christopher Cheng wrote:
> This is the normal procedure to obtain a session with opencmis api
>
> SessionFactory f = SessionFactoryImpl.newInstance();
> Map<String, String> params = new HashMap<String, String>();
> params.put(SessionParameter.USER, "admin");
> params.put(SessionParameter.PASSWORD, "admin");
> params.put(SessionParameter.ATOMPUB_URL, "
> http://localhost:8080/alfresco/service/cmis");
> params.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
> params.put(SessionParameter.REPOSITORY_ID,
> f.getRepositories(params).get(0).getId());
> Session s = f.createSession(params);
>
> Is there any component in chemistry to make this more spring friendly and
> poolable like Hibernate or ActiveMQ session factories?
>