Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#4485] Allow plugins to detect and set application type
- Loading branch information
Showing
31 changed files
with
630 additions
and
418 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
...re/src/main/java/com/navercorp/pinpoint/bootstrap/plugin/ProfilerPluginGlobalContext.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,34 @@ | ||
/* | ||
* Copyright 2018 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.bootstrap.plugin; | ||
|
||
import com.navercorp.pinpoint.bootstrap.config.ProfilerConfig; | ||
import com.navercorp.pinpoint.common.trace.ServiceType; | ||
|
||
/** | ||
* @author HyunGil Jeong | ||
*/ | ||
public interface ProfilerPluginGlobalContext { | ||
|
||
ProfilerConfig getConfig(); | ||
|
||
ServiceType getConfiguredApplicationType(); | ||
|
||
ServiceType getApplicationType(); | ||
|
||
boolean registerApplicationType(ServiceType applicationType); | ||
} |
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
152 changes: 78 additions & 74 deletions
152
...resolver/condition/PropertyCondition.java → ...er/condition/SystemPropertyCondition.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 |
---|---|---|
@@ -1,74 +1,78 @@ | ||
/* | ||
* Copyright 2015 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.bootstrap.resolver.condition; | ||
|
||
import com.navercorp.pinpoint.bootstrap.logging.PLogger; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; | ||
import com.navercorp.pinpoint.common.util.SimpleProperty; | ||
import com.navercorp.pinpoint.common.util.StringUtils; | ||
import com.navercorp.pinpoint.common.util.SystemProperty; | ||
|
||
/** | ||
* @author HyunGil Jeong | ||
* | ||
*/ | ||
public class PropertyCondition implements Condition<String>, ConditionValue<SimpleProperty> { | ||
|
||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass().getName()); | ||
|
||
private final SimpleProperty property; | ||
|
||
public PropertyCondition() { | ||
this(SystemProperty.INSTANCE); | ||
} | ||
|
||
public PropertyCondition(SimpleProperty property) { | ||
this.property = property; | ||
} | ||
|
||
/** | ||
* Checks if the specified value is in <tt>SimpleProperty</tt>. | ||
* | ||
* @param requiredKey the values to check if they exist in <tt>SimpleProperty</tt> | ||
* @return <tt>true</tt> if the specified key is in <tt>SimpleProperty</tt>; | ||
* <tt>false</tt> if otherwise, or if <tt>null</tt> or empty key is provided | ||
*/ | ||
@Override | ||
public boolean check(String requiredKey) { | ||
if (StringUtils.isEmpty(requiredKey)) { | ||
return false; | ||
} | ||
if (this.property.getProperty(requiredKey) != null) { | ||
logger.debug("Property '{}' found in [{}]", requiredKey, this.property.getClass().getSimpleName()); | ||
return true; | ||
} else { | ||
logger.debug("Property '{}' not found in [{}]", requiredKey, this.property.getClass().getSimpleName()); | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Returns the <tt>SimpleProperty</tt>. | ||
* | ||
* @return the {@link SimpleProperty} instance | ||
*/ | ||
@Override | ||
public SimpleProperty getValue() { | ||
return this.property; | ||
} | ||
|
||
} | ||
/* | ||
* Copyright 2015 NAVER Corp. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.navercorp.pinpoint.bootstrap.resolver.condition; | ||
|
||
import com.navercorp.pinpoint.bootstrap.logging.PLogger; | ||
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory; | ||
import com.navercorp.pinpoint.common.annotations.VisibleForTesting; | ||
import com.navercorp.pinpoint.common.util.SimpleProperty; | ||
import com.navercorp.pinpoint.common.util.StringUtils; | ||
import com.navercorp.pinpoint.common.util.SystemProperty; | ||
|
||
/** | ||
* @author HyunGil Jeong | ||
* | ||
*/ | ||
public class SystemPropertyCondition implements Condition<String>, ConditionValue<SystemProperty> { | ||
|
||
public static final SystemPropertyCondition INSTANCE = new SystemPropertyCondition(); | ||
|
||
private final PLogger logger = PLoggerFactory.getLogger(this.getClass().getName()); | ||
|
||
private final SystemProperty property; | ||
|
||
private SystemPropertyCondition() { | ||
this(SystemProperty.INSTANCE); | ||
} | ||
|
||
@VisibleForTesting | ||
SystemPropertyCondition(SystemProperty property) { | ||
this.property = property; | ||
} | ||
|
||
/** | ||
* Checks if the specified value is in <tt>SimpleProperty</tt>. | ||
* | ||
* @param requiredKey the values to check if they exist in <tt>SimpleProperty</tt> | ||
* @return <tt>true</tt> if the specified key is in <tt>SimpleProperty</tt>; | ||
* <tt>false</tt> if otherwise, or if <tt>null</tt> or empty key is provided | ||
*/ | ||
@Override | ||
public boolean check(String requiredKey) { | ||
if (StringUtils.isEmpty(requiredKey)) { | ||
return false; | ||
} | ||
if (this.property.getProperty(requiredKey) != null) { | ||
logger.debug("Property '{}' found in [{}]", requiredKey, this.property.getClass().getSimpleName()); | ||
return true; | ||
} else { | ||
logger.debug("Property '{}' not found in [{}]", requiredKey, this.property.getClass().getSimpleName()); | ||
return false; | ||
} | ||
} | ||
|
||
/** | ||
* Returns the <tt>SimpleProperty</tt>. | ||
* | ||
* @return the {@link SimpleProperty} instance | ||
*/ | ||
@Override | ||
public SystemProperty getValue() { | ||
return this.property; | ||
} | ||
|
||
} |
Oops, something went wrong.