View Javadoc

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  
19  package org.apache.geronimo.connector.deployment;
20  
21  import javax.enterprise.deploy.model.DeployableObject;
22  import javax.enterprise.deploy.shared.ModuleType;
23  import javax.enterprise.deploy.spi.DeploymentConfiguration;
24  
25  import org.apache.geronimo.connector.deployment.dconfigbean.ResourceAdapterDConfigRoot;
26  import org.apache.geronimo.connector.deployment.dconfigbean.ResourceAdapter_1_0DConfigRoot;
27  import org.apache.geronimo.connector.deployment.jsr88.Connector15DCBRoot;
28  import org.apache.geronimo.deployment.ModuleConfigurer;
29  import org.apache.geronimo.gbean.GBeanInfo;
30  import org.apache.geronimo.gbean.GBeanInfoBuilder;
31  import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
32  
33  /**
34   *
35   *
36   * @version $Rev: 470597 $ $Date: 2006-11-02 15:30:55 -0800 (Thu, 02 Nov 2006) $
37   */
38  public class RARConfigurer implements ModuleConfigurer {
39  
40      public DeploymentConfiguration createConfiguration(DeployableObject deployable) {
41          if (ModuleType.RAR.equals(deployable.getType())) {
42              String ddBeanRootVersion = deployable.getDDBeanRoot().getDDBeanRootVersion();
43              if (ddBeanRootVersion != null && ddBeanRootVersion.equals("1.5")) {
44                  return new RARConfiguration(deployable, new Connector15DCBRoot(deployable.getDDBeanRoot()));
45              }
46              String[] specVersion = deployable.getDDBeanRoot().getText("connector/spec-version");
47              if (specVersion.length > 0 && "1.0".equals(specVersion[0])) {
48                  return new RARConfiguration(deployable, new ResourceAdapter_1_0DConfigRoot(deployable.getDDBeanRoot()));
49              }
50              throw new IllegalArgumentException("Unknown resource adapter version: " + deployable.getDDBeanRoot().getDDBeanRootVersion());
51          } else {
52              return null;
53          }
54      }
55  
56      public static final GBeanInfo GBEAN_INFO;
57  
58      static {
59          GBeanInfoBuilder infoFactory = GBeanInfoBuilder.createStatic(RARConfigurer.class, NameFactory.DEPLOYMENT_CONFIGURER);
60          infoFactory.addInterface(ModuleConfigurer.class);
61          GBEAN_INFO = infoFactory.getBeanInfo();
62      }
63  
64      public static GBeanInfo getGBeanInfo() {
65          return GBEAN_INFO;
66      }
67  }