Information

25
Story Points

Technologies

Decompiled Java File
package com.acme.anvil.listener;

import com.acme.anvil.management.AnvilInvokeBeanImpl;
import java.util.Hashtable;
import java.util.Iterator;
import javax.management.MBeanServer;
import javax.management.ObjectName;
import javax.naming.Context;
import javax.naming.NamingException;
import weblogic.common.T3ServicesDef;
import weblogic.common.T3StartupDef;
import weblogic.i18n.logging.NonCatalogLogger;
import weblogic.jndi.Environment;

public class AnvilWebStartupListener implements T3StartupDef {
   private static final String MBEAN_NAME = "com.acme:Name=anvil,Type=com.acme.anvil.management.AnvilInvokeBeanT3StartupDef";
   private NonCatalogLogger log = new NonCatalogLogger("AnvilWebStartupListener");
   private T3ServicesDef services;

   public void setServices(T3ServicesDef services) {
      this.services = services;
   }

   public String startup(String name, Hashtable ht) {
      this.log.info("Starting Server Startup Class: " + name + " with properties: ");
      Iterator i$ = ht.keySet().iterator();

      while(i$.hasNext()) {
         Object key = i$.next();
         this.log.info("Key[" + key + "] = Value[" + ht.get(key) + "]");
      }

      return "Completed Startup Class: " + name;
   }

   private MBeanServer getMBeanServer() throws NamingException {
      Environment env = new Environment();
      env.setProviderUrl("t3://weblogicServer:7001");
      env.setSecurityPrincipal("fred");
      env.setSecurityCredentials("seafood");
      Context context = env.getContext();
      MBeanServer server = (MBeanServer)context.lookup("java:comp/jmx/runtime");
      return server;
   }

   private void registerMBean() {
      this.log.info("Registering MBeans.");

      try {
         MBeanServer server = this.getMBeanServer();
         server.registerMBean(new AnvilInvokeBeanImpl(), new ObjectName("com.acme:Name=anvil,Type=com.acme.anvil.management.AnvilInvokeBeanT3StartupDef"));
         this.log.info("Registered MBean[com.acme:Name=anvil,Type=com.acme.anvil.management.AnvilInvokeBeanT3StartupDef]");
      } catch (Exception var3) {
         this.log.error("Exception while registering MBean[com.acme:Name=anvil,Type=com.acme.anvil.management.AnvilInvokeBeanT3StartupDef]");
      }

   }
}