<commit_before>package org.fiteagle.fnative.rest;

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.annotation.Resource;
import javax.inject.Inject;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.JMSProducer;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import org.fiteagle.api.core.IResourceRepository;
import org.fiteagle.api.core.IResourceRepository.Serialization;

@Path("/repo")
public class ResourceRepository {

	private static Logger log = Logger.getLogger(ResourceRepository.class
			.toString());
	private IResourceRepository repo;
	@Inject
	private JMSContext context;
	@Resource(mappedName = "java:/topic/core")
	private Topic topic;

	public ResourceRepository() throws NamingException {
		final Context context = new InitialContext();
		repo = (IResourceRepository) context
				.lookup("java:global/core-resourcerepository/ResourceRepositoryEJB");
	}

	@GET
	@Path("/resources.rdf")
	@Produces("application/rdf+xml")
	public String listResourcesXML() {
		log.log(Level.INFO, "Getting resources as RDF...");
		return repo.listResources(Serialization.XML);
	}

	@GET
	@Path("/resources.ttl")
	@Produces("text/turtle")
	public String listResourcesTTL() {
		log.log(Level.INFO, "Getting resources as TTL...");
		return repo.listResources(Serialization.TTL);
	}

	@GET
	@Path("/async/resources.rdf")
	@Produces("application/rdf+xml")
	public String listResourcesXMLviaMDB() throws JMSException {
		String text = "timeout";
		
		log.log(Level.INFO, "Getting resources as RDF via MDB...");
		JMSProducer producer = context.createProducer();
		producer.send(topic, "test");
		JMSConsumer consumer = context.createConsumer(topic);
		
		TextMessage result = (TextMessage) consumer.receive(3000);
		if (null != result)
			text = result.getText();
		
		return text;
	}

}<commit_msg>added async example (not finished)<commit_after>package org.fiteagle.fnative.rest;

import java.util.logging.Level;
import java.util.logging.Logger;

import javax.annotation.Resource;
import javax.inject.Inject;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.JMSProducer;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;
import javax.jms.Topic;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import org.fiteagle.api.core.IResourceRepository;
import org.fiteagle.api.core.IResourceRepository.Serialization;

@Path("/repo")
public class ResourceRepository {

	private static Logger LOGGER = Logger.getLogger(ResourceRepository.class
			.toString());
	private IResourceRepository repo;
	@Inject
	private JMSContext context;
	@Resource(mappedName = "java:/topic/core")
	private Topic topic;

	public ResourceRepository() throws NamingException {
		final Context context = new InitialContext();
		repo = (IResourceRepository) context
				.lookup("java:global/core-resourcerepository/ResourceRepositoryEJB");
	}

	@GET
	@Path("/resources.rdf")
	@Produces("application/rdf+xml")
	public String listResourcesXML() {
		LOGGER.log(Level.INFO, "Getting resources as RDF...");
		return repo.listResources(Serialization.XML);
	}

	@GET
	@Path("/resources.ttl")
	@Produces("text/turtle")
	public String listResourcesTTL() {
		LOGGER.log(Level.INFO, "Getting resources as TTL...");
		return repo.listResources(Serialization.TTL);
	}

	@GET
	@Path("/async/resources.rdf")
	@Produces("application/rdf+xml")
	public String listResourcesXMLviaMDB() throws JMSException, InterruptedException {		
		LOGGER.log(Level.INFO, "Getting resources as RDF via MDB...");
		JMSProducer producer = context.createProducer();
		JMSConsumer consumer = context.createConsumer(topic, "foo = bar");
		Message message = context.createMessage();
		message.setStringProperty("method", "listResources");
		producer.send(topic, message);
		Message result = consumer.receive(1000);
		return result.getStringProperty("result");
	}
}
{'fraction_non_alphanumeric': 0.12479589456496384, 'fraction_numerical': 0.0018661068346162819, 'mean_word_length': 5.5167173252279635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, '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': '6815565', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1343, 'n_words': 279}