I am currently developping java/jee app using spring as framework and alfresco as ged.I am using apache chemistry to connect to the alfresco repository. this the code i am using to get a session.Is there a way to change this code with spring bean because i m going to use this session in diffrent classes and it would be better to be singleton.
Map<String, String> parameter = new HashMap<String, String>();
// user credentials
parameter.put(SessionParameter.USER, "admin");
parameter.put(SessionParameter.PASSWORD, "admin");
// connection settings
parameter.put(SessionParameter.ATOMPUB_URL, "http://localhost:8080/alfresco/cmisatom");
parameter.put(SessionParameter.BINDING_TYPE, BindingType.ATOMPUB.value());
System.out.println(BindingType.ATOMPUB.value());
// set the alfresco object factory
parameter.put(SessionParameter.OBJECT_FACTORY_CLASS, "org.alfresco.cmis.client.impl.AlfrescoObjectFactoryImpl");
// create session
SessionFactory factory = SessionFactoryImpl.newInstance();
Session session = factory.getRepositories(parameter).get(0).createSession();
Solved! Go to Solution.
This isn't really an Alfresco question - more a generic "how to use Spring" one. You can use a factory bean to create a global session object as a singleton in the Spring context.
This isn't really an Alfresco question - more a generic "how to use Spring" one. You can use a factory bean to create a global session object as a singleton in the Spring context.
yes i did that thank you
@Beanpublic Session sessionBean() { Map<String, String> parameter = new HashMap<String, String>(); // ... SessionFactory factory = SessionFactoryImpl.newInstance(); Session session = factory.getRepositories(parameter).get(0).createSession(); return session;}
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.