1 30 31 package org.objectweb.fractal.rmi.io; 32 33 import org.objectweb.fractal.api.control.BindingController; 34 35 import org.objectweb.jonathan.apis.binding.NamingContext; 36 import org.objectweb.jonathan.apis.kernel.ContextFactory; 37 import org.objectweb.jonathan.apis.presentation.Marshaller; 38 import org.objectweb.jonathan.apis.presentation.MarshallerFactory; 39 import org.objectweb.jonathan.apis.presentation.UnMarshaller; 40 import org.objectweb.jonathan.apis.resources.Chunk; 41 import org.objectweb.jonathan.apis.resources.ChunkFactory; 42 import org.objectweb.jonathan.apis.resources.ChunkProvider; 43 44 47 48 public class RmiMarshallerFactory 49 implements MarshallerFactory, BindingController 50 { 51 52 55 56 protected NamingContext domain; 57 58 62 63 protected ChunkFactory chunkFactory; 64 65 69 70 protected ContextFactory contextFactory; 71 72 75 76 public RmiMarshallerFactory () { 77 } 78 79 83 public String [] listFc () { 84 return new String [] { 85 "domain", 86 "chunk-factory", 87 "context-factory" 88 }; 89 } 90 91 public Object lookupFc (final String clientItfName) { 92 if (clientItfName.equals("domain")) { 93 return domain; 94 } else if (clientItfName.equals("chunk-factory")) { 95 return chunkFactory; 96 } else if (clientItfName.equals("context-factory")) { 97 return contextFactory; 98 } 99 return null; 100 } 101 102 public void bindFc (final String clientItfName, final Object serverItf) { 103 if (clientItfName.equals("domain")) { 104 domain = (NamingContext)serverItf; 105 } else if (clientItfName.equals("chunk-factory")) { 106 chunkFactory = (ChunkFactory)serverItf; 107 } else if (clientItfName.equals("context-factory")) { 108 contextFactory = (ContextFactory)serverItf; 109 } 110 } 111 112 public void unbindFc (final String clientItfName) { 113 if (clientItfName.equals("domain")) { 114 domain = null; 115 } else if (clientItfName.equals("chunk-factory")) { 116 chunkFactory = null; 117 } else if (clientItfName.equals("context-factory")) { 118 contextFactory = null; 119 } 120 } 121 122 126 131 132 public Marshaller newMarshaller() { 133 return new RmiMarshaller(domain, chunkFactory, contextFactory); 134 } 135 136 143 144 public UnMarshaller newUnMarshaller (final ChunkProvider message) { 145 return new RmiUnMarshaller(domain, contextFactory, message); 146 } 147 148 157 158 public UnMarshaller newUnMarshaller (final Chunk chunk, final int read) { 159 return new RmiUnMarshaller(domain, contextFactory, chunk, read); 160 } 161 } 162 163 | Popular Tags |