当前位置: 首页>>代码示例>>Java>>正文


Java ReflectionUtils类代码示例

本文整理汇总了Java中org.codehaus.plexus.util.ReflectionUtils的典型用法代码示例。如果您正苦于以下问题:Java ReflectionUtils类的具体用法?Java ReflectionUtils怎么用?Java ReflectionUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ReflectionUtils类属于org.codehaus.plexus.util包,在下文中一共展示了ReflectionUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: silenceUnarchiver

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
private void silenceUnarchiver ( UnArchiver unArchiver )
{
    // dangerous but handle any errors. It's the only
    // way to silence the
    // unArchiver.
    try
    {
        Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( "logger", unArchiver.getClass() );

        field.setAccessible( true );

        field.set( unArchiver, this.getLog() );
    }
    catch ( Exception e )
    {
        // was a nice try. Don't bother logging because
        // the log is silent.
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:20,代码来源:AbstractDependencyMojo.java

示例2: doExecute

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Test
public void doExecute() throws Exception {
    final PackageMojo mojo = getMojoFromPom();
    final PackageMojo mojoSpy = spy(mojo);
    ReflectionUtils.setVariableValueInObject(mojoSpy, "finalName", "artifact-0.1.0");
    doReturn(mock(AnnotationHandler.class)).when(mojoSpy).getAnnotationHandler();
    doReturn(ClasspathHelper.forPackage("com.microsoft.azure.maven.function.handlers").toArray()[0])
            .when(mojoSpy)
            .getTargetClassUrl();
    doReturn("target/azure-functions").when(mojoSpy).getDeploymentStageDirectory();
    doReturn("target").when(mojoSpy).getBuildDirectoryAbsolutePath();
    doReturn(mock(MavenProject.class)).when(mojoSpy).getProject();
    doReturn(mock(MavenSession.class)).when(mojoSpy).getSession();
    doReturn(mock(MavenResourcesFiltering.class)).when(mojoSpy).getMavenResourcesFiltering();

    mojoSpy.doExecute();
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:18,代码来源:PackageMojoTest.java

示例3: doExecute

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Test
public void doExecute() throws Exception {
    final AddMojo mojo = getMojoFromPom();
    final Settings settings = new Settings();
    settings.setInteractiveMode(false);
    ReflectionUtils.setVariableValueInObject(mojo, "basedir", new File("target/test"));
    ReflectionUtils.setVariableValueInObject(mojo, "settings", settings);
    mojo.setFunctionTemplate("HttpTrigger");
    mojo.setFunctionName("New-Function");
    mojo.setFunctionPackageName("com.microsoft.azure");

    final File newFunctionFile = new File("target/test/src/main/java/com/microsoft/azure/New_Function.java");
    newFunctionFile.delete();

    mojo.doExecute();

    assertTrue(newFunctionFile.exists());
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:19,代码来源:AddMojoTest.java

示例4: getIndexDiskCache

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
private static IndexedDiskCache<String, CacheResponse> getIndexDiskCache(
		CompositeCache<String, CacheResponse> cache) {
	try {
		Object fieldValue = ReflectionUtils.getValueIncludingSuperclasses(
				"auxCaches", cache);
		if (fieldValue == null || !(fieldValue instanceof AuxiliaryCache[])) {
			return null;
		}
		@SuppressWarnings("unchecked")
		AuxiliaryCache<String, CacheResponse>[] auxCaches = (AuxiliaryCache[]) fieldValue;
		if (auxCaches.length == 0
				|| !(auxCaches[0] instanceof IndexedDiskCache)) {
			return null;
		}
		return (IndexedDiskCache<String, CacheResponse>) auxCaches[0];
	} catch (IllegalArgumentException | IllegalAccessException e) {
		// do nothing
	}
	return null;
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:21,代码来源:JCSCache.java

示例5: ProxyServerMitmManager

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
public ProxyServerMitmManager(Authority authority, boolean trustAllServers,
		boolean sendCerts) throws RootCertificateException {
	try {
		sslEngineSource = new BouncyCastleSslEngineSource(authority,
				trustAllServers, sendCerts);
		SSLContext sslContext = (SSLContext) ReflectionUtils
				.getValueIncludingSuperclasses("sslContext",
						sslEngineSource);
		SSLContextImpl sslContextImpl = (SSLContextImpl) ReflectionUtils
				.getValueIncludingSuperclasses("contextSpi", sslContext);
		ReflectionUtils.setVariableValueInObject(sslContextImpl,
				"trustManager", new InsecureX509ExtendedTrustManager());
	} catch (final Exception e) {
		throw new RootCertificateException(
				"Errors during assembling root CA.", e);
	}
}
 
开发者ID:eBay,项目名称:ServiceCOLDCache,代码行数:18,代码来源:ProxyServerMitmManager.java

示例6: execute

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
public void execute()
    throws MojoExecutionException, MojoFailureException
{
    try
    {
        AntRunMojo antRunMojo = new AntRunMojo();
        antRunMojo.setLog( getLog() );
        ReflectionUtils.setVariableValueInObject( antRunMojo, "project", session.getCurrentProject() );
        ReflectionUtils.setVariableValueInObject( antRunMojo, "target", getConfiguration() );
        ReflectionUtils.setVariableValueInObject( antRunMojo, "localRepository", localRepository );
        ReflectionUtils.setVariableValueInObject( antRunMojo, "versionsPropertyName",
                                                  "maven.project.dependencies.versions" );
        antRunMojo.execute();
    }
    catch ( Exception e )
    {
        throw new MojoExecutionException( "There was an error creating the AntRun task.", e );
    }
}
 
开发者ID:frincon,项目名称:openeos,代码行数:20,代码来源:AbstractHibernateMojo.java

示例7: createProvider

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
private XmlBasedTestDataProvider createProvider(AludraTestConfig config) throws Exception {
    XmlBasedTestDataProvider provider = new XmlBasedTestDataProvider();
    if (config == null) {
        config = new AludraTestConfigImpl();
        DefaultConfigurator configurator = new DefaultConfigurator();
        configurator.configure(config);
    }

    Map<String, ScriptLibrary> libs = new HashMap<String, ScriptLibrary>();

    DefaultScriptLibrary lib = new DefaultScriptLibrary();
    ReflectionUtils.setVariableValueInObject(lib, "aludraConfig", config);
    libs.put("default", lib);

    ReflectionUtils.setVariableValueInObject(provider, "aludraConfig", config);
    ReflectionUtils.setVariableValueInObject(provider, "scriptLibraries", libs);
    return provider;
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:19,代码来源:XmlBasedTestDataProviderTest.java

示例8: initField

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void initField(final Class implementation) {
	field = ReflectionUtils.getFieldByNameIncludingSuperclasses(fieldName,
			object.getClass());

	if (field == null) {
		return;
	}

	fieldType = field.getType();
	if (implementation != null
			&& fieldType.isAssignableFrom(implementation)) {
		fieldType = implementation; // more specific, compatible type
	}

	try {
		fieldTypeConverter = lookup.lookupConverterForType(fieldType);

		if (fieldTypeConverter instanceof ParameterizedConfigurationConverter) {
			fieldTypeArguments = getTypeArguments(field.getGenericType());
		}
	} catch (final ComponentConfigurationException e) {
		// ignore, handle later
	}
}
 
开发者ID:link-intersystems,项目名称:maven,代码行数:26,代码来源:ComponentValueSetter.java

示例9: setVariableValueToObject

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
/**
 * convience method to set values to variables in objects that don't have
 * setters
 * 
 * @param object
 * @param variable
 * @param value
 * @throws IllegalAccessException
 */
public static void setVariableValueToObject( Object object, String variable, Object value )
    throws IllegalAccessException
{
    Field field = ReflectionUtils.getFieldByNameIncludingSuperclasses( variable, object.getClass() );

    field.setAccessible( true );

    field.set( object, value );
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:19,代码来源:DependencyTestUtils.java

示例10: getTelemetryProperties

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Test
public void getTelemetryProperties() throws Exception {
    final DeployMojo mojo = getMojoFromPom("/pom-linux.xml");
    ReflectionUtils.setVariableValueInObject(mojo, "plugin", plugin);

    final Map map = mojo.getTelemetryProperties();

    assertEquals(10, map.size());
    assertTrue(map.containsKey(JAVA_VERSION_KEY));
    assertTrue(map.containsKey(JAVA_WEB_CONTAINER_KEY));
    assertTrue(map.containsKey(DOCKER_IMAGE_TYPE_KEY));
    assertTrue(map.containsKey(DEPLOYMENT_TYPE_KEY));
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:14,代码来源:DeployMojoTest.java

示例11: setUp

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    MockitoAnnotations.initMocks(this);
    doReturn(PLUGIN_NAME).when(plugin).getArtifactId();
    doReturn(PLUGIN_VERSION).when(plugin).getVersion();
    doReturn("target").when(buildDirectory).getAbsolutePath();
    ReflectionUtils.setVariableValueInObject(mojo, "subscriptionId", SUBSCRIPTION_ID);
    ReflectionUtils.setVariableValueInObject(mojo, "allowTelemetry", false);
    ReflectionUtils.setVariableValueInObject(mojo, "failsOnError", true);
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:11,代码来源:AbstractAzureMojoTest.java

示例12: getUserAgentWhenTelemetryAllowed

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Test
public void getUserAgentWhenTelemetryAllowed() throws IllegalAccessException {
    ReflectionUtils.setVariableValueInObject(mojo, "allowTelemetry", true);
    final String userAgent = mojo.getUserAgent();
    assertTrue(StringUtils.contains(userAgent, PLUGIN_NAME));
    assertTrue(StringUtils.contains(userAgent, PLUGIN_VERSION));
    assertTrue(StringUtils.contains(userAgent, mojo.getInstallationId()));
    assertTrue(StringUtils.contains(userAgent, mojo.getSessionId()));
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:10,代码来源:AbstractAzureMojoTest.java

示例13: getAuthType

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Test
public void getAuthType() throws Exception {
    assertEquals("Unknown", mojo.getAuthType());

    doReturn("serverId").when(authenticationSetting).getServerId();
    doReturn(null).when(authenticationSetting).getFile();
    assertEquals("ServerId", mojo.getAuthType());

    doReturn(null).when(authenticationSetting).getServerId();
    doReturn(new File("/pom.xml")).when(authenticationSetting).getFile();
    assertEquals("AuthFile", mojo.getAuthType());

    ReflectionUtils.setVariableValueInObject(mojo, "authentication", null);
    assertEquals("AzureCLI", mojo.getAuthType());
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:16,代码来源:AbstractAzureMojoTest.java

示例14: getRunFunctionCommandWithInputOnWindows

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Test
public void getRunFunctionCommandWithInputOnWindows() throws Exception {
    final RunMojo mojo = getMojoFromPom();
    ReflectionUtils.setVariableValueInObject(mojo, "targetFunction", "httpTrigger");
    ReflectionUtils.setVariableValueInObject(mojo, "functionInputString", "input");
    final RunMojo mojoSpy = spy(mojo);
    doReturn("target").when(mojoSpy).getDeploymentStageDirectory();
    doReturn(true).when(mojoSpy).isWindows();

    final String[] command = mojoSpy.getRunFunctionCommand();

    assertEquals(3, command.length);
    assertEquals("cd /D target && func function run httpTrigger --no-interactive -c input", command[2]);
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:15,代码来源:RunMojoTest.java

示例15: getRunFunctionCommandWithInputFileOnWindows

import org.codehaus.plexus.util.ReflectionUtils; //导入依赖的package包/类
@Test
public void getRunFunctionCommandWithInputFileOnWindows() throws Exception {
    final RunMojo mojo = getMojoFromPom();
    ReflectionUtils.setVariableValueInObject(mojo, "targetFunction", "httpTrigger");
    ReflectionUtils.setVariableValueInObject(mojo, "functionInputFile", new File("pom.xml"));
    final RunMojo mojoSpy = spy(mojo);
    doReturn("target").when(mojoSpy).getDeploymentStageDirectory();
    doReturn(true).when(mojoSpy).isWindows();

    final String[] command = mojoSpy.getRunFunctionCommand();

    assertEquals(3, command.length);
    assertTrue(command[2].startsWith("cd /D target && func function run httpTrigger --no-interactive -f"));
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:15,代码来源:RunMojoTest.java


注:本文中的org.codehaus.plexus.util.ReflectionUtils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。