Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 1997-2011 Oracle and/or its affiliates. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common Development
   * and Distribution License("CDDL") (collectively, the "License").  You
   * may not use this file except in compliance with the License.  You can
  * obtain a copy of the License at
  * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
  * or packager/legal/LICENSE.txt.  See the License for the specific
  * language governing permissions and limitations under the License.
  *
  * When distributing the software, include this License Header Notice in each
  * file and include the License file at packager/legal/LICENSE.txt.
  *
  * GPL Classpath Exception:
  * Oracle designates this particular file as subject to the "Classpath"
  * exception as provided by Oracle in the GPL Version 2 section of the License
  * file that accompanied this code.
  *
  * Modifications:
  * If applicable, add the following below the License Header, with the fields
  * enclosed by brackets [] replaced by your own identifying information:
  * "Portions Copyright [year] [name of copyright owner]"
  *
  * Contributor(s):
  * If you wish your version of this file to be governed by only the CDDL or
  * only the GPL Version 2, indicate your decision by adding "[Contributor]
  * elects to include this software in this distribution under the [CDDL or GPL
  * Version 2] license."  If you don't indicate a single choice of license, a
  * recipient has the option to distribute your version of this file under
  * either the CDDL, the GPL Version 2 or to extend the choice of license to
  * its licensees as provided above.  However, if you add GPL Version 2 code
  * and therefore, elected the GPL Version 2 license, then the option applies
  * only if the new code is made subject to such option by the copyright
  * holder.
  */
 
 package com.sun.enterprise.connectors.service;
 
 
 import java.io.File;
 import java.util.Set;
This is configuration parser service. Retrieves various configuration information from ra.xml

Author(s):
Srikanth P
 
 public class ConnectorConfigurationParserServiceImpl extends ConnectorService {

    
Default constructor
 
          super();
      }

    
Obtains the Permission string that needs to be added to the to the security policy files. These are the security permissions needed by the resource adapter implementation classes. These strings are obtained by parsing the ra.xml

Parameters:
moduleName rar module Name
Returns:
Required policy permissions in server.policy file
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException If rar.xml parsing fails.
 
     public String getSecurityPermissionSpec(String moduleName)
             throws ConnectorRuntimeException {
 
         if (moduleName == null) {
             return null;
         }
         String policyString = null;
 
         //check whether the policy file already has required permissions.
         String fileName = System.getProperty("java.security.policy");
         if (fileName != null) {
             File policyFile = new File(fileName);
             String policyContent = getFileContent(policyFile);
 
             ConnectorDescriptor connectorDescriptor = getConnectorDescriptor(moduleName);
             Set securityPermissions = connectorDescriptor.getSecurityPermissions();
             Iterator it = securityPermissions.iterator();
             SecurityPermission secPerm = null;
             String permissionString = null;
            while (it.hasNext()) {
                secPerm = (SecurityPermissionit.next();
                permissionString = secPerm.getPermission();
                int intIndex = policyContent.indexOf(permissionString);
                if (intIndex == -1) {
                    if (permissionString != null) {
                        if (policyString != null) {
                            policyString = policyString + "\n \n" + permissionString;
                        } else {
                            policyString = "\n\n" + permissionString;
                        }
                    }
                }
            }
            //print the missing permissions
            if (policyString != null) {
                policyString =  + policyString;
            }
        }
        return policyString;
    }

    
Obtain the content of server.policy file

Parameters:
file File server.policy file
Returns:
String content of server.policy file
    public String getFileContent(File file) {
        StringBuilder contents = new StringBuilder();
        BufferedReader input = null;
        try {
            input = new BufferedReader(new FileReader(file));
            try {
                String line = null;
                while ((line = input.readLine()) != null) {
                    contents.append(line);
                    contents.append(System.getProperty("line.separator"));
                }
            } finally {
                input.close();
            }
        }
        catch (Exception ex) {
            .log(."Exception while performing resource-adapter's " +
                    "security permission check : "ex);
        }
        return contents.toString();
    }

    
Obtains all the Connection definition names of a rar

Parameters:
rarName rar moduleName
Returns:
Array of connection definition names.
    public String[] getConnectionDefinitionNames(String rarName)
               throws ConnectorRuntimeException
    {
        String[] result = new String[0];
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            MCFConfigParser mcfConfigParser = (MCFConfigParser)
              ConnectorConfigParserFactory.getParser(.);
            return mcfConfigParser.getConnectionDefinitionNames(desc);
        } else {
            return result;
        }
    }

    
