FileDocCategorySizeDatePackage
LoaderRepositoryUrlUtil.javaAPI DocJBoss 4.2.15548Fri Jul 13 21:02:24 BST 2007org.jboss.aop.deployment

LoaderRepositoryUrlUtil

public class LoaderRepositoryUrlUtil extends Object implements NotificationListener
author
Kabir Khan
version
$Revision: 1.1 $

Fields Summary
static final MBeanServer
SERVER
static final ObjectName
MAIN_LOADER_REPOSITORY_OBJECT_NAME
static final org.jboss.mx.loading.LoaderRepository
MAIN_LOADER_REPOSITORY
long
currentSequenceNumber
long
lastSequenceNumber
URL[]
urls
Constructors Summary
public LoaderRepositoryUrlUtil()

   
    
   
      try
      {
         SERVER.addNotificationListener(MAIN_LOADER_REPOSITORY_OBJECT_NAME, this, null, null);
      }
      catch (InstanceNotFoundException e)
      {
         throw new RuntimeException(e);
      }
   
Methods Summary
public longgetCurrentSequenceNumber()

      return currentSequenceNumber;
   
private java.net.URL[]getLocalUrls(org.jboss.mx.loading.HeirarchicalLoaderRepository3 scopedRepository, java.net.URL[] globalUrls)

      URL[] scopedRepositoryUrls = scopedRepository.getURLs();

      //This is a bit of a hack, since this relies on the order of the urls returned by HeirarchicalLoaderRepository3
      //My urls, followed by parent urls.
      int scopedLength = 0;
      for (int i = 0 ; i < scopedRepositoryUrls.length ; i++)
      {
         URL scopedUrl = scopedRepositoryUrls[i];
         for (int j = 0 ; j < globalUrls.length ; j ++)
         {
            URL globalUrl = globalUrls[j];
            if (scopedRepositoryUrls[i].equals(globalUrls[j]))
            {
               scopedLength = i;
               break;
            }
         }
         if (scopedLength > 0)
         {
            break;
         }
      }
      
      URL[] localUrls = new URL[scopedLength];
      System.arraycopy(scopedRepositoryUrls, 0, localUrls, 0, scopedLength);
      return localUrls;
   
public synchronized org.jboss.aop.deployment.LoaderRepositoryUrlUtil$UrlInfogetURLInfo(org.jboss.mx.loading.HeirarchicalLoaderRepository3 scopedLoader, org.jboss.aop.deployment.LoaderRepositoryUrlUtil$UrlInfo urlInfo)

      boolean changed = false;
      if (lastSequenceNumber != currentSequenceNumber)
      {
         urls = MAIN_LOADER_REPOSITORY.getURLs();
         lastSequenceNumber = currentSequenceNumber;
         changed = true;
      }
      if (!changed)
      {
         changed = urlInfo != null && (urlInfo.getSequenceNumber() != lastSequenceNumber);
      }
      if (urlInfo == null || changed)
      {
         URL[] localUrls = getLocalUrls(scopedLoader, urls);
         urlInfo = new UrlInfo(urls, localUrls, lastSequenceNumber);
      }
      return urlInfo;
   
public synchronized voidhandleNotification(javax.management.Notification notification, java.lang.Object handback)

      if (notification.getType().equals(LoaderRepository.CLASSLOADER_ADDED))
      {
         currentSequenceNumber = notification.getSequenceNumber();
      }
      else if (notification.getType().equals(LoaderRepository.CLASSLOADER_REMOVED))
      {
         currentSequenceNumber = notification.getSequenceNumber();
      }