本文整理汇总了Java中java.util.ServiceConfigurationError.printStackTrace方法的典型用法代码示例。如果您正苦于以下问题:Java ServiceConfigurationError.printStackTrace方法的具体用法?Java ServiceConfigurationError.printStackTrace怎么用?Java ServiceConfigurationError.printStackTrace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ServiceConfigurationError
的用法示例。
在下文中一共展示了ServiceConfigurationError.printStackTrace方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDatabase
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
/**
* Iterate over all providers return the last provider.
*
* @return
*/
public Database getDatabase() {
Database database = null;
//TODO fail when more than one provider was found?
try {
Iterator<Database> databaseProviders = loader.iterator();
while (database == null && databaseProviders.hasNext()) {
database = databaseProviders.next();
log.debug("Found database service provider {" + database.getClass() + "}");
}
} catch (ServiceConfigurationError serviceError) {
serviceError.printStackTrace();
}
if (database == null) {
throw new RuntimeException("Could not find database provider.");
}
return database;
}
示例2: getStorage
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
/**
* Iterate over all providers and return the last provider.
*
* @return
*/
public BinaryStorage getStorage() {
BinaryStorage binaryStorage = null;
// TODO fail when more than one provider was found?
try {
Iterator<BinaryStorage> providers = loader.iterator();
while (binaryStorage == null && providers.hasNext()) {
binaryStorage = providers.next();
log.debug("Found service provider {" + binaryStorage.getClass() + "}");
}
} catch (ServiceConfigurationError serviceError) {
serviceError.printStackTrace();
}
if (binaryStorage == null) {
throw new RuntimeException("Could not find image provider.");
}
return binaryStorage;
}
示例3: getImageProvider
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
/**
* Iterate over all providers return the last provider.
*
* @return
*/
public ImageManipulator getImageProvider() {
ImageManipulator imageManipulator = null;
//TODO fail when more than one provider was found?
try {
Iterator<ImageManipulator> providers = loader.iterator();
while (imageManipulator == null && providers.hasNext()) {
imageManipulator = providers.next();
log.debug("Found service provider {" + imageManipulator.getClass() + "}");
}
} catch (ServiceConfigurationError serviceError) {
serviceError.printStackTrace();
}
if (imageManipulator == null) {
throw new RuntimeException("Could not find image provider.");
}
return imageManipulator;
}
示例4: registerApplicationClasspathSpis
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
/**
* Registers all available service providers found on the
* application class path, using the default
* <code>ClassLoader</code>. This method is typically invoked by
* the <code>ImageIO.scanForPlugins</code> method.
*
* @see javax.imageio.ImageIO#scanForPlugins
* @see ClassLoader#getResources
*/
public void registerApplicationClasspathSpis() {
// FIX: load only from application classpath
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Iterator categories = getCategories();
while (categories.hasNext()) {
Class<IIOServiceProvider> c = (Class)categories.next();
Iterator<IIOServiceProvider> riter =
ServiceLoader.load(c, loader).iterator();
while (riter.hasNext()) {
try {
// Note that the next() call is required to be inside
// the try/catch block; see 6342404.
IIOServiceProvider r = riter.next();
registerServiceProvider(r);
} catch (ServiceConfigurationError err) {
if (System.getSecurityManager() != null) {
// In the applet case, we will catch the error so
// registration of other plugins can proceed
err.printStackTrace();
} else {
// In the application case, we will throw the
// error to indicate app/system misconfiguration
throw err;
}
}
}
}
}
示例5: registerApplicationClasspathSpis
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
/**
* Registers all available service providers found on the
* application class path, using the default
* {@code ClassLoader}. This method is typically invoked by
* the {@code ImageIO.scanForPlugins} method.
*
* @see javax.imageio.ImageIO#scanForPlugins
* @see ClassLoader#getResources
*/
public void registerApplicationClasspathSpis() {
// FIX: load only from application classpath
ClassLoader loader = Thread.currentThread().getContextClassLoader();
Iterator<Class<?>> categories = getCategories();
while (categories.hasNext()) {
@SuppressWarnings("unchecked")
Class<IIOServiceProvider> c = (Class<IIOServiceProvider>)categories.next();
Iterator<IIOServiceProvider> riter =
ServiceLoader.load(c, loader).iterator();
while (riter.hasNext()) {
try {
// Note that the next() call is required to be inside
// the try/catch block; see 6342404.
IIOServiceProvider r = riter.next();
registerServiceProvider(r);
} catch (ServiceConfigurationError err) {
if (System.getSecurityManager() != null) {
// In the applet case, we will catch the error so
// registration of other plugins can proceed
err.printStackTrace();
} else {
// In the application case, we will throw the
// error to indicate app/system misconfiguration
throw err;
}
}
}
}
}
示例6: getJdbcEventListener
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
@Override
public JdbcEventListener getJdbcEventListener() {
// return first custom implementaion
for (Iterator<LoggingEventListener> iterator = customLoggingEventListener.iterator(); iterator.hasNext(); ) {
try {
return iterator.next();
} catch (ServiceConfigurationError e) {
e.printStackTrace();
}
}
// if none found, return default impl
return LoggingEventListener.INSTANCE;
}
示例7: registerEventListenersFromServiceLoader
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
protected void registerEventListenersFromServiceLoader(CompoundJdbcEventListener compoundEventListener) {
for (Iterator<JdbcEventListener> iterator = jdbcEventListenerServiceLoader.iterator(); iterator.hasNext(); ) {
try {
compoundEventListener.addListender(iterator.next());
} catch (ServiceConfigurationError e) {
e.printStackTrace();
}
}
}
示例8: printCloudServices
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
public void printCloudServices() {
try {
Iterator<Cloud> providers = loader.iterator();
while (providers.hasNext()) {
Cloud c = providers.next();
System.out.println("Provider Name: " + c.getProviderName());
List<String> serviceNames = c.getServiceNames();
for (String name : serviceNames) {
System.out.println(name);
}
}
} catch (ServiceConfigurationError e) {
e.printStackTrace();
}
}
示例9: printSearchResults
import java.util.ServiceConfigurationError; //导入方法依赖的package包/类
public void printSearchResults(String keyword) {
try {
Iterator<Search> providers = loader.iterator();
while (providers.hasNext()) {
Search s = providers.next();
System.out.println("Provider Name: " + s.getProviderName());
List<String> searchResults = s.search(keyword);
for (String result : searchResults) {
System.out.println(result);
}
}
} catch (ServiceConfigurationError e) {
e.printStackTrace();
}
}