<commit_before>package uk.ac.edukapp.renderer;

import org.apache.wookie.connector.framework.WookieConnectorException;
import org.apache.wookie.connector.framework.WookieConnectorService;



public class WidgetRenderer {
	public static String render(String url){
		
		try {
			WookieConnectorService conn = new WookieConnectorService("http://widgets.open.ac.uk:8080/wookie/", "TEST", "myshareddata");
		} catch (WookieConnectorException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		
		return null;
	}
}<commit_msg>set up widget renderer as a Singleton<commit_after>package uk.ac.edukapp.renderer;

import java.io.IOException;

import org.apache.wookie.connector.framework.User;
import org.apache.wookie.connector.framework.WidgetInstance;
import org.apache.wookie.connector.framework.WookieConnectorException;
import org.apache.wookie.connector.framework.WookieConnectorService;

import uk.ac.edukapp.repository.SolrConnector;



public class WidgetRenderer {
  
  private static WidgetRenderer renderer = new WidgetRenderer();
  
  private WookieConnectorService conn;
  
  
  private WidgetRenderer(){
    try {
      conn = new WookieConnectorService("http://widgets.open.ac.uk:8080/wookie/", "TEST", "myshareddata");      
    }catch(WookieConnectorException wce){
      wce.printStackTrace();
    }
  }  
  
  
  public static WidgetRenderer getInstance() {
    return renderer;
  }
  
  /**
   * Returns html markup of widget instance as an iframe
   * @param the id (typically a uri) of widget to render
   * @return html-ready code as a string
   */
	public String render(String uri){
	  String html = "";
	  WidgetInstance widgetInstance = null;
	  try {
	    conn.setCurrentUser(new User("edukapp-front-page","edukapp-front-page"));
	    widgetInstance = conn.getOrCreateInstance(uri);
	  }catch(IOException ioe){
	    ioe.printStackTrace();
	    return null;
	  }catch(WookieConnectorException wce){
	    wce.printStackTrace();
	    return null;
	  }
	  html+="<p>"+uri+"</p>";
	  html+="<iframe src=\""+widgetInstance.getUrl()+"\"";
	  html+=" width=\""+"100"+"\"";
	  html+=" height=\""+"100"+"\"";
	  html+="></iframe>";
	  return html;
	}
}
{'fraction_non_alphanumeric': 0.1295787545787546, 'fraction_numerical': 0.00641025641025641, 'mean_word_length': 4.011467889908257, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5759187', 'n_tokens_mistral': 713, 'n_tokens_neox': 675, 'n_words': 139}