1 19 20 package org.netbeans.modules.j2ee.weblogic9.config; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.io.OutputStream ; 25 import javax.enterprise.deploy.model.DeployableObject ; 26 import javax.enterprise.deploy.spi.exceptions.ConfigurationException ; 27 import org.netbeans.modules.j2ee.weblogic9.config.gen.WeblogicEjbJar; 28 import org.openide.ErrorManager; 29 import org.openide.filesystems.FileUtil; 30 import org.openide.loaders.DataObjectNotFoundException; 31 32 33 38 public class EjbDeploymentConfiguration extends WLDeploymentConfiguration { 39 40 private File file; 41 private WeblogicEjbJar weblogicEjbJar; 42 43 46 public EjbDeploymentConfiguration(DeployableObject deployableObject) { 47 super(deployableObject); 48 } 49 50 56 public void init(File file) { 57 this.file = file; 58 getWeblogicEjbJar(); 59 if (dataObject == null) { 60 try { 61 dataObject = dataObject.find(FileUtil.toFileObject(file)); 62 } catch(DataObjectNotFoundException donfe) { 63 ErrorManager.getDefault().notify(donfe); 64 } 65 } 66 } 67 68 74 public synchronized WeblogicEjbJar getWeblogicEjbJar() { 75 if (weblogicEjbJar == null) { 76 try { 77 if (file.exists()) { 78 try { 80 weblogicEjbJar = weblogicEjbJar.createGraph(file); 81 } catch (IOException ioe) { 82 ErrorManager.getDefault().notify(ioe); 83 } catch (RuntimeException re) { 84 } 86 } else { 87 weblogicEjbJar = genereateWeblogicEjbJar(); 89 writefile(file, weblogicEjbJar); 90 } 91 } catch (ConfigurationException ce) { 92 ErrorManager.getDefault().notify(ce); 93 } 94 } 95 return weblogicEjbJar; 96 } 97 98 100 public void save(OutputStream os) throws ConfigurationException { 101 WeblogicEjbJar weblogicEjbJar = getWeblogicEjbJar(); 102 if (weblogicEjbJar == null) { 103 throw new ConfigurationException ("Cannot read configuration, it is probably in an inconsistent state."); } 105 try { 106 weblogicEjbJar.write(os); 107 } catch (IOException ioe) { 108 throw new ConfigurationException (ioe.getLocalizedMessage()); 109 } 110 } 111 112 114 117 private WeblogicEjbJar genereateWeblogicEjbJar() { 118 return new WeblogicEjbJar(); 119 } 120 } 121 | Popular Tags |