public static LogEvent of(long sequenceNumber, boolean isLoggable, String name, String className, String methodName, java.util.logging.Level level, ResourceBundle bundle, String key, Throwable thrown, Object... params) { LogEvent evt = new LogEvent(sequenceNumber); evt.loggerName = name; evt.level = level; evt.args = params; evt.bundle = bundle; evt.thrown = thrown; evt.msg = key; evt.isLoggable = isLoggable; evt.className = className; evt.methodName = methodName; return evt; }
/** * Constructs a ModelMBeanAttributeInfo object with a default descriptor. * * @param name The name of the attribute * @param type The type or class name of the attribute * @param description A human readable description of the attribute. * @param isReadable True if the attribute has a getter method, false otherwise. * @param isWritable True if the attribute has a setter method, false otherwise. * @param isIs True if the attribute has an "is" getter, false otherwise. * */ public ModelMBeanAttributeInfo(String name, String type, String description, boolean isReadable, boolean isWritable, boolean isIs) { super(name, type, description, isReadable, isWritable, isIs); // create default descriptor if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, ModelMBeanAttributeInfo.class.getName(), "ModelMBeanAttributeInfo(" + "String,String,String,boolean,boolean,boolean)", "Entry", name); } attrDescriptor = validDescriptor(null); }
private LogEvent(BootstrapLogger bootstrap, Level level, ResourceBundle bundle, String msg, Throwable thrown, Object[] params) { this.acc = AccessController.getContext(); this.timeMillis = System.currentTimeMillis(); this.nanoAdjustment = VM.getNanoTimeAdjustment(timeMillis); this.level = level; this.platformLevel = null; this.bundle = bundle; this.msg = msg; this.msgSupplier = null; this.thrown = thrown; this.params = params; this.sourceClass = null; this.sourceMethod = null; this.bootstrap = bootstrap; }
/** * Constructs a new ModelMBeanOperationInfo object from this * ModelMBeanOperation Object. * * @param inInfo the ModelMBeanOperationInfo to be duplicated * */ public ModelMBeanOperationInfo(ModelMBeanOperationInfo inInfo) { super(inInfo.getName(), inInfo.getDescription(), inInfo.getSignature(), inInfo.getReturnType(), inInfo.getImpact()); if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "ModelMBeanOperationInfo(ModelMBeanOperationInfo)" + "Entry"); } Descriptor newDesc = inInfo.getDescriptor(); operationDescriptor = validDescriptor(newDesc); }
private LogEvent(BootstrapLogger bootstrap, PlatformLogger.Level platformLevel, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Throwable thrown, Object[] params) { this.acc = AccessController.getContext(); this.timeMillis = System.currentTimeMillis(); this.nanoAdjustment = VM.getNanoTimeAdjustment(timeMillis); this.level = null; this.platformLevel = platformLevel; this.bundle = bundle; this.msg = msg; this.msgSupplier = null; this.thrown = thrown; this.params = params; this.sourceClass = sourceClass; this.sourceMethod = sourceMethod; this.bootstrap = bootstrap; }
/** * If the relation is represented by an MBean (created by the user and * added as a relation in the Relation Service), returns the ObjectName of * the MBean. * * @param relationId relation id identifying the relation * * @return ObjectName of the corresponding relation MBean, or null if * the relation is not an MBean. * * @exception IllegalArgumentException if null parameter * @exception RelationNotFoundException there is no relation associated * to that id */ public ObjectName isRelationMBean(String relationId) throws IllegalArgumentException, RelationNotFoundException{ if (relationId == null) { String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationId); // Can throw RelationNotFoundException Object result = getRelation(relationId); if (result instanceof ObjectName) { return ((ObjectName)result); } else { return null; } }
/** * Constructor where all role definitions are dynamically created and * passed as parameter. * * @param relationTypeName Name of relation type * @param roleInfoArray List of role definitions (RoleInfo objects) * * @exception IllegalArgumentException if null parameter * @exception InvalidRelationTypeException if: * <P>- the same name has been used for two different roles * <P>- no role info provided * <P>- one null role info provided */ public RelationTypeSupport(String relationTypeName, RoleInfo[] roleInfoArray) throws IllegalArgumentException, InvalidRelationTypeException { if (relationTypeName == null || roleInfoArray == null) { String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); // Can throw InvalidRelationTypeException, ClassNotFoundException // and NotCompliantMBeanException initMembers(relationTypeName, roleInfoArray); RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; }
/** * Retrieves role info for given role name of a given relation type. * * @param relationTypeName name of relation type * @param roleInfoName name of role * * @return RoleInfo object. * * @exception IllegalArgumentException if null parameter * @exception RelationTypeNotFoundException if the relation type is not * known in the Relation Service * @exception RoleInfoNotFoundException if the role is not part of the * relation type. */ public RoleInfo getRoleInfo(String relationTypeName, String roleInfoName) throws IllegalArgumentException, RelationTypeNotFoundException, RoleInfoNotFoundException { if (relationTypeName == null || roleInfoName == null) { String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } RELATION_LOGGER.log(Level.TRACE, "ENTRY {0} {1}", relationTypeName, roleInfoName); // Can throw a RelationTypeNotFoundException RelationType relType = getRelationType(relationTypeName); // Can throw a RoleInfoNotFoundException RoleInfo roleInfo = relType.getRoleInfo(roleInfoName); RELATION_LOGGER.log(Level.TRACE, "RETURN"); return roleInfo; }
/** * Tests if the first specified Number is strictly greater than the last. * Both integer and floating-point types are allowed. * * @param greater The first Number to compare with the second. * @param less The second Number to compare with the first. * @param className The number class name. * @return <CODE>true</CODE> if the first specified Number is * strictly greater than the last, <CODE>false</CODE> otherwise. */ private boolean isFirstStrictlyGreaterThanLast(Number greater, Number less, String className) { if (className.equals("java.lang.Integer") || className.equals("java.lang.Byte") || className.equals("java.lang.Short") || className.equals("java.lang.Long")) { return (greater.longValue() > less.longValue()); } else if (className.equals("java.lang.Float") || className.equals("java.lang.Double")) { return (greater.doubleValue() > less.doubleValue()); } else { // Should never occur... MONITOR_LOGGER.log(Level.TRACE, "the threshold type is invalid"); return false; } }
/** * Creates a relation type (a RelationTypeSupport object) with given * role infos (provided by the RoleInfo objects), and adds it in the * Relation Service. * * @param relationTypeName name of the relation type * @param roleInfoArray array of role infos * * @exception IllegalArgumentException if null parameter * @exception InvalidRelationTypeException If: * <P>- there is already a relation type with that name * <P>- the same name has been used for two different role infos * <P>- no role info provided * <P>- one null role info provided */ public void createRelationType(String relationTypeName, RoleInfo[] roleInfoArray) throws IllegalArgumentException, InvalidRelationTypeException { if (relationTypeName == null || roleInfoArray == null) { String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", relationTypeName); // Can throw an InvalidRelationTypeException RelationType relType = new RelationTypeSupport(relationTypeName, roleInfoArray); addRelationTypeInt(relType); RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; }
@Override public void logrb(sun.util.logging.PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Throwable thrown) { log(LogEvent.of(isLoggable(level), name, sourceClass, sourceMethod, level, bundle, msg, thrown, (Object[])null)); }
/** * Enables MBeanServerNotifications concerning given ObjectName. * * @param objectName ObjectName of interest * * @exception IllegalArgumentException if the given ObjectName is null */ public synchronized void enableObjectName(ObjectName objectName) throws IllegalArgumentException { if (objectName == null) { String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", objectName); // Removes from deselected ObjectNames, if present if (deselectedNames != null) { if (deselectedNames.size() != 0) { deselectedNames.remove(objectName); } } // Adds it in selected ObjectNames if (selectedNames != null) { // If all are selected, no need to do anything :) if (!(selectedNames.contains(objectName))) { // ObjectName was not already selected selectedNames.add(objectName); } } RELATION_LOGGER.log(Level.TRACE, "RETURN"); return; }
/** * Creates and returns a new ModelMBeanOperationInfo which is a * duplicate of this ModelMBeanOperationInfo. * */ public Object clone () { if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanOperationInfo(this)) ; }
/** * Appends the specified URL to the list of URLs to search for classes and * resources. * @exception ServiceNotFoundException The specified URL is malformed. */ public void addURL(String url) throws ServiceNotFoundException { try { URL ur = new URL(url); if (!Arrays.asList(getURLs()).contains(ur)) super.addURL(ur); } catch (MalformedURLException e) { if (MLET_LOGGER.isLoggable(Level.DEBUG)) { MLET_LOGGER.log(Level.DEBUG, "Malformed URL: " + url, e); } throw new ServiceNotFoundException("The specified URL is malformed"); } }
public static void main(String[] args) { Set<Level> untested = EnumSet.allOf(Level.class); testLevel(untested, Level.ALL, java.util.logging.Level.ALL); testLevel(untested, Level.TRACE, java.util.logging.Level.FINER); testLevel(untested, Level.DEBUG, java.util.logging.Level.FINE); testLevel(untested, Level.INFO, java.util.logging.Level.INFO); testLevel(untested, Level.WARNING, java.util.logging.Level.WARNING); testLevel(untested, Level.ERROR, java.util.logging.Level.SEVERE); testLevel(untested, Level.OFF, java.util.logging.Level.OFF); if (!untested.isEmpty()) { throw new RuntimeException("Some level values were not tested: " + untested); } }
public static LogEvent of(long sequenceNumber, boolean isLoggable, String name, sun.util.logging.PlatformLogger.Level level, ResourceBundle bundle, String key, Throwable thrown, Object... params) { return LogEvent.of(sequenceNumber, isLoggable, name, null, null, level, bundle, key, thrown, params); }
@Override public void logrb(PlatformLogger.Level level, ResourceBundle bundle, String msg, Throwable thrown) { final PlatformLogger.Bridge platformProxy = platformProxy(); if (platformProxy == null) { wrapped().log(level.systemLevel(), bundle, msg, thrown); } else { platformProxy.logrb(level, bundle, msg, thrown); } }
void testGetLocalizedLogger(String desc, String name, ResourceBundle bundle, Module mod, Class<? extends Throwable> thrown) { try { LoggerFinder finder = System.LoggerFinder.getLoggerFinder(); Logger logger = finder.getLocalizedLogger(name, bundle, mod); if (thrown != null) { throw new AssertionError("Exception " + thrown.getName() + " not thrown for " + "LoggerFinder.getLocalizedLogger" + " with " + desc); } // Make sure we don't fail if tests are run in parallel synchronized(RecordStream.LOCK) { LOG_STREAM.startRecording(); byte[] logged = null; try { logger.log(Level.INFO, MESSAGE, "LoggerFinder.getLocalizedLogger", desc); } finally { logged = LOG_STREAM.stopRecording(); } check(logged, "testGetLocalizedLogger", desc, bundle, "LoggerFinder.getLocalizedLogger"); } } catch (Throwable x) { if (thrown != null && thrown.isInstance(x)) { System.out.printf("Got expected exception for %s with %s: %s\n", "LoggerFinder.getLocalizedLogger", desc, String.valueOf(x)); } else throw x; } }
@Override public void logp(sun.util.logging.PlatformLogger.Level level, String sourceClass, String sourceMethod, Supplier<String> msgSupplier) { log(LogEvent.of(isLoggable(level), name, sourceClass, sourceMethod, level, null, msgSupplier, null, (Object[])null)); }
public static LogEvent of(boolean isLoggable, String name, Level level, ResourceBundle bundle, String key, Object... params) { LogEvent evt = new LogEvent(); evt.isLoggable = isLoggable; evt.loggerName = name; evt.level = level; evt.args = params; evt.bundle = bundle; evt.thrown = null; evt.supplier = null; evt.msg = key; return evt; }
static LogEvent valueOf(BootstrapLogger bootstrap, PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object[] params) { return new LogEvent(Objects.requireNonNull(bootstrap), Objects.requireNonNull(level), sourceClass, sourceMethod, bundle, msg, null, params); }
/** * Creates and returns a new ModelMBeanNotificationInfo which is a * duplicate of this ModelMBeanNotificationInfo. **/ public Object clone () { if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanNotificationInfo(this)); }
public void removeNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener instance = getListener(listener); if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance, filter, handback); }
@Override public void log(Level level, ResourceBundle bundle, String key, Throwable thrown) { if (checkBootstrapping()) { push(LogEvent.valueOf(this, level, bundle, key, thrown)); } else { final Logger spi = holder.wrapped(); spi.log(level, bundle, key, thrown); } }
@Override public void log(Level level, ResourceBundle bundle, String format, Object... params) { if (checkBootstrapping()) { push(LogEvent.valueOf(this, level, bundle, format, params)); } else { final Logger spi = holder.wrapped(); spi.log(level, bundle, format, params); } }
@Override public void log(Level level, String msg, Throwable thrown) { if (checkBootstrapping()) { push(LogEvent.valueOf(this, level, null, msg, thrown)); } else { final Logger spi = holder.wrapped(); spi.log(level, msg, thrown); } }
@Override public void logrb(sun.util.logging.PlatformLogger.Level level, String sourceClass, String sourceMethod, ResourceBundle bundle, String msg, Object... params) { log(LogEvent.of(isLoggable(level), name, sourceClass, sourceMethod, level, bundle, msg, null, params)); }
RoleResult getAllRolesInt(boolean relationServCallFlg, RelationService relationServ) throws IllegalArgumentException, RelationServiceNotRegisteredException { if (relationServCallFlg && relationServ == null) { String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } RELATION_LOGGER.log(Level.TRACE, "ENTRY"); List<String> roleNameList; synchronized(myRoleName2ValueMap) { roleNameList = new ArrayList<String>(myRoleName2ValueMap.keySet()); } String[] roleNames = new String[roleNameList.size()]; roleNameList.toArray(roleNames); RoleResult result = getRolesInt(roleNames, relationServCallFlg, relationServ); RELATION_LOGGER.log(Level.TRACE, "RETURN"); return result; }
public ModelMBeanNotificationInfo getNotification(String inName) throws MBeanException, RuntimeOperationsException { ModelMBeanNotificationInfo retInfo = null; if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (inName == null) { throw new RuntimeOperationsException( new IllegalArgumentException("Notification name is null"), "Exception occurred trying to get the " + "ModelMBeanNotificationInfo of the MBean"); } MBeanNotificationInfo[] notifList = modelMBeanNotifications; //this.getNotifications(); int numNotifs = 0; if (notifList != null) numNotifs = notifList.length; for (int i=0; (i < numNotifs) && (retInfo == null); i++) { if (inName.equals(notifList[i].getName())) { retInfo = ((ModelMBeanNotificationInfo) notifList[i].clone()); } } if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "Exit"); } return retInfo; }
@Override public void log(PlatformLogger.Level level, String msg) { if (checkBootstrapping()) { push(LogEvent.valueOf(this, level, msg)); } else { final PlatformLogger.Bridge spi = holder.platform(); spi.log(level, msg); } }
/** * Creates and returns a new ModelMBeanConstructorInfo which is a duplicate of this ModelMBeanConstructorInfo. * */ @Override public Object clone () { if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanConstructorInfo(this)) ; }
@Override public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, Supplier<String> msgSupplier) { if (checkBootstrapping()) { push(LogEvent.valueOf(this, level, sourceClass, sourceMethod, msgSupplier, null)); } else { final PlatformLogger.Bridge spi = holder.platform(); spi.logp(level, sourceClass, sourceMethod, msgSupplier); } }
/** * Returns a copy of the associated Descriptor. * * @return Descriptor associated with the * ModelMBeanConstructorInfo object. * * @see #setDescriptor */ @Override public Descriptor getDescriptor() { if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } if (consDescriptor == null){ consDescriptor = validDescriptor(null); } return((Descriptor)consDescriptor.clone()); }
@Override public void logp(PlatformLogger.Level level, String sourceClass, String sourceMethod, String msg, Throwable thrown) { if (checkBootstrapping()) { push(LogEvent.valueOf(this, level, sourceClass, sourceMethod, null, msg, thrown)); } else { final PlatformLogger.Bridge spi = holder.platform(); spi.logp(level, sourceClass, sourceMethod, msg, thrown); } }
/** * Returns the number of MBeans currently referenced in the given role. * * @param roleName name of role * * @return the number of currently referenced MBeans in that role * * @exception IllegalArgumentException if null role name * @exception RoleNotFoundException if there is no role with given name */ public Integer getRoleCardinality(String roleName) throws IllegalArgumentException, RoleNotFoundException { if (roleName == null) { String excMsg = "Invalid parameter."; throw new IllegalArgumentException(excMsg); } RELATION_LOGGER.log(Level.TRACE, "ENTRY {0}", roleName); // Try to retrieve the role Role role; synchronized(myRoleName2ValueMap) { // No null Role is allowed, so direct use of get() role = (myRoleName2ValueMap.get(roleName)); } if (role == null) { int pbType = RoleStatus.NO_ROLE_WITH_NAME; // Will throw a RoleNotFoundException // // Will not throw InvalidRoleValueException, so catch it for the // compiler try { RelationService.throwRoleProblemException(pbType, roleName); } catch (InvalidRoleValueException exc) { // OK : Do not throw InvalidRoleValueException as // a RoleNotFoundException will be thrown. } } List<ObjectName> roleValue = role.getRoleValue(); RELATION_LOGGER.log(Level.TRACE, "RETURN"); return roleValue.size(); }
/** * Creates and returns a new ModelMBeanAttributeInfo which is a duplicate of this ModelMBeanAttributeInfo. * * @exception RuntimeOperationsException for illegal value for * field Names or field Values. If the descriptor construction * fails for any reason, this exception will be thrown. */ @Override public Object clone() { if (MODELMBEAN_LOGGER.isLoggable(Level.TRACE)) { MODELMBEAN_LOGGER.log(Level.TRACE, "Entry"); } return(new ModelMBeanAttributeInfo(this)); }
public static LogEvent of(long sequenceNumber, boolean isLoggable, String name, java.util.logging.Level level, ResourceBundle bundle, String key, Throwable thrown, Object... params) { return LogEvent.of(sequenceNumber, isLoggable, name, DefaultLoggerTest.class.getName(), "testLogger", level, bundle, key, thrown, params); }
public void removeNotificationListener(ObjectName name, ObjectName listener) throws InstanceNotFoundException, ListenerNotFoundException { NotificationListener instance = getListener(listener); if (MBEANSERVER_LOGGER.isLoggable(Level.TRACE)) { MBEANSERVER_LOGGER.log(Level.TRACE, "ObjectName = " + name + ", Listener = " + listener); } server.removeNotificationListener(name, instance); }