1 24 25 package org.objectweb.dream.adl.legacy; 26 27 import java.util.List ; 28 import java.util.Map ; 29 30 import org.objectweb.deployment.scheduling.component.lib.AbstractInstanceProviderTask; 31 import org.objectweb.fractal.adl.ADLException; 32 import org.objectweb.fractal.adl.Node; 33 import org.objectweb.fractal.adl.TaskMap; 34 import org.objectweb.fractal.adl.components.ComponentContainer; 35 import org.objectweb.fractal.adl.components.PrimitiveCompiler; 36 import org.objectweb.fractal.api.control.BindingController; 37 38 43 public class LegacyImplementationCompiler 44 implements 45 BindingController, 46 PrimitiveCompiler 47 { 48 49 53 public static final String BUILDER_BINDING = "builder"; 54 55 protected LegacyComponentBuilder builder; 56 57 60 public void compile(List path, ComponentContainer container, TaskMap tasks, 61 Map context) throws ADLException 62 { 63 Object legacyInstance = ((Node) container).astGetDecoration("legacy"); 64 if (legacyInstance != null) 65 { 66 tasks.addTask("create", container, new LegacyInstanceProviderTask( 67 legacyInstance, builder)); 68 } 69 } 70 71 75 78 public String [] listFc() 79 { 80 return new String []{BUILDER_BINDING}; 81 } 82 83 86 public Object lookupFc(final String itf) 87 { 88 if (itf.equals(BUILDER_BINDING)) 89 { 90 return builder; 91 } 92 return null; 93 } 94 95 98 public void bindFc(final String itf, final Object value) 99 { 100 if (itf.equals(BUILDER_BINDING)) 101 { 102 builder = (LegacyComponentBuilder) value; 103 } 104 } 105 106 109 public void unbindFc(final String itf) 110 { 111 if (itf.equals(BUILDER_BINDING)) 112 { 113 builder = null; 114 } 115 } 116 117 static class LegacyInstanceProviderTask extends AbstractInstanceProviderTask 118 { 119 120 private LegacyComponentBuilder builder; 121 122 128 public LegacyInstanceProviderTask(Object legacyComponent, 129 LegacyComponentBuilder builder) 130 { 131 setInstance(legacyComponent); 132 this.builder = builder; 133 } 134 135 138 public void execute(Object ctx) throws Exception 139 { 140 builder.stopComponent(getInstance(), ctx); 142 } 143 } 144 } | Popular Tags |