01 /*
02 *
03 * Licensed to the Apache Software Foundation (ASF) under one
04 * or more contributor license agreements. See the NOTICE file
05 * distributed with this work for additional information
06 * regarding copyright ownership. The ASF licenses this file
07 * to you under the Apache License, Version 2.0 (the
08 * "License"); you may not use this file except in compliance
09 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 */
21 package org.apache.qpid.management.wsdm.common;
22
23 import javax.management.ObjectName;
24 import javax.xml.namespace.QName;
25
26 import org.apache.muse.core.routing.ResourceIdFactory;
27 import org.apache.qpid.management.Names;
28
29 /**
30 * ResourceIdFactory implementation that is using an objectName as
31 * resource identifier.
32 * This is done in order to make a relationship between an MBean (which is part of the
33 * JMX core domain model) and a WS-Resource (the same entity as is represented on WS-DM adapter side).
34 *
35 * @author Andrea Gazzarini
36 */
37 public class ObjectNameIdFactory implements ResourceIdFactory
38 {
39 /**
40 * Returns the name of the identifier element.
41 *
42 * @return the name of the identifier element.
43 */
44 public QName getIdentifierName()
45 {
46 return Names.RESOURCE_ID_QNAME;
47 }
48
49 /**
50 * Returns the object name used as a resource identifier.
51 * Developer note : this factory is highly coupled with ThreadSessionManager stuff because
52 * the object name that will be used as identifier is supposed to be in the thread session.
53 *
54 * @return the object name used as a resource identifier.
55 */
56 public String getNextIdentifier()
57 {
58 ObjectName objectName = ThreadSessionManager.getInstance().getSession().getObjectName();
59 return objectName.getKeyProperty(Names.OBJECT_ID);
60 }
61 }
|