1 16 package org.apache.catalina.storeconfig; 17 18 import org.apache.catalina.cluster.CatalinaCluster; 19 import org.apache.catalina.cluster.ClusterDeployer; 20 import org.apache.catalina.cluster.ClusterReceiver; 21 import org.apache.catalina.cluster.ClusterSender; 22 import org.apache.catalina.cluster.MembershipService; 23 import org.apache.catalina.deploy.ContextEjb; 24 import org.apache.catalina.deploy.ContextEnvironment; 25 import org.apache.catalina.deploy.ContextLocalEjb; 26 import org.apache.catalina.deploy.ContextResource; 27 import org.apache.catalina.deploy.ContextResourceEnvRef; 28 import org.apache.catalina.deploy.ContextResourceLink; 29 import org.apache.catalina.deploy.NamingResources; 30 import org.apache.catalina.storeconfig.IStoreFactory; 31 import org.apache.catalina.storeconfig.StoreDescription; 32 import org.apache.catalina.storeconfig.StoreRegistry; 33 import org.apache.commons.logging.Log; 34 import org.apache.commons.logging.LogFactory; 35 36 40 public class DescriptorHelper { 41 private static Log log = LogFactory.getLog(DescriptorHelper.class); 42 43 public static StoreDescription registerDescriptor( 44 StoreDescription parentdesc, StoreRegistry registry, String tag, 45 Class aClass) { 46 return registerDescriptor(parentdesc, registry, aClass.getName(), tag, 47 aClass.getName(), 48 "org.apache.catalina.storeconfig.StoreFactoryBase", false, 49 false); 50 } 51 52 public static StoreDescription registerDescriptor( 53 StoreDescription parentdesc, StoreRegistry registry, String tag, 54 String aClassToken, String factoryClass, boolean fstandard, 55 boolean fdefault) { 56 return registerDescriptor(parentdesc, registry, aClassToken, tag, 57 aClassToken, 58 "org.apache.catalina.storeconfig.StoreFactoryBase", false, 59 false); 60 } 61 62 75 public static StoreDescription registerDescriptor( 76 StoreDescription parentdesc, StoreRegistry registry, String id, 77 String tag, String aClassToken, String factoryClass, 78 boolean fstandard, boolean fdefault) { 79 StoreDescription descChild = new StoreDescription(); 81 descChild.setId(id); 82 descChild.setTag(tag); 83 descChild.setTagClass(aClassToken); 84 descChild.setStandard(fstandard); 85 descChild.setDefault(fdefault); 86 descChild.setStoreFactoryClass(factoryClass); 87 Object factory = null; 88 try { 89 Class aFactoryClass = Class.forName(factoryClass); 90 factory = aFactoryClass.newInstance(); 91 } catch (Exception e) { 92 log.error(e); 93 } 94 if (factory != null) { 95 ((IStoreFactory) factory).setRegistry(registry); 96 descChild.setStoreFactory((IStoreFactory) factory); 97 } 98 if (parentdesc != null) 99 parentdesc.setChilds(true); 100 registry.registerDescription(descChild); 101 return descChild; 102 } 103 104 112 public static StoreDescription registerNamingDescriptor( 113 StoreDescription parent, StoreRegistry registry) throws Exception { 114 115 StoreDescription nameingDesc = DescriptorHelper.registerDescriptor( 116 parent, registry, NamingResources.class.getName(), 117 "NamingResources", NamingResources.class.getName(), 118 "org.apache.catalina.storeconfig.NamingResourcesSF", true, 119 false); 120 registerDescriptor(nameingDesc, registry, ContextEjb.class.getName(), 121 "EJB", ContextEjb.class.getName(), 122 "org.apache.catalina.storeconfig.StoreFactoryBase", true, false); 123 registerDescriptor(nameingDesc, registry, ContextEnvironment.class 124 .getName(), "Environment", ContextEnvironment.class.getName(), 125 "org.apache.catalina.storeconfig.StoreFactoryBase", true, false); 126 registerDescriptor(nameingDesc, registry, ContextLocalEjb.class 127 .getName(), "LocalEjb", ContextLocalEjb.class.getName(), 128 "org.apache.catalina.storeconfig.StoreFactoryBase", true, false); 129 registerDescriptor(nameingDesc, registry, ContextResource.class 130 .getName(), "Resource", ContextResource.class.getName(), 131 "org.apache.catalina.storeconfig.StoreFactoryBase", true, false); 132 registerDescriptor(nameingDesc, registry, ContextResourceLink.class 133 .getName(), "ResourceLink", 134 ContextResourceLink.class.getName(), 135 "org.apache.catalina.storeconfig.StoreFactoryBase", true, false); 136 registerDescriptor(nameingDesc, registry, ContextResourceEnvRef.class 137 .getName(), "ResourceEnvRef", ContextResourceEnvRef.class 138 .getName(), "org.apache.catalina.storeconfig.StoreFactoryBase", 139 true, false); 140 return nameingDesc; 141 } 142 143 151 public static StoreDescription registerClusterDescriptor( 152 StoreDescription parent, StoreRegistry registry) throws Exception { 153 154 StoreDescription clusterDesc = DescriptorHelper.registerDescriptor( 155 parent, registry, CatalinaCluster.class.getName(), "Cluster", 156 CatalinaCluster.class.getName(), 157 "org.apache.catalina.storeconfig.CatalinaClusterSF", false, 158 false); 159 registerDescriptor(clusterDesc, registry, 160 ClusterSender.class.getName(), "Sender", ClusterSender.class 161 .getName(), 162 "org.apache.catalina.storeconfig.StoreFactoryBase", false, 163 false); 164 registerDescriptor(clusterDesc, registry, ClusterReceiver.class 165 .getName(), "Receiver", ClusterReceiver.class.getName(), 166 "org.apache.catalina.storeconfig.StoreFactoryBase", false, 167 false); 168 registerDescriptor(clusterDesc, registry, MembershipService.class 169 .getName(), "Membership", MembershipService.class.getName(), 170 "org.apache.catalina.storeconfig.StoreFactoryBase", false, 171 false); 172 registerDescriptor(clusterDesc, registry, ClusterDeployer.class 173 .getName(), "Deployer", ClusterDeployer.class.getName(), 174 "org.apache.catalina.storeconfig.StoreFactoryBase", false, 175 false); 176 return clusterDesc; 177 } 178 179 } | Popular Tags |