本文整理汇总了Java中org.netbeans.api.java.classpath.ClassPath.getClassLoader方法的典型用法代码示例。如果您正苦于以下问题:Java ClassPath.getClassLoader方法的具体用法?Java ClassPath.getClassLoader怎么用?Java ClassPath.getClassLoader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.java.classpath.ClassPath
的用法示例。
在下文中一共展示了ClassPath.getClassLoader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
public static Class getType(Project project, String typeName) {
List<ClassPath> classPaths = SourceGroupSupport.gerClassPath(project);
for (ClassPath cp : classPaths) {
try {
Class ret = Util.getPrimitiveType(typeName);
if (ret != null) {
return ret;
}
ClassLoader cl = cp.getClassLoader(true);
ret = Util.getGenericRawType(typeName, cl);
if (ret != null) {
return ret;
}
if (cl != null) {
return cl.loadClass(typeName);
}
} catch (ClassNotFoundException ex) {
//Logger.global.log(Level.INFO, ex.getLocalizedMessage(), ex);
}
}
return null;
}
示例2: getUpToDateClassLoader
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
static ClassLoader getUpToDateClassLoader(FileObject fileInProject, ClassLoader clSoFar) {
ClassLoader existingCL = clSoFar instanceof ProjectClassLoader ?
((ProjectClassLoader)clSoFar).projectClassLoaderDelegate : clSoFar;
ClassPath classPath = ClassPath.getClassPath(fileInProject, ClassPath.EXECUTE);
ClassLoader actualCL = classPath != null ? classPath.getClassLoader(true) : null;
if (actualCL == existingCL)
return clSoFar;
if (actualCL == null)
return null;
return new ProjectClassLoader(actualCL, ClassPath.getClassPath(fileInProject, ClassPath.SOURCE));
}
示例3: valid
import org.netbeans.api.java.classpath.ClassPath; //导入方法依赖的package包/类
boolean valid(WizardDescriptor wizard) {
// List<Entity> entities = (List<Entity>) wizard.getProperty(WizardProperties.ENTITY_CLASS);
// String controllerPkg = getPackage();
//
// boolean filesAlreadyExist = false;
// String troubleMaker = "";
// for (Entity entity : entities) {
// String entityClass = entity.getClass2();
// String simpleClassName = JSFClientGenerator.simpleClassName(entityClass);
// String firstLower = simpleClassName.substring(0, 1).toLowerCase() + simpleClassName.substring(1);
// String folder = jsfFolder.getText().endsWith("/") ? jsfFolder.getText() : jsfFolder.getText() + "/";
// folder = folder + firstLower;
// String controller = controllerPkg + "." + simpleClassName + "Controller";
// String fqn = getPackage().length() > 0 ? getPackage().replace('.', '/') + "/" + simpleClassName : simpleClassName;
// if (getLocationValue().getRootFolder().getFileObject(fqn + "Controller.java") != null) {
// filesAlreadyExist = true;
// troubleMaker = controllerPkg + "." + simpleClassName + "Controller.java";
// break;
// }
// if (getLocationValue().getRootFolder().getFileObject(fqn + "Converter.java") != null) {
// filesAlreadyExist = true;
// troubleMaker = controllerPkg + "." + simpleClassName + "Converter.java";
// break;
// }
// }
// if (filesAlreadyExist) {
// wizard.putProperty("WizardPanel_errorMessage", // NOI18N
// NbBundle.getMessage(JpaControllerSetupPanelVisual.class, "MSG_FilesAlreadyExist", troubleMaker));
// return false;
// }
// wizard.putProperty("WizardPanel_errorMessage", null); // NOI18N
if (Util.isContainerManaged(project)) {
ClassPath cp = ClassPath.getClassPath(getLocationValue().getRootFolder(), ClassPath.COMPILE);
ClassLoader cl = cp.getClassLoader(true);
try {
Class.forName("javax.transaction.UserTransaction", false, cl);
}
catch (ClassNotFoundException cnfe) {
wizard.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JpaControllerSetupPanelVisual.class, "ERR_UserTransactionUnavailable"));
return false;
}
catch (java.lang.UnsupportedClassVersionError err)
{
// wizard.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JpaControllerSetupPanelVisual.class, "ERR_UserTransactionJavaVersion"));
// return false;
}
}
// Sources srcs = (Sources) project.getLookup().lookup(Sources.class);
// SourceGroup sgWeb[] = srcs.getSourceGroups("doc_root"); //NOI18N fixme(mbohm): move into constant
// FileObject pagesRootFolder = sgWeb[0].getRootFolder();
// File pagesRootFolderAsFile = FileUtil.toFile(pagesRootFolder);
// String jsfFolderText = jsfFolder.getText();
// try {
// String canonPath = new File(pagesRootFolderAsFile, jsfFolderText).getCanonicalPath();
// }
// catch (IOException ioe) {
// wizard.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JpaControllerSetupPanelVisual.class, "ERR_JsfTargetChooser_InvalidJsfFolder"));
// return false;
// }
String packageName = getPackage();
if (packageName.trim().equals("")) { // NOI18N
wizard.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JpaControllerSetupPanelVisual.class, "ERR_JavaTargetChooser_CantUseDefaultPackage"));
return false;
}
if (!JavaIdentifiers.isValidPackageName(packageName)) {
wizard.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JpaControllerSetupPanelVisual.class,"ERR_JavaTargetChooser_InvalidPackage")); //NOI18N
return false;
}
if (!SourceGroups.isFolderWritable(getLocationValue(), packageName)) {
wizard.putProperty("WizardPanel_errorMessage", NbBundle.getMessage(JpaControllerSetupPanelVisual.class, "ERR_JavaTargetChooser_UnwritablePackage")); //NOI18N
return false;
}
wizard.putProperty("WizardPanel_errorMessage", null); // NOI18N
return true;
}