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


Java JavaClassSource.setName方法代码示例

本文整理汇总了Java中org.jboss.forge.roaster.model.source.JavaClassSource.setName方法的典型用法代码示例。如果您正苦于以下问题:Java JavaClassSource.setName方法的具体用法?Java JavaClassSource.setName怎么用?Java JavaClassSource.setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.forge.roaster.model.source.JavaClassSource的用法示例。


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

示例1: createJavaSourceForComponent

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
private void createJavaSourceForComponent(Project project, String schemeName, String packageName, String className) {
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);
    String fqn = packageName + "." + className;

    JavaResource existing = facet.getJavaResource(fqn);
    if (existing != null && existing.exists()) {
        // override existing
        existing.delete();
    }

    // need to parse to be able to extends another class
    final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
    javaClass.setName(className);
    javaClass.setPackage(packageName);
    javaClass.setSuperType("DjangoComponent");
    javaClass.addImport("io.fabric8.django.component.connector.DjangoComponent");

    // add public no-arg constructor
    javaClass.addMethod().setPublic().setConstructor(true).setBody("super(\"" + schemeName + "\", \"" + fqn + "\");");

    facet.saveJavaSource(javaClass);
}
 
开发者ID:fabric8io,项目名称:django,代码行数:23,代码来源:ConnectorSelectComponentStep.java

示例2: probe

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
/**
 * Creates an implementation of the network probe. The created class extends
 * {@link ExternalProbe}, setting the queuing server's connection data.
 * 
 * @param modified
 *            The modified service interface
 * @return The created source code
 */
public JavaClassSource probe(final JavaInterfaceSource modified) {

	File file = new File(this.interfacePath);
	String className = new NameProposal("NetworkLatencyProbe.java",
			file.getParentFile()).getNewName();

	JavaClassSource javaClass = Roaster.create(JavaClassSource.class);

	// Set general properties
	javaClass.setName(className);
	javaClass.setPackage(modified.getPackage());
	javaClass.setSuperType(ExternalProbe.class);

	// Add imports
	javaClass.addImport(ExternalProbe.class);
	javaClass.addImport(PascaniRuntime.Context.class);

	Context context = Context.PROBE;
	String body = NetworkLatencyTemplates.getProbeInitialization(
			this.routingKey, context);
	javaClass.addMethod().setConstructor(true).setBody(body)
			.addThrows(Exception.class);

	return javaClass;
}
 
开发者ID:unicesi,项目名称:pascani,代码行数:34,代码来源:LatencyProbeGenerator.java

示例3: probe

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
/**
 * Generates a class extending {@link LocalProbe} with the corresponding
 * connection information.
 * 
 * @param packageName
 *            The package of the generated java class
 * @param routingKey
 *            The routing key designated to the probe
 * @return an object encapsulating the java source code
 */
public JavaClassSource probe(final String packageName,
		final String routingKey) {

	File directory = new File(this.path);
	String className = new NameProposal(getProbeClassName(), directory)
			.getNewName();

	JavaClassSource javaClass = Roaster.create(JavaClassSource.class);

	// Add imports
	javaClass.addImport(LocalProbe.class);
	javaClass.addImport(Context.class);

	// Set general properties
	javaClass.setPackage(packageName);
	javaClass.setName(className);
	javaClass.setSuperType(LocalProbe.class);

	String constructorBody = InterceptorBasedProbeTemplates
			.getProbeConstructor(routingKey, Context.PROBE);

	MethodSource<?> constructor = javaClass.addMethod();
	constructor.setConstructor(true);
	constructor.setBody(constructorBody);
	constructor.addThrows(Exception.class);

	return javaClass;
}
 
开发者ID:unicesi,项目名称:pascani,代码行数:39,代码来源:InterceptorBasedProbeGenerator.java