Retrieves the Resource adapter javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned.

Parameters:
rarName rar module name
Returns:
Resource adapter javabean properties with default values.
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if property retrieval fails.
                throws ConnectorRuntimeException
    {
        return getConnectorConfigJavaBeans(
               rarName,null,.);
    }

    
Retrieves the MCF javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned.

Parameters:
rarName rar module name
Returns:
managed connection factory javabean properties with default values.
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if property retrieval fails.
     String rarName,String connectionDefNamethrows ConnectorRuntimeException
    {
        Properties props = getConnectorConfigJavaBeans(
               rarName,connectionDefName,.);
/* TODO V3 handle JMS-RA later
	if (rarName.equals(ConnectorConstants.DEFAULT_JMS_ADAPTER)) {
            props.remove(ActiveJmsResourceAdapter.ADDRESSLIST);
	}
*/
        return props;
    }

    
Retrieves the admin object javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned.

Parameters:
rarName rar module name
Returns:
admin object javabean properties with default values.
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if property retrieval fails.
      String rarName,String adminObjectIntfthrows ConnectorRuntimeException
    {
        return getConnectorConfigJavaBeans(
               rarName,adminObjectIntf,.);
    }

    
Retrieves the admin object javabean properties with default values. The default values will the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned.

Parameters:
rarName rar module name
adminObjectIntf admin object interface
adminObjectClass admin object class
Returns:
admin object javabean properties with default values.
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if property retrieval fails.
      String rarName,String adminObjectIntfString adminObjectClassthrows ConnectorRuntimeException
    {
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            AdminObjectConfigParser adminObjectConfigParser =
                 (AdminObjectConfigParser)
                 ConnectorConfigParserFactory.getParser(
                 .);
            return adminObjectConfigParser.getJavaBeanProps(
                       desc,adminObjectIntfadminObjectClassrarName);
        } else {
            return null;
        }
    }

    
Retrieves the XXX javabean properties with default values. The javabean to introspect/retrieve is specified by the type. The default values will be the values present in the ra.xml. If the value is not present in ra.xxml, javabean is introspected to obtain the default value present, if any. If intrspection fails or null is the default value, empty string is returned. If ra.xml has only the property and no value, empty string is the value returned.

Parameters:
rarName rar module name
Returns:
admin object javabean properties with default values.
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if property retrieval fails.
        String connectionDefName,String typethrows ConnectorRuntimeException
    {
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            ConnectorConfigParser ccParser =
                     ConnectorConfigParserFactory.getParser(type);
            return ccParser.getJavaBeanProps(desc,connectionDefNamerarName);
        } else {
            return null;
        }
    }

    
Return the ActivationSpecClass name for given rar and messageListenerType

Parameters:
moduleDir The directory where rar is exploded.
messageListenerType MessageListener type
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException If moduleDir is null. If corresponding rar is not deployed.
    public String getActivationSpecClassString rarName,
             String messageListenerTypethrows ConnectorRuntimeException
    {
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            MessageListenerConfigParser messagelistenerConfigParser =
                 (MessageListenerConfigParser)
                 ConnectorConfigParserFactory.getParser(
                 .);
            return messagelistenerConfigParser.getActivationSpecClass(
                       desc,messageListenerType);
        } else {
            return null;
        }
    }
    /* Parses the ra.xml and returns all the Message listener types.
     *
     * @param  rarName name of the rar module.
     * @return Array of message listener types as strings.
     * @throws  ConnectorRuntimeException If moduleDir is null.
     *          If corresponding rar is not deployed.
     *
     */
    public String[] getMessageListenerTypes(String rarName)
               throws ConnectorRuntimeException
    {
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            MessageListenerConfigParser messagelistenerConfigParser =
                (MessageListenerConfigParser)
                ConnectorConfigParserFactory.getParser(
                .);
            return messagelistenerConfigParser.getMessageListenerTypes(desc);
        } else {
            return null;
        }
    }

    
Parses the ra.xml for the ActivationSpec javabean properties. The ActivationSpec to be parsed is identified by the moduleDir where ra.xml is present and the message listener type. message listener type will be unique in a given ra.xml. It throws ConnectorRuntimeException if either or both the parameters are null, if corresponding rar is not deployed, if message listener type mentioned as parameter is not found in ra.xml. If rar is deployed and message listener (type mentioned) is present but no properties are present for the corresponding message listener, null is returned.

