001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel;
018
019 /**
020 * Used for defining if a given class is singleton or not. If the class is a singleton,
021 * then a single instance will be shared (and hence should be treated as immutable and
022 * be used in a thread-safe manner).
023 * <p/>
024 * This interface is not implemented as a marker interface (i.e., it's necessary to read
025 * {@link #isSingleton()} instead of <tt>instanceof(IsSingleton))</tt>.
026 * This allows for subclasses to have a singleton status different from a parent and
027 * for objects to have this value dynamically changed.
028 * <p/>
029 * Camel component is very often singleton based, only a few components is not.
030 *
031 * @version
032 */
033 public interface IsSingleton {
034
035 /**
036 * Whether this class supports being singleton or not.
037 *
038 * @return <tt>true</tt> to be a single shared instance, <tt>false</tt> to create new instances.
039 */
040 boolean isSingleton();
041
042 }