Save This Page
Home » openejb-3.1.2-src » org.apache.openejb.spring » [javadoc | source]
    1   /**
    2    *
    3    * Licensed to the Apache Software Foundation (ASF) under one or more
    4    * contributor license agreements.  See the NOTICE file distributed with
    5    * this work for additional information regarding copyright ownership.
    6    * The ASF licenses this file to You under the Apache License, Version 2.0
    7    * (the "License"); you may not use this file except in compliance with
    8    * the License.  You may obtain a copy of the License at
    9    *
   10    *     http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    *  Unless required by applicable law or agreed to in writing, software
   13    *  distributed under the License is distributed on an "AS IS" BASIS,
   14    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   15    *  See the License for the specific language governing permissions and
   16    *  limitations under the License.
   17    */
   18   package org.apache.openejb.spring;
   19   
   20   import java.util.Properties;
   21   
   22   import org.springframework.beans.factory.BeanNameAware;
   23   import org.apache.openejb.OpenEJBException;
   24   import org.apache.openejb.config.sys.Resource;
   25   
   26   public abstract class AbstractResourceProvider implements ResourceProvider, BeanNameAware {
   27       private String id;
   28       private String beanName;
   29       private String provider;
   30   
   31       public String getId() {
   32           return id;
   33       }
   34   
   35       public void setId(String id) {
   36           this.id = id;
   37       }
   38   
   39       public void setBeanName(String beanName) {
   40           this.beanName = beanName;
   41       }
   42   
   43       public String getProvider() {
   44           return provider;
   45       }
   46   
   47       public void setProvider(String provider) {
   48           this.provider = provider;
   49       }
   50   
   51       public abstract String getType();
   52   
   53       public abstract Properties getProperties();
   54   
   55       public Resource getResourceDefinition() throws OpenEJBException {
   56           Resource resource = new Resource();
   57   
   58           if (id != null) {
   59               resource.setId(id);
   60           } else if (beanName != null) {
   61               resource.setId(beanName);
   62           } else {
   63               throw new OpenEJBException("No id defined for Resource");
   64           }
   65   
   66           if (provider != null) {
   67               resource.setProvider(provider);
   68           }
   69   
   70           if (getType() != null) {
   71               resource.setType(getType());
   72           }
   73   
   74           resource.getProperties().putAll(getProperties());
   75   
   76           return resource;
   77       }
   78   }

Save This Page
Home » openejb-3.1.2-src » org.apache.openejb.spring » [javadoc | source]