Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright (c) 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.resource.deployer;
 
 
 import java.util.List;
 
 import static org.glassfish.deployment.common.JavaEEResourceType.*;

Author(s):
Dapeng Hu
 
 
     @Inject
 
     private static Logger _logger = LogDomains.getLogger(ConnectorResourceDefinitionDeployer.class.);
     final static String PROPERTY_PREFIX = "org.glassfish.connector-connection-pool.";
 
     public void deployResource(Object resourceString applicationNameString moduleNamethrows Exception {
         //TODO ASR
     }
     
     public void deployResource(Object resourcethrows Exception {
 
         String poolName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), );
         String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(),desc.getResourceType());
 
         if(.isLoggable(.)) {
             .log(."ConnectorResourceDefinitionDeployer.deployResource() : pool-name ["+poolName+"], " +
                     " resource-name ["+resourceName+"]");
         }
 
        ConnectorConnectionPool connectorCp = new MyConnectorConnectionPool(descpoolName);
        //deploy pool
        getDeployer(connectorCp).deployResource(connectorCp);
        //deploy resource
        ConnectorResource connectorResource = new MyConnectorResource(poolNameresourceName);
        getDeployer(connectorResource).deployResource(connectorResource);
        
    }

    
    public boolean canDeploy(boolean postApplicationDeploymentCollection<ResourceallResourcesResource resource){
        if(handles(resource)){
            if(!postApplicationDeployment){
                return true;
            }
        }
        return false;
    }

    
                                          com.sun.enterprise.config.serverbeans.Application newApp
                                          Resource resource,
                                          Resources allResources)
    throws ResourceConflictException {
        //do nothing.
    }
    private ResourceDeployer getDeployer(Object resource) {
        return .get().getResourceDeployer(resource);
    }
    private ConnectorResourceProperty convertProperty(String nameString value) {
        return new ConnectorResourceProperty(namevalue);
    }
    public void undeployResource(Object resourceString applicationNameString moduleNamethrows Exception {
        //TODO ASR
    }
    public void undeployResource(Object resourcethrows Exception {
        String poolName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(), );
        String resourceName = ConnectorsUtil.deriveResourceName(desc.getResourceId(), desc.getName(),desc.getResourceType());
        if(.isLoggable(.)) {
            .log(."ConnectorResourceDefinitionDeployer.undeployResource() : pool-name ["+poolName+"], " +
                    " resource-name ["+resourceName+"]");
        }
        //undeploy resource
        ConnectorResource connectorResource = new MyConnectorResource(poolNameresourceName);
        getDeployer(connectorResource).undeployResource(connectorResource);
        //undeploy pool
        ConnectorConnectionPool connectorCp = new MyConnectorConnectionPool(descpoolName);
        getDeployer(connectorCp).undeployResource(connectorCp);
    }
    public void redeployResource(Object resourcethrows Exception {
        throw new UnsupportedOperationException("redeploy() not supported for connector-resource-definition type");
    }
    public void enableResource(Object resourcethrows Exception {
        throw new UnsupportedOperationException("enable() not supported for connector-resource-definition type");
    }
    public void disableResource(Object resourcethrows Exception {
        throw new UnsupportedOperationException("disable() not supported for connector-resource-definition type");
    }
    public boolean handles(Object resource) {
        return resource instanceof ConnectorResourceDefinitionDescriptor;
    }

    

InheritDoc:
    public boolean supportsDynamicReconfiguration() {
        return false;
    }

    

InheritDoc:
        return new Class[0];
    }
    abstract class FakeConfigBean implements ConfigBeanProxy {
 
        public ConfigBeanProxy deepCopy(ConfigBeanProxy parent) {
            throw new UnsupportedOperationException();
        }
        public ConfigBeanProxy getParent() {
            return null;
        }
        public <T extends ConfigBeanProxy> T getParent(Class<T> tClass) {
            return null;
        }
        public <T extends ConfigBeanProxy> T createChild(Class<T> tClassthrows TransactionFailure {
            return null;
        }        
    }
    class ConnectorResourceProperty extends FakeConfigBean implements Property {
        private String name;
        private String value;
        private String description;
        ConnectorResourceProperty(String nameString value) {
            this. = name;
            this. = value;
        }
        public String getName() {
            return ;
        }
        public void setName(String valuethrows PropertyVetoException {
            this. = value;
        }
        public String getValue() {
            return ;
        }
        public void setValue(String valuethrows PropertyVetoException {
            this. = value;
        }
        public String getDescription() {
            return ;
        }
        public void setDescription(String valuethrows PropertyVetoException {
            this. = value;
        }
        public void injectedInto(Object o) {
            //do nothing
        }
    }
    class MyConnectorResource extends FakeConfigBean implements ConnectorResource {
        private String poolName;
        private String jndiName;
        MyConnectorResource(String poolNameString jndiName) {
            this. = poolName;
            this. = jndiName;
        }
        public String getPoolName() {
            return ;
        }
        public void setPoolName(String valuethrows PropertyVetoException {
            this. = value;
        }
        public String getObjectType() {
            return null;
        }
        public void setObjectType(String valuethrows PropertyVetoException {
        }
        public String getIdentity() {
            return ;
        }
        public String getEnabled() {
            return String.valueOf(true);
        }
        public void setEnabled(String valuethrows PropertyVetoException {
        }
        public String getDescription() {
            return null;
        }
        public void setDescription(String valuethrows PropertyVetoException {
        }
        public List<PropertygetProperty() {
            return null;
        }
        public Property getProperty(String name) {
            return null;
        }
        public String getPropertyValue(String name) {
            return null;
        }
        public String getPropertyValue(String nameString defaultValue) {
            return null;
        }
        public void injectedInto(Object o) {
        }
        public String getJndiName() {
            return ;
        }
        public void setJndiName(String valuethrows PropertyVetoException {
            this. = value;
        }
    }
        private String name;
            this. = desc;
            this. = name;
        }
        @Override
        public String getObjectType() {
            return "user";  //To change body of implemented methods use File | Settings | File Templates.
        }
        @Override
        public void setObjectType(String valuethrows PropertyVetoException {
            //To change body of implemented methods use File | Settings | File Templates.
        }
        public String getIdentity() {
            return ;
        }
        public String getSteadyPoolSize() {
            String minPoolSize = .getProperty(+"steady-pool-size");
            if(minPoolSize!=null && !minPoolSize.equals("")){
                return minPoolSize;
            }else{
                return "8";
            }
        }
        public void setSteadyPoolSize(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getMaxPoolSize() {
            String maxPoolSize = .getProperty(+"max-pool-size");
            if (maxPoolSize != null && !maxPoolSize.equals("")) {
                return maxPoolSize;
            }else{
                return "32";
            }
        }
        public void setMaxPoolSize(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getMaxWaitTimeInMillis() {
            String maxWaitTimeInMillis = .getProperty(+"max-wait-time-in-millis");
            if (maxWaitTimeInMillis != null && !maxWaitTimeInMillis.equals("")) {
                return maxWaitTimeInMillis;
            }else{
                return "60000";
            }
        }
        public void setMaxWaitTimeInMillis(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getPoolResizeQuantity() {
            String poolResizeQuantity = .getProperty(+"pool-resize-quantity");
            if (poolResizeQuantity != null && !poolResizeQuantity.equals("")) {
                return poolResizeQuantity;
            }else{
                return "2";
            }
        }
        public void setPoolResizeQuantity(String valuethrows PropertyVetoException {
            //do nothing
        }
        
        public String getIdleTimeoutInSeconds() {
            String idleTimeoutInSeconds = .getProperty(+"idle-timeout-in-seconds");
            if (idleTimeoutInSeconds != null && !idleTimeoutInSeconds.equals("")) {
                return idleTimeoutInSeconds;
            }else{
                return "300";
            }
        }
        public void setIdleTimeoutInSeconds(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getIsConnectionValidationRequired() {
            String isConnectionValidationRequired = .getProperty(+"is-connection-validation-required");
            if (isConnectionValidationRequired != null && !isConnectionValidationRequired.equals("")) {
                return isConnectionValidationRequired;
            }else{
                return "false";
            }
        }
        public void setIsConnectionValidationRequired(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getResourceAdapterName() {
            String resourceAdapterName = .getProperty(+"resource-adapter-name");
            if (resourceAdapterName != null && !resourceAdapterName.equals("")) {
                return resourceAdapterName;
            }else{
                return null;
            }
        }
        public void setResourceAdapterName(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getConnectionDefinitionName() {
            return .getClassName();
        }
        public void setConnectionDefinitionName(String value)  throws PropertyVetoException {
            //do nothing
        }
        public String getFailAllConnections() {
            String failAllConnections = .getProperty(+"fail-all-connections");
            if (failAllConnections != null && !failAllConnections.equals("")) {
                return failAllConnections;
            }else{
                return "false";
            }
        }
        public void setFailAllConnections(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getTransactionSupport() {
            String transactionSupport = .getProperty(+"transaction-support");
            if (transactionSupport != null && !transactionSupport.equals("")) {
                return transactionSupport;
            }else{
                return "NoTransaction";
            }
        }
        public void setTransactionSupport(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getValidateAtmostOncePeriodInSeconds() {
            String validateAtmostOncePeriodInSeconds = .getProperty(+"validate-at-most-once-period-in-seconds");
            if (validateAtmostOncePeriodInSeconds != null && !validateAtmostOncePeriodInSeconds.equals("")) {
                return validateAtmostOncePeriodInSeconds;
            }else{
                return "0";
            }
        }
        public void setValidateAtmostOncePeriodInSeconds(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getConnectionLeakTimeoutInSeconds() {
            String connectionLeakTimeoutInSeconds = .getProperty(+"connection-leak-timeout-in-seconds");
            if (connectionLeakTimeoutInSeconds != null && !connectionLeakTimeoutInSeconds.equals("")) {
                return connectionLeakTimeoutInSeconds;
            }else{
                return "0";
            }
        }
        public void setConnectionLeakTimeoutInSeconds(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getConnectionLeakReclaim() {
            String connectionLeakReclaim = .getProperty(+"connection-leak-reclaim");
            if (connectionLeakReclaim != null && !connectionLeakReclaim.equals("")) {
                return connectionLeakReclaim;
            }else{
                return "0";
            }
        }
        public void setConnectionLeakReclaim(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getConnectionCreationRetryAttempts() {
            String connectionCreationRetryAttempts = .getProperty(+"connection-creation-retry-attempts");
            if (connectionCreationRetryAttempts != null && !connectionCreationRetryAttempts.equals("")) {
                return connectionCreationRetryAttempts;
            }else{
                return "0";
            }
        }
        public void setConnectionCreationRetryAttempts(String valuethrows PropertyVetoException {
            //do nothing
        }
            String connectionCreationRetryIntervalInSeconds = .getProperty(+"connection-creation-retry-interval-in-seconds");
            if (connectionCreationRetryIntervalInSeconds != null && !connectionCreationRetryIntervalInSeconds.equals("")) {
                return connectionCreationRetryIntervalInSeconds;
            }else{
                return "0";
            }
        }
        public void setConnectionCreationRetryIntervalInSeconds(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getLazyConnectionEnlistment() {
            String lazyConnectionEnlistment = .getProperty(+"lazy-connection-enlistment");
            if (lazyConnectionEnlistment != null && !lazyConnectionEnlistment.equals("")) {
                return lazyConnectionEnlistment;
            }else{
                return "false";
            }
        }
        public void setLazyConnectionEnlistment(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getLazyConnectionAssociation() {
            String lazyConnectionAssociation = .getProperty(+"lazy-connection-association");
            if (lazyConnectionAssociation != null && !lazyConnectionAssociation.equals("")) {
                return lazyConnectionAssociation;
            }else{
                return "false";
            }
        }
        public void setLazyConnectionAssociation(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getAssociateWithThread() {
            String associateWithThread = .getProperty(+"associate-with-thread");
            if (associateWithThread != null && !associateWithThread.equals("")) {
                return associateWithThread;
            }else{
                return "false";
            }
        }
        public void setAssociateWithThread(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getPooling() {
            String pooling = .getProperty(+"pooling");
            if (pooling != null && !pooling.equals("")) {
                return pooling;
            }else{
                return "true";
            }
        }
        public void setPooling(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getMatchConnections() {
            String matchConnections = .getProperty(+"match-connections");
            if (matchConnections != null && !matchConnections.equals("")) {
                return matchConnections;
            }else{
                return "true";
            }
        }
        public void setMatchConnections(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getMaxConnectionUsageCount() {
            String maxConnectionUsageCount = .getProperty(+"max-connection-usage-count");
            if (maxConnectionUsageCount != null && !maxConnectionUsageCount.equals("")) {
                return maxConnectionUsageCount;
            }else{
                return "0";
            }
        }
        public void setMaxConnectionUsageCount(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getDescription() {
            return .getDescription();
        }
        public void setDescription(String valuethrows PropertyVetoException {
            //do nothing
        }
        public List<PropertygetProperty() {
            Properties p = .getProperties();
            List<PropertyconnectorResourceProperties = new ArrayList<Property>();
            for (Entry<ObjectObjectentry : p.entrySet()) {
                String key = (Stringentry.getKey();
                if(key.startsWith()){
                    continue;
                }
                String value = (Stringentry.getValue();
                ConnectorResourceProperty dp = convertProperty(keyvalue);
                connectorResourceProperties.add(dp);
            }
            return connectorResourceProperties;
        }
 
        public Property getProperty(String name) {
            String value = .getProperty(name);
            return new ConnectorResourceProperty(namevalue);
        }
        public String getPropertyValue(String name) {
            return .getProperty(name);
        }
        public String getPropertyValue(String nameString defaultValue) {
            String value = null;
            value = .getProperty(name);
            if (value != null) {
                return value;
            } else {
                return defaultValue;
            }
        }
        public void injectedInto(Object o) {
            //do nothing
        }
        public String getName() {
            return ;
        }
        public void setName(String valuethrows PropertyVetoException {
            //do nothing
        }
        public String getPing() {
            String ping = .getProperty(+"ping");
            if (ping != null && !ping.equals("")) {
                return ping;
            }else{
                return "false";
            }
        }
        public void setPing(String valuethrows PropertyVetoException {
            //do nothing
        }
        public List<SecurityMapgetSecurityMap() {
            return new ArrayList<SecurityMap>(0);
        }
    }
New to GrepCode? Check out our FAQ X