Package mx4j.log

Examples of mx4j.log.Logger


      // check type name
      String relationTypeName = relationType.getRelationTypeName();
      if (relationTypeName == null) throw new IllegalArgumentException("RelationTypeName must not be null");

      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Adding a RelationType");

      List roleInfoList = relationType.getRoleInfos();
      if (roleInfoList == null)
      {
         logger.warn("Cannot add RelationType: " + relationType.getClass().getName() + " RoleInfo information was not provided with the RelationType.");
         throw new InvalidRelationTypeException("No RoleInfo provided with Relation Type");
      }
      // build the roleInfo[] to validate the RoleInfo
      RoleInfo[] roleInfos = new RoleInfo[roleInfoList.size()];
      int index = 0;
View Full Code Here


    *                                       referenced, queried via the relation service though.</p>
    */
   public void removeRelationType(String relationTypeName) throws IllegalArgumentException,
                                                                  RelationServiceNotRegisteredException, RelationTypeNotFoundException
   {
      Logger logger = getLogger();
      isActive();
      if (relationTypeName == null) throw new IllegalArgumentException("Illegal: relationType name cannot be null.");
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Removing RelationType with relationTypeName: " + relationTypeName);

      // will throw RelationTypeNotFoundException if not found
      getRelationType(relationTypeName);

      // no need to clone as relationIdList is internal and get its values from a private method.
View Full Code Here

                                                                                                    InvalidRelationIdException, RelationTypeNotFoundException, InvalidRoleValueException
   {
      isActive();
      if (relationId == null) throw new IllegalArgumentException("Null Relation Id");
      if (relationTypeName == null) throw new IllegalArgumentException("Null Relation Type Name");
      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.DEBUG))
      {
         logger.debug("Creating an InternalRelation with ID: " + relationId + " and relationType name: " + relationTypeName);
      }
      // creating InternalRelation to represent the internal relations
      InternalRelation internalRelation = new InternalRelation(relationId, m_relationServiceObjectName,
                                                               relationTypeName, roleList);
      try
      {
         if (getRelationObject(relationId) != null)
         {
            logger.warn("There is a Relation already registered in the RelationServcie with ID: " + relationId);
            throw new InvalidRelationIdException("There is already a relation with id: " + relationId);
         }
      }
      catch (RelationNotFoundException ex)
      {/*Do nothing as should not be found*/
      }

      RelationType relationType = getRelationType(relationTypeName);
      ArrayList roleInfoList = (ArrayList)(buildRoleInfoList(relationType, roleList));
      if (!(roleInfoList.isEmpty()))
      {
         initializeMissingCreateRoles(roleInfoList, internalRelation, relationId, relationTypeName);
      }

      synchronized (m_relationIdToRelationObject)
      {
         m_relationIdToRelationObject.put(relationId, internalRelation);
      }
      addRelationId(relationId, relationTypeName);
      addRelationTypeName(relationId, relationTypeName);
      updateRoles(roleList, relationId);
      try
      {
         if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("sending RelationCreation notification to all listeners");
         sendRelationCreationNotification(relationId);
      }
      catch (RelationNotFoundException ex)
      {
         throw new RuntimeOperationsException(null, "Unable to send notification as Relation not found");
View Full Code Here

   private Integer checkRoleCardinality(String roleName, List roleValue, RoleInfo roleInfo)
   {
      if (roleName == null) throw new IllegalArgumentException("Null Role Name");
      if (roleValue == null) throw new IllegalArgumentException("Null roleValue List");
      if (roleInfo == null) throw new IllegalArgumentException("Null RoleInfo");
      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("checking role cardinality");

      if (!(roleName.equals(roleInfo.getName())))
      {
         logger.warn("Role does not have a valid roleName");
         return new Integer(RoleStatus.NO_ROLE_WITH_NAME);
      }
      if (!(roleInfo.checkMinDegree(roleValue.size())))
      {
         logger.warn("Minimum number of references defined in the RoleInfo has fallen below minimum");
         return (new Integer(RoleStatus.LESS_THAN_MIN_ROLE_DEGREE));
      }
      if (!(roleInfo.checkMaxDegree(roleValue.size())))
      {
         logger.warn("Maximum number of references defined in the RoleInfo has gone above the maximum");
         return new Integer(RoleStatus.MORE_THAN_MAX_ROLE_DEGREE);
      }

      String referencedClassName = roleInfo.getRefMBeanClassName();
      for (Iterator i = roleValue.iterator(); i.hasNext();)
      {
         ObjectName currentObjectName = (ObjectName)i.next();
         if (currentObjectName == null)
         {
            logger.warn("The mbean with RoleName: " + roleName + " is not registered in the MBeanServer");
            return new Integer(RoleStatus.REF_MBEAN_NOT_REGISTERED);
         }
         if (!(m_server.isRegistered(currentObjectName)))
         {
            logger.warn("The mbean with ObjectName: " + currentObjectName.getCanonicalName() + " is not registered in the MBeanServer");
            return new Integer(RoleStatus.REF_MBEAN_NOT_REGISTERED);
         }
         try
         {
            if (!(m_server.isInstanceOf(currentObjectName, referencedClassName)))
            {
               logger.warn("The class referenced: " + currentObjectName.toString() + " does not match the class expected: " +
                           referencedClassName + " in RoleInfo: " + roleInfo.toString());
               return new Integer(RoleStatus.REF_MBEAN_OF_INCORRECT_CLASS);
            }
         }
         catch (InstanceNotFoundException ex)
View Full Code Here

                                                                      NoSuchMethodException, InvalidRelationIdException, InstanceNotFoundException,
                                                                      InvalidRelationServiceException, RelationTypeNotFoundException,
                                                                      RoleNotFoundException, InvalidRoleValueException
   {
      isActive();
      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("adding a Relation with ObjectName: " + relationMBeanObjectName.toString());
      // checks through the MBeanServer that the class is an instance of the Relation interface which
      // RelationSupport implements
      checkValidRelation(relationMBeanObjectName);
      //create the proxy
View Full Code Here

   }

   private void checkValidRelation(ObjectName relationMBeanObjectName) throws IllegalArgumentException, InstanceNotFoundException, NoSuchMethodException
   {
      if (relationMBeanObjectName == null) throw new IllegalArgumentException("Cannot have a null Relation ObjectName");
      Logger logger = getLogger();
      if (!(m_server.isInstanceOf(relationMBeanObjectName, "javax.management.relation.Relation")))
      {
         logger.warn("An MBean which is to be added as a Relation must implement the Relation interface");
         throw new NoSuchMethodException("MBean does implement the Relation interface");
      }
   }
View Full Code Here

   public Integer checkRoleReading(String roleName, String relationTypeName) throws IllegalArgumentException,
                                                                                    RelationTypeNotFoundException
   {
      if (roleName == null) throw new IllegalArgumentException("Null RoleName");
      if (relationTypeName == null) throw new IllegalArgumentException("Null RelationType name.");
      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("checking if Role with RoleName: " + roleName + " is readable");
      RelationType relationType = getRelationType(relationTypeName);
      try
      {
         RoleInfo roleInfo = relationType.getRoleInfo(roleName);
         if (!(roleName.equals(roleInfo.getName()))) return (new Integer(RoleStatus.NO_ROLE_WITH_NAME));
         if (!(roleInfo.isReadable()))
         {
            logger.warn("RoleInfo: " + roleInfo.toString() + " cannot be read");
            return (new Integer(RoleStatus.ROLE_NOT_READABLE));
         }
      }
      catch (RoleInfoNotFoundException ex)
      {
         logger.warn("roleInfo for roleName: " + roleName + " has not been found.");
         return (new Integer(RoleStatus.NO_ROLE_WITH_NAME));
      }
      return new Integer(0);
   }
View Full Code Here

                                                                                              IllegalArgumentException, RelationTypeNotFoundException
   {
      if (role == null) throw new IllegalArgumentException("checkRoleWriting was given a null Role");
      if (relationTypeName == null) throw new IllegalArgumentException("checkRoleWriting was given a null RelationTypeName");
      if (isInitialized == null) throw new IllegalArgumentException("checkRoleWriting was given a null Boolean");
      Logger logger = getLogger();
      RelationType relationType = getRelationType(relationTypeName);
      String roleName = role.getRoleName();
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("checking if Role with RoleName: " + roleName + " is readable");
      ArrayList roleValue = (ArrayList)role.getRoleValue();
      boolean canWrite = true;
      if (isInitialized.booleanValue()) canWrite = false;
      RoleInfo roleInfo;
      try
      {
         roleInfo = relationType.getRoleInfo(roleName);
      }
      catch (RoleInfoNotFoundException ex)
      {
         logger.warn("roleInfo for roleName: " + roleName + " has not been found.");
         return new Integer(RoleStatus.NO_ROLE_WITH_NAME);
      }
      if (canWrite)
      {
         if (!(roleInfo.isWritable()))
         {
            logger.warn("RoleInfo: " + roleInfo.toString() + " cannot be written to.");
            return new Integer(RoleStatus.ROLE_NOT_WRITABLE);
         }
      }
      return (checkRoleCardinality(roleName, roleValue, roleInfo));
   }
View Full Code Here

    */
   public void sendRelationCreationNotification(String relationId) throws IllegalArgumentException,
                                                                          RelationNotFoundException
   {
      if (relationId == null) throw new IllegalArgumentException("Null Relation Id.");
      Logger logger = getLogger();
      String message = "Creation of relation " + relationId;
      String relationTypeName = getRelationTypeNameFromMap(relationId);

      if (logger.isEnabledFor(Logger.DEBUG))
         logger.debug("A relation has been created with ID: " + relationId +
                      " and relationTypeName: " + relationTypeName + " ..sending notification");

      ObjectName relationObjectName = isRelationMBean(relationId);
      String notificationType = getCreationNotificationType(relationObjectName);
      long sequenceNumber = getNotificationSequenceNumber().longValue();
View Full Code Here

   {
      if (relationId == null) throw new IllegalArgumentException("Null RelationId");
      if (newRole == null) throw new IllegalArgumentException("Null Role");
      if (oldRoleValues == null) throw new IllegalArgumentException("Null List of role values");

      Logger logger = getLogger();
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Sending a roleUpdateNotification of Relation with ID: " + relationId);
      String roleName = newRole.getRoleName();
      List newRoleValues = newRole.getRoleValue();
      String newRoleValueMessage = Role.roleValueToString(newRoleValues);
      String oldRoleValueMessage = Role.roleValueToString(oldRoleValues);
      StringBuffer message = new StringBuffer("Value of the role ");
      message.append(roleName);
      message.append(" has changed\nOld value:\n");
      message.append(oldRoleValueMessage);
      message.append("\nNew value:\n");
      message.append(newRoleValueMessage);
      if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Notification message: " + message.toString());
      String relationTypeName = getRelationTypeNameFromMap(relationId);

      // determine if this is a relation update or a relation mbean update
      ObjectName relationObjectName = isRelationMBean(relationId);
      String notificationType;
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.