@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress hostAddress = context.getCurrentAddress().getParent(); final PathAddress serverAddress = hostAddress.getParent(); final String name = context.getCurrentAddressValue(); final String handler = LocationDefinition.HANDLER.resolveModelAttribute(context, model).asString(); final LocationService service = new LocationService(name); final String serverName = serverAddress.getLastElement().getValue(); final String hostName = hostAddress.getLastElement().getValue(); final ServiceName serviceName = UndertowService.locationServiceName(serverName, hostName, name); final ServiceBuilder<LocationService> builder = context.getCapabilityServiceTarget().addCapability(LocationDefinition.LOCATION_CAPABILITY, service) .addCapabilityRequirement(Capabilities.CAPABILITY_HANDLER, HttpHandler.class, service.getHttpHandler(),handler) .addCapabilityRequirement(Capabilities.CAPABILITY_HOST, Host.class, service.getHost(), serverName, hostName); builder.setInitialMode(ServiceController.Mode.ACTIVE) .addAliases(serviceName) .install(); } }
LocationService locService = new LocationService(); locService.startService(new Intent());
private static EmbeddedDatabase _db; private static LocationService _svc; @BeforeClass public static void setUp() throws Exception { _db = new EmbeddedDatabaseBuilder().setType(EmbeddedDatabaseType.HSQL) .setName("myTestDB").build(); assertThat(_db, is(notNullValue())); _svc = new LocationService(); _svc.setDataSource(_db); } @AfterClass public static void tearDown() throws Exception { _db.shutdown(); }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress hostAddress = context.getCurrentAddress().getParent(); final PathAddress serverAddress = hostAddress.getParent(); final String name = context.getCurrentAddressValue(); final String handler = LocationDefinition.HANDLER.resolveModelAttribute(context, model).asString(); final LocationService service = new LocationService(name); final String serverName = serverAddress.getLastElement().getValue(); final String hostName = hostAddress.getLastElement().getValue(); final ServiceName serviceName = UndertowService.locationServiceName(serverName, hostName, name); final ServiceBuilder<LocationService> builder = context.getCapabilityServiceTarget().addCapability(LocationDefinition.LOCATION_CAPABILITY, service) .addCapabilityRequirement(Capabilities.CAPABILITY_HANDLER, HttpHandler.class, service.getHttpHandler(),handler) .addCapabilityRequirement(Capabilities.CAPABILITY_HOST, Host.class, service.getHost(), serverName, hostName); builder.setInitialMode(ServiceController.Mode.ACTIVE) .addAliases(serviceName) .install(); } }
@Override protected void performRuntime(OperationContext context, ModelNode operation, ModelNode model) throws OperationFailedException { final PathAddress hostAddress = context.getCurrentAddress().getParent(); final PathAddress serverAddress = hostAddress.getParent(); final String name = context.getCurrentAddressValue(); final String handler = LocationDefinition.HANDLER.resolveModelAttribute(context, model).asString(); final LocationService service = new LocationService(name); final String serverName = serverAddress.getLastElement().getValue(); final String hostName = hostAddress.getLastElement().getValue(); final ServiceName serviceName = UndertowService.locationServiceName(serverName, hostName, name); final ServiceBuilder<LocationService> builder = context.getCapabilityServiceTarget().addCapability(LocationDefinition.LOCATION_CAPABILITY, service) .addCapabilityRequirement(Capabilities.CAPABILITY_HANDLER, HttpHandler.class, service.getHttpHandler(),handler) .addCapabilityRequirement(Capabilities.CAPABILITY_HOST, Host.class, service.getHost(), serverName, hostName); builder.setInitialMode(ServiceController.Mode.ACTIVE) .addAliases(serviceName) .install(); } }