KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > services > monitor > ModuleInstance


1 /*
2
3    Derby - Class org.apache.derby.impl.services.monitor.ModuleInstance
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.services.monitor;
23
24 import org.apache.derby.iapi.services.monitor.PersistentService;
25
26 import java.util.Properties JavaDoc;
27
28 /**
29     A description of an instance of a module.
30 */

31
32
33 class ModuleInstance {
34
35     /*
36     ** Fields.
37     */

38
39     /**
40         The module instance
41     */

42     protected Object JavaDoc instance;
43
44     /**
45         name of module, can be null
46     */

47     protected String JavaDoc identifier;
48
49     /**
50         the top-level service this module lives in, can be null or the service itself
51     */

52     protected Object JavaDoc topLevelService;
53
54     /**
55         the actual service to which I belong, could be null.
56     */

57     protected Object JavaDoc service;
58
59     /*
60     ** Constructor
61     */

62
63     protected ModuleInstance(Object JavaDoc instance, String JavaDoc identifier,
64             Object JavaDoc service, Object JavaDoc topLevelService)
65     {
66         super();
67         this.instance = instance;
68         this.identifier = identifier;
69         this.topLevelService = topLevelService;
70         this.service = service;
71
72     }
73
74     protected ModuleInstance(Object JavaDoc instance) {
75
76         this(instance, null, null, null);
77     }
78
79     protected boolean isTypeAndName(PersistentService serviceType,
80         Class JavaDoc factoryInterface, String JavaDoc otherCanonicalName)
81     {
82         // see if the correct interface is implemented
83
if (!factoryInterface.isInstance(instance))
84             return false;
85
86         if ((serviceType != null) && (otherCanonicalName != null))
87             return serviceType.isSameService(identifier, otherCanonicalName);
88
89
90         // see if the identifiers match
91
if (otherCanonicalName != null) {
92             if (identifier == null)
93                 return false;
94             if (!otherCanonicalName.equals(identifier))
95                 return false;
96         } else if (identifier != null) {
97             return false;
98         }
99
100         return true;
101     }
102
103     protected String JavaDoc getIdentifier() {
104         return identifier;
105     }
106
107     protected Object JavaDoc getTopLevelService() {
108         return topLevelService;
109     }
110
111     protected Object JavaDoc getInstance() {
112         return instance;
113     }
114 }
115
Popular Tags