Home » geronimo-2.2-source-release » org.apache.geronimo.deployment.plugin » [javadoc | source]

    1   /**
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    *
    9    *     http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   
   18   package org.apache.geronimo.deployment.plugin;
   19   
   20   import java.io.OutputStream;
   21   import java.io.InputStream;
   22   import java.io.IOException;
   23   
   24   import javax.enterprise.deploy.spi.DeploymentConfiguration;
   25   import javax.enterprise.deploy.spi.DConfigBeanRoot;
   26   import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
   27   import javax.enterprise.deploy.spi.exceptions.BeanNotFoundException;
   28   import javax.enterprise.deploy.model.DeployableObject;
   29   import javax.enterprise.deploy.model.DDBeanRoot;
   30   
   31   import org.apache.xmlbeans.XmlException;
   32   
   33   /**
   34    *
   35    *
   36    * @version $Rev: 697438 $ $Date: 2008-09-20 17:45:30 -0700 (Sat, 20 Sep 2008) $
   37    */
   38   public abstract class DeploymentConfigurationSupport implements DeploymentConfiguration {
   39       private final DeployableObject deployable;
   40   
   41       protected DConfigBeanRootSupport dConfigRoot;
   42   
   43       public DeploymentConfigurationSupport(DeployableObject deployable, DConfigBeanRootSupport dConfigRoot) {
   44           this.deployable = deployable;
   45           this.dConfigRoot = dConfigRoot;
   46       }
   47   
   48       public DeployableObject getDeployableObject() {
   49           return deployable;
   50       }
   51   
   52       public DConfigBeanRoot getDConfigBeanRoot(DDBeanRoot bean) throws ConfigurationException {
   53           if (getDeployableObject().getDDBeanRoot().equals(bean)) {
   54               return dConfigRoot;
   55           }
   56           return null;
   57       }
   58   
   59       public void removeDConfigBean(DConfigBeanRoot bean) throws BeanNotFoundException {
   60       }
   61   
   62       public void save(OutputStream outputArchive) throws ConfigurationException {
   63           try {
   64               dConfigRoot.toXML(outputArchive);
   65               outputArchive.flush();
   66           } catch (IOException e) {
   67               throw (ConfigurationException) new ConfigurationException("Unable to save configuration").initCause(e);
   68           }
   69       }
   70   
   71       public void restore(InputStream inputArchive) throws ConfigurationException {
   72           try {
   73               dConfigRoot.fromXML(inputArchive);
   74           } catch (IOException e) {
   75               throw (ConfigurationException) new ConfigurationException("Error reading configuration input").initCause(e);
   76           } catch (XmlException e) {
   77               throw (ConfigurationException) new ConfigurationException("Error parsing configuration input").initCause(e);
   78           }
   79       }
   80   
   81       public void saveDConfigBean(OutputStream outputArchive, DConfigBeanRoot bean) throws ConfigurationException {
   82           try {
   83               ((DConfigBeanRootSupport)bean).toXML(outputArchive);
   84               outputArchive.flush();
   85           } catch (IOException e) {
   86               throw (ConfigurationException) new ConfigurationException("Unable to save configuration").initCause(e);
   87           }
   88       }
   89   
   90       //todo figure out how to implement this.
   91       public DConfigBeanRoot restoreDConfigBean(InputStream inputArchive, DDBeanRoot bean) throws ConfigurationException {
   92           return null;
   93       }
   94   }

Home » geronimo-2.2-source-release » org.apache.geronimo.deployment.plugin » [javadoc | source]