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-2012 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;
 
 
 import java.util.Set;

This class abstract the ra.xml values pertaining to the connection management. It contains various config properties of MCF, Resource adapter, Connection and also their respective classes and interfaces.

Author(s):
Srikanth P
 
 
 public final class ConnectorDescriptorInfo implements Serializable {
 
     private String rarName_;
     private String resourceAdapterClass_;
     private String connectionDefinitionName_;
     private String connectionFactoryClass_;
     private String connectionClass_;
     private String connectionInterface_;
Default constructor
 
     public ConnectorDescriptorInfo() {
 
     }

    
Clone method

Returns:
ConnectorDescriptorInfo instance
 
 
     public ConnectorDescriptorInfo doClone() {
 
         ConnectorDescriptorInfo cdi = new ConnectorDescriptorInfo();
                 );
         cdi.setRarName();
         cdi.setConnectionClass();
        return cdi;
    }

    
Constructor

Parameters:
mcfConfigProperties Array of MCF config properties
resourceAdapterConfigProperties Array of Resource adapter config props
            ConnectorConfigProperty [] mcfConfigProperties,
            ConnectorConfigProperty [] resourceAdapterConfigProperties) {
        this();
        if (mcfConfigProperties != null) {
            for (ConnectorConfigProperty  mcfConfigProperty : mcfConfigProperties) {
                .add(mcfConfigProperty);
            }
            if (resourceAdapterConfigProperties != null) {
                for (ConnectorConfigProperty  mcfConfigProperty : mcfConfigProperties) {
                    .add(mcfConfigProperty);
                }
            }
        }
    }

    
Adds an MCF config property to the existing array/Set of MCF config properties.

Parameters:
configProperty Config property to be added.
    public void addMCFConfigProperty(ConnectorConfigProperty  configProperty) {
        if (configProperty != null) {
            .add(configProperty);
        }
    }

    
Removes an config property from the existing array/Set of MCF config properties

Parameters:
configProperty Config property to be removed.
    public void removeMCFConfigProperty(ConnectorConfigProperty  configProperty) {
        if (configProperty != null) {
            .remove(configProperty);
        }
    }

    
Setter method for MCFConfigProperties property.

Parameters:
configProperties Set MCF config properties
    public void setMCFConfigProperties(Set configProperties) {
         = configProperties;
    }

    
Setter method for MCFConfigProperties property.

Parameters:
configProperties Array of MCF config properties
    public void setMCFConfigProperties(ConnectorConfigProperty [] configProperties) {
        if (configProperties != null) {
            for (int i = 0; i < configProperties.length; ++i) {
                .add(configProperties[i]);
            }
        }
    }

    
Getter method for MCFConfigProperties property

Returns:
Set of managed connection factory config properties
    public Set getMCFConfigProperties() {
        return ;
    }

    
Adds a Resource Adapter config property to the existing array/Set of Resource Adapter config properties.

Parameters:
configProperty Config property to be added.
    public void addResourceAdapterConfigProperty(ConnectorConfigProperty  configProperty) {
        if (configProperty != null) {
            .add(configProperty);
        }
    }

    
Removes a Resource Adapter config property to the existing array/Set of Resource Adapter config properties.

Parameters:
configProperty Config property to be removed.
    public void removeResourceAdapterConfigProperty(ConnectorConfigProperty  configProperty) {
        if (configProperty != null) {
            .remove(configProperty);
        }
    }

    
Setter method for ResourceAdapterConfigProperties property.

Parameters:
configProperties Set ResourceAdapter config properties
    public void setResourceAdapterConfigProperties(Set configProperties) {
         = configProperties;
    }

    
Setter method for ResourceAdapterConfigProperties property.

Parameters:
configProperties Array ResourceAdapter config properties
            ConnectorConfigProperty [] configProperties) {
        if (configProperties != null) {
            for (ConnectorConfigProperty  configProperty : configProperties) {
                .add(configProperty);
            }
        }
    }

    
Getter method for ResourceAdapterConfigProperties property

Returns:
Set of resource adapter config properties
        return ;
    }

    
Getter method for RarName property

Returns:
rarName
    public String getRarName() {
        return ;
    }

    
Setter method for RarName property

Parameters:
rarName rar name
    public void setRarName(String rarName) {
         = rarName;
    }

    
Getter method for ResourceAdapterClassName property

Returns:
Resource adapter class name
        return ;
    }

    
