Kirk Rader  1.0-SNAPSHOT
Classes | Static Public Member Functions | Static Package Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
us.rader.logging.AnnotationsAgent Class Reference

Instrumentation agent used to scan loaded classes. More...

Classes

class  LoadJarsAction
 Privileged action used by AnnotationsAgent#loadJars. More...
 

Static Public Member Functions

static void agentmain (final String agentArgs, final Instrumentation instrumentation)
 Agent-Class entry point. More...
 
static Class<?> [] getAllLoadedClasses ()
 
static Class<?> [] loadJars (final String... paths)
 Return the set of classes loaded from the specified JAR files. More...
 
static void premain (final String agentArgs, final Instrumentation instrumentation)
 Premain-Class entry point. More...
 

Static Package Functions

 [static initializer]
 

Private Member Functions

 AnnotationsAgent ()
 Hidden constructor for utility class. More...
 

Static Private Member Functions

static void initialize (final Instrumentation instrumentation)
 

Static Private Attributes

static volatile Instrumentation instrumentation
 Populated by initialize. More...
 
static Object instrumentationMonitor
 Make accesses to instrumentation thread safe. More...
 
static Logger logger
 Debug logging / tracing. More...
 

Detailed Description

Instrumentation agent used to scan loaded classes.

Definition at line 38 of file AnnotationsAgent.java.

Constructor & Destructor Documentation

◆ AnnotationsAgent()

us.rader.logging.AnnotationsAgent.AnnotationsAgent ( )
private

Hidden constructor for utility class.

Definition at line 205 of file AnnotationsAgent.java.

205  {
206 
207  throw new IllegalStateException("do not instantiate utility classes");
208 
209  }

Member Function Documentation

◆ [static initializer]()

us.rader.logging.AnnotationsAgent.[static initializer] ( )
staticpackage

◆ agentmain()

static void us.rader.logging.AnnotationsAgent.agentmain ( final String  agentArgs,
final Instrumentation  instrumentation 
)
static

Agent-Class entry point.

Parameters
agentArgsNot used.
instrumentationHandle on java.lang.instrument API

Definition at line 220 of file AnnotationsAgent.java.

References us.rader.logging.AnnotationsAgent.initialize().

220  {
221 
222  logger.fine(String.format("agentmain: %s, %s", agentArgs, instrumentation.toString()));
224 
225  }
static Logger logger
Debug logging / tracing.
static void initialize(final Instrumentation instrumentation)
static volatile Instrumentation instrumentation
Populated by initialize.

◆ getAllLoadedClasses()

static Class<?> [] us.rader.logging.AnnotationsAgent.getAllLoadedClasses ( )
static
Returns
All currently loaded classes.

Definition at line 230 of file AnnotationsAgent.java.

230  {
231 
232  if (instrumentation == null) {
233 
234  throw new IllegalStateException("instrumentation not initialized");
235 
236  }
237 
238  return instrumentation.getAllLoadedClasses();
239 
240  }
static volatile Instrumentation instrumentation
Populated by initialize.

◆ initialize()

static void us.rader.logging.AnnotationsAgent.initialize ( final Instrumentation  instrumentation)
staticprivate
Parameters
instrumentationValue for instrumentation

Definition at line 276 of file AnnotationsAgent.java.

References us.rader.logging.AnnotationsAgent.instrumentation, and us.rader.logging.AnnotationsAgent.instrumentationMonitor.

Referenced by us.rader.logging.AnnotationsAgent.agentmain(), and us.rader.logging.AnnotationsAgent.premain().

276  {
277 
278  if (AnnotationsAgent.instrumentation == null) {
279 
280  synchronized (instrumentationMonitor) {
281 
282  if (AnnotationsAgent.instrumentation == null) {
283 
284  logger.logp(Level.FINE, AnnotationsAgent.class.getName(), "initialize(Instrumentation)",
285  String.format("initializing instrumentation to %s", instrumentation));
286  AnnotationsAgent.instrumentation = instrumentation;
287 
288  }
289  }
290  }
291  }
static Logger logger
Debug logging / tracing.
AnnotationsAgent()
Hidden constructor for utility class.
static Object instrumentationMonitor
Make accesses to instrumentation thread safe.
static volatile Instrumentation instrumentation
Populated by initialize.

◆ loadJars()

static Class<?> [] us.rader.logging.AnnotationsAgent.loadJars ( final String...  paths)
static

Return the set of classes loaded from the specified JAR files.

Parameters
pathsThe path names of the JAR files to load
Returns
All classes loaded from the given JAR files.

Definition at line 250 of file AnnotationsAgent.java.

References us.rader.logging.AnnotationsAgent.LoadJarsAction.LoadJarsAction(), and us.rader.logging.AnnotationsAgent.LoadJarsAction.paths.

250  {
251 
252  return AccessController.doPrivileged(new LoadJarsAction(paths));
253 
254  }

◆ premain()

static void us.rader.logging.AnnotationsAgent.premain ( final String  agentArgs,
final Instrumentation  instrumentation 
)
static

Premain-Class entry point.

Parameters
agentArgsNot used.
instrumentationHandle on java.lang.instrument API

Definition at line 265 of file AnnotationsAgent.java.

References us.rader.logging.AnnotationsAgent.initialize().

265  {
266 
267  logger.fine(String.format("premain: %s, %s", agentArgs, instrumentation.toString()));
269 
270  }
static Logger logger
Debug logging / tracing.
static void initialize(final Instrumentation instrumentation)
static volatile Instrumentation instrumentation
Populated by initialize.

Member Data Documentation

◆ instrumentation

volatile Instrumentation us.rader.logging.AnnotationsAgent.instrumentation
staticprivate

Populated by initialize.

Definition at line 183 of file AnnotationsAgent.java.

Referenced by us.rader.logging.AnnotationsAgent.initialize().

◆ instrumentationMonitor

Object us.rader.logging.AnnotationsAgent.instrumentationMonitor
staticprivate

Make accesses to instrumentation thread safe.

Definition at line 188 of file AnnotationsAgent.java.

Referenced by us.rader.logging.AnnotationsAgent.initialize().

◆ logger

Logger us.rader.logging.AnnotationsAgent.logger
staticprivate

The documentation for this class was generated from the following file: