Package javax.management

Examples of javax.management.MBeanServer


    *
    * @throws Exception
    */
   protected void destroyService() throws Exception
   {
      MBeanServer server = getServer();

      unregisterWithCurrentDeployers(server);

      cleanupLeftoverMBeans(server);

View Full Code Here


      if( config != null )
      {
         log.debug("Using embedded config");
         Set names = config.getConfigNames();
         Iterator iter = names.iterator();
         MBeanServer server = super.getServer();
         while( iter.hasNext() )
         {
            String name = (String) iter.next();
            ApplicationPolicy aPolicy = config.get(name);
            if(aPolicy == null)
               throw new IllegalStateException("Application Policy is null for "+name);
           
            AuthenticationInfo info = (AuthenticationInfo)aPolicy.getAuthenticationInfo();
            if(info == null)
              throw new IllegalStateException("Authentication Info is null for " + name);
            AppConfigurationEntry[] entry = info.getAppConfigurationEntry();
            // addAppConfig(String, AppConfigurationEntry[]);
            //Object[] args = {name, entry};
            //String[] sig = {String.class.getName(), entry.getClass().getName()};
            Object[] args = {name, aPolicy};
            String[] sig = {String.class.getName(), aPolicy.getClass().getName()};
            //server.invoke(loginConfigService, "addAppConfig", args, sig);
            server.invoke(loginConfigService, "addApplicationPolicy", args, sig);
         }
         configNames = new String[names.size()];
         names.toArray(configNames);
      }
      else
      {
         //JBAS-3422: Ensure that the AuthConf is neither null nor default login-config.xml
         if( authConf== null || authConf.length() == 0)
            throw new IllegalStateException("AuthConf is null. Please " +
                  "configure an appropriate config resource");
         
         // Look for the authConf as resource
         ClassLoader loader = Thread.currentThread().getContextClassLoader();
         URL loginConfig = loader.getResource(authConf);
         if(loginConfig == null)
         {
           try
           {
             //JBAS-3210: Allow an absolute url
             loginConfig = new URL(authConf);
           }
           catch(Exception e)
           {
             loginConfig = null;
           }
         }
         if( loginConfig != null )
         {
            validateAuthConfigURL(loginConfig);
            log.debug("Using JAAS AuthConfig: "+loginConfig.toExternalForm());
            MBeanServer server = super.getServer();
            Object[] args = {loginConfig};
            String[] sig = {URL.class.getName()};
            configNames = (String[]) server.invoke(loginConfigService,
               "loadConfig", args, sig);
            int count = configNames == null ? 0 : configNames.length;
            for(int n = 0; n < count; n ++)
            {
               log.debug("Loaded config: "+configNames[n]);
View Full Code Here

   /** Start the service. This entails unloading the AuthConf file contents
    * using the LoginConfigService.
    */
   protected void stopService() throws Exception
   {
      MBeanServer server = super.getServer();
      flushAuthenticationCaches();
      if( configNames != null && configNames.length > 0 )
      {
         Object[] args = {configNames};
         String[] sig = {configNames.getClass().getName()};
         server.invoke(loginConfigService, "removeConfigs", args, sig);
      }
   }
View Full Code Here

   public void start() throws LifecycleException
   {
      try
      {
         MBeanServer server = MBeanServerLocator.locateJBoss();
         ccm = (CachedConnectionManager) server.getAttribute(new ObjectName(ccmName), "Instance");
         tm = (TransactionManager) server.getAttribute(new ObjectName(tmName), "TransactionManager");
      }
      catch (Exception e)
      {
         throw new LifecycleException(e);
      }
View Full Code Here

         ClassLoader refCl = reference.getClassLoader();
         Object outcome = true;
         if (testCl.equals(refCl) == false)
            outcome = "Expected " + refCl + " got " + testCl;
        
         MBeanServer server = MBeanServerLocator.locateJBoss();
         ObjectName testFromDD = new ObjectName("jboss.test:service=LegacyWebClassLoader");
         System.out.println(getClass().getName() + " " + test + " ==> " + outcome);
         server.setAttribute(testFromDD, new Attribute(test, outcome));
      }
      catch (Exception e)
      {
         throw new RuntimeException(e);
      }
View Full Code Here

   {
      JBossWebMetaData metaData = warInfo.getMetaData();
      String ctxPath = metaData.getContextRoot();

      // TODO: Need to remove the dependency on MBeanServer
      MBeanServer server = MBeanServerLocator.locateJBoss();
      // If the server is gone, all apps were stopped already
      if (server == null)
         return;

      ObjectName objectName = new ObjectName(config.getCatalinaDomain() + ":j2eeType=WebModule,name=//" + ((hostName == null) ? "localhost" : hostName) + ctxPath
            + ",J2EEApplication=none,J2EEServer=none");

      if (server.isRegistered(objectName))
      {
         try
         {
            // JBAS-8406: Temp hack, will move to NamingListener
            CurrentComponent.push(component);
            // Contexts should be stopped by the host already
            server.invoke(objectName, "destroy", new Object[] {}, new String[] {});
         }
         finally
         {
            CurrentComponent.pop();
         }
View Full Code Here

      lc.logout();
   }
   public void testLdapExample11Encrypt() throws Exception
   {
      System.out.println("testLdapExample11Encrypt");
      MBeanServer server = MBeanServerFactory.createMBeanServer("jboss");
      JaasSecurityDomain secDomain = new JaasSecurityDomain("testLdapExample11Encrypt");
      secDomain.setSalt("abcdefgh");
      secDomain.setIterationCount(13);
      secDomain.setKeyStorePass("master");
      secDomain.setManagerServiceName(null);
      secDomain.start();
      ObjectName name = new ObjectName("jboss.test:service=JaasSecurityDomain,domain=testLdapExample11Encrypt");
      server.registerMBean(secDomain, name);

      // secret1 encrypts to 7hInTB4HCBL
      UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke", "theduke".toCharArray());
      LoginContext lc = new LoginContext("testLdapExample11Encrypt", handler);
      lc.login();
View Full Code Here

      lc.logout();
   }
   public void testLdapExample21Encrypt() throws Exception
   {
      System.out.println("testLdapExample21Encrypt");
      MBeanServer server = MBeanServerFactory.createMBeanServer("jboss");
      JaasSecurityDomain secDomain = new JaasSecurityDomain("testLdapExample21Encrypt");
      secDomain.setSalt("abcdefgh");
      secDomain.setIterationCount(13);
      secDomain.setKeyStorePass("master");
      secDomain.setManagerServiceName(null);
      secDomain.start();
      ObjectName name = new ObjectName("jboss.test:service=JaasSecurityDomain,domain=testLdapExample21Encrypt");
      server.registerMBean(secDomain, name);

      UsernamePasswordHandler handler = new UsernamePasswordHandler("jduke",
         "theduke".toCharArray());
      LoginContext lc = new LoginContext("testLdapExample21Encrypt", handler);
      lc.login();
View Full Code Here

   protected void registerManagerMBean()
   {
      String objname = null;
      try
      {
         MBeanServer server = getMBeanServer();

         String domain;
         if (container_ instanceof ContainerBase)
         {
            domain = ((ContainerBase) container_).getDomain();
         }
         else
         {
            domain = server.getDefaultDomain();
         }
         String hostName = ((Host) container_.getParent()).getName();
         hostName = (hostName == null) ? "localhost" : hostName;
         String path = ((Context) container_).getPath();
         path = "".equals(path) ? "/" : path;
         objname = domain + ":type=Manager,host=" + hostName + ",path=" + path;
         ObjectName clusterName = new ObjectName(objname);

         if (server.isRegistered(clusterName))
         {
            log_.warn("MBean " + clusterName + " already registered");
            return;
         }
        
         try
         {
            Registry.getRegistry(null, null).registerComponent(this, clusterName, null );
         }
         catch (Exception e)
         {
            log_.debug("Unable to register " + getName() + " with JBoss Web " +
                  Registry.class.getSimpleName() + " -- perhaps this class is " +
                      "not listed in an mbean-descriptors.xml? Falling back " +
                      "on direct registration with the MBeanServer");
            server.registerMBean(this, clusterName);
         }
         objectName_ = clusterName;
      }
      catch (Exception ex)
      {
View Full Code Here

    * @param principal
    * @throws JMException
    */
   private void flushAuthenticationCache(Principal principal) throws JMException
   {
      MBeanServer server = MBeanServerLocator.locateJBoss();
      ObjectName on = new ObjectName("jboss.security:service=JaasSecurityManager");
      Object[] obj = new Object[] {securityDomain, principal};
      String[] sig = new String[]{"java.lang.String", "java.security.Principal"};
      if(trace)
         logAuthenticatedPrincipals(on, true);
     
      //Flush the Authentication Cache
      server.invoke(on,"flushAuthenticationCache", obj, sig);
      if(trace)
         logAuthenticatedPrincipals(on, false)
   }
View Full Code Here

TOP

Related Classes of javax.management.MBeanServer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.