use of com.sun.jersey.core.spi.scanning.PackageNamesScanner in project coprhd-controller by CoprHD.
the class PackageScanner method getModelClasses.
@SuppressWarnings("unchecked")
protected Collection<Class<?>> getModelClasses(Class<? extends Annotation>... annotations) {
PackageNamesScanner clazzScanner = new PackageNamesScanner(this.packages);
AnnotationScannerListener scannerListener = new AnnotationScannerListener(annotations);
clazzScanner.scan(scannerListener);
return scannerListener.getAnnotatedClasses();
}
use of com.sun.jersey.core.spi.scanning.PackageNamesScanner in project coprhd-controller by CoprHD.
the class PackageScanner method setPackages.
/**
* Package where model classes are defined
*
* @param packages
*/
public void setPackages(String... packages) {
this.packages = packages;
_scanner = new PackageNamesScanner(packages);
}
use of com.sun.jersey.core.spi.scanning.PackageNamesScanner in project coprhd-controller by CoprHD.
the class Documenter method getMessageBundleClasses.
@SuppressWarnings("unchecked")
public static List<Class<?>> getMessageBundleClasses() {
final PackageNamesScanner scanner = new PackageNamesScanner(PACKAGES);
final AnnotationScannerListener scannerListener = new AnnotationScannerListener(MessageBundle.class);
scanner.scan(scannerListener);
final List<Class<?>> list = new ArrayList<Class<?>>();
for (final Class<?> clazz : scannerListener.getAnnotatedClasses()) {
if (clazz.isEnum()) {
continue;
}
list.add(clazz);
}
return list;
}
use of com.sun.jersey.core.spi.scanning.PackageNamesScanner in project joynr by bmwcarit.
the class AbstractJoynrServletModule method bindAnnotatedFilters.
/**
* Sets up filters that are annotated with the {@link WebFilter} annotation.
* Every class in the classpath is searched for the annotation.
*/
@SuppressWarnings("unchecked")
private void bindAnnotatedFilters() {
String appsPackages = null;
if (System.getProperties().containsKey(IO_JOYNR_APPS_PACKAGES)) {
logger.info("Using property {} from system properties", IO_JOYNR_APPS_PACKAGES);
appsPackages = System.getProperty(IO_JOYNR_APPS_PACKAGES);
} else {
Properties servletProperties = PropertyLoader.loadProperties("servlet.properties");
if (servletProperties.containsKey(IO_JOYNR_APPS_PACKAGES)) {
appsPackages = servletProperties.getProperty(IO_JOYNR_APPS_PACKAGES);
}
}
if (appsPackages != null) {
String[] packageNames = appsPackages.split(";");
logger.info("Searching packages for @WebFilter annotation: {}", Arrays.toString(packageNames));
PackageNamesScanner scanner = new PackageNamesScanner(packageNames);
AnnotationScannerListener sl = new AnnotationScannerListener(WebFilter.class);
scanner.scan(sl);
for (Class<?> webFilterAnnotatedClass : sl.getAnnotatedClasses()) {
if (Filter.class.isAssignableFrom(webFilterAnnotatedClass)) {
bind(webFilterAnnotatedClass).in(Singleton.class);
filter("/*").through((Class<? extends Filter>) webFilterAnnotatedClass);
logger.info("Adding filter {} for '/*'", webFilterAnnotatedClass.getName());
}
}
}
}
use of com.sun.jersey.core.spi.scanning.PackageNamesScanner in project coprhd-controller by CoprHD.
the class DBClient method init.
public void init() {
try {
System.out.println("Initializing db client ...");
ctx = new ClassPathXmlApplicationContext("/dbutils-conf.xml");
InternalDbClientImpl dbClient = (InternalDbClientImpl) ctx.getBean("dbclient");
_geodbContext = (DbClientContext) ctx.getBean("geodbclientcontext");
vdcConfHelper = (VdcConfigHelper) ctx.getBean("vdcConfHelper");
geoEncryptionProvider = (EncryptionProviderImpl) ctx.getBean("geoEncryptionProvider");
encryptionProvider = (EncryptionProviderImpl) ctx.getBean("encryptionProvider");
dbClient.setBypassMigrationLock(skipMigrationCheck);
dbClient.start();
_dbClient = dbClient;
// scan for classes with @Cf annotation
System.out.println("Initializing column family map ...");
AnnotationScannerListener scannerListener = new AnnotationScannerListener(Cf.class);
String[] packages = { pkgs };
PackageNamesScanner scanner = new PackageNamesScanner(packages);
scanner.scan(scannerListener);
Iterator<Class<?>> it = scannerListener.getAnnotatedClasses().iterator();
while (it.hasNext()) {
Class clazz = it.next();
// The fields of SchemaRecord don't have Name annotation either.
if (DataObject.class.isAssignableFrom(clazz)) {
DataObjectType doType = TypeMap.getDoType(clazz);
_cfMap.put(doType.getCF().getName(), clazz);
}
}
} catch (Exception e) {
System.err.println("Caught Exception: " + e);
log.error("Caught Exception: ", e);
}
}
Aggregations