1 26 package org.objectweb.openccm.descriptor.componentassembly.ccm.deployer.installer; 27 28 import java.lang.reflect.Constructor ; 29 import java.util.Hashtable ; 30 import java.util.Iterator ; 31 32 import org.objectweb.openccm.descriptor.deployerconfig.DeployerconfigImpl; 33 import org.objectweb.openccm.descriptor.deployerconfig.Destination; 34 35 43 public class DefaultDestinationDeployerFactory 44 implements DestinationDeployerFactory 45 { 46 private DeployerconfigImpl deployerConfig; 52 private Hashtable supportedDestination; 53 54 public 60 DefaultDestinationDeployerFactory(DeployerconfigImpl deployerConfig) 61 { 62 this.deployerConfig=deployerConfig; 63 supportedDestination=new Hashtable (); 64 setupSupportedDestination(); 65 } 66 72 private void setupSupportedDestination(){ 73 for(Iterator it=deployerConfig.getSupporteddestination().getDestinationList().iterator(); 74 it.hasNext();) 75 { 76 Destination dest=(Destination)it.next(); 77 addDeployer(dest.getType(),dest.getDeployerclass()); 78 } 79 } 80 92 public DestinationDeployerBase 93 getDestinationDeployer(String destinationtype) 94 throws UnknownDestinationDeployer 95 { 96 97 if(!supportedDestination.containsKey(destinationtype)) 98 throw new UnknownDestinationDeployer(destinationtype); 99 String clazz=(String )supportedDestination.get(destinationtype); 100 try{ 101 Constructor constru=Class.forName(clazz) 102 .getConstructor(new Class [0]); 103 return (DestinationDeployerBase)constru.newInstance(new Object [0]); 104 } 105 catch(Exception e){ 106 e.printStackTrace(); 107 throw new UnknownDestinationDeployer(destinationtype); 108 } 109 } 110 111 120 public void 121 addDeployer(String prefixIdentifier, 122 String className) 123 { 124 supportedDestination.put(prefixIdentifier,className); 125 } 126 127 } 128 | Popular Tags |