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 javax.util.concurrent;
018    
019    import java.util.concurrent.ThreadFactory;
020    
021    /**
022     * A manageable version of a {@link java.util.concurrent.ThreadFactory}.<p>
023     *
024     * A ManagedThreadFactory provides a method for creating threads for execution
025     * in a managed environment.  Implementations of the ManagedThreadFactory are
026     * provided by a Java&TRADE; EE Product Provider.  Application Component Providers
027     * use the Java Naming and Directory Interface&trade; (JNDI) to look-up instances of one
028     * or more ManagedThreadFactory objects using resource environment references.<p>
029     *
030     * The Concurrency Utilities for Java&trade; EE specification describes several
031     * behaviors that a ManagedThreadFactory can implement.  The Application
032     * Component Provider and Deployer identify these requirements and map the
033     * resource environment reference appropriately.<p>
034     *
035     * The Runnable task that is allocated to the new thread using the
036     * {@link java.util.concurrent.ThreadFactory#newThread(java.lang.Runnable)} method
037     * will run with the application component context of the component instance
038     * that created (looked-up) this ManagedThreadFactory instance.<p>
039     *
040     * The task runs without an explicit transaction (they do not enlist in the application
041     * component's transaction).  If a transaction is required, use a
042     * {@link javax.transaction.UserTransaction} instance.  A UserTransaction instance is
043     * available in JNDI using the name: &QUOT;java:comp/UserTransaction&QUOT<p>
044     *
045     * Example:<pre>
046     * public run() {
047     *     // Begin of task
048     *     InitialContext ctx = new InitialContext();
049     *     UserTransaction ut = (UserTransaction) ctx.lookup("java:comp/UserTransaction");
050     *     ut.begin();
051     *
052     *     // Perform transactional business logic
053     *
054     *     ut.commit();
055     * }</PRE>
056     *
057     * A ManagedThreadFactory can be used with Java SE ExecutorService implementations directly.<p>
058     *
059     * Example:<pre>
060     * &#47;**
061     *  * Create a ThreadPoolExecutor using a ManagedThreadFactory.
062     *  * Resource Mappings:
063     *  *  type:      javax.util.concurrent.ManagedThreadFactory
064     *  *  jndi-name: concurrent/tf/DefaultThreadFactory
065     *  *&#47;
066     * public ExecutorService getManagedThreadPool() {
067     *     InitialContext ctx = new InitialContext();
068     *     ManagedThreadFactory tf = (ManagedThreadFactory)
069     *         ctx.lookup("java:comp/env/concurrent/tf/DefaultThreadFactory");
070     *
071     *     // All threads will run as part of this application component.
072     *     return new ThreadPoolExecutor(5, 10, 5, TimeUnit.SECONDS,
073     *         new ArrayBlockingQueue&LT;Runnable&GT;(10), tf);
074     * }
075     * </pre>
076     */
077    public interface ManagedThreadFactory extends ThreadFactory {
078    
079    }