1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.registry; |
12 | |
|
13 | |
import org.mule.api.MuleContext; |
14 | |
import org.mule.api.MuleException; |
15 | |
import org.mule.api.NamedObject; |
16 | |
import org.mule.api.agent.Agent; |
17 | |
import org.mule.api.config.MuleProperties; |
18 | |
import org.mule.api.construct.FlowConstruct; |
19 | |
import org.mule.api.endpoint.EndpointBuilder; |
20 | |
import org.mule.api.endpoint.EndpointFactory; |
21 | |
import org.mule.api.endpoint.ImmutableEndpoint; |
22 | |
import org.mule.api.lifecycle.Disposable; |
23 | |
import org.mule.api.lifecycle.Initialisable; |
24 | |
import org.mule.api.lifecycle.InitialisationException; |
25 | |
import org.mule.api.lifecycle.LifecycleException; |
26 | |
import org.mule.api.model.Model; |
27 | |
import org.mule.api.registry.AbstractServiceDescriptor; |
28 | |
import org.mule.api.registry.MuleRegistry; |
29 | |
import org.mule.api.registry.RegistrationException; |
30 | |
import org.mule.api.registry.ResolverException; |
31 | |
import org.mule.api.registry.ServiceDescriptor; |
32 | |
import org.mule.api.registry.ServiceDescriptorFactory; |
33 | |
import org.mule.api.registry.ServiceException; |
34 | |
import org.mule.api.registry.ServiceType; |
35 | |
import org.mule.api.registry.TransformerResolver; |
36 | |
import org.mule.api.service.Service; |
37 | |
import org.mule.api.transformer.DataType; |
38 | |
import org.mule.api.transformer.DiscoverableTransformer; |
39 | |
import org.mule.api.transformer.Transformer; |
40 | |
import org.mule.api.transformer.TransformerException; |
41 | |
import org.mule.api.transport.Connector; |
42 | |
import org.mule.config.i18n.CoreMessages; |
43 | |
import org.mule.transformer.types.SimpleDataType; |
44 | |
import org.mule.util.SpiUtils; |
45 | |
import org.mule.util.StringUtils; |
46 | |
import org.mule.util.UUID; |
47 | |
|
48 | |
import java.util.ArrayList; |
49 | |
import java.util.Collection; |
50 | |
import java.util.Collections; |
51 | |
import java.util.Comparator; |
52 | |
import java.util.Iterator; |
53 | |
import java.util.List; |
54 | |
import java.util.Map; |
55 | |
import java.util.Properties; |
56 | |
|
57 | |
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap; |
58 | |
|
59 | |
import org.apache.commons.logging.Log; |
60 | |
import org.apache.commons.logging.LogFactory; |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public class MuleRegistryHelper implements MuleRegistry |
67 | |
{ |
68 | 0 | protected transient Log logger = LogFactory.getLog(MuleRegistryHelper.class); |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
private DefaultRegistryBroker registry; |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | 0 | protected ConcurrentHashMap exactTransformerCache = new ConcurrentHashMap(8); |
79 | 0 | protected ConcurrentHashMap transformerListCache = new ConcurrentHashMap(8); |
80 | |
|
81 | |
private MuleContext muleContext; |
82 | |
|
83 | |
public MuleRegistryHelper(DefaultRegistryBroker registry, MuleContext muleContext) |
84 | 0 | { |
85 | 0 | this.registry = registry; |
86 | 0 | this.muleContext = muleContext; |
87 | 0 | } |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
public void initialise() throws InitialisationException |
93 | |
{ |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | 0 | } |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public void dispose() |
104 | |
{ |
105 | 0 | transformerListCache.clear(); |
106 | 0 | exactTransformerCache.clear(); |
107 | 0 | } |
108 | |
|
109 | |
public void fireLifecycle(String phase) throws LifecycleException |
110 | |
{ |
111 | 0 | if(Initialisable.PHASE_NAME.equals(phase)) |
112 | |
{ |
113 | 0 | registry.initialise(); |
114 | |
} |
115 | 0 | else if(Disposable.PHASE_NAME.equals(phase)) |
116 | |
{ |
117 | 0 | registry.dispose(); |
118 | |
} |
119 | |
else |
120 | |
{ |
121 | 0 | registry.fireLifecycle(phase); |
122 | |
} |
123 | 0 | } |
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
public Connector lookupConnector(String name) |
129 | |
{ |
130 | 0 | return (Connector) registry.lookupObject(name); |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
|
167 | |
public EndpointBuilder lookupEndpointBuilder(String name) |
168 | |
{ |
169 | 0 | Object o = registry.lookupObject(name); |
170 | 0 | if (o instanceof EndpointBuilder) |
171 | |
{ |
172 | 0 | logger.debug("Global endpoint EndpointBuilder for name: " + name + " found"); |
173 | 0 | return (EndpointBuilder) o; |
174 | |
} |
175 | |
else |
176 | |
{ |
177 | 0 | logger.debug("No endpoint builder with the name: " + name + " found."); |
178 | 0 | return null; |
179 | |
} |
180 | |
} |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
public EndpointFactory lookupEndpointFactory() |
186 | |
{ |
187 | 0 | return (EndpointFactory) registry.lookupObject(MuleProperties.OBJECT_MULE_ENDPOINT_FACTORY); |
188 | |
} |
189 | |
|
190 | |
|
191 | |
|
192 | |
|
193 | |
public Transformer lookupTransformer(String name) |
194 | |
{ |
195 | 0 | return (Transformer) registry.lookupObject(name); |
196 | |
} |
197 | |
|
198 | |
|
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
@Deprecated |
206 | |
public Transformer lookupTransformer(Class inputType, Class outputType) throws TransformerException |
207 | |
{ |
208 | 0 | return lookupTransformer(new SimpleDataType(inputType), new SimpleDataType(outputType)); |
209 | |
} |
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
|
215 | |
|
216 | |
|
217 | |
|
218 | |
@Deprecated |
219 | |
public List<Transformer> lookupTransformers(Class input, Class output) |
220 | |
{ |
221 | 0 | return lookupTransformers(new SimpleDataType(input), new SimpleDataType(output)); |
222 | |
} |
223 | |
|
224 | |
|
225 | |
|
226 | |
|
227 | |
public Transformer lookupTransformer(DataType source, DataType result) throws TransformerException |
228 | |
{ |
229 | 0 | final String dataTypePairHash = getDataTypeSourceResultPairHash(source, result); |
230 | 0 | Transformer cachedTransformer = (Transformer) exactTransformerCache.get(dataTypePairHash); |
231 | 0 | if (cachedTransformer != null) |
232 | |
{ |
233 | 0 | return cachedTransformer; |
234 | |
} |
235 | |
|
236 | 0 | Transformer trans = resolveTransformer(source, result); |
237 | |
|
238 | 0 | if (trans != null) |
239 | |
{ |
240 | 0 | Transformer concurrentlyAddedTransformer = (Transformer) exactTransformerCache.putIfAbsent( |
241 | |
dataTypePairHash, trans); |
242 | 0 | if (concurrentlyAddedTransformer != null) |
243 | |
{ |
244 | 0 | return concurrentlyAddedTransformer; |
245 | |
} |
246 | |
else |
247 | |
{ |
248 | 0 | return trans; |
249 | |
} |
250 | |
} |
251 | |
else |
252 | |
{ |
253 | 0 | throw new TransformerException(CoreMessages.noTransformerFoundForMessage(source, result)); |
254 | |
} |
255 | |
} |
256 | |
|
257 | |
protected Transformer resolveTransformer(DataType source, DataType result) throws TransformerException |
258 | |
{ |
259 | 0 | List<TransformerResolver> resolvers = (List<TransformerResolver>) lookupObjects(TransformerResolver.class); |
260 | 0 | Collections.sort(resolvers, new TransformerResolverComparator()); |
261 | |
|
262 | 0 | for (TransformerResolver resolver : resolvers) |
263 | |
{ |
264 | |
try |
265 | |
{ |
266 | 0 | Transformer trans = resolver.resolve(source, result); |
267 | 0 | if (trans != null) |
268 | |
{ |
269 | 0 | return trans; |
270 | |
} |
271 | |
} |
272 | 0 | catch (ResolverException e) |
273 | |
{ |
274 | 0 | throw new TransformerException(CoreMessages.noTransformerFoundForMessage(source, result), e); |
275 | 0 | } |
276 | |
} |
277 | 0 | return null; |
278 | |
} |
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
public List<Transformer> lookupTransformers(DataType source, DataType result) |
284 | |
{ |
285 | 0 | final String dataTypePairHash = getDataTypeSourceResultPairHash(source, result); |
286 | |
|
287 | 0 | List<Transformer> results = (List<Transformer>) transformerListCache.get(dataTypePairHash); |
288 | 0 | if (results != null) |
289 | |
{ |
290 | 0 | return results; |
291 | |
} |
292 | |
|
293 | 0 | results = new ArrayList<Transformer>(2); |
294 | 0 | Collection<Transformer> transformers = getTransformers(); |
295 | 0 | for (Transformer t : transformers) |
296 | |
{ |
297 | |
|
298 | |
|
299 | |
|
300 | 0 | if (!(t instanceof DiscoverableTransformer)) |
301 | |
{ |
302 | 0 | continue; |
303 | |
} |
304 | 0 | DataType dt = t.getReturnDataType(); |
305 | 0 | if (result.isCompatibleWith(dt) && t.isSourceDataTypeSupported(source)) |
306 | |
{ |
307 | 0 | results.add(t); |
308 | |
} |
309 | 0 | } |
310 | |
|
311 | 0 | List<Transformer> concurrentlyAddedTransformers = (List<Transformer>) transformerListCache.putIfAbsent( |
312 | |
dataTypePairHash, results); |
313 | 0 | if (concurrentlyAddedTransformers != null) |
314 | |
{ |
315 | 0 | return concurrentlyAddedTransformers; |
316 | |
} |
317 | |
else |
318 | |
{ |
319 | 0 | return results; |
320 | |
} |
321 | |
} |
322 | |
|
323 | |
|
324 | |
|
325 | |
|
326 | |
public Model lookupModel(String name) |
327 | |
{ |
328 | 0 | return (Model) registry.lookupObject(name); |
329 | |
} |
330 | |
|
331 | |
|
332 | |
|
333 | |
|
334 | |
public Model lookupSystemModel() |
335 | |
{ |
336 | 0 | return lookupModel(MuleProperties.OBJECT_SYSTEM_MODEL); |
337 | |
} |
338 | |
|
339 | |
|
340 | |
|
341 | |
|
342 | |
public Collection<Model> getModels() |
343 | |
{ |
344 | 0 | return registry.lookupObjects(Model.class); |
345 | |
} |
346 | |
|
347 | |
|
348 | |
|
349 | |
|
350 | |
public Collection<Connector> getConnectors() |
351 | |
{ |
352 | 0 | return registry.lookupObjects(Connector.class); |
353 | |
} |
354 | |
|
355 | |
|
356 | |
|
357 | |
|
358 | |
public Collection<Agent> getAgents() |
359 | |
{ |
360 | 0 | return registry.lookupObjects(Agent.class); |
361 | |
} |
362 | |
|
363 | |
|
364 | |
|
365 | |
|
366 | |
public Collection<ImmutableEndpoint> getEndpoints() |
367 | |
{ |
368 | 0 | return registry.lookupObjects(ImmutableEndpoint.class); |
369 | |
} |
370 | |
|
371 | |
|
372 | |
|
373 | |
|
374 | |
public Collection<Transformer> getTransformers() |
375 | |
{ |
376 | 0 | return registry.lookupObjects(Transformer.class); |
377 | |
} |
378 | |
|
379 | |
|
380 | |
|
381 | |
|
382 | |
public Agent lookupAgent(String name) |
383 | |
{ |
384 | 0 | return (Agent) registry.lookupObject(name); |
385 | |
} |
386 | |
|
387 | |
|
388 | |
|
389 | |
|
390 | |
public Service lookupService(String name) |
391 | |
{ |
392 | 0 | return (Service) registry.lookupObject(name); |
393 | |
} |
394 | |
|
395 | |
|
396 | |
|
397 | |
|
398 | |
public Collection<Service> lookupServices() |
399 | |
{ |
400 | 0 | return lookupObjects(Service.class); |
401 | |
} |
402 | |
|
403 | |
|
404 | |
|
405 | |
|
406 | |
public Collection<Service> lookupServices(String model) |
407 | |
{ |
408 | 0 | Collection<Service> services = lookupServices(); |
409 | 0 | List<Service> modelServices = new ArrayList<Service>(); |
410 | 0 | Iterator it = services.iterator(); |
411 | |
Service service; |
412 | 0 | while (it.hasNext()) |
413 | |
{ |
414 | 0 | service = (Service) it.next(); |
415 | 0 | if (model.equals(service.getModel().getName())) |
416 | |
{ |
417 | 0 | modelServices.add(service); |
418 | |
} |
419 | |
} |
420 | 0 | return modelServices; |
421 | |
} |
422 | |
|
423 | |
|
424 | |
|
425 | |
|
426 | |
public FlowConstruct lookupFlowConstruct(String name) |
427 | |
{ |
428 | 0 | return (FlowConstruct) registry.lookupObject(name); |
429 | |
} |
430 | |
|
431 | |
|
432 | |
|
433 | |
|
434 | |
public Collection<FlowConstruct> lookupFlowConstructs() |
435 | |
{ |
436 | 0 | return lookupObjects(FlowConstruct.class); |
437 | |
} |
438 | |
|
439 | |
|
440 | |
|
441 | |
|
442 | |
public final void registerTransformer(Transformer transformer) throws MuleException |
443 | |
{ |
444 | 0 | registry.registerObject(getName(transformer), transformer, Transformer.class); |
445 | 0 | notifyTransformerResolvers(transformer, TransformerResolver.RegistryAction.ADDED); |
446 | 0 | } |
447 | |
|
448 | |
protected void notifyTransformerResolvers(Transformer t, TransformerResolver.RegistryAction action) |
449 | |
{ |
450 | 0 | if (t instanceof DiscoverableTransformer) |
451 | |
{ |
452 | 0 | Collection<TransformerResolver> resolvers = lookupObjects(TransformerResolver.class); |
453 | 0 | for (TransformerResolver resolver : resolvers) |
454 | |
{ |
455 | 0 | resolver.transformerChange(t, action); |
456 | |
} |
457 | 0 | transformerListCache.clear(); |
458 | 0 | exactTransformerCache.clear(); |
459 | |
} |
460 | 0 | } |
461 | |
|
462 | |
|
463 | |
|
464 | |
|
465 | |
public ServiceDescriptor lookupServiceDescriptor(ServiceType type, String name, Properties overrides) throws ServiceException |
466 | |
{ |
467 | 0 | String key = new AbstractServiceDescriptor.Key(name, overrides).getKey(); |
468 | |
|
469 | |
|
470 | 0 | ServiceDescriptor sd = (ServiceDescriptor) registry.lookupObject(key); |
471 | |
|
472 | 0 | synchronized (this) |
473 | |
{ |
474 | 0 | if (sd == null) |
475 | |
{ |
476 | 0 | sd = createServiceDescriptor(type, name, overrides); |
477 | |
try |
478 | |
{ |
479 | 0 | registry.registerObject(key, sd, ServiceDescriptor.class); |
480 | |
} |
481 | 0 | catch (RegistrationException e) |
482 | |
{ |
483 | 0 | throw new ServiceException(e.getI18nMessage(), e); |
484 | 0 | } |
485 | |
} |
486 | 0 | } |
487 | 0 | return sd; |
488 | |
} |
489 | |
|
490 | |
protected ServiceDescriptor createServiceDescriptor(ServiceType type, String name, Properties overrides) throws ServiceException |
491 | |
{ |
492 | |
|
493 | 0 | String scheme = name; |
494 | 0 | if (name.contains(":")) |
495 | |
{ |
496 | 0 | scheme = name.substring(0, name.indexOf(":")); |
497 | |
} |
498 | |
|
499 | 0 | Properties props = SpiUtils.findServiceDescriptor(type, scheme); |
500 | 0 | if (props == null) |
501 | |
{ |
502 | 0 | throw new ServiceException(CoreMessages.failedToLoad(type + " " + scheme)); |
503 | |
} |
504 | |
|
505 | 0 | return ServiceDescriptorFactory.create(type, name, props, overrides, muleContext, null); |
506 | |
} |
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
public void registerAgent(Agent agent) throws MuleException |
512 | |
{ |
513 | 0 | registry.registerObject(getName(agent), agent, Agent.class); |
514 | 0 | } |
515 | |
|
516 | |
|
517 | |
|
518 | |
|
519 | |
public void registerConnector(Connector connector) throws MuleException |
520 | |
{ |
521 | 0 | registry.registerObject(getName(connector), connector, Connector.class); |
522 | 0 | } |
523 | |
|
524 | |
|
525 | |
|
526 | |
|
527 | |
public void registerEndpoint(ImmutableEndpoint endpoint) throws MuleException |
528 | |
{ |
529 | 0 | registry.registerObject(getName(endpoint), endpoint, ImmutableEndpoint.class); |
530 | 0 | } |
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
public void registerEndpointBuilder(String name, EndpointBuilder builder) throws MuleException |
536 | |
{ |
537 | 0 | registry.registerObject(name, builder, EndpointBuilder.class); |
538 | 0 | } |
539 | |
|
540 | |
|
541 | |
|
542 | |
|
543 | |
public void registerModel(Model model) throws MuleException |
544 | |
{ |
545 | 0 | registry.registerObject(getName(model), model, Model.class); |
546 | 0 | } |
547 | |
|
548 | |
|
549 | |
|
550 | |
|
551 | |
public void registerService(Service service) throws MuleException |
552 | |
{ |
553 | 0 | registry.registerObject(getName(service), service, Service.class); |
554 | 0 | } |
555 | |
|
556 | |
|
557 | |
|
558 | |
|
559 | |
public void unregisterService(String serviceName) throws MuleException |
560 | |
{ |
561 | 0 | registry.unregisterObject(serviceName, Service.class); |
562 | 0 | } |
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
public void registerFlowConstruct(FlowConstruct flowConstruct) throws MuleException |
568 | |
{ |
569 | 0 | registry.registerObject(getName(flowConstruct), flowConstruct, FlowConstruct.class); |
570 | 0 | } |
571 | |
|
572 | |
|
573 | |
|
574 | |
|
575 | |
public void unregisterFlowConstruct(String flowConstructName) throws MuleException |
576 | |
{ |
577 | 0 | registry.unregisterObject(flowConstructName, FlowConstruct.class); |
578 | 0 | } |
579 | |
|
580 | |
|
581 | |
|
582 | |
|
583 | |
public void unregisterAgent(String agentName) throws MuleException |
584 | |
{ |
585 | 0 | registry.unregisterObject(agentName, Agent.class); |
586 | 0 | } |
587 | |
|
588 | |
|
589 | |
|
590 | |
|
591 | |
public void unregisterConnector(String connectorName) throws MuleException |
592 | |
{ |
593 | 0 | registry.unregisterObject(connectorName, Connector.class); |
594 | 0 | } |
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
public void unregisterEndpoint(String endpointName) throws MuleException |
600 | |
{ |
601 | 0 | registry.unregisterObject(endpointName, ImmutableEndpoint.class); |
602 | 0 | } |
603 | |
|
604 | |
|
605 | |
|
606 | |
|
607 | |
public void unregisterModel(String modelName) throws MuleException |
608 | |
{ |
609 | 0 | registry.unregisterObject(modelName, Model.class); |
610 | 0 | } |
611 | |
|
612 | |
|
613 | |
|
614 | |
|
615 | |
public void unregisterTransformer(String transformerName) throws MuleException |
616 | |
{ |
617 | 0 | Transformer transformer = lookupTransformer(transformerName); |
618 | 0 | notifyTransformerResolvers(transformer, TransformerResolver.RegistryAction.REMOVED); |
619 | 0 | registry.unregisterObject(transformerName, Transformer.class); |
620 | |
|
621 | 0 | } |
622 | |
|
623 | |
|
624 | |
|
625 | |
|
626 | |
public Object applyProcessorsAndLifecycle(Object object) throws MuleException |
627 | |
{ |
628 | 0 | object = applyProcessors(object); |
629 | 0 | object = applyLifecycle(object); |
630 | 0 | return object; |
631 | |
} |
632 | |
|
633 | |
|
634 | |
|
635 | |
|
636 | |
public Object applyProcessors(Object object) throws MuleException |
637 | |
{ |
638 | 0 | return registry.getTransientRegistry().applyProcessors(object, null); |
639 | |
} |
640 | |
|
641 | |
|
642 | |
|
643 | |
|
644 | |
public Object applyProcessors(Object object, int flags) throws MuleException |
645 | |
{ |
646 | 0 | return registry.getTransientRegistry().applyProcessors(object, flags); |
647 | |
} |
648 | |
|
649 | |
|
650 | |
|
651 | |
|
652 | |
public Object applyLifecycle(Object object) throws MuleException |
653 | |
{ |
654 | 0 | return registry.getTransientRegistry().applyLifecycle(object); |
655 | |
} |
656 | |
|
657 | |
public Object applyLifecycle(Object object, String phase) throws MuleException |
658 | |
{ |
659 | 0 | return registry.getTransientRegistry().applyLifecycle(object, phase); |
660 | |
} |
661 | |
|
662 | |
|
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
public <T> T lookupObject(Class<T> type) throws RegistrationException |
670 | |
{ |
671 | 0 | return registry.lookupObject(type); |
672 | |
} |
673 | |
|
674 | |
@SuppressWarnings("unchecked") |
675 | |
public <T> T lookupObject(String key) |
676 | |
{ |
677 | 0 | return (T) registry.lookupObject(key); |
678 | |
} |
679 | |
|
680 | |
|
681 | |
|
682 | |
|
683 | |
public <T> Collection<T> lookupObjects(Class<T> type) |
684 | |
{ |
685 | 0 | return registry.lookupObjects(type); |
686 | |
} |
687 | |
|
688 | |
|
689 | |
|
690 | |
|
691 | |
public <T> Collection<T> lookupObjectsForLifecycle(Class<T> type) |
692 | |
{ |
693 | 0 | return registry.lookupObjectsForLifecycle(type); |
694 | |
} |
695 | |
|
696 | |
@SuppressWarnings("unchecked") |
697 | |
public <T> T get(String key) |
698 | |
{ |
699 | 0 | return (T)registry.get(key); |
700 | |
} |
701 | |
|
702 | |
public <T> Map<String, T> lookupByType(Class<T> type) |
703 | |
{ |
704 | 0 | return registry.lookupByType(type); |
705 | |
} |
706 | |
|
707 | |
|
708 | |
|
709 | |
|
710 | |
public void registerObject(String key, Object value, Object metadata) throws RegistrationException |
711 | |
{ |
712 | 0 | registry.registerObject(key, value, metadata); |
713 | 0 | } |
714 | |
|
715 | |
|
716 | |
|
717 | |
|
718 | |
public void registerObject(String key, Object value) throws RegistrationException |
719 | |
{ |
720 | 0 | registry.registerObject(key, value); |
721 | 0 | } |
722 | |
|
723 | |
|
724 | |
|
725 | |
|
726 | |
public void registerObjects(Map objects) throws RegistrationException |
727 | |
{ |
728 | 0 | registry.registerObjects(objects); |
729 | 0 | } |
730 | |
|
731 | |
|
732 | |
|
733 | |
|
734 | |
public void unregisterObject(String key, Object metadata) throws RegistrationException |
735 | |
{ |
736 | 0 | registry.unregisterObject(key, metadata); |
737 | 0 | } |
738 | |
|
739 | |
|
740 | |
|
741 | |
|
742 | |
public void unregisterObject(String key) throws RegistrationException |
743 | |
{ |
744 | 0 | registry.unregisterObject(key); |
745 | 0 | } |
746 | |
|
747 | |
|
748 | |
|
749 | |
|
750 | |
|
751 | |
|
752 | |
|
753 | |
|
754 | |
protected String getName(Object obj) |
755 | |
{ |
756 | 0 | String name = null; |
757 | 0 | if (obj instanceof NamedObject) |
758 | |
{ |
759 | 0 | name = ((NamedObject) obj).getName(); |
760 | |
} |
761 | 0 | if (StringUtils.isBlank(name)) |
762 | |
{ |
763 | 0 | name = obj.getClass().getName() + ":" + UUID.getUUID(); |
764 | |
} |
765 | 0 | return name; |
766 | |
} |
767 | |
|
768 | |
|
769 | |
|
770 | |
|
771 | |
|
772 | |
|
773 | |
|
774 | |
|
775 | |
public String getRegistryId() |
776 | |
{ |
777 | 0 | return this.toString(); |
778 | |
} |
779 | |
|
780 | |
|
781 | |
|
782 | |
|
783 | |
public boolean isReadOnly() |
784 | |
{ |
785 | 0 | return false; |
786 | |
} |
787 | |
|
788 | |
|
789 | |
|
790 | |
|
791 | |
public boolean isRemote() |
792 | |
{ |
793 | 0 | return false; |
794 | |
} |
795 | |
|
796 | |
private String getDataTypeSourceResultPairHash(DataType<?> source, DataType<?> result) |
797 | |
{ |
798 | 0 | return source.getClass().getName() + source.hashCode() + ":" + result.getClass().getName() |
799 | |
+ result.hashCode(); |
800 | |
} |
801 | |
|
802 | 0 | private class TransformerResolverComparator implements Comparator<TransformerResolver> |
803 | |
{ |
804 | |
public int compare(TransformerResolver transformerResolver, TransformerResolver transformerResolver1) |
805 | |
{ |
806 | 0 | if (transformerResolver.getClass().equals(TypeBasedTransformerResolver.class)) |
807 | |
{ |
808 | 0 | return 1; |
809 | |
} |
810 | |
|
811 | 0 | if (transformerResolver1.getClass().equals(TypeBasedTransformerResolver.class)) |
812 | |
{ |
813 | 0 | return -1; |
814 | |
} |
815 | 0 | return 0; |
816 | |
} |
817 | |
} |
818 | |
} |
819 | |
|
820 | |
|