本文整理汇总了Java中play.classloading.ApplicationClasses.ApplicationClass类的典型用法代码示例。如果您正苦于以下问题:Java ApplicationClass类的具体用法?Java ApplicationClass怎么用?Java ApplicationClass使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ApplicationClass类属于play.classloading.ApplicationClasses包,在下文中一共展示了ApplicationClass类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rebuildAllIndexes
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public void rebuildAllIndexes() throws Exception {
stop();
File fl = new File(DATA_PATH);
Files.deleteDirectory(fl);
fl.mkdirs();
List<ApplicationClass> classes = Play.classes.getAnnotatedClasses(Indexed.class);
for (ApplicationClass applicationClass : classes) {
List<JPABase> objects = JPA.em().createQuery(
"select e from " + applicationClass.javaClass.getCanonicalName() + " as e")
.getResultList();
for (JPABase jpaBase : objects) {
index(jpaBase, applicationClass.javaClass.getName());
}
}
Logger.info("Rebuild index finished");
}
示例2: openClassfile
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public InputStream openClassfile(String className) throws NotFoundException {
if(Play.usePrecompiled) {
try {
File file = Play.getFile("precompiled/java/" + className.replace(".", "/") + ".class");
return new FileInputStream(file);
} catch(Exception e) {
Logger.error("Missing class %s", className);
}
}
ApplicationClass appClass = Play.classes.getApplicationClass(className);
if ( appClass.enhancedByteCode == null) {
throw new RuntimeException("Trying to visit uncompiled class while enhancing. Uncompiled class: " + className);
}
return new ByteArrayInputStream(appClass.enhancedByteCode);
}
示例3: ApplicationClassloader
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public ApplicationClassloader() {
super(ApplicationClassloader.class.getClassLoader());
// Clean the existing classes
for (ApplicationClass applicationClass : Play.classes.all()) {
applicationClass.uncompile();
}
pathHash = computePathHash();
try {
CodeSource codeSource = new CodeSource(new URL("file:" + Play.applicationPath.getAbsolutePath()), (Certificate[]) null);
Permissions permissions = new Permissions();
permissions.add(new AllPermission());
protectionDomain = new ProtectionDomain(codeSource, permissions);
} catch (MalformedURLException e) {
throw new UnexpectedException(e);
}
}
示例4: enhance
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
@Override
public void enhance(ApplicationClass applicationClass) throws Exception {
Class<?>[] enhancers = new Class[]{
SigEnhancer.class,
ControllersEnhancer.class,
ContinuationEnhancer.class,
MailerEnhancer.class,
PropertiesEnhancer.class,
LocalvariablesNamesEnhancer.class
};
for (Class<?> enhancer : enhancers) {
try {
long start = System.currentTimeMillis();
((Enhancer) enhancer.newInstance()).enhanceThisClass(applicationClass);
if (Logger.isTraceEnabled()) {
Logger.trace("%sms to apply %s to %s", System.currentTimeMillis() - start, enhancer.getSimpleName(), applicationClass.name);
}
} catch (Exception e) {
throw new UnexpectedException("While applying " + enhancer + " on " + applicationClass.name, e);
}
}
}
示例5: listIndexes
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public List<ManagedIndex> listIndexes() {
List<ManagedIndex> indexes = new ArrayList<ManagedIndex>();
List<ApplicationClass> classes = Play.classes.getAnnotatedClasses(Indexed.class);
for (ApplicationClass applicationClass : classes) {
ManagedIndex index = new ManagedIndex();
index.name = applicationClass.javaClass.getName();
index.optimized = getIndexSearcher(index.name).getIndexReader().isOptimized();
index.documentCount = getIndexSearcher(index.name).getIndexReader().numDocs();
index.jpaCount = (Long ) JPA.em().createQuery("select count (*) from " + applicationClass.javaClass.getCanonicalName()+ ")").getSingleResult();
indexes.add(index);
}
return indexes;
}
示例6: init
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public static void init() {
Logger.debug("init FileExtractor");
List<ApplicationClass> classes = Play.classes.getAssignableClasses(TextExtractor.class);
List<TextExtractor> extractors = new ArrayList<TextExtractor>();
for (ApplicationClass applicationClass : classes) {
try {
Logger.trace("adding %s as a TextExtractor", applicationClass.name);
extractors.add((TextExtractor) applicationClass.javaClass.newInstance());
} catch (Exception e) {
Logger.warn(e,"Could not instanciate text extractor %s",applicationClass.javaClass.getName());
}
}
FileExtractor.extractors = extractors;
}
示例7: DatabaseException
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public DatabaseException(String message, Throwable cause) {
super(message, cause);
StackTraceElement element = getInterestingStrackTraceElement(cause);
if(element != null) {
ApplicationClass applicationClass = Play.classes.getApplicationClass(element.getClassName());
sourceFile = applicationClass.javaFile.relativePath();
source = Arrays.asList(applicationClass.javaSource.split("\n"));
line = element.getLineNumber();
}
}
示例8: MailException
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public MailException(String message, Throwable cause) {
super(message, cause);
StackTraceElement element = getInterestingStrackTraceElement(cause);
if(element != null) {
ApplicationClass applicationClass = Play.classes.getApplicationClass(element.getClassName());
sourceFile = applicationClass.javaFile.relativePath();
source = Arrays.asList(applicationClass.javaSource.split("\n"));
line = element.getLineNumber();
}
}
示例9: CacheException
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public CacheException(String message, Throwable cause) {
super(message, cause);
StackTraceElement element = getInterestingStrackTraceElement(cause);
if(element != null) {
ApplicationClass applicationClass = Play.classes.getApplicationClass(element.getClassName());
sourceFile = applicationClass.javaFile.relativePath();
source = Arrays.asList(applicationClass.javaSource.split("\n"));
line = element.getLineNumber();
}
}
示例10: enhanceThisClass
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
@Override
public void enhanceThisClass(ApplicationClass applicationClass) throws Exception {
if (isScala(applicationClass)) {
return;
}
CtClass ctClass = makeClass(applicationClass);
if (!ctClass.subtypeOf(classPool.get(Mailer.class.getName()))) {
return;
}
for (final CtMethod ctMethod : ctClass.getDeclaredMethods()) {
if (Modifier.isPublic(ctMethod.getModifiers()) && Modifier.isStatic(ctMethod.getModifiers()) && ctMethod.getReturnType().isPrimitive()) {
try {
ctMethod.insertBefore("if(infos.get() != null) {play.Logger.warn(\"You call " + ctMethod.getLongName() + " from \" + ((java.util.Map)infos.get()).get(\"method\") + \". It's forbidden in a Mailer. It will propably fail...\", new Object[0]);}; infos.set(new java.util.HashMap());((java.util.Map)infos.get()).put(\"method\", \"" + ctMethod.getLongName() + "\");");
ctMethod.insertAfter("infos.set(null);", true);
} catch (Exception e) {
Logger.error(e, "Error in MailerEnhancer");
throw new UnexpectedException("Error in MailerEnhancer", e);
}
}
}
// Done.
applicationClass.enhancedByteCode = ctClass.toBytecode();
ctClass.defrost();
}
示例11: isEnhanced
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
public static boolean isEnhanced(String appClassName) {
ApplicationClass appClass = Play.classes.getApplicationClass( appClassName);
if ( appClass == null) {
return false;
}
// All classes enhanced for Continuations are implementing the interface EnhancedForContinuations
return EnhancedForContinuations.class.isAssignableFrom( appClass.javaClass );
}
示例12: enhanceThisClass
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
@Override
public void enhanceThisClass(ApplicationClass applicationClass) throws Exception {
if (isScala(applicationClass)) {
return;
}
CtClass ctClass = makeClass(applicationClass);
if (!ctClass.subtypeOf(classPool.get(ControllersEnhancer.ControllerSupport.class.getName()))) {
return ;
}
boolean needsContinuations = shouldEnhance( ctClass );
if (!needsContinuations) {
return;
}
// To be able to runtime detect if a class is enhanced for Continuations,
// we add the interface EnhancedForContinuations to the class
CtClass enhancedForContinuationsInterface;
try {
InputStream in = getClass().getClassLoader().getResourceAsStream("play/classloading/enhancers/EnhancedForContinuations.class");
enhancedForContinuationsInterface = classPool.makeClass( in );
in.close();
} catch (Exception e) {
throw new RuntimeException(e);
}
ctClass.addInterface( enhancedForContinuationsInterface );
// Apply continuations
applicationClass.enhancedByteCode = new AsmClassTransformer().transform( ctClass.toBytecode());
ctClass.defrost();
enhancedForContinuationsInterface.defrost();
}
示例13: getAssignableClasses
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
/**
* Retrieve all application classes assignable to this class.
* @param clazz The superclass, or the interface.
* @return A list of class
*/
public List<Class> getAssignableClasses(Class clazz) {
getAllClasses();
List<Class> results = new ArrayList<Class>();
for (ApplicationClass c : Play.classes.getAssignableClasses(clazz)) {
results.add(c.javaClass);
}
return results;
}
示例14: getClassIgnoreCase
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
/**
* Find a class in a case insensitive way
* @param name The class name.
* @return a class
*/
public Class getClassIgnoreCase(String name) {
getAllClasses();
for (ApplicationClass c : Play.classes.all()) {
if (c.name.equalsIgnoreCase(name) || c.name.replace("$", ".").equalsIgnoreCase(name)) {
if (Play.usePrecompiled) {
return c.javaClass;
}
return loadApplicationClass(c.name);
}
}
return null;
}
示例15: getAnnotatedClasses
import play.classloading.ApplicationClasses.ApplicationClass; //导入依赖的package包/类
/**
* Retrieve all application classes with a specific annotation.
* @param clazz The annotation class.
* @return A list of class
*/
public List<Class> getAnnotatedClasses(Class<? extends Annotation> clazz) {
getAllClasses();
List<Class> results = new ArrayList<Class>();
for (ApplicationClass c : Play.classes.getAnnotatedClasses(clazz)) {
results.add(c.javaClass);
}
return results;
}