KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > impl > role > ECMMetaInfoManager


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

19
20 package org.apache.avalon.fortress.impl.role;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Properties JavaDoc;
24
25 import org.apache.avalon.fortress.MetaInfoEntry;
26 import org.apache.avalon.fortress.MetaInfoManager;
27
28 /**
29  * ECMMetaInfoManager
30  *
31  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
32  * @version CVS Revision: 1.1 $
33  */

34 public final class ECMMetaInfoManager extends AbstractMetaInfoManager
35 {
36
37     /**
38      * Create a ECMMetaInfoManager.
39      */

40     public ECMMetaInfoManager()
41     {
42         super( (MetaInfoManager) null );
43     }
44
45     /**
46      * Create a ServiceMetaManager with a parent.
47      *
48      * @param parent
49      */

50     public ECMMetaInfoManager( final MetaInfoManager parent )
51     {
52         super( parent );
53     }
54
55     /**
56      * Create a ECMMetaInfoManager with the supplied classloader and
57      * parent Rr.
58      *
59      * @param parent
60      * @param loader
61      */

62     public ECMMetaInfoManager( final MetaInfoManager parent, final ClassLoader JavaDoc loader )
63     {
64         super( parent, loader );
65     }
66
67     /**
68      * Add a component defined inside a selector
69      */

70     public final void addSelectorComponent( final String JavaDoc role,
71                                             final String JavaDoc hint,
72                                             final String JavaDoc className,
73                                             final String JavaDoc handlerClassName )
74     {
75         Properties JavaDoc props = new Properties JavaDoc();
76         final String JavaDoc lifestyle;
77         if (MetaInfoEntry.THREADSAFE_HANDLER.equals(handlerClassName) )
78         {
79             lifestyle = "singleton";
80         }
81         else if ( MetaInfoEntry.PER_THREAD_HANDLER.equals(handlerClassName) )
82         {
83             lifestyle = "thread";
84         }
85         else if ( MetaInfoEntry.POOLABLE_HANDLER.equals(handlerClassName) )
86         {
87             lifestyle = "pooled";
88         }
89         else
90         {
91             lifestyle = "transient";
92         }
93         
94         props.setProperty("x-avalon.lifestyle", lifestyle);
95         props.setProperty("x-avalon.name", role + '/' + hint);
96         super.addComponent(role, className, props, new ArrayList JavaDoc());
97         
98     }
99 }
100
Popular Tags