Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
mskacelik committed Aug 8, 2024
1 parent b2d003d commit dff4912
Show file tree
Hide file tree
Showing 28 changed files with 1,317 additions and 8 deletions.
126 changes: 126 additions & 0 deletions client-subsystem/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2019 Red Hat, Inc.
~
~ 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.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>wildfly-microprofile-graphql-parent</artifactId>
<groupId>org.wildfly.extras.graphql</groupId>
<version>2.4.1.Final-SNAPSHOT</version>
</parent>
<version>2.4.1.Final-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>

<artifactId>wildfly-microprofile-graphql-client</artifactId>
<name>WildFly MicroProfile GraphQL - Client Subsystem</name>

<dependencies>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-servlet</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-cdi</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-schema-builder</artifactId>
</dependency>
<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql-schema-model</artifactId>
</dependency>
<dependency>
<groupId>com.graphql-java</groupId>
<artifactId>graphql-java</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<!--
This is a compile-time dependency of this project, but is not needed at compile or runtime by other
projects that depend on this project.
-->
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-controller</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-server</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ee</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.metadata</groupId>
<artifactId>jboss-metadata-web</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-web-common</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-weld</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-undertow</artifactId>
</dependency>

<dependency>
<groupId>io.smallrye</groupId>
<artifactId>smallrye-graphql</artifactId>
</dependency>
<dependency>
<groupId>jakarta.json.bind</groupId>
<artifactId>jakarta.json.bind-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.websocket</groupId>
<artifactId>jakarta.websocket-client-api</artifactId>
</dependency>

<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-subsystem-test</artifactId>
<type>pom</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>

</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright 2020 Red Hat, Inc.
*
* 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 org.wildfly.extension.microprofile.graphql.client;

import org.jboss.as.controller.ExtensionContext;
import org.jboss.as.controller.ModelVersion;
import org.jboss.as.controller.PathElement;
import org.jboss.as.controller.SubsystemRegistration;
import org.jboss.as.controller.descriptions.ResourceDescriptionResolver;
import org.jboss.as.controller.descriptions.StandardResourceDescriptionResolver;
import org.jboss.as.controller.operations.common.GenericSubsystemDescribeHandler;
import org.jboss.as.controller.parsing.ExtensionParsingContext;
import org.jboss.as.controller.registry.ManagementResourceRegistration;

import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;

