1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.modeshape.jboss.managed;
25
26 import java.util.concurrent.TimeUnit;
27 import org.jboss.managed.api.ManagedOperation.Impact;
28 import org.jboss.managed.api.annotation.ManagementComponent;
29 import org.jboss.managed.api.annotation.ManagementObject;
30 import org.jboss.managed.api.annotation.ManagementObjectID;
31 import org.jboss.managed.api.annotation.ManagementOperation;
32 import org.jboss.managed.api.annotation.ManagementProperties;
33 import org.jboss.managed.api.annotation.ManagementProperty;
34 import org.jboss.managed.api.annotation.ViewUse;
35 import org.modeshape.common.util.CheckArg;
36 import org.modeshape.common.util.Logger;
37 import org.modeshape.common.util.Logger.Level;
38 import org.modeshape.graph.connector.RepositorySource;
39
40
41
42
43 @ManagementObject( description = "A ModeShape connector (repository source)", componentType = @ManagementComponent( type = "ModeShape", subtype = "Connector" ), properties = ManagementProperties.EXPLICIT )
44 public class ManagedConnector implements ModeShapeManagedObject {
45
46
47 protected ManagedConnector() {
48 this.connector = null;
49 }
50
51
52
53
54
55
56
57
58 private final RepositorySource connector;
59
60
61
62
63
64
65 public ManagedConnector( RepositorySource connector ) {
66 CheckArg.isNotNull(connector, "connector");
67 this.connector = connector;
68 }
69
70
71
72
73
74
75 @ManagementProperty( name = "Retry Limit", description = "The maximum number of retries to perform on an operation", readOnly = false, use = ViewUse.RUNTIME )
76 public int getRetryLimit() {
77 return this.connector.getRetryLimit();
78 }
79
80
81
82
83
84
85 @ManagementProperty( name = "Connector Name", description = "The name of the repository source", readOnly = true, use = ViewUse.CONFIGURATION )
86 @ManagementObjectID(prefix="ModeShape-")
87 public String getName() {
88 return this.connector.getName();
89 }
90
91
92
93
94
95
96 @ManagementProperty( name = "Supports Creating Workspaces", description = "Indicates if creating workspaces is allowed", readOnly = true, use = ViewUse.CONFIGURATION )
97 public boolean isSupportingCreatingWorkspaces() {
98 return this.connector.getCapabilities().supportsCreatingWorkspaces();
99 }
100
101
102
103
104
105
106 @ManagementProperty( name = "Supports Events", description = "Indicates if the publishing of changes events is supported", readOnly = true, use = ViewUse.CONFIGURATION )
107 public boolean isSupportingEvents() {
108 return this.connector.getCapabilities().supportsEvents();
109 }
110
111
112
113
114
115
116 @ManagementProperty( name = "Supports Locks", description = "Indicates if locks can be created", readOnly = true, use = ViewUse.CONFIGURATION )
117 public boolean isSupportingLocks() {
118 return this.connector.getCapabilities().supportsLocks();
119 }
120
121
122
123
124
125
126 @ManagementProperty( name = "Supports Queries", description = "Indicates if queries are supported", readOnly = true, use = ViewUse.CONFIGURATION )
127 public boolean isSupportingQueries() {
128 return this.connector.getCapabilities().supportsQueries();
129 }
130
131
132
133
134
135
136 @ManagementProperty( name = "Supports References", description = "Indicates if references by identifiers are supported", readOnly = true, use = ViewUse.CONFIGURATION )
137 public boolean isSupportingReferences() {
138 return this.connector.getCapabilities().supportsReferences();
139 }
140
141
142
143
144
145
146
147 @ManagementProperty( name = "Supports Same Name Siblings", description = "Indicates if siblings can have the same name", readOnly = true, use = ViewUse.CONFIGURATION )
148 public boolean isSupportingSameNameSiblings() {
149 return this.connector.getCapabilities().supportsSameNameSiblings();
150 }
151
152
153
154
155
156
157 @ManagementProperty( name = "Supports Searches", description = "Indicates if full-text searches are supported", readOnly = true, use = ViewUse.CONFIGURATION )
158 public boolean isSupportingSearches() {
159 return this.connector.getCapabilities().supportsSearches();
160 }
161
162
163
164
165
166
167 @ManagementProperty( name = "Supports Updates", description = "Indicates if updates can be made to the repository source", readOnly = true, use = ViewUse.CONFIGURATION )
168 public boolean isSupportingUpdates() {
169 return this.connector.getCapabilities().supportsUpdates();
170 }
171
172
173
174
175
176
177 @ManagementOperation( description = "Indicates if the connection is valid and alive", impact = Impact.ReadOnly )
178 public boolean ping() {
179 try {
180 return this.connector.getConnection().ping(2, TimeUnit.SECONDS);
181 } catch (Exception e) {
182 Logger.getLogger(getClass()).log(Level.ERROR,
183 e,
184 JBossManagedI18n.errorDeterminingIfConnectionIsAlive,
185 this.connector.getName());
186 return false;
187 }
188 }
189
190
191
192
193
194
195 public void setRetryLimit( int limit ) {
196 CheckArg.isNonNegative(limit, "limit");
197 this.connector.setRetryLimit(limit);
198 }
199
200 }