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.st.core.jaxb; 19 20 import javax.xml.bind.JAXBElement; 21 import javax.xml.bind.JAXBException; 22 23 import org.apache.geronimo.st.core.internal.Trace; 24 import org.eclipse.core.resources.IFile; 25 26 /** 27 * <strong>ConversionHelper</strong> is a helper class with numerous static 28 * methods to aid in the conversion of Geronimo-specific deployment plans from 29 * one JAXB version to another (e.g., v1.1 to v2.1)<p> 30 * 31 * @version $Rev: 817996 $ $Date: 2009-09-23 16:04:12 +0800 (Wed, 23 Sep 2009) $ 32 */ 33 public class ConversionHelper { 34 35 /** 36 * Convert a geronimo-web.xml deployment plan file (if necessary) 37 * and return the JAXB representation 38 * 39 * @param plan Geronimo deployment plan 40 * @throws Exception 41 */ 42 public static void convertGeronimoWebFile( IFile plan ) throws Exception { 43 Trace.tracePoint("Entry", "ConversionHelper.convertGeronimoWebFile", plan); 44 45 convertNamespace( plan ); 46 47 Trace.tracePoint("Exit ", "ConversionHelper.convertGeronimoWebFile"); 48 } 49 50 51 /** 52 * Convert an openejb-jar.xml deployment plan file (if necessary) and return the 53 * JAXB representation 54 * 55 * @param plan OpenEJB deployment plan 56 * @throws Exception 57 */ 58 public static void convertOpenEjbJarFile( IFile plan ) throws Exception { 59 Trace.tracePoint("Entry", "ConversionHelper.convertGeronimoOpenEjbFile", plan); 60 61 convertNamespace( plan ); 62 63 Trace.tracePoint("Exit ", "ConversionHelper.convertGeronimoOpenEjbFile"); 64 } 65 66 67 /** 68 * Convert a geronimo-application.xml deployment plan file (if necessary) 69 * and return the JAXB representation 70 * 71 * @param plan Geronimo deployment plan 72 * 73 * @exception JAXBException if JAXB error 74 */ 75 public static void convertGeronimoApplicationFile( IFile plan ) throws Exception { 76 Trace.tracePoint("Entry", "ConversionHelper.convertGeronimoApplicationFile", plan); 77 78 convertNamespace( plan ); 79 80 Trace.tracePoint("Exit ", "ConversionHelper.convertGeronimoApplicationFile"); 81 } 82 83 84 /** 85 * Convert a geronimo-ra.xml deployment plan file (if necessary) 86 * and return the JAXB representation 87 * 88 * @param plan Geronimo deployment plan 89 * 90 * @exception JAXBException if JAXB error 91 */ 92 public static void convertGeronimoRaFile( IFile plan ) throws Exception { 93 Trace.tracePoint("Entry", "ConversionHelper.convertGeronimoRaFile", plan); 94 95 convertNamespace( plan ); 96 97 Trace.tracePoint("Exit ", "ConversionHelper.convertGeronimoRaFile"); 98 } 99 100 101 /** 102 * Convert a geronimo-application-client.xml deployment plan file 103 * and return the JAXB representation 104 * 105 * @param plan Geronimo deployment plan 106 * 107 * @exception JAXBException if JAXB error 108 */ 109 public static void convertGeronimoApplicationClientFile( IFile plan ) throws Exception { 110 Trace.tracePoint("Entry", "ConversionHelper.convertGeronimoApplicationClientFile", plan); 111 112 convertNamespace( plan ); 113 114 Trace.tracePoint("Exit ", "ConversionHelper.convertGeronimoApplicationClientFile"); 115 } 116 117 118 /*------------------------------------------------------------------------*\ 119 | | 120 | Private method(s) | 121 | | 122 \*------------------------------------------------------------------------*/ 123 124 125 /** 126 * Convert the namespace of the Geronimo deployment plan and then save the 127 * deployment plan 128 * 129 * @param plan Geronimo deployment plan 130 */ 131 private static void convertNamespace( IFile plan ) throws Exception{ 132 133 // 134 // Unmarshall and filter the deployment plan 135 // 136 JAXBElement jaxbElement = JAXBUtils.unmarshalFilterDeploymentPlan(plan); 137 138 // 139 // Marshall and save the deployment plan from the jaxbElement 140 // 141 JAXBUtils.marshalDeploymentPlan( jaxbElement, plan ); 142 } 143 }