1 23 24 package org.objectweb.clif.deploy; 25 26 27 import org.objectweb.fractal.api.Component; 28 import org.objectweb.fractal.api.type.ComponentType; 29 import org.objectweb.fractal.adl.Factory; 30 import org.objectweb.fractal.adl.FactoryFactory; 31 import org.objectweb.fractal.util.Fractal; 32 33 import java.util.Map ; 34 import java.util.HashMap ; 35 36 37 42 public class ServerDeploy extends Thread 43 { 44 protected Component bootstrap; 45 protected Component clifserver = null; 46 protected boolean terminated = false; 47 static private Factory factory = null; 48 49 static 50 { 51 try 52 { 53 factory = FactoryFactory.getFactory(FactoryFactory.FRACTAL_BACKEND); 54 } 55 catch (Exception ex) 56 { 57 throw new Error ("Could not get Fractal backend FactoryFactory", ex); 58 } 59 } 60 61 65 public ServerDeploy(Component bootstrap) 66 { 67 super("CLIF server deployment on " + bootstrap); 68 this.bootstrap = bootstrap; 69 } 70 71 72 75 public synchronized void run() 76 { 77 try 78 { 79 Map hints = new HashMap (); 80 hints.put("bootstrap", bootstrap); 81 clifserver = Fractal.getGenericFactory(bootstrap).newFcInstance( 82 (ComponentType) factory.newComponentType( 83 "org.objectweb.clif.server.api.ClifServerType", 84 hints), 85 "primitive", 86 "org.objectweb.clif.server.lib.ClifServerImpl"); 87 } 88 catch (Exception ex) 89 { 90 ex.printStackTrace(System.err); 91 } 92 terminated = true; 93 notify(); 94 } 95 96 97 102 public synchronized Component get() 103 { 104 while (! terminated) 105 { 106 try 107 { 108 wait(); 109 } 110 catch (InterruptedException ex) 111 { 112 System.err.println(ex); 113 } 114 } 115 return clifserver; 116 } 117 } 118 | Popular Tags |