001 /*****************************************************************************
002 * Copyright (C) NanoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 * *
008 * Original code by Joerg Schaible *
009 *****************************************************************************/
010
011 package org.picocontainer.gems.jmx;
012
013 import javax.management.DynamicMBean;
014 import javax.management.ObjectName;
015
016
017 /**
018 * An ObjectNameFactory, that uses the key of the Pico component as {@link ObjectName}, if the key is of this type.
019 * @author Jörg Schaible
020 */
021 public class PredefinedObjectNameFactory implements ObjectNameFactory {
022
023 /**
024 * Return the <code>key</code> if it is an {@link ObjectName}.
025 * @see org.picocontainer.gems.jmx.ObjectNameFactory#create(java.lang.Object, javax.management.DynamicMBean)
026 */
027 public ObjectName create(final Object key, final DynamicMBean mBean) {
028 return key instanceof ObjectName ? (ObjectName)key : null;
029 }
030
031 }