Parameters:
rarName name of the rar module.
messageListenerType message listener type.It is uniqie across all <messagelistener> sub-elements in <messageadapter> element in a given rar.
Returns:
Javabean properties with the property names and values of properties. The property values will be the values mentioned in ra.xml if present. Otherwise it will be the default values obtained by introspecting the javabean. In both the case if no value is present, empty String is returned as the value.
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if either of the parameters are null. If corresponding rar is not deployed i.e moduleDir is invalid. If messagelistener type is not found in ra.xml
         String messageListenerType)throws ConnectorRuntimeException
    {
        return getConnectorConfigJavaBeans(
               rarName,messageListenerType,.);
    }

    
Returns the Properties object consisting of propertyname as the key and datatype as the value.

Parameters:
rarName name of the rar module.
messageListenerType message listener type.It is uniqie across all <messagelistener> sub-elements in <messageadapter> element in a given rar.
Returns:
Properties object with the property names(key) and datatype of property(as value).
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if either of the parameters are null. If corresponding rar is not deployed i.e moduleDir is invalid. If messagelistener type is not found in ra.xml
               String messageListenerTypethrows ConnectorRuntimeException
    {
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            MessageListenerConfigParser messagelistenerConfigParser =
                (MessageListenerConfigParser)
                ConnectorConfigParserFactory.getParser(
                .);
            return messagelistenerConfigParser.getJavaBeanReturnTypes(
                    descmessageListenerTyperarName);
        } else {
            return null;
        }
    }

    
Obtains all the Connection definition names of a rar

Parameters:
rarName rar moduleName
Returns:
Array of connection definition names.
    public String[] getAdminObjectInterfaceNames(String rarName)
               throws ConnectorRuntimeException
    {
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            AdminObjectConfigParser adminObjectConfigParser =
                 (AdminObjectConfigParser)
                 ConnectorConfigParserFactory.getParser(
                 .);
            return adminObjectConfigParser.getAdminObjectInterfaceNames(desc);
        } else {
            return null;
        }
    }

    
gets the adminObjectClassNames pertaining to a rar & a specific adminObjectInterfaceName

Parameters:
rarName resource-adapter name
intfName admin-object-interface name
Returns:
Array of AdminObjectInterface names as Strings
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException if parsing fails
    public String[] getAdminObjectClassNames(String rarNameString intfName)
            throws ConnectorRuntimeException {
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            AdminObjectConfigParser adminObjectConfigParser =
                 (AdminObjectConfigParser)
                 ConnectorConfigParserFactory.getParser(
                 .);
            return adminObjectConfigParser.getAdminObjectClassNames(descintfName);
        } else {
            return null;
        }
    }

    
checks whether the specified intfName, className has presence in admin objects of the RAR

Parameters:
rarName resource-adapter name
intfName admin object interface name
className admin object class name
Returns:
boolean indicating the presence of admin object
Throws:
com.sun.appserv.connectors.internal.api.ConnectorRuntimeException when unable to determine the presence
    public boolean hasAdminObject(String rarNameString intfNameString className)
        throws ConnectorRuntimeException{
        ConnectorDescriptor desc = getConnectorDescriptor(rarName);
        if(desc != null) {
            AdminObjectConfigParser adminObjectConfigParser =
                 (AdminObjectConfigParser)
                 ConnectorConfigParserFactory.getParser(
                 .);
            return adminObjectConfigParser.hasAdminObject(descintfNameclassName);
        } else {
            return false;
        }
    }

    
Finds the properties of a RA JavaBean bundled in a RAR without exploding the RAR

Parameters:
pathToDeployableUnit a physical,accessible location of the connector module. [either a RAR for RAR-based deployments or a directory for Directory based deployments]
Returns:
A Map that is of <String RAJavaBeanPropertyName, String defaultPropertyValue> An empty map is returned in the case of a 1.0 RAR
/*   TODO V3
    public Map getRABeanProperties(String pathToDeployableUnit) throws ConnectorRuntimeException{
        return RARUtils.getRABeanProperties(pathToDeployableUnit);
    }
*/
New to GrepCode? Check out our FAQ X