forked from pinpoint-apm/pinpoint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pinpoint-apm#115 from emeroad/scope_api_refactoring
scope api refactoring
- Loading branch information
Showing
19 changed files
with
187 additions
and
51 deletions.
There are no files selected for viewing
11 changes: 11 additions & 0 deletions
11
bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/instrument/Attachment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.navercorp.pinpoint.bootstrap.instrument; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public interface Attachment { | ||
|
||
Object getAttachment(); | ||
|
||
void setAttachment(Object object); | ||
} |
7 changes: 7 additions & 0 deletions
7
bootstrap/src/main/java/com/navercorp/pinpoint/bootstrap/instrument/AttachmentScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.navercorp.pinpoint.bootstrap.instrument; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public interface AttachmentScope extends Scope, Attachment { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ | |
* @author emeroad | ||
*/ | ||
public interface Scope { | ||
|
||
int ZERO = 0; | ||
|
||
int push(); | ||
|
||
int depth(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
commons/src/main/java/com/navercorp/pinpoint/common/util/Clock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.navercorp.pinpoint.common.util; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public interface Clock { | ||
long getTime(); | ||
} |
18 changes: 18 additions & 0 deletions
18
commons/src/main/java/com/navercorp/pinpoint/common/util/MockClock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.navercorp.pinpoint.common.util; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public class MockClock implements Clock { | ||
|
||
private long time; | ||
|
||
public void setTime(long time) { | ||
this.time = time; | ||
} | ||
|
||
@Override | ||
public long getTime() { | ||
return time; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
commons/src/main/java/com/navercorp/pinpoint/common/util/SystemClock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.navercorp.pinpoint.common.util; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public final class SystemClock implements Clock { | ||
|
||
public static final Clock INSTANCE = new SystemClock(); | ||
|
||
private SystemClock() { | ||
} | ||
|
||
@Override | ||
public final long getTime() { | ||
return System.currentTimeMillis(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
profiler/src/main/java/com/navercorp/pinpoint/profiler/util/ScopeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.navercorp.pinpoint.profiler.util; | ||
|
||
import com.navercorp.pinpoint.bootstrap.instrument.Scope; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public interface ScopeFactory { | ||
|
||
Scope createScope(); | ||
|
||
String getName(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
profiler/src/main/java/com/navercorp/pinpoint/profiler/util/SimpleScope.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.navercorp.pinpoint.profiler.util; | ||
|
||
import com.navercorp.pinpoint.bootstrap.instrument.Scope; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public class SimpleScope implements Scope { | ||
|
||
private final String name; | ||
|
||
private int depth = 0; | ||
|
||
public SimpleScope(String name) { | ||
this.name = name; | ||
} | ||
|
||
public int push() { | ||
return depth++; | ||
} | ||
|
||
public int pop() { | ||
return --depth; | ||
} | ||
|
||
public int depth() { | ||
return depth; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "Depth"; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder sb = new StringBuilder("SimpleScope{"); | ||
sb.append("name=").append(name); | ||
sb.append('}'); | ||
return sb.toString(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
profiler/src/main/java/com/navercorp/pinpoint/profiler/util/SimpleScopeFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.navercorp.pinpoint.profiler.util; | ||
|
||
import com.navercorp.pinpoint.bootstrap.instrument.Scope; | ||
|
||
/** | ||
* @author emeroad | ||
*/ | ||
public class SimpleScopeFactory implements ScopeFactory { | ||
|
||
private final String name; | ||
|
||
public SimpleScopeFactory(String name) { | ||
this.name = name; | ||
} | ||
|
||
@Override | ||
public Scope createScope() { | ||
return new SimpleScope(name); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return name; | ||
} | ||
} |
Oops, something went wrong.