05-01-2007 09:18 AM
// 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
}
05-01-2007 10:51 AM
// either
ctx = ApplicationContextHelper.getApplicationContext();
// Or
ctx = new ClassPathXmlApplicationContext("alfresco/application-context.xml");
05-04-2007 11:40 AM
public static void main(String … args)
{
ClassPathXmlApplicationContext ctx = (ClassPathXmlApplicationContext) getApplicationContext();
synchronized (ctx)
{
try { ctx.wait(10000L); } catch (Throwable e) {}
}
ctx.close();
}
Alfresco doesn't control the lifecycle but responds to lifecycle callbacks provided by Spring. If the code above doesn't work (and I've just checked that it does) then a component has been added that isn't listening to the lifecycle callbacks.05-04-2007 11:54 AM
06-25-2007 04:15 AM
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.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.