1 9 package org.jboss.portal.core.plugins.preferences; 10 11 import java.lang.reflect.Proxy ; 12 13 import org.apache.log4j.Logger; 14 import org.jboss.portal.common.metadata.MetaData; 15 import org.jboss.portal.common.util.ProxyInfo; 16 import org.jboss.portal.core.metadata.ProxyPreferenceSetMetaData; 17 import org.jboss.portal.core.util.ProxyValidator; 18 import org.jboss.portal.server.Application; 19 import org.jboss.portal.server.Component; 20 import org.jboss.portal.server.plugins.PluginService; 21 22 26 public class ProxyPreferenceSetPlugin 27 extends PluginService 28 { 29 30 31 protected Logger log = Logger.getLogger(getClass()); 32 33 34 protected ProxyPreferenceSetMetaData metaData; 35 36 37 protected ProxyInfo proxy; 38 39 public ProxyPreferenceSetPlugin() 40 { 41 } 42 43 public void start() throws Exception 44 { 45 String proxyClassName = this.metaData.getProxyClassName(); 46 47 try 48 { 49 Component component = (Component)container; 50 Application application = component.getApplication(); 51 ClassLoader loader = application.getClassLoader(); 52 Class proxyITF = loader.loadClass(proxyClassName); 53 log.debug("Preferences proxy class loaded " + proxyClassName); 54 55 ProxyValidator.Error[] errors = ProxyValidator.validate(proxyITF); 57 if (errors.length == 0) 58 { 59 Class proxyClass = Proxy.getProxyClass(loader, new Class []{proxyITF}); 61 proxy = new ProxyInfo(proxyClass); 62 log.debug("Preferences proxy class created " + proxyClassName); 63 } 64 else 65 { 66 log.error("Invalid preference proxy class, it will not be created"); 68 for (int i = 0;i < errors.length;i++) 69 { 70 ProxyValidator.Error error = errors[i]; 71 log.error("Invalid preference proxy class" + error.getDescription()); 72 } 73 } 74 } 75 catch (Exception e) 76 { 77 log.error("Cannot load preference proxy class " + proxyClassName); 78 } 79 } 80 81 public void setMetaData(MetaData metaData) 82 { 83 this.metaData = (ProxyPreferenceSetMetaData)metaData; 85 } 86 87 public MetaData getMetaData() 88 { 89 return metaData; 90 } 91 92 public ProxyInfo getProxy() 93 { 94 return proxy; 95 } 96 } 97 | Popular Tags |