Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 
 package org.apache.tomcat.util.modeler.modules;
 
 import java.util.List;
 
 
 
 public class MbeansDescriptorsDOMSource extends ModelerSource
 {
 
     Registry registry;
     String location;
     String type;
     Object source;
     List mbeans=new ArrayList();
 
     public void setRegistry(Registry reg) {
         this.=reg;
     }
 
     public void setLocationString loc ) {
         this.=loc;
     }

    
Used if a single component is loaded

Parameters:
type
 
     public void setTypeString type ) {
        this.=type;
     }
 
     public void setSourceObject source ) {
         this.=source;
     }
 
     public List loadDescriptorsRegistry registryString location,
                                  String typeObject source)
             throws Exception
     {
         setRegistry(registry);
         setLocation(location);
         setType(type);
         setSource(source);
         execute();
         return ;
     }
 
     public void execute() throws Exception {
         if==null ) =Registry.getRegistry();
 
         try {
             InputStream stream=(InputStream);
             long t1=System.currentTimeMillis();
             Document doc=DomUtil.readXml(stream);
             // Ignore for now the name of the root element
             Node descriptorsN=doc.getDocumentElement();
             //Node descriptorsN=DomUtil.getChild(doc, "mbeans-descriptors");
             ifdescriptorsN == null ) {
                 ..noDescriptorsFound();
                 return;
             }
 
             Node firstMbeanN=null;
             if"mbean".equalsdescriptorsN.getNodeName() ) ) {
                 firstMbeanN=descriptorsN;
             } else {
                 firstMbeanN=DomUtil.getChild(descriptorsN"mbean");
             }
 
            iffirstMbeanN==null ) {
                ..noMbeansFound();
                return;
            }
            // Process each <mbean> element
            for (Node mbeanN = firstMbeanNmbeanN != null;
                 mbeanN= DomUtil.getNext(mbeanN))
            {
                // Create a new managed bean info
                ManagedBean managed=new ManagedBean();
                DomUtil.setAttributes(managedmbeanN);
                Node firstN;
                // Process descriptor subnode
                /*Node mbeanDescriptorN =
                    DomUtil.getChild(mbeanN, "descriptor");
                if (mbeanDescriptorN != null) {
                    Node firstFieldN =
                        DomUtil.getChild(mbeanDescriptorN, "field");
                    for (Node fieldN = firstFieldN; fieldN != null;
                         fieldN = DomUtil.getNext(fieldN)) {
                        FieldInfo fi = new FieldInfo();
                        DomUtil.setAttributes(fi, fieldN);
                        managed.addField(fi);
                    }
                }*/
                // process attribute nodes
                firstN=DomUtil.getChildmbeanN"attribute");
                for (Node descN = firstNdescN != null;
                     descN = DomUtil.getNextdescN ))
                {
                    // Create new attribute info
                    AttributeInfo ai=new AttributeInfo();
                    DomUtil.setAttributes(aidescN);
                    // Process descriptor subnode
                    /*Node descriptorN =
                        DomUtil.getChild(descN, "descriptor");
                    if (descriptorN != null) {
                        Node firstFieldN =
                            DomUtil.getChild(descriptorN, "field");
                        for (Node fieldN = firstFieldN; fieldN != null;
                             fieldN = DomUtil.getNext(fieldN)) {
                            FieldInfo fi = new FieldInfo();
                            DomUtil.setAttributes(fi, fieldN);
                            ai.addField(fi);
                        }
                    }
                    */
                    // Add this info to our managed bean info
                    managed.addAttributeai );
                    if (..isTraceEnabled()) {
                        ..trace("Create attribute " + ai);
                    }
                }
                // process constructor nodes
                /*
                firstN=DomUtil.getChild( mbeanN, "constructor");
                for (Node descN = firstN; descN != null;
                     descN = DomUtil.getNext( descN )) {
                    // Create new constructor info
                    ConstructorInfo ci=new ConstructorInfo();
                    DomUtil.setAttributes(ci, descN);
                    // Process descriptor subnode
                    Node firstDescriptorN =
                        DomUtil.getChild(descN, "descriptor");
                    if (firstDescriptorN != null) {
                        Node firstFieldN =
                            DomUtil.getChild(firstDescriptorN, "field");
                        for (Node fieldN = firstFieldN; fieldN != null;
                             fieldN = DomUtil.getNext(fieldN)) {
                            FieldInfo fi = new FieldInfo();
                            DomUtil.setAttributes(fi, fieldN);
                            ci.addField(fi);
                        }
                    }
                    // Process parameter subnodes
                    Node firstParamN=DomUtil.getChild( descN, "parameter");
                    for (Node paramN = firstParamN;  paramN != null;
                         paramN = DomUtil.getNext(paramN))
                    {
                        ParameterInfo pi=new ParameterInfo();
                        DomUtil.setAttributes(pi, paramN);
                        ci.addParameter( pi );
                    }
                    // Add this info to our managed bean info
                    managed.addConstructor( ci );
                    if (log.isTraceEnabled()) {
                        log.trace("Create constructor " + ci);
                    }
                }*/
                // process notification nodes
                firstN=DomUtil.getChildmbeanN"notification");
                for (Node descN = firstNdescN != null;
                     descN = DomUtil.getNextdescN ))
                {
                    // Create new notification info
                    NotificationInfo ni=new NotificationInfo();
                    DomUtil.setAttributes(nidescN);
                    // Process descriptor subnode
                    /*Node firstDescriptorN =
                        DomUtil.getChild(descN, "descriptor");
                    if (firstDescriptorN != null) {
                        Node firstFieldN =
                            DomUtil.getChild(firstDescriptorN, "field");
                        for (Node fieldN = firstFieldN; fieldN != null;
                             fieldN = DomUtil.getNext(fieldN)) {
                            FieldInfo fi = new FieldInfo();
                            DomUtil.setAttributes(fi, fieldN);
                            ni.addField(fi);
                        }
                    }*/
                    // Process notification-type subnodes
                    Node firstParamN=DomUtil.getChilddescN"notification-type");
                    for (Node paramN = firstParamN;  paramN != null;
                         paramN = DomUtil.getNext(paramN))
                    {
                        ni.addNotifType( DomUtil.getContent(paramN) );
                    }
                    // Add this info to our managed bean info
                    managed.addNotificationni );
                    if (..isTraceEnabled()) {
                        ..trace("Created notification " + ni);
                    }
                }
                // process operation nodes
                firstN=DomUtil.getChildmbeanN"operation");
                for (Node descN = firstNdescN != null;
                     descN = DomUtil.getNextdescN ))
                {
                    // Create new operation info
                    OperationInfo oi=new OperationInfo();
                    DomUtil.setAttributes(oidescN);
                    // Process descriptor subnode
                    /*Node firstDescriptorN =
                        DomUtil.getChild(descN, "descriptor");
                    if (firstDescriptorN != null) {
                        Node firstFieldN =
                            DomUtil.getChild(firstDescriptorN, "field");
                        for (Node fieldN = firstFieldN; fieldN != null;
                             fieldN = DomUtil.getNext(fieldN)) {
                            FieldInfo fi = new FieldInfo();
                            DomUtil.setAttributes(fi, fieldN);
                            oi.addField(fi);
                        }
                    }*/
                    // Process parameter subnodes
                    Node firstParamN=DomUtil.getChilddescN"parameter");
                    for (Node paramN = firstParamN;  paramN != null;
                         paramN = DomUtil.getNext(paramN))
                    {
                        ParameterInfo pi=new ParameterInfo();
                        DomUtil.setAttributes(piparamN);
                        if..isTraceEnabled())
                            ..trace("Add param " + pi.getName());
                        oi.addParameterpi );
                    }
                    // Add this info to our managed bean info
                    managed.addOperationoi );
                    if..isTraceEnabled()) {
                        ..trace("Create operation " + oi);
                    }
                }
                // Add the completed managed bean info to the registry
                //registry.addManagedBean(managed);
                .addmanaged );
            }
            long t2=System.currentTimeMillis();
            ..debug"Reading descriptors ( dom ) " + (t2-t1));
        } catchException ex ) {
        }
    }
New to GrepCode? Check out our FAQ X