As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
// Setup Spring and Transaction Service ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml"); // Retrieve Repository Repository repository = (Repository)context.getBean("JCR.Repository"); // Login to workspace // Note: Default workspace is the one used by Alfresco Web Client which contains all the Spaces // and their documents Session session = repository.login(new SimpleCredentials("admin", "admin".toCharArray())); try { // Retrieve Company Home Node root = session.getRootNode(); Node companyHome = root.getNode("app:company_home"); // Iterator through children of Company Home NodeIterator iterator = companyHome.getNodes(); while(iterator.hasNext()) { Node child = iterator.nextNode(); System.out.println(child.getName()); PropertyIterator propIterator = child.getProperties(); while(propIterator.hasNext()) { Property prop = propIterator.nextProperty(); if (!prop.getDefinition().isMultiple()) { System.out.println(" " + prop.getName() + " = " + prop.getString()); } } } } finally { session.logout(); System.exit(0); ////////////////// This kills the program }
// either ctx = ApplicationContextHelper.getApplicationContext(); // Or ctx = new ClassPathXmlApplicationContext("alfresco/application-context.xml");
public static void main(String … args) { ClassPathXmlApplicationContext ctx = (ClassPathXmlApplicationContext) getApplicationContext(); synchronized (ctx) { try { ctx.wait(10000L); } catch (Throwable e) {} } ctx.close(); }
Another thing is that you are starting the entire Alfresco server-level application context and then shutting it down. You should consider JCR-RMI and connect to an instance of the server that remains alive.