public void addPackageToScan(String packageName) { logger.debug("Adding package to scan: " + packageName); packagesToScan.add(packageName); }
public <T> Class<? extends T>[] findClasses(Class<T> requiredInterface) throws ServiceNotFoundException { logger.debug("ServiceLocator.findClasses for " + requiredInterface.getName()); try { Class.forName(requiredInterface.getName()); if (!classesBySuperclass.containsKey(requiredInterface)) { classesBySuperclass.put(requiredInterface, findClassesImpl(requiredInterface)); } } catch (Exception e) { throw new ServiceNotFoundException(e); } List<Class> classes = classesBySuperclass.get(requiredInterface); HashSet<Class> uniqueClasses = new HashSet<Class>(classes); return uniqueClasses.toArray(new Class[uniqueClasses.size()]); }
private PackageScanClassResolver defaultClassLoader() { if (WebSpherePackageScanClassResolver.isWebSphereClassLoader(this.getClass().getClassLoader())) { logger.debug("Using WebSphere Specific Class Resolver"); return new WebSpherePackageScanClassResolver("liquibase/parser/core/xml/dbchangelog-2.0.xsd"); } else { return new DefaultPackageScanClassResolver(); } }
/** * API method. */ public CDILiquibaseConfig createCDILiquibaseConfig() { final String id = UUID.randomUUID().toString(); log.debug(LogType.LOG, String.format("[id = %s] createConfig(). Date: '%s'", id, new Date())); final InputStream is = SchemesCDIConfigBuilder.class.getResourceAsStream(SCHEMA_NAME); try { return jvmLocked(id, new Callable<CDILiquibaseConfig>() { public CDILiquibaseConfig call() throws Exception { return createCDILiquibaseConfig(id, is); } }); } catch (Exception ex) { log.warning(LogType.LOG, String.format("[id = %s] Unable to initialize liquibase where '%s'.", id, ex.getMessage()), ex); return null; } finally { try { is.close(); } catch (IOException ioe) { log.warning(LogType.LOG, String.format("[id = %s] IOException during closing an input stream '%s'.", id, ioe.getMessage()), ioe); } } }
@Override protected void find(PackageScanFilter test, String packageName, Set<Class<?>> classes) { packageName = packageName.replace('.', '/'); Collection<String> names = bundleWiring.listResources(packageName, "*.class", BundleWiring.LISTRESOURCES_RECURSE); if (names == null) { return; } ClassLoader bundleClassLoader = bundleWiring.getClassLoader(); for (String name : names) { String fixedName = name.substring(0, name.indexOf('.')).replace('/', '.'); try { Class<?> klass = bundleClassLoader.loadClass(fixedName); if (test.matches(klass)) { classes.add(klass); } } catch (ClassNotFoundException e) { log.debug("Cant load class: " + e.getMessage()); } } } }
public Set<InputStream> getResourcesAsStream(String path) throws IOException { if (path == null) { return null; } else { Set<InputStream> returnSet = new HashSet(); Resource[] resources = ResourcePatternUtils.getResourcePatternResolver(CustomSpringLiquibase.this.getResourceLoader()).getResources(this.adjustClasspath(path)); if (resources != null && resources.length != 0) { Resource[] arr$ = resources; int len$ = resources.length; for(int i$ = 0; i$ < len$; ++i$) { Resource resource = arr$[i$]; LogFactory.getInstance().getLog().debug("Opening " + resource.getURL().toExternalForm() + " as " + path); URLConnection connection = resource.getURL().openConnection(); connection.setUseCaches(false); returnSet.add(connection.getInputStream()); } return returnSet; } else { return null; } } }
throw new RuntimeException(String.format("[id = %s] Cannot create [%s] dirs.", id, liquibaseDir)); log.debug(LogType.LOG, String.format("[id = %s] Includes directory: [path='%s']", id, liquibaseDir.getAbsolutePath())); log.debug(LogType.LOG, String.format("[id = %s] File [path='%s'] already exists, deleting", id, path)); if (output.delete()) { log.debug(LogType.LOG, String.format("[id = %s] File [path='%s'] already exists, deleted successfully.", id, path)); } else { log.debug(LogType.LOG, String.format("[id = %s] File [path='%s'] already exists, failed to delete.", id, path)); log.debug(LogType.LOG, String.format("[id = %s] Root liquibase file [path='%s'] ready.", id, path)); log.debug(LogType.LOG, String.format("[id = %s] Resolved schemes: %n%s%n", id, schemes)); log.debug(LogType.LOG, String.format("[id = %s] Generating root liquibase file...", id)); log.debug(LogType.LOG, String.format("[id = %s] Generation complete.", id)); log.debug(LogType.LOG, String.format("[id = %s] Root liquibase xml: %n %s %n", id, xml));
private void resolveDataSources() throws NamingException { Context context = new InitialContext(); int lastIndexOf = this.jndiBase.lastIndexOf("/"); String jndiRoot = this.jndiBase.substring(0, lastIndexOf); String jndiParent = this.jndiBase.substring(lastIndexOf + 1); Context base = (Context)context.lookup(jndiRoot); NamingEnumeration list = base.list(jndiParent); while(list.hasMoreElements()) { NameClassPair entry = (NameClassPair)list.nextElement(); String name = entry.getName(); String jndiUrl; if (entry.isRelative()) { jndiUrl = this.jndiBase + "/" + name; } else { jndiUrl = name; } Object lookup = context.lookup(jndiUrl); if (lookup instanceof DataSource) { this.dataSources.add((DataSource)lookup); this.log.debug("Added a data source at " + jndiUrl); } else { this.log.info("Skipping a resource " + jndiUrl + " not compatible with DataSource."); } } }
log.debug(LogType.LOG, String.format("[id = %s] LiquibaseSchema path is [path='%s'].", id, path)); log.debug(LogType.LOG, String.format("[id = %s] LiquibaseSchema path contains intermediate directories [path='%s'], preparing its...", id, dirPath)); log.info(LogType.LOG, String.format("[id = %s] File [path='%s'] created.", id, file.getAbsolutePath())); log.debug(LogType.LOG, String.format("[id = %s] LiquibaseSchema file [path='%s'] is ready, copying data...", id, file.getAbsolutePath()));
log.debug(LogType.LOG, String.format("[id = %s] build(%s)", id, schemes)); log.debug(LogType.LOG, String.format("[id = %s] Selected dependencies tree root [%s]", id, root.getItem())); log.debug(LogType.LOG, String.format("[id = %s] Made other non-dependent schemes children of root. [%s] dependent schemes to resolve. Resolving...", id, availableSchemes.size() log.debug(LogType.LOG, String.format("[id = %s] Resolution cycle [%s] started.", id, cycles)); int additions = 0; //we will count dependencies resolution for each resolution cycle. for (LiquibaseSchema liquibaseSchema : schemes) { log.debug(LogType.LOG, String.format( "[id = %s] LiquibaseSchema [name=%s] depends on liquibaseSchema [name=%s].", id, liquibaseSchema.name(), liquibaseSchema.depends() log.debug(LogType.LOG, String.format( "[id = %s] Dependency not found in resolved dependencies tree, skipping liquibaseSchema [name=%s] for a while.", id, liquibaseSchema.name() log.debug(LogType.LOG, String.format( "[id = %s] Dependency found for liquibaseSchema [name=%s], moving it to resolved dependencies tree.", id, liquibaseSchema.name() log.debug(LogType.LOG, String.format("[id = %s] Resolution cycle [%s] completed", id, cycles));
log.debug("includeAll for " + pathName); log.debug("Using file opener for includeAll: " + resourceAccessor.toString()); boolean isRelativeToChangelogFile = Boolean.parseBoolean(atts.getValue("relativeToChangelogFile")); File zipFileDir = OSGiXMLChangeLogSAXHandler.extractZipFile(fileUrl); if (pathName.startsWith("classpath:")) { log.debug("replace classpath"); pathName = pathName.replaceFirst("classpath:", ""); log.debug("replace classpath*"); pathName = pathName.replaceFirst("classpath\\*:", ""); fileUrl = fileUri.toURL(); } else { log.debug(fileUrl.toExternalForm() + " is not a file path"); continue; log.debug("includeAll using path " + file.getCanonicalPath()); if (!file.exists()) { throw new SAXException("includeAll path " + pathName + " could not be found. Tried in " log.debug(file.getCanonicalPath() + " is a directory"); for (File childFile : new TreeSet<File>(Arrays.asList(file.listFiles()))) { String path = pathName + childFile.getName(); if (!seenPaths.add(path)) { log.debug("already included " + path); continue; String path = pathName + file.getName();
@PostConstruct public void onStartup() { log.info(LogType.LOG, "Booting Liquibase " + LiquibaseUtil.getBuildVersion()); String hostName; try { hostName = NetUtil.getLocalHostName(); } catch (Exception e) { log.warning(LogType.LOG, "Cannot find hostname: " + e.getMessage()); log.debug(LogType.LOG, "", e); return; } LiquibaseConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance(); if (!liquibaseConfiguration.getConfiguration(GlobalConfiguration.class).getShouldRun()) { log.info(LogType.LOG, String.format("Liquibase did not run on %s because %s was set to false.", hostName, liquibaseConfiguration.describeValueLookupLogic( GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN) )); return; } initialized = true; try { performUpdate(); } catch (LiquibaseException e) { throw new UnexpectedLiquibaseException(e); } }