Search in sources :

Example 11 with ApplicationClass

use of play.classloading.ApplicationClasses.ApplicationClass in project play-cookbook by spinscale.

the class ActiveMqPlugin method onApplicationStart.

@Override
public void onApplicationStart() {
    Logger.info("ActiveMQ Plugin started");
    try {
        List<Class> jobClasses = new ArrayList<Class>();
        for (ApplicationClass applicationClass : Play.classes.getAssignableClasses(ActiveMqJob.class)) {
            if (Job.class.isAssignableFrom(applicationClass.javaClass)) {
                jobClasses.add(applicationClass.javaClass);
            }
        }
        MessageListener listener = new ActiveMqConsumer(jobClasses);
        connectionFactory = new ActiveMQConnectionFactory();
        // receive
        receiveConnection = connectionFactory.createTopicConnection();
        receiveConnection.start();
        receiveSession = receiveConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        receiveTopic = receiveSession.createTopic("playMessages");
        receiveSubscriber = receiveSession.createSubscriber(receiveTopic);
        receiveSubscriber.setMessageListener(listener);
        // send
        sendingConnection = connectionFactory.createTopicConnection();
        sendingConnection.start();
        sendingSession = sendingConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
        sendingTopic = sendingSession.createTopic("playMessages");
        sendingPublisher = sendingSession.createPublisher(sendingTopic);
    } catch (Exception e) {
        Logger.error(e, "Could not start activemq broker");
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) ArrayList(java.util.ArrayList) MessageListener(javax.jms.MessageListener) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) JMSException(javax.jms.JMSException)

Example 12 with ApplicationClass

use of play.classloading.ApplicationClasses.ApplicationClass in project play-cookbook by spinscale.

the class SearchHelperPlugin method getIndexedFields.

private List<String> getIndexedFields(ApplicationClass applicationClass) {
    try {
        Class clazz = applicationClass.javaClass;
        List<String> fieldList = (List<String>) clazz.getMethod("getIndexedFields").invoke(null);
        return fieldList;
    } catch (Exception e) {
    }
    return Collections.emptyList();
}
Also used : ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) List(java.util.List)

Example 13 with ApplicationClass

use of play.classloading.ApplicationClasses.ApplicationClass in project play-cookbook by spinscale.

the class SearchHelperPlugin method isIndexed.

private boolean isIndexed(ApplicationClass applicationClass) {
    try {
        Class clazz = applicationClass.javaClass;
        Boolean isIndexed = (Boolean) clazz.getMethod("isIndexed").invoke(null);
        return isIndexed;
    } catch (Exception e) {
    }
    return false;
}
Also used : ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass)

Aggregations

ApplicationClass (play.classloading.ApplicationClasses.ApplicationClass)13 ArrayList (java.util.ArrayList)4 RendererClass (cn.bran.japid.rendererloader.RendererClass)2 GsonBuilder (com.google.gson.GsonBuilder)2 Method (java.lang.reflect.Method)2 JAXBException (javax.xml.bind.JAXBException)2 RouterClass (cn.bran.play.routing.RouterClass)1 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 JsonPrimitive (com.google.gson.JsonPrimitive)1 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 List (java.util.List)1 JMSException (javax.jms.JMSException)1 MessageListener (javax.jms.MessageListener)1 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)1 Route (play.mvc.Router.Route)1