1 23 package com.sun.appserv.management.deploy; 24 25 import java.util.Set ; 26 import java.util.Map ; 27 import java.util.Iterator ; 28 import java.util.jar.JarInputStream ; 29 import java.io.FileInputStream ; 30 import java.io.File ; 31 import java.io.IOException ; 32 import java.io.Serializable ; 33 34 import com.sun.appserv.management.base.MapCapableBase; 35 import com.sun.appserv.management.deploy.DeploymentSource; 36 37 38 40 41 public final class DeploymentSourceImpl 42 extends MapCapableBase 43 implements DeploymentSource 44 { 45 48 public static final String ARCHIVE_FILE_KEY = "Archive"; 49 50 53 public static final String IS_COMPLETE_ARCHIVE_KEY = "IsCompleteArchive"; 54 55 58 public static final String ENTRIES_ADDED_KEY = "EntriesAdded"; 59 60 63 public static final String ENTRIES_REMOVED_KEY = "EntriesRemoved"; 64 65 68 public static final String ENTRIES_DELETED_KEY = "EntriesDeleted"; 69 70 public 71 DeploymentSourceImpl( final DeploymentSource src ) 72 { 73 this( src.asMap() ); 74 } 75 76 public <T extends Serializable > 77 DeploymentSourceImpl( final Map <String , 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 > 86 DeploymentSourceImpl( 87 final String archiveFile, 88 final boolean isCompleteArchive, 89 final String [] entriesAdded, 90 final String [] entriesRemoved, 91 final String [] entriesDeleted, 92 final Map <String ,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 ( 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 .class ); 110 111 if ( valid ) 112 { 113 valid = validateNullOrOfType( IS_COMPLETE_ARCHIVE_KEY, Boolean .class ); 114 } 115 116 if ( valid ) 117 { 118 valid = validateNullOrOfType( ENTRIES_ADDED_KEY, String [].class ) && 119 validateNullOrOfType( ENTRIES_REMOVED_KEY, String [].class ) && 120 validateNullOrOfType( ENTRIES_DELETED_KEY, String [].class ); 121 } 122 123 return( valid ); 124 } 125 126 127 public String 128 getMapClassName() 129 { 130 return( DEPLOYMENT_SOURCE_CLASS_NAME ); 131 } 132 133 public File 134 getArchive() 135 { 136 return( getFile( ARCHIVE_FILE_KEY ) ); 137 } 138 139 public JarInputStream 140 getArchiveAsStream() 141 throws IOException 142 { 143 return( new JarInputStream ( new FileInputStream ( getArchive() ) ) ); 144 } 145 146 public boolean 147 isCompleteArchive() 148 { 149 return( getboolean( IS_COMPLETE_ARCHIVE_KEY ) ); 150 } 151 152 public String [] 153 getEntriesAdded() 154 { 155 return( getStringArray( ENTRIES_ADDED_KEY ) ); 156 } 157 158 public String [] 159 getEntriesRemoved() 160 { 161 return( getStringArray( ENTRIES_REMOVED_KEY ) ); 162 } 163 164 public String [] 165 getEntriesDeleted() 166 { 167 return( getStringArray( ENTRIES_DELETED_KEY ) ); 168 } 169 } 170 171 172 173 174 175 176 177 178 | Popular Tags |