public class MicroProfileGraphQLClientExtension implements org.jboss.as.controller.Extension {

public static final String SUBSYSTEM_NAME = "microprofile-graphql-client-smallrye";
protected static final PathElement SUBSYSTEM_PATH = PathElement.pathElement(SUBSYSTEM, SUBSYSTEM_NAME);

protected static final ModelVersion VERSION_1_0_0 = ModelVersion.create(1, 0, 0);
private static final ModelVersion CURRENT_MODEL_VERSION = VERSION_1_0_0;

private static final MicroProfileGraphQLClientParser_1_0 CURRENT_PARSER = new MicroProfileGraphQLClientParser_1_0();

static final String WELD_CAPABILITY_NAME = "org.wildfly.weld";
static final String CONFIG_CAPABILITY_NAME = "org.wildfly.microprofile.config";

private static final String RESOURCE_NAME = MicroProfileGraphQLClientExtension.class.getPackage().getName() + ".LocalDescriptions";

@Override
public void initialize(ExtensionContext extensionContext) {
final SubsystemRegistration sr = extensionContext.registerSubsystem(SUBSYSTEM_NAME, CURRENT_MODEL_VERSION);
sr.registerXMLElementWriter(CURRENT_PARSER);
final ManagementResourceRegistration root = sr.registerSubsystemModel(new MicroProfileGraphQLClientSubsystemDefinition());
root.registerOperationHandler(GenericSubsystemDescribeHandler.DEFINITION, GenericSubsystemDescribeHandler.INSTANCE, false);
}

@Override
public void initializeParsers(ExtensionParsingContext extensionParsingContext) {
extensionParsingContext.setSubsystemXmlMapping(SUBSYSTEM_NAME, MicroProfileGraphQLClientParser_1_0.NAMESPACE, CURRENT_PARSER);
}

static ResourceDescriptionResolver getResourceDescriptionResolver(final String... keyPrefix) {
return getResourceDescriptionResolver(true, keyPrefix);
}

static ResourceDescriptionResolver getResourceDescriptionResolver(final boolean useUnprefixedChildTypes, final String... keyPrefix) {
StringBuilder prefix = new StringBuilder();
for (String kp : keyPrefix) {
if (prefix.length() > 0){
prefix.append('.');
}
prefix.append(kp);
}
return new StandardResourceDescriptionResolver(prefix.toString(), RESOURCE_NAME, MicroProfileGraphQLClientExtension.class.getClassLoader(), true, useUnprefixedChildTypes);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.wildfly.extension.microprofile.graphql.client;

import org.jboss.as.controller.PersistentResourceXMLDescription;
import org.jboss.as.controller.PersistentResourceXMLParser;

public class MicroProfileGraphQLClientParser_1_0 extends PersistentResourceXMLParser {

public static final String NAMESPACE = "urn:wildfly:microprofile-graphql-client-smallrye:1.0";

private static final PersistentResourceXMLDescription xmlDescription;

static {
xmlDescription = org.jboss.as.controller.PersistentResourceXMLDescription.builder(MicroProfileGraphQLClientExtension.SUBSYSTEM_PATH, NAMESPACE)
.build();
}

@Override
public PersistentResourceXMLDescription getParserDescription() {
return xmlDescription;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2019 Red Hat, Inc.
*
* 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 org.wildfly.extension.microprofile.graphql.client;

import org.jboss.as.controller.AbstractBoottimeAddStepHandler;
import org.jboss.as.controller.AttributeDefinition;
import org.jboss.as.controller.ModelOnlyRemoveStepHandler;
import org.jboss.as.controller.OperationContext;
import org.jboss.as.controller.OperationFailedException;
import org.jboss.as.controller.PersistentResourceDefinition;
import org.jboss.as.controller.capability.RuntimeCapability;
import org.jboss.as.server.AbstractDeploymentChainStep;
import org.jboss.as.server.DeploymentProcessorTarget;
import org.jboss.as.server.deployment.Phase;
import org.jboss.dmr.ModelNode;
//import org.wildfly.extension.microprofile.graphql._private.MicroProfileGraphQLLogger;
import org.wildfly.extension.microprofile.graphql.client.deployment.MicroProfileGraphQLClientDependencyProcessor;
import org.wildfly.extension.microprofile.graphql.client.deployment.MicroProfileGraphQLClientDeploymentProcessor;

import java.util.Collection;
import java.util.Collections;

import static org.wildfly.extension.microprofile.graphql.client.MicroProfileGraphQLClientExtension.CONFIG_CAPABILITY_NAME;
import static org.wildfly.extension.microprofile.graphql.client.MicroProfileGraphQLClientExtension.SUBSYSTEM_NAME;
import static org.wildfly.extension.microprofile.graphql.client.MicroProfileGraphQLClientExtension.SUBSYSTEM_PATH;
import static org.wildfly.extension.microprofile.graphql.client.MicroProfileGraphQLClientExtension.WELD_CAPABILITY_NAME;

public class MicroProfileGraphQLClientSubsystemDefinition extends PersistentResourceDefinition {

private static final String GRAPHQL_CAPABILITY_NAME = "org.wildfly.microprofile.graphql";

private static final RuntimeCapability<Void> GRAPHQL_CAPABILITY = RuntimeCapability.Builder
.of(GRAPHQL_CAPABILITY_NAME)
.addRequirements(WELD_CAPABILITY_NAME)
.addRequirements(CONFIG_CAPABILITY_NAME)
.build();

public MicroProfileGraphQLClientSubsystemDefinition() {
super(
new Parameters(
SUBSYSTEM_PATH,
MicroProfileGraphQLClientExtension.getResourceDescriptionResolver(SUBSYSTEM_NAME))
.setAddHandler(AddHandler.INSTANCE)
.setRemoveHandler(new ModelOnlyRemoveStepHandler())
.setCapabilities(GRAPHQL_CAPABILITY)
);
}

@Override
public Collection<AttributeDefinition> getAttributes() {
return Collections.emptyList();
}

static class AddHandler extends AbstractBoottimeAddStepHandler {

static AddHandler INSTANCE = new AddHandler();

private AddHandler() {
super(Collections.emptyList());
}

@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
super.performBoottime(context, operation, model);

context.addStep(new AbstractDeploymentChainStep() {
public void execute(DeploymentProcessorTarget processorTarget) {
final int DEPENDENCIES_MICROPROFILE_GRAPHQL = 6288;
processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, Phase.DEPENDENCIES, DEPENDENCIES_MICROPROFILE_GRAPHQL, new MicroProfileGraphQLClientDependencyProcessor());
final int POST_MODULE_MICROPROFILE_GRAPHQL = 14241;
processorTarget.addDeploymentProcessor(SUBSYSTEM_NAME, Phase.POST_MODULE, POST_MODULE_MICROPROFILE_GRAPHQL, new MicroProfileGraphQLClientDeploymentProcessor());
}
}, OperationContext.Stage.RUNTIME);

// MicroProfileGraphQLLogger.LOGGER.activatingSubsystem();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2020 Red Hat, Inc.
*
* 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 org.wildfly.extension.microprofile.graphql.client.deployment;
// org.wildfly.extension.microprofile.graphql-client-smallrye

import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentPhaseContext;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.server.deployment.DeploymentUnitProcessor;
import org.jboss.as.server.deployment.annotation.CompositeIndex;
import org.jboss.logging.Logger;

import static org.wildfly.extension.microprofile.graphql.client.deployment.MicroProfileGraphQLClientDeploymentProcessor.GRAPHQL_CLIENT_API;

public class MicroProfileGraphQLClientDependencyProcessor implements DeploymentUnitProcessor {

static final Logger LOG = Logger.getLogger(MicroProfileGraphQLClientDependencyProcessor.class);

@Override
public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final CompositeIndex compositeIndex = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
if(!compositeIndex.getAnnotations(GRAPHQL_CLIENT_API).isEmpty()) {
LOG.info("GRAPHQL CLIENT API FOUND");
// final ModuleSpecification moduleSpecification = deploymentUnit.getAttachment(Attachments.MODULE_SPECIFICATION);
// final ModuleLoader moduleLoader = Module.getBootModuleLoader();
// ModuleDependency dependency = new ModuleDependency(moduleLoader, "io.smallrye.graphql.client.vertx", false, false, true, false);
// this is an equivalent of meta-inf="import" in jboss-deployment-structure.xml and is needed to be able to see CDI beans from the module
// dependency.addImportFilter(s -> s.equals("META-INF"), true);
// moduleSpecification.addSystemDependency(dependency);
}
}

@Override
public void undeploy(DeploymentUnit context) {

}
}
Loading

0 comments on commit dff4912

Please sign in to comment.