本文整理汇总了Java中com.google.common.eventbus.SubscriberExceptionHandler类的典型用法代码示例。如果您正苦于以下问题:Java SubscriberExceptionHandler类的具体用法?Java SubscriberExceptionHandler怎么用?Java SubscriberExceptionHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubscriberExceptionHandler类属于com.google.common.eventbus包,在下文中一共展示了SubscriberExceptionHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: LoadController
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
public LoadController(Loader loader)
{
this.loader = loader;
this.masterChannel = new EventBus(new SubscriberExceptionHandler()
{
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context)
{
FMLLog.log("FMLMainChannel", Level.ERROR, exception, "Could not dispatch event: %s to %s", context.getEvent(), context.getSubscriberMethod());
}
});
this.masterChannel.register(this);
state = LoaderState.NOINIT;
packageOwners = ArrayListMultimap.create();
}
示例2: newEventBus
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
private static EventBus newEventBus(final String name, final Executor executor) {
try {
Class<?> dispatcherClass = EventBus.class.getClassLoader().loadClass("com.google.common.eventbus.Dispatcher");
// immediate dispatcher means events are always processed in a reentrant fashion
Method immediateDispatcherMethod = dispatcherClass.getDeclaredMethod("immediate");
immediateDispatcherMethod.setAccessible(true);
// EventBus constructor that accepts custom executor is not yet part of the public API
Constructor<EventBus> eventBusConstructor = EventBus.class.getDeclaredConstructor(
String.class, Executor.class, dispatcherClass, SubscriberExceptionHandler.class);
eventBusConstructor.setAccessible(true);
Object immediateDispatcher = immediateDispatcherMethod.invoke(null);
SubscriberExceptionHandler exceptionHandler = new Slf4jSubscriberExceptionHandler(name);
return eventBusConstructor.newInstance(name, executor, immediateDispatcher, exceptionHandler);
}
catch (Exception e) {
Throwables.throwIfUnchecked(e);
throw new LinkageError("Unable to create EventBus with custom executor", e);
}
}
示例3: BlazeWorkspace
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
public BlazeWorkspace(
BlazeRuntime runtime,
BlazeDirectories directories,
SkyframeExecutor skyframeExecutor,
SubscriberExceptionHandler eventBusExceptionHandler,
WorkspaceStatusAction.Factory workspaceStatusActionFactory,
BinTools binTools,
@Nullable AllocationTracker allocationTracker) {
this.runtime = runtime;
this.eventBusExceptionHandler = eventBusExceptionHandler;
this.workspaceStatusActionFactory = workspaceStatusActionFactory;
this.binTools = binTools;
this.allocationTracker = allocationTracker;
this.directories = directories;
this.skyframeExecutor = skyframeExecutor;
if (directories.inWorkspace()) {
writeOutputBaseReadmeFile();
writeDoNotBuildHereFile();
}
setupExecRoot();
// Here we use outputBase instead of outputPath because we need a file system to create the
// latter.
this.outputBaseFilesystemTypeName = FileSystemUtils.getFileSystem(getOutputBase());
}
示例4: unhandledExceptionInEventThreadCallsSubscriberExceptionHandler
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
@Test
public void unhandledExceptionInEventThreadCallsSubscriberExceptionHandler() {
SubscriberExceptionHandler handler = mock(SubscriberExceptionHandler.class);
EventBus bus = new EventBus(handler);
final IllegalStateException exception = new IllegalStateException("Excepted Unhandled Exception");
bus.register(new Object() {
@Subscribe
public void throwUnhandledException(TriggerUnhandledException event) {
throw exception;
}
});
bus.post(new TriggerUnhandledException());
verify(handler).handleException(eq(exception), any(SubscriberExceptionContext.class));
}
示例5: buildModList
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
@Subscribe
public void buildModList(FMLLoadEvent event)
{
Builder<String, EventBus> eventBus = ImmutableMap.builder();
for (final ModContainer mod : loader.getModList())
{
//Create mod logger, and make the EventBus logger a child of it.
EventBus bus = new EventBus(new SubscriberExceptionHandler()
{
@Override
public void handleException(final Throwable exception, final SubscriberExceptionContext context)
{
LoadController.this.errorOccurred(mod, exception);
}
});
boolean isActive = mod.registerBus(bus, this);
if (isActive)
{
activeModList.add(mod);
modStates.put(mod.getModId(), ModState.UNLOADED);
eventBus.put(mod.getModId(), bus);
FMLCommonHandler.instance().addModToResourcePack(mod);
}
else
{
FMLLog.log(mod.getModId(), Level.WARN, "Mod %s has been disabled through configuration", mod.getModId());
modStates.put(mod.getModId(), ModState.UNLOADED);
modStates.put(mod.getModId(), ModState.DISABLED);
}
modNames.put(mod.getModId(), mod.getName());
}
eventChannels = eventBus.build();
}
示例6: MentorEventBus
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
MentorEventBus() {
this(Executors.newWorkStealingPool(), new SubscriberExceptionHandler() {
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
Log.error("Error in event handler ({})", context, exception);
}
});
}
示例7: build
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
BlazeWorkspace build(
BlazeRuntime runtime,
PackageFactory packageFactory,
ConfiguredRuleClassProvider ruleClassProvider,
SubscriberExceptionHandler eventBusExceptionHandler) throws AbruptExitException {
// Set default values if none are set.
if (skyframeExecutorFactory == null) {
skyframeExecutorFactory = new SequencedSkyframeExecutorFactory();
}
SkyframeExecutor skyframeExecutor =
skyframeExecutorFactory.create(
packageFactory,
runtime.getFileSystem(),
directories,
runtime.getActionKeyContext(),
workspaceStatusActionFactory,
ruleClassProvider.getBuildInfoFactories(),
diffAwarenessFactories.build(),
skyFunctions.build(),
customDirtinessCheckers.build());
return new BlazeWorkspace(
runtime,
directories,
skyframeExecutor,
eventBusExceptionHandler,
workspaceStatusActionFactory,
binTools,
allocationTracker);
}
示例8: EventBusThatPublishesUnhandledExceptionEvents
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
public EventBusThatPublishesUnhandledExceptionEvents() {
super(new SubscriberExceptionHandler() {
@Override
public void handleException(Throwable throwable, SubscriberExceptionContext subscriberExceptionContext) {
postUncaughtExceptionEvent(throwable);
}
});
errorMessageBus.register(this);
}
开发者ID:DavidWhitlock,项目名称:PortlandStateJava,代码行数:11,代码来源:EventBusThatPublishesUnhandledExceptionEvents.java
示例9: AppEventBus
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
public AppEventBus() {
eventbus = new EventBus(new SubscriberExceptionHandler() {
@Override
public void handleException(Throwable exception, SubscriberExceptionContext context) {
log.error("Could not dispatch event: " + context.getSubscriber() + " to " + context.getSubscriberMethod());
exception.printStackTrace();
}
});
}
示例10: ReentrantEventBus
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
public ReentrantEventBus(SubscriberExceptionHandler subscriberExceptionHandler) {
super(subscriberExceptionHandler);
this.isDispatching = getIsDispatching();
}
示例11: configure
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
@Override
protected void configure() {
bind(SubscriberExceptionHandler.class).to(EventExceptionHandler.class);
}
示例12: eventBus
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
@Provides @Singleton
EventBus eventBus(SubscriberExceptionHandler exceptionHandler) {
return new ReentrantEventBus(exceptionHandler);
}
示例13: BlazeRuntime
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
private BlazeRuntime(
FileSystem fileSystem,
QueryEnvironmentFactory queryEnvironmentFactory,
ImmutableList<QueryFunction> queryFunctions,
ImmutableList<OutputFormatter> queryOutputFormatters,
PackageFactory pkgFactory,
ConfiguredRuleClassProvider ruleClassProvider,
ImmutableList<ConfigurationFragmentFactory> configurationFragmentFactories,
ImmutableMap<String, InfoItem> infoItems,
ActionKeyContext actionKeyContext,
Clock clock,
Runnable abruptShutdownHandler,
OptionsProvider startupOptionsProvider,
Iterable<BlazeModule> blazeModules,
SubscriberExceptionHandler eventBusExceptionHandler,
ProjectFile.Provider projectFileProvider,
InvocationPolicy moduleInvocationPolicy,
Iterable<BlazeCommand> commands,
String productName,
PathConverter pathToUriConverter) {
// Server state
this.fileSystem = fileSystem;
this.blazeModules = blazeModules;
overrideCommands(commands);
this.packageFactory = pkgFactory;
this.projectFileProvider = projectFileProvider;
this.moduleInvocationPolicy = moduleInvocationPolicy;
this.ruleClassProvider = ruleClassProvider;
this.configurationFragmentFactories = configurationFragmentFactories;
this.infoItems = infoItems;
this.actionKeyContext = actionKeyContext;
this.clock = clock;
this.abruptShutdownHandler = abruptShutdownHandler;
this.startupOptionsProvider = startupOptionsProvider;
this.queryEnvironmentFactory = queryEnvironmentFactory;
this.queryFunctions = queryFunctions;
this.queryOutputFormatters = queryOutputFormatters;
this.eventBusExceptionHandler = eventBusExceptionHandler;
this.defaultsPackageContent =
ruleClassProvider.getDefaultsPackageContent(getModuleInvocationPolicy());
CommandNameCache.CommandNameCacheInstance.INSTANCE.setCommandNameCache(
new CommandNameCacheImpl(getCommandMap()));
this.productName = productName;
this.pathToUriConverter = pathToUriConverter;
}
示例14: setEventBusExceptionHandler
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
@VisibleForTesting
public Builder setEventBusExceptionHandler(
SubscriberExceptionHandler eventBusExceptionHandler) {
this.eventBusExceptionHandler = eventBusExceptionHandler;
return this;
}
示例15: VisEventBus
import com.google.common.eventbus.SubscriberExceptionHandler; //导入依赖的package包/类
public VisEventBus (SubscriberExceptionHandler subscriberExceptionHandler) {
super(subscriberExceptionHandler);
}