示例4: execute

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Override
public Result execute(UIExecutionContext context) throws Exception {
    Project project = getSelectedProject(context);
    JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class);

    // does the project already have camel?
    Dependency core = findCamelCoreDependency(project);
    if (core == null) {
        return Results.fail("The project does not include camel-core");
    }

    // do we already have a class with the name
    String fqn = targetPackage.getValue() != null ? targetPackage.getValue() + "." + name.getValue() : name.getValue();

    JavaResource existing = facet.getJavaResource(fqn);
    if (existing != null && existing.exists()) {
        return Results.fail("A class with name " + fqn + " already exists");
    }

    // need to parse to be able to extends another class
    final JavaClassSource javaClass = Roaster.create(JavaClassSource.class);
    javaClass.setName(name.getValue());
    if (targetPackage.getValue() != null) {
        javaClass.setPackage(targetPackage.getValue());
    }
    javaClass.setSuperType("RouteBuilder");
    javaClass.addImport("org.apache.camel.builder.RouteBuilder");

    boolean cdi = CamelCommandsHelper.isCdiProject(getSelectedProject(context));
    boolean spring = CamelCommandsHelper.isSpringProject(getSelectedProject(context));

    if (cdi) {
        javaClass.addAnnotation("javax.inject.Singleton");
    } else if (spring) {
        javaClass.addAnnotation("org.springframework.stereotype.Component");
    }

    javaClass.addMethod()
            .setPublic()
            .setReturnTypeVoid()
            .setName("configure")
            .addThrows(Exception.class).setBody("");

    JavaResource javaResource = facet.saveJavaSource(javaClass);

    // if we are in an GUI editor then open the file
    if (isRunningInGui(context.getUIContext())) {
        context.getUIContext().setSelection(javaResource);
    }

    return Results.success("Created new RouteBuilder class " + name.getValue());
}
 
开发者ID:fabric8io,项目名称:fabric8-forge,代码行数:53,代码来源:CamelNewRouteBuilderCommand.java

示例5: interceptor

import org.jboss.forge.roaster.model.source.JavaClassSource; //导入方法依赖的package包/类
@Override public JavaClassSource interceptor(final String packageName,
		final List<Class<? extends Event<?>>> events) {

	File directory = new File(path);
	String className = new NameProposal(
			this.probeName + "Interceptor.java", directory).getNewName();

	JavaClassSource javaClass = Roaster.create(JavaClassSource.class);

	// Add imports
	javaClass.addImport(PascaniRuntime.class);
	javaClass.addImport(LocalEventProducer.class);
	javaClass.addImport(Event.class);
	javaClass.addImport(UUID.class);

	for (Class<? extends Event<?>> clazz : events)
		javaClass.addImport(clazz);

	// Set general properties
	javaClass.setPackage(packageName);
	javaClass.addAnnotation(Scope.class).setStringValue("value",
			"COMPOSITE");
	javaClass.setName(className);
	javaClass.addInterface(IntentHandler.class);

	// Add an event producer
	String producerVar = "producer";

	FieldSource<?> field = javaClass.addField();
	field.setType(LocalEventProducer.class.getSimpleName() + "<"
			+ Event.class.getSimpleName() + "<?>" + ">");
	field.setName(producerVar).setPrivate().setFinal(true);

	String constructor = ProbeTemplates
			.getProducerInitialization(producerVar);
	javaClass.addMethod().setConstructor(true).setBody(constructor);

	// Override the invoke method
	String paramName = "ijp";
	String invokeBody = ProbeTemplates.getInterceptorMethodBody(
			producerVar, paramName, events);

	MethodSource<?> invoke = javaClass.addMethod();

	invoke.setReturnType(Object.class);
	invoke.setName("invoke");
	invoke.addThrows("Throwable");
	invoke.addParameter(IntentJoinPoint.class, paramName);
	invoke.setBody(invokeBody);
	invoke.setPublic();

	return javaClass;
}
 
开发者ID:unicesi,项目名称:pascani,代码行数:54,代码来源:ScaProbeGenerator.java


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