DeveelDB
20151217
complete SQL database system, primarly developed for .NET/Mono frameworks
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
deveeldb.git
src
deveeldb
Deveel.Data.Diagnostics
EventRegistry.cs
Go to the documentation of this file.
1
//
2
// Copyright 2010-2015 Deveel
3
//
4
// Licensed under the Apache License, Version 2.0 (the "License");
5
// you may not use this file except in compliance with the License.
6
// You may obtain a copy of the License at
7
//
8
// http://www.apache.org/licenses/LICENSE-2.0
9
//
10
// Unless required by applicable law or agreed to in writing, software
11
// distributed under the License is distributed on an "AS IS" BASIS,
12
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
// See the License for the specific language governing permissions and
14
// limitations under the License.
15
//
16
17
using
System
;
18
19
using
Deveel
.
Data
.
Configuration
;
20
21
namespace
Deveel
.Data.Diagnostics {
22
public
sealed
class
EventRegistry
:
ThreadedQueue
<IEvent>,
IEventRegistry
, IDisposable {
23
private
bool
disposed
;
24
25
private
readonly
int
threadCount
;
26
27
public
EventRegistry
(
IContext
context) {
28
if
(context == null)
29
throw
new
ArgumentNullException(
"context"
);
30
31
Context
= context;
32
33
var config = context.ResolveService<
IConfiguration
>();
34
threadCount = config.GetInt32(
"system.events.threadCount"
, 4);
35
}
36
37
~EventRegistry
() {
38
Dispose(
false
);
39
}
40
41
public
IContext
Context
{
get
;
private
set; }
42
43
public
override
int
ThreadCount {
44
get
{
return
threadCount; }
45
}
46
47
public
void
RegisterEvent
(
IEvent
@event) {
48
Enqueue(@event);
49
}
50
51
protected
override
void
Consume
(
IEvent
message) {
52
var routers =
Context
.ResolveAllServices<
IEventRouter
>();
53
foreach
(var router
in
routers) {
54
try
{
55
if
(router.CanRoute(message))
56
router.
RouteEvent
(message);
57
}
catch
(Exception ex) {
58
Enqueue(
new
ErrorEvent
(ex, -1,
ErrorLevel
.Critical));
59
}
60
}
61
}
62
63
protected
override
void
Dispose
(
bool
disposing) {
64
if
(disposed) {
65
Context
= null;
66
disposed =
true
;
67
}
68
69
base.
Dispose
(disposing);
70
}
71
}
72
}
Deveel.Data.Diagnostics.EventRegistry.threadCount
readonly int threadCount
Definition:
EventRegistry.cs:25
Deveel.Data.Diagnostics.EventRegistry.disposed
bool disposed
Definition:
EventRegistry.cs:23
Deveel
System
Definition:
NonSerializedAttribute.cs:3
Deveel.Data.Diagnostics.IEvent
This is an event occurred during the lifetime of a database.
Definition:
IEvent.cs:24
Deveel.Data.Diagnostics.IEventRouter.RouteEvent
void RouteEvent(IEvent e)
Routes the input event to the final destination.
Deveel.Data.Context
Definition:
Context.cs:22
Deveel.Data.Context.Dispose
virtual void Dispose(bool disposing)
Definition:
Context.cs:63
Deveel.Data.Diagnostics.EventRegistry.EventRegistry
EventRegistry(IContext context)
Definition:
EventRegistry.cs:27
Deveel.Data.Diagnostics.EventRegistry
Definition:
EventRegistry.cs:22
Deveel.Data.Diagnostics.ErrorLevel
ErrorLevel
In case of error messages, this enumerates the level of severity of the error.
Definition:
ErrorLevel.cs:24
Deveel.Data.Diagnostics.EventRegistry.~EventRegistry
~EventRegistry()
Definition:
EventRegistry.cs:37
Deveel.Data.Diagnostics.IEventRegistry
Implementations of this interface handle the registration of events fired within the system...
Definition:
IEventRegistry.cs:32
Deveel.Data.Configuration.IConfiguration
Defines the contract for the configuration node of a component within the system or of the system its...
Definition:
IConfiguration.cs:33
Deveel.Data.Diagnostics.EventRegistry.Dispose
override void Dispose(bool disposing)
Definition:
EventRegistry.cs:63
Deveel.Data.Diagnostics.ThreadedQueue
Definition:
ThreadedQueue.cs:26
Deveel.Data.Diagnostics.ErrorEvent
Definition:
ErrorEvent.cs:21
Deveel.Data
Definition:
ActiveSessionList.cs:22
Deveel.Data.Configuration
Definition:
ConfigGroup.cs:19
Deveel.Data.Diagnostics.EventRegistry.RegisterEvent
void RegisterEvent(IEvent @event)
Adds the specified event object to the registry.
Definition:
EventRegistry.cs:47
Deveel.Data.Diagnostics.IEventRouter
Defines the basic logic for the dispatching of events within a system workflow.
Definition:
IEventRouter.cs:36
Deveel.Data.Diagnostics.EventRegistry.Consume
override void Consume(IEvent message)
Definition:
EventRegistry.cs:51
Deveel.Data.IContext
Definition:
IContext.cs:22
Generated by
1.8.10