KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > connectors > ConnectorAdminObjectAdminServiceImpl


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
24 package com.sun.enterprise.connectors;
25
26 import java.util.*;
27 import java.util.logging.*;
28 import javax.naming.*;
29 import com.sun.enterprise.server.*;
30
31 /**
32  * AdminObject administration service. It performs the functionality of
33  * creating and deleting the Admin Objects
34  * @author Binod P.G and Srikanth P
35  */

36
37
38 public class ConnectorAdminObjectAdminServiceImpl extends
39                ConnectorServiceImpl implements ConnectorAdminService {
40
41
42     public ConnectorAdminObjectAdminServiceImpl() {
43         super();
44     }
45      
46     public void addAdminObject (
47             String JavaDoc appName,
48             String JavaDoc connectorName,
49             String JavaDoc jndiName,
50             String JavaDoc adminObjectType,
51             Properties props)
52             throws ConnectorRuntimeException
53     {
54         ActiveResourceAdapter ar =
55                     _registry.getActiveResourceAdapter(connectorName);
56         if(ar == null) {
57             ifSystemRarLoad(connectorName);
58             ar = _registry.getActiveResourceAdapter(connectorName);
59         }
60         if (ar instanceof ActiveInboundResourceAdapter) {
61             ActiveInboundResourceAdapter air =
62                             (ActiveInboundResourceAdapter) ar;
63             air.addAdminObject(appName,connectorName,jndiName,
64                             adminObjectType, props);
65         } else {
66             ConnectorRuntimeException cre = new ConnectorRuntimeException(
67                             "This adapter is not 1.5 compliant");
68             _logger.log(Level.SEVERE,
69                             "rardeployment.non_1.5_compliant_rar",jndiName);
70             throw cre;
71         }
72     }
73
74     public void deleteAdminObject(String JavaDoc jndiName)
75                            throws ConnectorRuntimeException
76     {
77
78         try {
79             InitialContext ic = new InitialContext();
80             ic.unbind(jndiName);
81         }
82         catch(NamingException ne) {
83             ResourcesUtil resutil = ResourcesUtil.getInstance();
84             if(resutil.adminObjectBelongsToSystemRar(jndiName)) {
85                 return;
86             }
87             if(ne instanceof NameNotFoundException){
88                 _logger.log(Level.FINE,
89                   "rardeployment.admin_object_delete_failure",jndiName);
90                 _logger.log(Level.FINE,"", ne);
91                 return;
92             }
93             ConnectorRuntimeException cre = new ConnectorRuntimeException(
94                            "Failed to delete admin object from jndi");
95             cre.initCause(ne);
96             _logger.log(Level.SEVERE,
97                   "rardeployment.admin_object_delete_failure",jndiName);
98             _logger.log(Level.SEVERE,"", cre);
99             throw cre;
100         }
101     }
102 }
103
Popular Tags