use of org.jboss.wsf.spi.publish.Context in project wildfly by wildfly.
the class EndpointPublisherImpl method doPublish.
/**
* Publish the webapp for the WS deployment unit
*
* @param target
* @param unit
* @return
* @throws Exception
*/
protected Context doPublish(ServiceTarget target, DeploymentUnit unit) throws Exception {
Deployment deployment = unit.getAttachment(WSAttachmentKeys.DEPLOYMENT_KEY);
List<Endpoint> endpoints = deployment.getService().getEndpoints();
//otherwise we need to explicitly wait for the endpoint services to be started before creating the webapp.
if (!runningInService) {
final ServiceRegistry registry = unit.getServiceRegistry();
for (Endpoint ep : endpoints) {
final ServiceName serviceName = EndpointService.getServiceName(unit, ep.getShortName());
registry.getRequiredService(serviceName).awaitValue();
}
}
//TODO simplify and use findChild later in destroy()/stopWebApp()
deployment.addAttachment(WebDeploymentController.class, startWebApp(host, unit));
return new Context(unit.getAttachment(WSAttachmentKeys.JBOSSWEB_METADATA_KEY).getContextRoot(), endpoints);
}
use of org.jboss.wsf.spi.publish.Context in project wildfly by wildfly.
the class XTSSubsystemAdd method performBoottime.
@Override
protected void performBoottime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException {
final String hostName = HOST_NAME.resolveModelAttribute(context, model).asString();
final ModelNode coordinatorURLAttribute = ENVIRONMENT_URL.resolveModelAttribute(context, model);
String coordinatorURL = coordinatorURLAttribute.isDefined() ? coordinatorURLAttribute.asString() : null;
if (coordinatorURL != null) {
String[] attrs = coordinatorURL.split("/");
boolean isIPv6Address = false;
for (int i = 0; i < attrs.length; i++) {
if (attrs[i].startsWith("::1")) {
attrs[i] = "[" + attrs[i].substring(0, 3) + "]" + attrs[i].substring(3);
isIPv6Address = true;
break;
}
}
if (isIPv6Address) {
StringBuffer sb = new StringBuffer(attrs[0]);
for (int i = 1; i < attrs.length; i++) {
sb.append('/').append(attrs[i]);
}
coordinatorURL = sb.toString();
}
}
if (coordinatorURL != null) {
XtsAsLogger.ROOT_LOGGER.debugf("nodeIdentifier=%s%n", coordinatorURL);
}
final boolean isDefaultContextPropagation = model.hasDefined(CommonAttributes.DEFAULT_CONTEXT_PROPAGATION) ? model.get(CommonAttributes.DEFAULT_CONTEXT_PROPAGATION).asBoolean() : false;
context.addStep(new AbstractDeploymentChainStep() {
protected void execute(DeploymentProcessorTarget processorTarget) {
processorTarget.addDeploymentProcessor(XTSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_XTS_COMPONENT_INTERCEPTORS, new XTSInterceptorDeploymentProcessor());
processorTarget.addDeploymentProcessor(XTSExtension.SUBSYSTEM_NAME, Phase.PARSE, Phase.PARSE_XTS_SOAP_HANDLERS, new XTSHandlerDeploymentProcessor());
processorTarget.addDeploymentProcessor(XTSExtension.SUBSYSTEM_NAME, Phase.DEPENDENCIES, Phase.DEPENDENCIES_XTS, new XTSDependenciesDeploymentProcessor());
processorTarget.addDeploymentProcessor(XTSExtension.SUBSYSTEM_NAME, Phase.POST_MODULE, Phase.POST_MODULE_XTS_PORTABLE_EXTENSIONS, new GracefulShutdownDeploymentProcessor());
}
}, OperationContext.Stage.RUNTIME);
final ServiceTarget target = context.getServiceTarget();
// TODO eventually we should add a config service which manages the XTS configuration
// this will allow us to include a switch enabling or disabling deployment of
// endpoints specific to client, coordinator or participant and then deploy
// and redeploy the relevant endpoints as needed/ the same switches can be used
// byte the XTS service to decide whether to perfomr client, coordinator or
// participant initialisation. we should also provide config switches which
// decide whether to initialise classes and deploy services for AT, BA or both.
// for now we will just deploy all the endpoints and always do client, coordinator
// and participant init for both AT and BA.
// add an endpoint publisher service for each of the required endpoint contexts
// specifying all the relevant URL patterns and SEI classes
final ClassLoader loader = XTSService.class.getClassLoader();
ServiceBuilder<Context> endpointBuilder;
ArrayList<ServiceController<Context>> controllers = new ArrayList<ServiceController<Context>>();
Map<Class<?>, Object> attachments = new HashMap<>();
attachments.put(RejectionRule.class, new GracefulShutdownRejectionRule());
for (ContextInfo contextInfo : contextDefinitions) {
String contextName = contextInfo.contextPath;
Map<String, String> map = new HashMap<String, String>();
for (EndpointInfo endpointInfo : contextInfo.endpointInfo) {
map.put(endpointInfo.URLPattern, endpointInfo.SEIClassname);
}
endpointBuilder = EndpointPublishService.createServiceBuilder(target, contextName, loader, hostName, map, null, null, null, attachments);
controllers.add(endpointBuilder.setInitialMode(Mode.ACTIVE).install());
}
XTSHandlersService.install(target, isDefaultContextPropagation);
// add an XTS service which depends on all the WS endpoints
final XTSManagerService xtsService = new XTSManagerService(coordinatorURL);
// this service needs to depend on the transaction recovery service
// because it can only initialise XTS recovery once the transaction recovery
// service has initialised the orb layer
ServiceBuilder<?> xtsServiceBuilder = target.addService(XTSServices.JBOSS_XTS_MAIN, xtsService);
xtsServiceBuilder.addDependency(TxnServices.JBOSS_TXN_ARJUNA_TRANSACTION_MANAGER);
// this service needs to depend on JBossWS Config Service to be notified of the JBoss WS config (bind address, port etc)
xtsServiceBuilder.addDependency(WSServices.CONFIG_SERVICE, ServerConfig.class, xtsService.getWSServerConfig());
xtsServiceBuilder.addDependency(WSServices.XTS_CLIENT_INTEGRATION_SERVICE);
// the service also needs to depend on the endpoint services
for (ServiceController<Context> controller : controllers) {
xtsServiceBuilder.addDependency(controller.getName());
}
xtsServiceBuilder.setInitialMode(Mode.ACTIVE).install();
// WS-AT / JTA Transaction bridge services:
final TxBridgeInboundRecoveryService txBridgeInboundRecoveryService = new TxBridgeInboundRecoveryService();
ServiceBuilder<?> txBridgeInboundRecoveryServiceBuilder = target.addService(XTSServices.JBOSS_XTS_TXBRIDGE_INBOUND_RECOVERY, txBridgeInboundRecoveryService);
txBridgeInboundRecoveryServiceBuilder.addDependency(XTSServices.JBOSS_XTS_MAIN);
txBridgeInboundRecoveryServiceBuilder.setInitialMode(Mode.ACTIVE).install();
final TxBridgeOutboundRecoveryService txBridgeOutboundRecoveryService = new TxBridgeOutboundRecoveryService();
ServiceBuilder<?> txBridgeOutboundRecoveryServiceBuilder = target.addService(XTSServices.JBOSS_XTS_TXBRIDGE_OUTBOUND_RECOVERY, txBridgeOutboundRecoveryService);
txBridgeOutboundRecoveryServiceBuilder.addDependency(XTSServices.JBOSS_XTS_MAIN);
txBridgeOutboundRecoveryServiceBuilder.setInitialMode(Mode.ACTIVE).install();
}
use of org.jboss.wsf.spi.publish.Context in project wildfly by wildfly.
the class EndpointPublishService method createServiceBuilder.
public static ServiceBuilder<Context> createServiceBuilder(final ServiceTarget serviceTarget, final String context, final ClassLoader loader, final String hostName, final Map<String, String> urlPatternToClassName, JBossWebMetaData jbwmd, WebservicesMetaData wsmd, JBossWebservicesMetaData jbwsmd, Map<Class<?>, Object> deploymentAttachments) {
final DeploymentUnit unit = EndpointDeployService.install(serviceTarget, context, loader, hostName, urlPatternToClassName, jbwmd, wsmd, jbwsmd, deploymentAttachments);
final EndpointPublishService service = new EndpointPublishService(context, unit);
final ServiceBuilder<Context> builder = serviceTarget.addService(service.getName(), service);
builder.addDependency(DependencyType.REQUIRED, WSServices.CONFIG_SERVICE);
builder.addDependency(WebHost.SERVICE_NAME.append(hostName), WebHost.class, service.getHostInjector());
for (ServiceName epServiceName : EndpointService.getServiceNamesFromDeploymentUnit(unit)) {
builder.addDependency(DependencyType.REQUIRED, epServiceName);
}
return builder;
}
Aggregations