List of usage examples for java.lang Package getName
public String getName()
From source file:com.bahmanm.karun.PackageCollection.java
/** * Adds packages in a 'sync' db to package collection. * @param dbFilePath Absolute path to .db file *//*from w ww.java 2s . c o m*/ private void addSyncPackages(final String repo) throws FileNotFoundException, IOException { traversPkgDir(new File(dbPathTempSync.getAbsolutePath() + "/" + repo), new PackageAction() { @Override public void action(Package pkg) { pkg.setRepo(repo); collection.put(pkg.getName(), pkg); } }); }
From source file:org.debux.webmotion.server.convention.DefaultConventionScan.java
/** * Scan the filters by convention.// www. ja v a2 s .c o m */ public List<FilterRule> scanFilters(Mapping mapping) { Pattern allPattern = Pattern.compile("/*"); Collection<Class<?>> filters = ReflectionUtils.getClassesBySuperClass(ConventionAllFilter.class); List<FilterRule> rules = new ArrayList<FilterRule>(filters.size()); for (Class<?> filter : filters) { FilterRule rule = new FilterRule(); rule.setMapping(mapping); rule.setLine(-1); rules.add(rule); rule.setMethods(Arrays.asList("*")); rule.setPattern(allPattern); Action action = new Action(); action.setType(Action.Type.ACTION); action.setFullName(filter.getName() + ".filter"); rule.setAction(action); } filters = ReflectionUtils.getClassesBySuperClass(ConventionPackageFilter.class); for (Class<?> filter : filters) { FilterRule rule = new FilterRule(); rule.setMapping(mapping); rule.setLine(-1); rules.add(rule); Package filterPackage = filter.getPackage(); if (filterPackage != null) { String packageName = filterPackage.getName(); String subPackageName = StringUtils.substringAfterLast(packageName, "."); String regexp = "/" + subPackageName.toLowerCase() + "/*"; rule.setPattern(Pattern.compile(regexp)); } else { rule.setPattern(allPattern); } rule.setMethods(Arrays.asList("*")); Action action = new Action(); action.setType(Action.Type.ACTION); action.setFullName(filter.getName() + ".filter"); rule.setAction(action); } return rules; }
From source file:com.virtualparadigm.packman.processor.JPackageManager.java
private static void archivePackage(Package installPackage, File packageManagerDataDir) { // create "archive" dir if it doesnt exist // create package archive dir (<package name>_v_<package version>) // copy contents of package metadata, autorun and patch file to archive dir try {// w w w . j a va2 s.com File archiveDir = new File(packageManagerDataDir.getAbsolutePath() + "/" + ARCHIVE_DIR_NAME); File archivePackageDir = new File(archiveDir.getAbsolutePath() + "/" + installPackage.getName() + "_v_" + installPackage.getVersion()); // if(!archivePackageDir.exists()) // { // archivePackageDir.mkdirs(); // } File archivePackageInstallDir = new File( archivePackageDir.getAbsolutePath() + "/" + JPackageManager.INSTALL_DIR_NAME); if (!archivePackageInstallDir.exists()) { archivePackageInstallDir.mkdirs(); } File archivePackageUninstallDir = new File( archivePackageDir.getAbsolutePath() + "/" + JPackageManager.UNINSTALL_DIR_NAME); if (!archivePackageUninstallDir.exists()) { archivePackageUninstallDir.mkdirs(); } // metadata archive dir FileUtils.copyDirectory( new File(packageManagerDataDir.getAbsolutePath() + "/" + TEMP_INSTALL_DIR_NAME + "/" + JPackageManager.METADATA_DIR_NAME), new File(archivePackageDir.getAbsolutePath() + "/" + JPackageManager.METADATA_DIR_NAME)); // install archive dir FileUtils.copyDirectory( new File(packageManagerDataDir.getAbsolutePath() + "/" + TEMP_INSTALL_DIR_NAME + "/" + JPackageManager.AUTORUN_DIR_NAME + "/" + JPackageManager.INSTALL_DIR_NAME), new File(archivePackageInstallDir.getAbsolutePath() + "/" + JPackageManager.AUTORUN_DIR_NAME)); FileUtils.copyFileToDirectory( new File(packageManagerDataDir.getAbsolutePath() + "/" + TEMP_INSTALL_DIR_NAME + "/" + JPackageManager.PATCH_DIR_NAME + "/" + JPackageManager.PATCH_FILE_NAME), new File(archivePackageInstallDir.getAbsolutePath() + "/" + JPackageManager.PATCH_DIR_NAME)); // uninstall archive dir FileUtils.copyDirectory( new File(packageManagerDataDir.getAbsolutePath() + "/" + TEMP_INSTALL_DIR_NAME + "/" + JPackageManager.AUTORUN_DIR_NAME + "/" + JPackageManager.UNINSTALL_DIR_NAME), new File( archivePackageUninstallDir.getAbsolutePath() + "/" + JPackageManager.AUTORUN_DIR_NAME)); FileUtils.copyFileToDirectory( new File(packageManagerDataDir.getAbsolutePath() + "/" + TEMP_INSTALL_DIR_NAME + "/" + JPackageManager.PATCH_DIR_NAME + "/" + JPackageManager.PATCH_FILE_NAME), new File(archivePackageUninstallDir.getAbsolutePath() + "/" + JPackageManager.PATCH_DIR_NAME)); } catch (Exception e) { logger.error("", e); } }
From source file:com.norconex.collector.core.AbstractCollector.java
private void printReleaseVersion() { printReleaseVersion("Collector", getClass().getPackage()); printReleaseVersion("Collector Core", AbstractCollector.class.getPackage()); printReleaseVersion("Importer", Importer.class.getPackage()); printReleaseVersion("JEF", IJob.class.getPackage()); //--- Committers --- printReleaseVersion("Committer Core", ICommitter.class.getPackage()); Set<ICommitter> committers = new HashSet<>(); for (ICrawler crawler : getCrawlers()) { ICommitter committer = crawler.getCrawlerConfig().getCommitter(); if (committer != null) { Package committerPackage = committer.getClass().getPackage(); if (committerPackage != null && !committerPackage.getName().startsWith("com.norconex.committer.core")) { committers.add(committer); }//from www . j ava 2s . co m } } for (ICommitter c : committers) { printReleaseVersion(c.getClass().getSimpleName(), c.getClass().getPackage()); } }
From source file:de.lmu.ifi.dbs.jfeaturelib.utils.PackageScanner.java
List<String> getNames(Package inPackage) throws UnsupportedEncodingException, URISyntaxException, ZipException, IOException { List<String> binaryNames = new ArrayList<>(); String packagePath = inPackage.getName(); packagePath = packagePath.replace('.', '/'); // During tests, this points to the classes/ directory, later, this points to the jar CodeSource src = PackageScanner.class.getProtectionDomain().getCodeSource(); URL location = src.getLocation(); // test case//from ww w . ja v a2 s . c o m File dirOrJar = new File(location.toURI()); if (dirOrJar.isDirectory()) { // +1 to include the slash after the directory name int basePathLength = dirOrJar.toString().length() + 1; File packageDir = new File(dirOrJar, packagePath); // list all .class files in this package directory for (File file : packageDir.listFiles((FilenameFilter) new SuffixFileFilter(".class"))) { // strip the leading directory String binaryName = file.getPath().substring(basePathLength); binaryName = pathToBinary(binaryName); binaryNames.add(binaryName); } } else { try (ZipFile jar = new ZipFile(dirOrJar)) { for (Enumeration entries = jar.entries(); entries.hasMoreElements();) { String binaryName = ((ZipEntry) entries.nextElement()).getName(); if (!binaryName.endsWith(".class")) { // we only need classes continue; } if (binaryName.startsWith(packagePath)) { binaryName = pathToBinary(binaryName); binaryNames.add(binaryName); } } } } return binaryNames; }
From source file:org.echocat.jomon.runtime.i18n.RecursiveResourceBundleFactory.java
@Nonnull protected List<ResourceBundle> getAllRecursivelyFor(@Nonnull Package aPackage, @Nullable Locale forLocale, @Nonnull ClassLoader withClassLoader) { final List<ResourceBundle> bundles = new ArrayList<>(); String current = aPackage.getName(); while (current != null) { final ResourceBundle bundle = tryFindFor(current, forLocale, withClassLoader); if (bundle != null) { bundles.add(bundle);/*from w w w .j a v a2s. co m*/ } final int lastDot = current.lastIndexOf('.'); if (lastDot >= 0) { current = current.substring(0, lastDot); } else if (!current.isEmpty()) { current = ""; } else { current = null; } } return bundles; }
From source file:org.debux.webmotion.server.convention.DefaultConventionScan.java
/** * Scan the controllers by convention.//ww w . j a va2s . co m */ public List<ActionRule> scanControllers(Mapping mapping) { Collection<Class<?>> controllers = ReflectionUtils.getClassesBySuperClass(ConventionController.class); List<ActionRule> rules = new ArrayList<ActionRule>(controllers.size()); for (Class<?> controller : controllers) { Method[] methods = controller.getMethods(); for (Method method : methods) { Class<?> declaringClass = method.getDeclaringClass(); if (!declaringClass.equals(Object.class) && !declaringClass.equals(WebMotionController.class)) { ActionRule rule = new ActionRule(); rule.setMapping(mapping); rule.setLine(-1); rules.add(rule); String className = controller.getName(); String methodName = method.getName(); // Create action Action action = new Action(); action.setFullName(className + "." + methodName); action.setType(Action.Type.ACTION); rule.setAction(action); // Search http method String httpMethod = "*"; if (methodName.startsWith("create")) { httpMethod = HttpContext.METHOD_PUT; methodName = methodName.replaceFirst("create", ""); } else if (methodName.startsWith("get")) { httpMethod = HttpContext.METHOD_GET; methodName = methodName.replaceFirst("get", ""); } else if (methodName.startsWith("delete")) { httpMethod = HttpContext.METHOD_DELETE; methodName = methodName.replaceFirst("delete", ""); } else if (methodName.startsWith("update")) { httpMethod = HttpContext.METHOD_POST; methodName = methodName.replaceFirst("update", ""); } rule.setMethods(Arrays.asList(httpMethod)); // Create path List<FragmentUrl> url = new ArrayList<FragmentUrl>(); String simpleClassName = controller.getSimpleName(); Package controllerPackage = controller.getPackage(); if (controllerPackage != null) { String packageName = controllerPackage.getName(); String subPackageName = StringUtils.substringAfterLast(packageName, "."); if (!StringUtils.startsWithIgnoreCase(simpleClassName, subPackageName)) { url.addAll(createFragmentUrlList(subPackageName)); } } url.addAll(createFragmentUrlList(simpleClassName)); if (methodName.length() != 0) { url.addAll(createFragmentUrlList(methodName)); } rule.setRuleUrl(url); } } } return rules; }
From source file:com.evolveum.midpoint.repo.sql.query2.definition.ClassDefinitionParser.java
private Class getJaxbClass(Method method, Class returnedClass) { JaxbType annotation = (JaxbType) method.getAnnotation(JaxbType.class); if (annotation != null) { return annotation.type(); }/*from w w w. j a v a2 s . c o m*/ Class classFromEntity = getJaxbClassForEntity(returnedClass); if (classFromEntity != null) { return classFromEntity; } Package returnedClassPkg = returnedClass.getPackage(); Package dataObjectsPkg = Marker.class.getPackage(); if (returnedClassPkg != null && returnedClassPkg.getName().startsWith(dataObjectsPkg.getName())) { return null; } else { return returnedClass; // probably the JAXB value } }
From source file:org.apache.drill.jdbc.proxy.InvocationReporterImpl.java
void reportAbbreviatedPackages() { final List<String> names = new ArrayList<>(); for (Package p : PACKAGES_TO_ABBREVIATE) { names.add(p.getName()); }/*from w w w .j a va 2s .co m*/ setupMessage("Abbreviating (unique) class names in packages " + StringUtils.join(names, ", ") + "."); }
From source file:org.castor.jaxb.reflection.ClassInfoBuilder.java
/** * Build the {@link PackageInfo} for a {@link Package}. * // w w w . j av a2s . c o m * @param pkg * the Package to describe * @return the PackageInfo build */ private PackageInfo buildPackageInfo(final Package pkg) { PackageInfo packageInfo = createPackageInfo(pkg.getName()); OoPackageNature ooPackageNature = new OoPackageNature(packageInfo); ooPackageNature.setPackage(pkg); packageAnnotationProcessingService.processAnnotations(new JaxbPackageNature(packageInfo), pkg.getAnnotations()); return packageInfo; }