]>
git.argeo.org Git - gpl/argeo-slc.git/blob - cms/org.argeo.slc.repo/src/org/eclipse/aether/RequestTrace.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 Sonatype, Inc.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
9 * Sonatype, Inc. - initial API and implementation
10 *******************************************************************************/
11 package org
.eclipse
.aether
;
14 * A trace of nested requests that are performed by the repository system. This trace information can be used to
15 * correlate repository events with higher level operations in the application code that eventually caused the events. A
16 * single trace can carry an arbitrary object as data which is meant to describe a request/operation that is currently
17 * executed. For call hierarchies within the repository system itself, this data will usually be the {@code *Request}
18 * object that is currently processed. When invoking methods on the repository system, client code may provide a request
19 * trace that has been prepopulated with whatever data is useful for the application to indicate its state for later
20 * evaluation when processing the repository events.
22 * @see RepositoryEvent#getTrace()
24 public class RequestTrace
27 private final RequestTrace parent
;
29 private final Object data
;
32 * Creates a child of the specified request trace. This method is basically a convenience that will invoke
33 * {@link RequestTrace#newChild(Object) parent.newChild()} when the specified parent trace is not {@code null} or
34 * otherwise instantiante a new root trace.
36 * @param parent The parent request trace, may be {@code null}.
37 * @param data The data to associate with the child trace, may be {@code null}.
38 * @return The child trace, never {@code null}.
40 public static RequestTrace
newChild( RequestTrace parent
, Object data
)
44 return new RequestTrace( data
);
46 return parent
.newChild( data
);
50 * Creates a new root trace with the specified data.
52 * @param data The data to associate with the trace, may be {@code null}.
54 public RequestTrace( Object data
)
60 * Creates a new trace with the specified data and parent
62 * @param parent The parent trace, may be {@code null} for a root trace.
63 * @param data The data to associate with the trace, may be {@code null}.
65 protected RequestTrace( RequestTrace parent
, Object data
)
72 * Gets the data associated with this trace.
74 * @return The data associated with this trace or {@code null} if none.
76 public final Object
getData()
82 * Gets the parent of this trace.
84 * @return The parent of this trace or {@code null} if this is the root of the trace stack.
86 public final RequestTrace
getParent()
92 * Creates a new child of this trace.
94 * @param data The data to associate with the child, may be {@code null}.
95 * @return The child trace, never {@code null}.
97 public RequestTrace
newChild( Object data
)
99 return new RequestTrace( this, data
);
103 public String
toString()
105 return String
.valueOf( getData() );