1 23 24 package com.sun.enterprise.admin.servermgmt.pe; 25 26 import java.io.File ; 27 import java.io.InputStream ; 28 import java.io.FileInputStream ; 29 import java.io.BufferedInputStream ; 30 import java.io.OutputStream ; 31 import java.io.FileOutputStream ; 32 import java.io.IOException ; 33 34 import com.sun.enterprise.admin.servermgmt.DomainConfig; 35 import com.sun.enterprise.admin.servermgmt.DomainException; 36 import com.sun.enterprise.admin.servermgmt.DomainXmlEventListener; 37 import com.sun.enterprise.admin.servermgmt.pe.PEFileLayout; 38 import com.sun.enterprise.admin.servermgmt.pe.PEDomainsManager; 39 import com.sun.enterprise.util.zip.ZipFile; 40 import com.sun.enterprise.util.zip.ZipFileException; 41 import com.sun.enterprise.util.io.FileUtils; 42 import com.sun.enterprise.util.i18n.StringManager; 43 44 45 public class PESamplesDomainXmlEventListener implements DomainXmlEventListener { 46 47 private static final StringManager strMgr = 48 StringManager.getManager(PEDomainsManager.class); 49 50 51 public void handleCreateEvent(DomainConfig cfg) throws DomainException { 52 PEFileLayout layout = new PEFileLayout(cfg); 53 File appsDir = layout.getInstallApplicationsDir(); 54 File domainDir = layout.getRepositoryDir(); 55 File jarFile = new File (appsDir, "samples.jar" ); 56 57 try{ 58 ZipFile file = new ZipFile(FileUtils.safeGetCanonicalPath(jarFile), 59 FileUtils.safeGetCanonicalPath(domainDir)); 60 file.explode(); 61 }catch(ZipFileException e){ 62 throw new DomainException( strMgr.getString("samplesDomainNotCreated") ,e ); 63 } 64 } 65 66 67 public void handleDeleteEvent(DomainConfig cfg) throws DomainException { 68 } 69 } 70 | Popular Tags |