You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2006/06/20 23:31:44 UTC
svn commit: r415811 [2/2] - in
/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler: ./ modules/
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/Registry.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/Registry.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/Registry.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/Registry.java Tue Jun 20 14:31:42 2006
@@ -23,7 +23,6 @@
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
@@ -38,7 +37,6 @@
import javax.management.MBeanServerFactory;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import javax.management.modelmbean.ModelMBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -73,10 +71,6 @@
* @author Costin Manolache
*/
public class Registry implements RegistryMBean, MBeanRegistration {
- /** Experimental support for manifest-based discovery.
- */
- public static String MODELER_MANIFEST="/META-INF/mbeans-descriptors.xml";
-
/**
* The Log instance to which we will write our log messages.
*/
@@ -84,7 +78,7 @@
// Support for the factory methods
- /** Will be used to isolate different apps and enhance security
+ /** Will be used to isolate different apps and enhance security.
*/
private static HashMap perLoaderRegistries=null;
@@ -106,19 +100,19 @@
* The set of ManagedBean instances for the beans this registry
* knows about, keyed by name.
*/
- private HashMap<String, ManagedBean> descriptors = new HashMap<String, ManagedBean>();
+ private HashMap descriptors = new HashMap();
/** List of managed byeans, keyed by class name
*/
- private HashMap<String, ManagedBean> descriptorsByClass = new HashMap<String, ManagedBean>();
+ private HashMap descriptorsByClass = new HashMap();
// map to avoid duplicated searching or loading descriptors
- private Hashtable<String, URL> searchedPaths=new Hashtable<String, URL>();
+ private HashMap searchedPaths=new HashMap();
- private Object key;
private Object guard;
// Id - small ints to use array access. No reset on stop()
+ // Used for notifications
private Hashtable idDomains=new Hashtable();
private Hashtable ids=new Hashtable();
@@ -160,7 +154,7 @@
localRegistry=(Registry)perLoaderRegistries.get(key);
if( localRegistry == null ) {
localRegistry=new Registry();
- localRegistry.key=key;
+// localRegistry.key=key;
localRegistry.guard=guard;
perLoaderRegistries.put( key, localRegistry );
return localRegistry;
@@ -184,7 +178,8 @@
return (registry);
}
- /** Allow containers to isolate apps. Can be called only once.
+ /**
+ * Allow containers to isolate apps. Can be called only once.
* It is highly recommended you call this method if using Registry in
* a container environment. The default is false for backward compatibility
*
@@ -199,28 +194,15 @@
// -------------------- Generic methods --------------------
- /** Set a guard object that will prevent access to this registry
- * by unauthorized components
- *
- * @param guard
- *
- * @since 1.1
- */
- public void setGuard( Object guard ) {
- if( this.guard!=null ) {
- return; // already set, only once
- }
- this.guard=guard;
- }
-
/** Lifecycle method - clean up the registry metadata.
+ * Called from resetMetadata().
*
* @since 1.1
*/
public void stop() {
- descriptorsByClass = new HashMap<String, ManagedBean>();
- descriptors = new HashMap<String, ManagedBean>();
- searchedPaths=new Hashtable<String, URL>();
+ descriptorsByClass = new HashMap();
+ descriptors = new HashMap();
+ searchedPaths=new HashMap();
}
/**
@@ -249,9 +231,6 @@
* descriptors file. In the case of File and URL, if the extension is ".ser"
* a serialized version will be loaded.
*
- * Also ( experimental for now ) a ClassLoader - in which case META-INF/ will
- * be used.
- *
* This method should be used to explicitely load metadata - but this is not
* required in most cases. The registerComponent() method will find metadata
* in the same pacakge.
@@ -259,13 +238,7 @@
* @param source
*/
public void loadMetadata(Object source ) throws Exception {
- if( source instanceof ClassLoader ) {
- loadMetaInfDescriptors((ClassLoader)source);
- return;
- } else {
- loadDescriptors( null, source, null );
- }
-
+ loadDescriptors( null, source, null );
}
/** Register a bean by creating a modeler mbean and adding it to the
@@ -411,11 +384,9 @@
*/
public void addManagedBean(ManagedBean bean) {
// XXX Use group + name
- synchronized(descriptors) {
- descriptors.put(bean.getName(), bean);
- if( bean.getType() != null ) {
- descriptorsByClass.put( bean.getType(), bean );
- }
+ descriptors.put(bean.getName(), bean);
+ if( bean.getType() != null ) {
+ descriptorsByClass.put( bean.getType(), bean );
}
}
@@ -430,12 +401,10 @@
*/
public ManagedBean findManagedBean(String name) {
// XXX Group ?? Use Group + Type
- synchronized(descriptors) {
- ManagedBean mb= descriptors.get(name);
- if( mb==null )
- mb=descriptorsByClass.get(name);
- return mb;
- }
+ ManagedBean mb=((ManagedBean) descriptors.get(name));
+ if( mb==null )
+ mb=(ManagedBean)descriptorsByClass.get(name);
+ return mb;
}
/**
@@ -445,9 +414,7 @@
* @since 1.0
*/
public String[] findManagedBeans() {
- synchronized(descriptors) {
- return ((String[]) descriptors.keySet().toArray(new String[0]));
- }
+ return ((String[]) descriptors.keySet().toArray(new String[0]));
}
@@ -462,15 +429,13 @@
public String[] findManagedBeans(String group) {
ArrayList results = new ArrayList();
- synchronized(descriptors) {
- Iterator<ManagedBean> items = descriptors.values().iterator();
- while (items.hasNext()) {
- ManagedBean item = items.next();
- if ((group == null) && (item.getGroup() == null)) {
- results.add(item.getName());
- } else if (group.equals(item.getGroup())) {
- results.add(item.getName());
- }
+ Iterator items = descriptors.values().iterator();
+ while (items.hasNext()) {
+ ManagedBean item = (ManagedBean) items.next();
+ if ((group == null) && (item.getGroup() == null)) {
+ results.add(item.getName());
+ } else if (group.equals(item.getGroup())) {
+ results.add(item.getName());
}
}
String values[] = new String[results.size()];
@@ -487,10 +452,8 @@
*/
public void removeManagedBean(ManagedBean bean) {
// TODO: change this to use group/name
- synchronized(descriptors) {
- descriptors.remove(bean.getName());
- descriptorsByClass.remove( bean.getType());
- }
+ descriptors.remove(bean.getName());
+ descriptorsByClass.remove( bean.getType());
}
// -------------------- Deprecated 1.0 methods --------------------
@@ -829,7 +792,7 @@
ManagedBean managed = findManagedBean(bean.getClass(), type);
// The real mbean is created and registered
- ModelMBean mbean = managed.createMBean(bean);
+ DynamicMBean mbean = managed.createMBean(bean);
if( getMBeanServer().isRegistered( oname )) {
if( log.isDebugEnabled()) {
@@ -850,7 +813,7 @@
*
* @param packageName
*/
- public synchronized void loadDescriptors( String packageName, ClassLoader classLoader ) {
+ public void loadDescriptors( String packageName, ClassLoader classLoader ) {
String res=packageName.replace( '.', '/');
if( log.isTraceEnabled() ) {
@@ -910,25 +873,6 @@
}
}
- /** Discover all META-INF/modeler.xml files in classpath and register
- * the components
- *
- * @since EXPERIMENTAL
- */
- private void loadMetaInfDescriptors(ClassLoader cl) {
- try {
- Enumeration en=cl.getResources(MODELER_MANIFEST);
- while( en.hasMoreElements() ) {
- URL url=(URL)en.nextElement();
- InputStream is=url.openStream();
- if( log.isDebugEnabled()) log.debug("Loading " + url);
- loadDescriptors("MbeansDescriptorsDigesterSource", is, null );
- }
- } catch( Exception ex ) {
- ex.printStackTrace();
- }
- }
-
/** Lookup the component descriptor in the package and
* in the parent packages.
*
@@ -1072,12 +1016,6 @@
}
}
- public List loadMBeans( Object source )
- throws Exception
- {
- return loadMBeans( source, null );
- }
-
/**
* Load the registry from a cached .ser file. This is typically 2-3 times
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDOMSource.java Tue Jun 20 14:31:42 2006
@@ -25,8 +25,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.tomcat.util.DomUtil;
import org.apache.tomcat.util.modeler.AttributeInfo;
-import org.apache.tomcat.util.modeler.ConstructorInfo;
-import org.apache.tomcat.util.modeler.FieldInfo;
import org.apache.tomcat.util.modeler.ManagedBean;
import org.apache.tomcat.util.modeler.NotificationInfo;
import org.apache.tomcat.util.modeler.OperationInfo;
@@ -116,7 +114,7 @@
Node firstN;
// Process descriptor subnode
- Node mbeanDescriptorN =
+ /*Node mbeanDescriptorN =
DomUtil.getChild(mbeanN, "descriptor");
if (mbeanDescriptorN != null) {
Node firstFieldN =
@@ -127,7 +125,7 @@
DomUtil.setAttributes(fi, fieldN);
managed.addField(fi);
}
- }
+ }*/
// process attribute nodes
firstN=DomUtil.getChild( mbeanN, "attribute");
@@ -140,7 +138,7 @@
DomUtil.setAttributes(ai, descN);
// Process descriptor subnode
- Node descriptorN =
+ /*Node descriptorN =
DomUtil.getChild(descN, "descriptor");
if (descriptorN != null) {
Node firstFieldN =
@@ -152,6 +150,7 @@
ai.addField(fi);
}
}
+ */
// Add this info to our managed bean info
managed.addAttribute( ai );
@@ -162,6 +161,7 @@
}
// process constructor nodes
+ /*
firstN=DomUtil.getChild( mbeanN, "constructor");
for (Node descN = firstN; descN != null;
descN = DomUtil.getNext( descN )) {
@@ -200,7 +200,7 @@
log.trace("Create constructor " + ci);
}
- }
+ }*/
// process notification nodes
firstN=DomUtil.getChild( mbeanN, "notification");
@@ -213,7 +213,7 @@
DomUtil.setAttributes(ni, descN);
// Process descriptor subnode
- Node firstDescriptorN =
+ /*Node firstDescriptorN =
DomUtil.getChild(descN, "descriptor");
if (firstDescriptorN != null) {
Node firstFieldN =
@@ -224,7 +224,7 @@
DomUtil.setAttributes(fi, fieldN);
ni.addField(fi);
}
- }
+ }*/
// Process notification-type subnodes
Node firstParamN=DomUtil.getChild( descN, "notification-type");
@@ -254,7 +254,7 @@
DomUtil.setAttributes(oi, descN);
// Process descriptor subnode
- Node firstDescriptorN =
+ /*Node firstDescriptorN =
DomUtil.getChild(descN, "descriptor");
if (firstDescriptorN != null) {
Node firstFieldN =
@@ -265,7 +265,7 @@
DomUtil.setAttributes(fi, fieldN);
oi.addField(fi);
}
- }
+ }*/
// Process parameter subnodes
Node firstParamN=DomUtil.getChild( descN, "parameter");
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsDigesterSource.java Tue Jun 20 14:31:42 2006
@@ -70,7 +70,7 @@
"addAttribute",
"org.apache.tomcat.util.modeler.AttributeInfo");
- digester.addObjectCreate
+ /*digester.addObjectCreate
("mbeans-descriptors/mbean/attribute/descriptor/field",
"org.apache.tomcat.util.modeler.FieldInfo");
digester.addSetProperties
@@ -119,7 +119,7 @@
("mbeans-descriptors/mbean/descriptor/field",
"addField",
"org.apache.tomcat.util.modeler.FieldInfo");
-
+ */
digester.addObjectCreate
("mbeans-descriptors/mbean/notification",
"org.apache.tomcat.util.modeler.NotificationInfo");
Modified: tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java
URL: http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java?rev=415811&r1=415810&r2=415811&view=diff
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java (original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/tomcat/util/modeler/modules/MbeansDescriptorsIntrospectionSource.java Tue Jun 20 14:31:42 2006
@@ -16,20 +16,8 @@
package org.apache.tomcat.util.modeler.modules;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.tomcat.util.modeler.AttributeInfo;
-import org.apache.tomcat.util.modeler.ConstructorInfo;
-import org.apache.tomcat.util.modeler.ManagedBean;
-import org.apache.tomcat.util.modeler.OperationInfo;
-import org.apache.tomcat.util.modeler.ParameterInfo;
-import org.apache.tomcat.util.modeler.Registry;
-
-import javax.management.ObjectName;
-
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
-import java.lang.reflect.Constructor;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -37,6 +25,16 @@
import java.util.Hashtable;
import java.util.List;
+import javax.management.ObjectName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.tomcat.util.modeler.AttributeInfo;
+import org.apache.tomcat.util.modeler.ManagedBean;
+import org.apache.tomcat.util.modeler.OperationInfo;
+import org.apache.tomcat.util.modeler.ParameterInfo;
+import org.apache.tomcat.util.modeler.Registry;
+
public class MbeansDescriptorsIntrospectionSource extends ModelerSource
{
private static Log log = LogFactory.getLog(MbeansDescriptorsIntrospectionSource.class);
@@ -363,7 +361,7 @@
}
}
- Constructor[] constructors = realClass.getConstructors();
+ /*Constructor[] constructors = realClass.getConstructors();
for(int i=0;i<constructors.length;i++) {
ConstructorInfo info = new ConstructorInfo();
String className = realClass.getName();
@@ -383,6 +381,7 @@
}
mbean.addConstructor(info);
}
+ */
if( log.isDebugEnabled())
log.debug("Setting name: " + type );
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org