List of usage examples for java.lang Package getPackage
@CallerSensitive @Deprecated(since = "9") @SuppressWarnings("deprecation") public static Package getPackage(String name)
From source file:com.spotify.apollo.elide.ElideResourceTest.java
@Before public void setUp() throws Exception { dataStore = new InMemoryDataStore(Package.getPackage("com.spotify.apollo.elide.testmodel")); elide = new Elide.Builder(dataStore).build(); resource = ElideResource.builder(PREFIX, elide).build(); addToDataStore(new Thing("1", "flerp")); addToDataStore(new Thing("2", "florpe")); }
From source file:org.tradex.tx.GenericJCAContainer.java
public void afterPropertiesSet() throws Exception { bootstrapContext = new SimpleBootstrapContext(workManager, xaTerminator); resourceAdapter.start(bootstrapContext); // now lets start all of the JCAConnector instances if (!lazyLoad) { if (applicationContext == null) { throw new IllegalArgumentException("applicationContext should have been set by Spring"); }//from www.j av a 2s. c o m applicationContext.getBeansOfType(JCAConnector.class); } String version = null; Package aPackage = Package.getPackage("org.jencks"); if (aPackage != null) { version = aPackage.getImplementationVersion(); } log.info("Jencks JCA Container (http://jencks.org/) has started running version: " + version); }
From source file:de.cenote.jasperstarter.Config.java
/** * * *//* w w w . jav a2 s . c om*/ public Config() { String jasperStarterVersion = ""; String jasperStarterRevision = ""; jasperStarterVersion = this.getClass().getPackage().getSpecificationVersion(); jasperStarterRevision = this.getClass().getPackage().getImplementationVersion(); String jasperReportsVersion = ""; try { jasperReportsVersion = Package.getPackage("net.sf.jasperreports.engine").getImplementationVersion(); } catch (NullPointerException e) { // ignore NullPointerException while running TestNG // @todo: solve problem in test } StringBuffer sb = new StringBuffer("JasperStarter ").append(jasperStarterVersion).append(" Rev ") .append(jasperStarterRevision).append("\n").append(" - JasperReports: ") .append(jasperReportsVersion); versionString = sb.toString(); }
From source file:com.moz.fiji.schema.util.Debug.java
/** * Logs the process configuration, for debugging purposes. * * Note: this is very verbose.// w ww . jav a 2 s . co m * * @param conf Configuration to log. */ public static void logConfiguration(final Configuration conf) { LOG.info(LINE); LOG.info("Using Job tracker: {}", conf.get("mapred.job.tracker")); LOG.info("Using default HDFS: {}", conf.get("fs.defaultFS")); LOG.info("Using HBase: quorum: {} - client port: {}", conf.get("hbase.zookeeper.quorum"), conf.get("hbase.zookeeper.property.clientPort")); LOG.info(LINE); LOG.info("Using Avro package: {}", Package.getPackage("org.apache.avro")); LOG.info(LINE); LOG.info("Environment variables:\n{}\n{}\n{}", LINE, toLogString(System.getenv().entrySet()), LINE); LOG.info("System properties:\n{}\n{}\n{}", LINE, toLogString(System.getProperties().entrySet()), LINE); LOG.info("Classpath:\n{}\n{}\n{}", LINE, Joiner.on("\n").join(System.getProperty("java.class.path").split(":")), LINE); LOG.info("Hadoop configuration:\n{}\n{}\n{}", LINE, toLogString(conf), LINE); }
From source file:org.apache.camel.spring.javaconfig.test.JavaConfigContextLoader.java
/** * Loads a new {@link ApplicationContext context} based on the supplied {@code locations}, * configures the context, and finally returns the context in fully <em>refreshed</em> state. * <p/>//from ww w . j a va2s . c o m * * Configuration locations are either fully-qualified class names or base package names. These * locations will be given to a {@link JavaConfigApplicationContext} for configuration via the * {@link JavaConfigApplicationContext#addConfigClass(Class)} and * {@link JavaConfigApplicationContext#addBasePackage(String)} methods. * * @param locations the locations to use to load the application context * @return a new application context * @throws IllegalArgumentException if any of <var>locations</var> are not valid fully-qualified * Class or Package names */ public ApplicationContext loadContext(String... locations) { if (logger.isDebugEnabled()) { logger.debug("Creating a JavaConfigApplicationContext for " + Arrays.asList(locations)); } AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); ArrayList<Class<?>> configClasses = new ArrayList<Class<?>>(); ArrayList<String> basePackages = new ArrayList<String>(); for (String location : locations) { // if the location refers to a class, use it. Otherwise assume it's a base package name try { final Class<?> aClass = this.getClass().getClassLoader().loadClass(location); configClasses.add(aClass); } catch (ClassNotFoundException e) { if (Package.getPackage(location) == null) { throw new IllegalArgumentException( String.format("A non-existent class or package name was specified: [%s]", location)); } basePackages.add(location); } } if (logger.isDebugEnabled()) { logger.debug("Setting config classes to " + configClasses); logger.debug("Setting base packages to " + basePackages); } for (Class<?> configClass : configClasses) { context.register(configClass); } for (String basePackage : basePackages) { context.scan(basePackage); } context.refresh(); // Have to create a child context that implements BeanDefinitionRegistry // to pass to registerAnnotationConfigProcessors, since // JavaConfigApplicationContext does not final GenericApplicationContext gac = new GenericApplicationContext(context); AnnotationConfigUtils.registerAnnotationConfigProcessors(gac); // copy BeanPostProcessors to the child context for (String bppName : context.getBeanFactory().getBeanNamesForType(BeanPostProcessor.class)) { gac.registerBeanDefinition(bppName, context.getBeanFactory().getBeanDefinition(bppName)); } gac.refresh(); gac.registerShutdownHook(); return gac; }
From source file:org.grouplens.lenskit.eval.graph.ComponentNodeBuilder.java
static String shortClassName(Class<?> type) { if (ClassUtils.isPrimitiveOrWrapper(type)) { if (!type.isPrimitive()) { type = ClassUtils.wrapperToPrimitive(type); }/*from w w w . ja va 2 s . c om*/ return type.getName(); } else if (type.getPackage().equals(Package.getPackage("java.lang"))) { return type.getSimpleName(); } else { String[] words = type.getName().split(" "); String fullClassName = words[words.length - 1]; String[] path = fullClassName.split("\\."); int i = 0; while (!Character.isUpperCase(path[i + 1].charAt(0))) { path[i] = path[i].substring(0, 1); i++; } return StringUtils.join(path, "."); } }
From source file:adalid.util.info.JavaInfo.java
public void printPackageDetails(String name) { Package pack = Package.getPackage(name); out.println("Package " + name + ": " + pack); if (pack != null) { out.println("\t" + Attributes.Name.IMPLEMENTATION_TITLE + ": " + pack.getImplementationTitle()); out.println("\t" + Attributes.Name.IMPLEMENTATION_VENDOR + ": " + pack.getImplementationVendor()); out.println("\t" + Attributes.Name.IMPLEMENTATION_VERSION + ": " + pack.getImplementationVersion()); out.println("\t" + Attributes.Name.SPECIFICATION_TITLE + ": " + pack.getSpecificationTitle()); out.println("\t" + Attributes.Name.SPECIFICATION_VENDOR + ": " + pack.getSpecificationVendor()); out.println("\t" + Attributes.Name.SPECIFICATION_VERSION + ": " + pack.getSpecificationVersion()); out.println();//from www.jav a 2 s. co m } }
From source file:org.jadira.scanner.classpath.types.JPackage.java
public JPackage getParentPackage() throws ClasspathAccessException { String name = getName();//from w ww .j a v a 2 s . c om Package retVal = null; while (retVal == null && name.lastIndexOf('.') != -1) { name = name.substring(0, name.lastIndexOf('.')); retVal = Package.getPackage(name); } if (retVal == null) { retVal = Package.getPackage(""); } return JPackage.getJPackage(retVal, getResolver()); }
From source file:org.apache.cxf.jaxrs.swagger.Swagger2Customizer.java
protected void applyDefaultVersion(Swagger data) { if (applyDefaultVersion && data.getInfo() != null && data.getInfo().getVersion() == null && beanConfig != null && beanConfig.getResourcePackage() != null) { Package resourcePackage = Package.getPackage(beanConfig.getResourcePackage()); if (resourcePackage != null) { data.getInfo().setVersion(resourcePackage.getImplementationVersion()); }/* w ww .j av a 2 s . c o m*/ } }
From source file:org.springframework.web.method.ControllerAdviceBean.java
private static List<Package> initBasePackagesFromBeanType(Class<?> beanType, ControllerAdvice annotation) { List<Package> basePackages = new ArrayList<Package>(); List<String> basePackageNames = new ArrayList<String>(); basePackageNames.addAll(Arrays.asList(annotation.value())); basePackageNames.addAll(Arrays.asList(annotation.basePackages())); for (String pkgName : basePackageNames) { if (StringUtils.hasText(pkgName)) { Package pkg = Package.getPackage(pkgName); if (pkg != null) { basePackages.add(pkg);//from ww w. j ava 2 s. co m } else { logger.warn("Package [" + pkgName + "] was not found, see [" + beanType.getName() + "]"); } } } for (Class<?> markerClass : annotation.basePackageClasses()) { Package pack = markerClass.getPackage(); if (pack != null) { basePackages.add(pack); } else { logger.warn("Package was not found for class [" + markerClass.getName() + "], see [" + beanType.getName() + "]"); } } return basePackages; }