Package mx4j.log

Examples of mx4j.log.Logger


      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("MLet service " + objectName + " preDeregistered successfully");
   }

   public void postDeregister()
   {
      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("MLet service " + objectName + " postDeregistered successfully");
   }
View Full Code Here


      addURL(createURL(url));
   }

   public void addURL(URL url)
   {
      Logger logger = getLogger();
      if (!Arrays.asList(getURLs()).contains(url))
      {
         if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Adding URL to this MLet (" + objectName + ") classpath: " + url);
         super.addURL(url);
      }
      else
      {
         if (logger.isEnabledFor(Logger.TRACE)) logger.trace("URL already present in this MLet (" + objectName + ") classpath: " + url);
      }
   }
View Full Code Here

      return repository.loadClassBefore(this, name);
   }

   protected Class findClass(String name) throws ClassNotFoundException
   {
      Logger logger = getLogger();
      boolean trace = logger.isEnabledFor(Logger.TRACE);

      // It may be possible that loading started with this MLet, then delegated to the CLR
      // and came again to query this MLet which, if not stopped, will delegate to the CLR
      // again in an endless loop. This is possible if this MLet is the parent of a child
      // MLet registered before its parent.
      if (loadingWithRepository.get() == Boolean.TRUE)
      {
         if (trace) logger.trace("MLet " + this + " is recursively calling itself to load class " + name + ": skipping further searches");
         throw new ClassNotFoundException(name);
      }

      if (trace) logger.trace("Finding class " + name + "...");

      try
      {
         Class cls = findClassLocally(name);
         if (trace) logger.trace("Class " + name + " found in this MLet's classpath " + this);
         return cls;
      }
      catch (ClassNotFoundException x)
      {
         if (!isDelegateToCLR())
         {
            if (trace) logger.trace("MLet " + this + " does not delegate to the ClassLoaderRepository");
            throw x;
         }

         if (loadingOnlyLocally.get() == Boolean.TRUE) throw x;

         if (server == null) throw x;

         if (trace) logger.trace("Class " + name + " not found in this MLet's classpath " + this + ", trying the ClassLoaderRepository...", x);
         try
         {
            loadingWithRepository.set(Boolean.TRUE);
            ClassLoaderRepository repository = server.getClassLoaderRepository();
            Class cls = loadClassFromRepository(name, repository);
            if (trace) logger.trace("Class " + name + " found with ClassLoaderRepository " + repository);
            return cls;
         }
         catch (ClassNotFoundException xx)
         {
            if (trace) logger.trace("Class " + name + " not found in ClassLoaderRepository, giving up", xx);
            throw new ClassNotFoundException(name);
         }
         finally
         {
            loadingWithRepository.set(Boolean.FALSE);
View Full Code Here

   public Set getMBeansFromURL(URL url) throws ServiceNotFoundException
   {
      if (url == null) throw new ServiceNotFoundException("Cannot load MBeans from null URL");

      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("MLet " + this + ", reading MLET file from " + url);

      InputStream is = null;
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      BufferedOutputStream os = new BufferedOutputStream(baos);
      try
      {
         is = url.openStream();
         readFromAndWriteTo(is, os);
      }
      catch (IOException x)
      {
         if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Cannot read input stream from URL " + url, x);
         throw new ServiceNotFoundException(x.toString());
      }
      finally
      {
         try
         {
            if (is != null) is.close();
            os.close();
         }
         catch (IOException ignored)
         {
         }
      }

      String mletFileContent = null;
      try
      {
         mletFileContent = new String(baos.toByteArray(), "UTF-8");
      }
      catch (UnsupportedEncodingException x)
      {
         mletFileContent = baos.toString();
      }
      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("MLet File content is:\n" + mletFileContent);

      return parseMLetFile(mletFileContent, url);
   }
View Full Code Here

      return parseMLetFile(mletFileContent, url);
   }

   private Set parseMLetFile(String content, URL mletFileURL) throws ServiceNotFoundException
   {
      Logger logger = getLogger();

      try
      {
         HashSet mbeans = new HashSet();
         MLetParser parser = new MLetParser(this);
         List tags = parser.parse(content);

         for (int i = 0; i < tags.size(); ++i)
         {
            MLetTag tag = (MLetTag)tags.get(i);

            // Add the MBean's codebase to the MLet classloader
            String[] jars = tag.parseArchive();
            for (int j = 0; j < jars.length; ++j)
            {
               String jar = jars[j];
               URL codebase = handleCheck(tag, jar, mletFileURL, mbeans);
               URL archiveURL = tag.createArchiveURL(codebase, jar);
               addURL(archiveURL);
            }

            // Create and register the MBean
            Object obj = createMBean(tag);
            mbeans.add(obj);
         }

         return mbeans;
      }
      catch (MLetParseException x)
      {
         if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Cannot parse MLet file", x);
         throw new ServiceNotFoundException(x.toString());
      }
   }
View Full Code Here

   private Object createMBean(MLetTag tag) throws ServiceNotFoundException
   {
      if (server == null) throw new ServiceNotFoundException("MLet not registered on the MBeanServer");

      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("MLet " + this + ", creating MBean from\n" + tag);

      try
      {
         Object mbean = null;
         if (tag.getObject() != null)
View Full Code Here

      return copyLibrary(osPath);
   }

   private String copyLibrary(String library)
   {
      Logger logger = getLogger();

      library = library.replace('\\', '/');
      if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Loading library " + library);

      URL libraryURL = getResource(library);

      InputStream is = null;
      OutputStream os = null;
      try
      {
         try
         {
            is = getResourceAsStream(library);
            if (is == null) return null;

            if (!(is instanceof BufferedInputStream)) is = new BufferedInputStream(is);
            File localLibrary = new File(getLibraryDirectory(), library);
            URL localLibraryURL = localLibrary.toURL();

            // The library is local and its directory is in the classpath of this MLet
            if (localLibraryURL.equals(libraryURL)) return localLibrary.getCanonicalPath();

            // Copy the library (that can be remote) locally, overwriting old versions
            try
            {
               os = new BufferedOutputStream(new FileOutputStream(localLibrary));
               readFromAndWriteTo(is, os);
               return localLibrary.getCanonicalPath();
            }
            finally
            {
               if (os != null) os.close();
            }
         }
         finally
         {
            if (is != null) is.close();
         }
      }
      catch (IOException x)
      {
         if (logger.isEnabledFor(Logger.TRACE)) logger.trace("Cannot copy the library to the library directory " + getLibraryDirectory(), x);
         return null;
      }
   }
View Full Code Here

    *          - thrown if the RelationService is not registered in the MBeanServer
    *          <p>Currently this class must be registered in the MBeanServer before any relations can be created or added</p>
    */
   public void isActive() throws RelationServiceNotRegisteredException
   {
      Logger logger = getLogger();
      if (m_server == null)
      {
         logger.error("RelationService has not been registered in the MBeanServer");
         throw new RelationServiceNotRegisteredException("Relation Service is not registered");
      }
   }
View Full Code Here

                                                                                        InvalidRelationTypeException
   {
      if (relationTypeName == null) throw new IllegalArgumentException("Illegal Null Relation Type Name value");
      if (roleInfos == null) throw new IllegalArgumentException("Illegal Null RoleInfo");

      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Creating Relation Type with relationTypeName: " + relationTypeName);

      RelationTypeSupport relationType = new RelationTypeSupport(relationTypeName, roleInfos);
      // created a new RelationType add it to our map
      addRelationTypeToMap(relationTypeName, relationType);
   }
View Full Code Here

   }

   /* Adds a relationTypeName as the key to a Map and the RelationType as the value */
   private void addRelationTypeToMap(String relationTypeName, RelationType relationType) throws InvalidRelationTypeException
   {
      Logger logger = getLogger();
      // synchronize all activities to map.
      synchronized (m_relationTypeNameToRelationTypeObject)
      {
         if ((m_relationTypeNameToRelationTypeObject.get(relationTypeName)) != null)
         {
            logger.warn("Cannot addRelationType as a relationType of the same name: " + relationTypeName + " already exists in the RelationService");
            throw new InvalidRelationTypeException("RelationType with name: " + relationTypeName + " already exists in the RelationService");
         }
         // set the RelationTypeSupport internal flag to true indicating that the relationType has been declared in the relation service
         if (relationType instanceof RelationTypeSupport)
         {
View Full Code Here

TOP

Related Classes of mx4j.log.Logger

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.