Setter method for ResourceAdapterClassName property

Parameters:
resourceAdapterClass Resource adapter class name
    public void setResourceAdapterClassName(String resourceAdapterClass) {
         = resourceAdapterClass;
    }

    
Getter method for ConnectionDefinitionName property

Returns:
connection definition name
        return ;
    }

    
Setter method for ConnectionDefinitionName property

Parameters:
connectionDefinitionName connection definition name
    public void setConnectionDefinitionName(String connectionDefinitionName) {
         = connectionDefinitionName;
    }

    
Getter method for ManagedConnectionFactoryClass property

Returns:
managed connection factory class
        return ;
    }

    
Setter method for ManagedConnectionFactoryClass property

Parameters:
managedConnectionFactoryClass managed connection factory class
            String managedConnectionFactoryClass) {
         = managedConnectionFactoryClass;
    }

    
Getter method for ConnectionFactoryClass property

Returns:
connection factory class
    public String getConnectionFactoryClass() {
        return ;
    }

    
Setter method for ConnectionFactoryClass property

Parameters:
connectionFactoryClass connection factory class
    public void setConnectionFactoryClass(String connectionFactoryClass) {
         = connectionFactoryClass;
    }

    
Getter method for ConnectionFactoryInterface property

Returns:
connection factory interface class
        return ;
    }

    
Setter method for ConnectionFactoryInterface property

Parameters:
connectionFactoryInterface connection factory interface class
    public void setConnectionFactoryInterface(
            String connectionFactoryInterface) {
         = connectionFactoryInterface;
    }

    
Getter method for ConnectionClass property

Returns:
connection class
    public String getConnectionClass() {
        return ;
    }

    
Setter method for ConnectionClass property

Parameters:
connectionClass connection Class
    public void setConnectionClass(String connectionClass) {
         = connectionClass;
    }

    
Getter method for ConnectionInterface property

Returns:
connectionInterface class
    public String getConnectionInterface() {
        return ;
    }

    
Setter method for ConnectionInterface property

Parameters:
connectionInterface connection interface class
    public void setConnectionInterface(String connectionInterface) {
         = connectionInterface;
    }

    
Compare the MCF Config properties in this object with the passed ones

Parameters:
cdi - The ConnDescInfo object whose MCF config props are to to be comapred against our props
Returns:
true - if the config properties are the same false otherwise
        return compareMCFConfigProperties(cdinew HashSet());
    }

    
Compare the MCF Config properties in this object with the passed ones. The properties in the Set of excluded properties are not compared against

Parameters:
cdi - The ConnDescInfo object whose MCF config props are to to be comapred against our props
excluded - list of properties to be excluded from comparison
Returns:
true - if the config properties are the same false otherwise
            ConnectorDescriptorInfo cdiSet excluded) {
        Set mcfConfigProps = cdi.getMCFConfigProperties();
        if (mcfConfigProps.size() != .size()) {
            //return false;
            //Cannot determine anything due to size disparity - assume restart
            return .;
        }
        boolean same = false;
        for (Object mcfConfigProp : mcfConfigProps) {
            ConnectorConfigProperty  prop = (ConnectorConfigProperty ) mcfConfigProp;
            //see if this property is in our list of excludes
            if (excluded.contains(prop.getName())) {
                //_logger.finest("mcfProp ignored : " + prop.getName() );
                continue;
            }
            for (ConnectorConfigProperty  property : ) {
                if (isEnvPropEqual(propproperty)) {
                    //we have a match
                    same = true;
                    //_logger.finest("mcfprop matched : " + prop.getName());
                    break;
                }
            }
            if (!same) {
                //_logger.finest("mcfprop not matched : " + prop.getName() );
                //return false;
                return .;
            }
            same = false;
        }
        return .;
    }

    
The ConnectorConfigProperty ::equals method only checks for name equality So we need to write a custom equals

Parameters:
e1 property
e2 property
Returns:
boolean - equality result
    private boolean isEnvPropEqual(ConnectorConfigProperty  e1,
                                   ConnectorConfigProperty  e2) {
        if (e1 != null && e2 != null &&
                e1.getName() != null && e2.getName() != null &&
                e1.getName().equals(e2.getName())) {
            if (e1.getValue() != null && e2.getValue() != null &&
                    e1.getValue().equals(e2.getValue())) {
                return true;
            }
        }
        return false;
    }
New to GrepCode? Check out our FAQ X