1 26 27 package org.objectweb.util.browser.core.naming; 28 29 30 import org.objectweb.util.browser.api.Context; 31 import org.objectweb.util.browser.api.Wrapper; 32 import org.objectweb.util.browser.core.api.Decoder; 33 import org.objectweb.util.browser.core.api.SpecificContextFactory; 34 35 41 public class DefaultContextFactory implements SpecificContextFactory { 42 43 44 protected Class class_ = null; 45 46 47 protected Decoder decoder_ = null; 48 49 53 public DefaultContextFactory(Decoder decoder) { 54 decoder_ = decoder; 55 } 56 57 63 public void setClassName(Class theClass) { 64 class_ = theClass; 65 } 66 67 72 public Context newOWContext(Object object) { 73 if (class_ != null) { 74 try { 75 Wrapper wrapper = (Wrapper) class_.newInstance(); 76 wrapper.setWrapped(object); 77 if (decoder_ != null) { 78 ContextDecoderManager interceptor = new ContextDecoderManager(); 79 interceptor.setDecoder(decoder_); 80 interceptor.setDelegate((Context) wrapper); 81 return interceptor; 82 } else { 83 return (Context) wrapper; 84 } 85 } catch (InstantiationException e) { 86 e.printStackTrace(); 87 } catch (IllegalAccessException e) { 88 e.printStackTrace(); 89 } 90 } 91 return null; 92 } 93 94 } 95 | Popular Tags |