KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > management > config > ProviderConfigFactory


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.management.config;
24
25 import java.util.Map JavaDoc;
26
27 import javax.management.ObjectName JavaDoc;
28
29 import com.sun.appserv.management.base.Util;
30
31 import com.sun.appserv.management.config.MessageSecurityConfig;
32 import com.sun.appserv.management.config.SecurityServiceConfig;
33 import com.sun.appserv.management.config.ProviderConfig;
34
35 import com.sun.appserv.management.util.misc.MapUtil;
36 import com.sun.enterprise.management.support.oldconfig.OldSecurityServiceMBean;
37 import com.sun.enterprise.management.support.oldconfig.OldMessageSecurityConfigMBean;
38
39 /**
40  */

41 public final class ProviderConfigFactory extends ConfigFactory
42     // implements ProviderConfigMgr
43
{
44     private final OldSecurityServiceMBean mOldSecurityServiceMBean;
45     private final OldMessageSecurityConfigMBean mOldMessageSecurityConfigMBean;
46     
47     public ProviderConfigFactory(final ConfigFactoryCallback callbacks)
48     {
49         super( callbacks );
50         
51         // the type=message-security MBean just doesn't work; we must use
52
// the type=security-service MBean instead.
53
mOldSecurityServiceMBean =
54             getOldConfigProxies().getOldSecurityServiceMBean( getConfigName() );
55         
56         mOldMessageSecurityConfigMBean = getOldMessageSecurityConfigMBean();
57     }
58     
59         private final OldMessageSecurityConfigMBean
60     getOldMessageSecurityConfigMBean()
61     {
62         final String JavaDoc name = getFactoryContainer().getName();
63         return getOldConfigProxies().getOldMessageSecurityConfigMBean( name );
64     }
65
66
67     /**
68         The underlying API is function-oriented mess. We actually have to "create" a new
69         message security (which might already exist) in order to create a provider-config.
70         This is a special-case compared to all the other ones.
71      */

72         public ObjectName JavaDoc
73     create(
74         final String JavaDoc name,
75         final String JavaDoc providerType,
76         final String JavaDoc providerClassname,
77         Map JavaDoc<String JavaDoc,String JavaDoc> optional )
78     {
79         final MessageSecurityConfig msc = (MessageSecurityConfig)getFactoryContainer();
80         final SecurityServiceConfig ss = (SecurityServiceConfig)(msc.getContainer());
81         
82         final MessageSecurityConfig newMSC =
83             ss.createMessageSecurityConfig( msc.getAuthLayer(), name, providerType, providerClassname, optional );
84         // 'newMSC' and 'msc' should be the same.
85

86         final ProviderConfig providerConfig = newMSC.getProviderConfigMap().get( name );
87         
88         return Util.getObjectName( providerConfig );
89     }
90
91
92         protected final void
93     removeByName(final String JavaDoc name)
94     {
95         getOldMessageSecurityConfigMBean().removeProviderConfigByProviderId( name );
96     }
97 }
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
Popular Tags