//Initialize Alfresco Server bindings
ContextHandlerCollection contexts = new ContextHandlerCollection();
alfrescoServer.setHandler(contexts);
WebAppContext alfrescoServerApi = new WebAppContext(alfrescoServerWarPath,"/alfresco");
alfrescoServerApi.setParentLoaderPriority(false);
HashLoginService dummyLoginService = new HashLoginService("TEST-SECURITY-REALM");
alfrescoServerApi.getSecurityHandler().setLoginService(dummyLoginService);
contexts.addHandler(alfrescoServerApi);
Class h2DataSource = Thread.currentThread().getContextClassLoader().loadClass("org.h2.jdbcx.JdbcDataSource");
Object o = h2DataSource.newInstance();
String jdbcUrl = "jdbc:h2:.alf_data_jetty/h2_data/alf_jetty";
String jdbcUsername = "alfresco";
String jdbcPassword = "alfresco";
String jdbcJndiName = "jdbc/dataSource";
h2DataSource.getMethod("setURL", new Class[] {String.class}).invoke(o, new Object[] {jdbcUrl});
h2DataSource.getMethod("setUser", new Class[] {String.class}).invoke(o, new Object[] {jdbcUsername});
h2DataSource.getMethod("setPassword", new Class[] {String.class}).invoke(o, new Object[] {jdbcPassword});
Resource jdbcResource = new Resource(jdbcJndiName, o);
alfrescoServer.start();
boolean entered = false;
while(alfrescoServer.isStarted()
&& alfrescoServerApi.isStarted()
&& !entered){
entered = true;
Thread.sleep(5000);
}
}