Search in sources :

Example 6 with ApplicationClass

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

the class SearchHelperPlugin method getStatus.

@Override
public String getStatus() {
    String output = "SearchHelperPlugin:\n~~~~~~~~~~~~~~~~~~~\n";
    List<ApplicationClass> classes = Play.classes.getAssignableClasses(IndexedModel.class);
    for (ApplicationClass applicationClass : classes) {
        if (isIndexed(applicationClass)) {
            List<String> fieldList = getIndexedFields(applicationClass);
            output += "Entity " + applicationClass.name + ": " + fieldList + "\n";
        }
    }
    return output;
}
Also used : ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass)

Example 7 with ApplicationClass

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

the class SearchHelperPlugin method getJsonStatus.

@Override
public JsonObject getJsonStatus() {
    JsonObject obj = new JsonObject();
    List<ApplicationClass> classes = Play.classes.getAssignableClasses(IndexedModel.class);
    for (ApplicationClass applicationClass : classes) {
        if (isIndexed(applicationClass)) {
            List<String> fieldList = getIndexedFields(applicationClass);
            JsonArray fields = new JsonArray();
            for (String field : fieldList) {
                fields.add(new JsonPrimitive(field));
            }
            obj.add(applicationClass.name, fields);
        }
    }
    return obj;
}
Also used : JsonArray(com.google.gson.JsonArray) JsonPrimitive(com.google.gson.JsonPrimitive) JsonObject(com.google.gson.JsonObject) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass)

Example 8 with ApplicationClass

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

the class RegistrationPlugin method onApplicationStart.

public void onApplicationStart() {
    ApplicationClass registrationService = Play.classes.getAssignableClasses(RegistrationService.class).get(0);
    if (registrationService == null) {
        Logger.error("Registration plugin disabled. No class implements RegistrationService interface");
    } else {
        try {
            service = (RegistrationService) registrationService.javaClass.newInstance();
            pluginActive = true;
        } catch (Exception e) {
            Logger.error(e, "Registration plugin disabled. Error when creating new instance");
        }
    }
}
Also used : ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass)

Example 9 with ApplicationClass

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

the class ApiPlugin method onApplicationStart.

@Override
public void onApplicationStart() {
    try {
        List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
        List<Class> classes = new ArrayList<Class>();
        for (ApplicationClass applicationClass : applicationClasses) {
            classes.add(applicationClass.javaClass);
        }
        jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
    } catch (JAXBException e) {
        Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
    }
    gson = new GsonBuilder().create();
    Logger.info("ApiPlugin loaded");
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass)

Example 10 with ApplicationClass

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

the class ApiPlugin method onApplicationStart.

public void onApplicationStart() {
    Logger.info("ApiPlugin loaded");
    try {
        List<ApplicationClass> applicationClasses = Play.classes.getAnnotatedClasses(XmlRootElement.class);
        List<Class> classes = new ArrayList<Class>();
        for (ApplicationClass applicationClass : applicationClasses) {
            classes.add(applicationClass.javaClass);
        }
        jc = JAXBContext.newInstance(classes.toArray(new Class[] {}));
    } catch (JAXBException e) {
        Logger.error(e, "Problem initializing jaxb context: %s", e.getMessage());
    }
    gson = new GsonBuilder().create();
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) JAXBException(javax.xml.bind.JAXBException) ArrayList(java.util.ArrayList) ApplicationClass(play.classloading.ApplicationClasses.ApplicationClass) 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