KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > admin > servermgmt > pe > PESamplesDomainXmlEventListener


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.admin.servermgmt.pe;
25
26 import java.io.File JavaDoc;
27 import java.io.InputStream JavaDoc;
28 import java.io.FileInputStream JavaDoc;
29 import java.io.BufferedInputStream JavaDoc;
30 import java.io.OutputStream JavaDoc;
31 import java.io.FileOutputStream JavaDoc;
32 import java.io.IOException JavaDoc;
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 /** The event listener class for PE Samples domain */
45 public class PESamplesDomainXmlEventListener implements DomainXmlEventListener {
46     
47     private static final StringManager strMgr =
48     StringManager.getManager(PEDomainsManager.class);
49
50     /** after the creation of domain.xml , unjar the bundled samples.jar. */
51     public void handleCreateEvent(DomainConfig cfg) throws DomainException {
52         PEFileLayout layout = new PEFileLayout(cfg);
53         File JavaDoc appsDir = layout.getInstallApplicationsDir();
54         File JavaDoc domainDir = layout.getRepositoryDir();
55         File JavaDoc jarFile = new File JavaDoc(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     /** currently do nothing */
67     public void handleDeleteEvent(DomainConfig cfg) throws DomainException {
68     }
69 }
70
Popular Tags