KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > appserv > management > deploy > DeploymentSourceImpl


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 package com.sun.appserv.management.deploy;
24
25 import java.util.Set JavaDoc;
26 import java.util.Map JavaDoc;
27 import java.util.Iterator JavaDoc;
28 import java.util.jar.JarInputStream JavaDoc;
29 import java.io.FileInputStream JavaDoc;
30 import java.io.File JavaDoc;
31 import java.io.IOException JavaDoc;
32 import java.io.Serializable JavaDoc;
33
34 import com.sun.appserv.management.base.MapCapableBase;
35 import com.sun.appserv.management.deploy.DeploymentSource;
36
37
38 /**
39  */

40
41 public final class DeploymentSourceImpl
42     extends MapCapableBase
43     implements DeploymentSource
44 {
45     /**
46         Key corresponding to getArchive()
47      */

48     public static final String JavaDoc ARCHIVE_FILE_KEY = "Archive";
49     
50     /**
51         Key corresponding to isComplete()
52      */

53     public static final String JavaDoc IS_COMPLETE_ARCHIVE_KEY = "IsCompleteArchive";
54     
55     /**
56         Key corresponding to getEntriesAdded()
57      */

58     public static final String JavaDoc ENTRIES_ADDED_KEY = "EntriesAdded";
59     
60     /**
61         Key corresponding to getEntriesRemoved()
62      */

63     public static final String JavaDoc ENTRIES_REMOVED_KEY = "EntriesRemoved";
64     
65     /**
66         Key corresponding to getEntriesDeleted()
67      */

68     public static final String JavaDoc ENTRIES_DELETED_KEY = "EntriesDeleted";
69     
70         public
71     DeploymentSourceImpl( final DeploymentSource src )
72     {
73         this( src.asMap() );
74     }
75     
76         public <T extends Serializable JavaDoc>
77     DeploymentSourceImpl( final Map JavaDoc<String JavaDoc, T> m )
78     {
79         super( m, DEPLOYMENT_SOURCE_CLASS_NAME);
80         checkValidType( m, DEPLOYMENT_SOURCE_CLASS_NAME );
81         
82         validateThrow();
83     }
84     
85         public <T extends Serializable JavaDoc>
86     DeploymentSourceImpl(
87         final String JavaDoc archiveFile,
88         final boolean isCompleteArchive,
89         final String JavaDoc[] entriesAdded,
90         final String JavaDoc[] entriesRemoved,
91         final String JavaDoc[] entriesDeleted,
92         final Map JavaDoc<String JavaDoc,T> other )
93     {
94         super( other, DEPLOYMENT_SOURCE_CLASS_NAME);
95         
96         putField( ARCHIVE_FILE_KEY, archiveFile );
97         putField( IS_COMPLETE_ARCHIVE_KEY, new Boolean JavaDoc( isCompleteArchive ) );
98         putField( ENTRIES_ADDED_KEY, entriesAdded );
99         putField( ENTRIES_REMOVED_KEY, entriesRemoved );
100         putField( ENTRIES_DELETED_KEY, entriesDeleted );
101         
102         validateThrow();
103     }
104     
105     
106         protected boolean
107     validate()
108     {
109         boolean valid = validateNullOrOfType( ARCHIVE_FILE_KEY, String JavaDoc.class );
110         
111         if ( valid )
112         {
113             valid = validateNullOrOfType( IS_COMPLETE_ARCHIVE_KEY, Boolean JavaDoc.class );
114         }
115         
116         if ( valid )
117         {
118             valid = validateNullOrOfType( ENTRIES_ADDED_KEY, String JavaDoc[].class ) &&
119                         validateNullOrOfType( ENTRIES_REMOVED_KEY, String JavaDoc[].class ) &&
120                         validateNullOrOfType( ENTRIES_DELETED_KEY, String JavaDoc[].class );
121         }
122         
123         return( valid );
124     }
125     
126
127         public String JavaDoc
128     getMapClassName()
129     {
130         return( DEPLOYMENT_SOURCE_CLASS_NAME );
131     }
132     
133         public File JavaDoc
134     getArchive()
135     {
136         return( getFile( ARCHIVE_FILE_KEY ) );
137     }
138        
139         public JarInputStream JavaDoc
140     getArchiveAsStream()
141         throws IOException JavaDoc
142     {
143         return( new JarInputStream JavaDoc( new FileInputStream JavaDoc( getArchive() ) ) );
144     }
145     
146         public boolean
147     isCompleteArchive()
148     {
149         return( getboolean( IS_COMPLETE_ARCHIVE_KEY ) );
150     }
151     
152         public String JavaDoc[]
153     getEntriesAdded()
154     {
155         return( getStringArray( ENTRIES_ADDED_KEY ) );
156     }
157     
158         public String JavaDoc[]
159     getEntriesRemoved()
160     {
161         return( getStringArray( ENTRIES_REMOVED_KEY ) );
162     }
163     
164         public String JavaDoc[]
165     getEntriesDeleted()
166     {
167         return( getStringArray( ENTRIES_DELETED_KEY ) );
168     }
169 }
170
171
172
173
174
175
176
177
178
Popular Tags