org.wildfly.swarm.topology.Topology Java Examples
The following examples show how to use
org.wildfly.swarm.topology.Topology.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TopologyManagerActivator.java From thorntail with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); TopologyManager.INSTANCE.setServiceTarget(target); target.addService(SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE))) .install(); BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example #2
Source File: TopologyManagerActivator.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 6 votes |
@Override public void activate(ServiceActivatorContext context) throws ServiceRegistryException { ServiceTarget target = context.getServiceTarget(); target.addService(TopologyManager.SERVICE_NAME, new ValueService<>(new ImmediateValue<>(TopologyManager.INSTANCE))) .install(); BinderService binderService = new BinderService(Topology.JNDI_NAME, null, true); target.addService(ContextNames.buildServiceName(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, Topology.JNDI_NAME), binderService) .addDependency(ContextNames.JBOSS_CONTEXT_SERVICE_NAME, ServiceBasedNamingStore.class, binderService.getNamingStoreInjector()) .addInjection(binderService.getManagedObjectInjector(), new ImmediateManagedReferenceFactory(TopologyManager.INSTANCE)) .setInitialMode(ServiceController.Mode.ACTIVE) .install(); }
Example #3
Source File: App.java From drools-workshop with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { Container container = new Container(); JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class); deployment.as(TopologyArchive.class).advertise("foodService"); deployment.setContextRoot("/api"); deployment.addPackages(true, "org.jboss.shrinkwrap.api"); deployment.addAsLibrary(container.createDefaultDeployment()); deployment.addAllDependencies(); container.start(); container.deploy(deployment); Topology lookup = Topology.lookup(); lookup.addListener(new TopologyListener() { @Override public void onChange(Topology tplg) { System.out.println(">>> Delivery Service: The Topology Has Changed!"); printTopology(lookup); } }); printTopology(lookup); }
Example #4
Source File: App.java From drools-workshop with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { Container container = new Container(); JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class); deployment.as(TopologyArchive.class).advertise("deliveryService"); deployment.setContextRoot("/api"); deployment.addPackages(true, "org.jboss.shrinkwrap.api"); deployment.addAsLibrary(container.createDefaultDeployment()); deployment.addAllDependencies(); container.start(); container.deploy(deployment); Topology lookup = Topology.lookup(); lookup.addListener(new TopologyListener() { @Override public void onChange(Topology tplg) { System.out.println(">>> Delivery Service: The Topology Has Changed!"); printTopology(lookup); } }); printTopology(lookup); }
Example #5
Source File: App.java From drools-workshop with Apache License 2.0 | 6 votes |
public static void main(String[] args) throws Exception { Container container = new Container(); JAXRSArchive deployment = ShrinkWrap.create(JAXRSArchive.class); deployment.as(TopologyArchive.class).advertise("restaurantService"); deployment.setContextRoot("/api"); deployment.addPackages(true, "org.jboss.shrinkwrap.api"); deployment.addAsLibrary(container.createDefaultDeployment()); deployment.addAllDependencies(); container.start(); container.deploy(deployment); Topology lookup = Topology.lookup(); lookup.addListener(new TopologyListener() { @Override public void onChange(Topology tplg) { System.out.println(">>> Delivery Service: The Topology Has Changed!"); printTopology(lookup); } }); printTopology(lookup); }
Example #6
Source File: TopologySSEServlet.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void onChange(Topology topology) { String json = topologyToJson(secure); synchronized (writeLock) { writer.write("event: topologyChange\n"); writer.write("data: " + json); writer.flush(); } }
Example #7
Source File: TopologyProxyService.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void start(StartContext context) throws StartException { try { Topology topology = Topology.lookup(); topology.addListener(this); } catch (NamingException ex) { throw new StartException(ex); } }
Example #8
Source File: TopologyProxyService.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void stop(StopContext context) { try { Topology.lookup().removeListener(this); } catch (NamingException e) { // Swallow, as we're closing anyway } }
Example #9
Source File: TopologyProxyService.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void onChange(Topology topology) { Map<String, List<Topology.Entry>> topologyMap = topology.asMap(); for (String serviceName : serviceNames) { if (topologyMap.containsKey(serviceName)) { updateProxyHosts(serviceName, topologyMap.get(serviceName)); } else { // All instances of this service went away updateProxyHosts(serviceName, Collections.emptyList()); } } }
Example #10
Source File: TopologyProxyService.java From thorntail with Apache License 2.0 | 5 votes |
private URI entryToURI(Topology.Entry entry) throws URISyntaxException { List<String> tags = entry.getTags(); String scheme = "http"; if (tags.contains("https")) { scheme = "https"; } return new URI(scheme, null, entry.getAddress(), entry.getPort(), null, null, null); }
Example #11
Source File: TopologySSEServlet.java From thorntail with Apache License 2.0 | 5 votes |
@Override public void init(ServletConfig config) throws ServletException { super.init(config); try { this.topology = Topology.lookup(); } catch (NamingException e) { throw new ServletException(e); } this.keepAliveExecutor = Executors.newScheduledThreadPool(2); }
Example #12
Source File: ArqTopologyOpenShiftTest.java From thorntail with Apache License 2.0 | 4 votes |
@Test public void testIt() throws Exception { Topology topology = Topology.lookup(); assertThat(topology).isNotNull(); }
Example #13
Source File: TopologySSEServlet.java From thorntail with Apache License 2.0 | 4 votes |
public TopologyAsyncListener(Topology topology, TopologyListener topologyListener, ScheduledFuture scheduledFuture) { this.topology = topology; this.topologyListener = topologyListener; this.keepAlive = scheduledFuture; }
Example #14
Source File: App.java From drools-workshop with Apache License 2.0 | 4 votes |
public static void printTopology(Topology lookup) { Map<String, List<Topology.Entry>> asMap = lookup.asMap(); for (String key : asMap.keySet()) { System.out.println("Key: " + key + " - Value: " + asMap.get(key)); } }
Example #15
Source File: App.java From drools-workshop with Apache License 2.0 | 4 votes |
public static void printTopology(Topology lookup){ Map<String, List<Topology.Entry>> asMap = lookup.asMap(); for(String key : asMap.keySet()){ System.out.println("Key: "+ key + " - Value: "+asMap.get(key)); } }
Example #16
Source File: ArqTopologyConsulTest.java From thorntail with Apache License 2.0 | 4 votes |
@Test public void testIt() throws Exception { Topology topology = Topology.lookup(); assertThat(topology).isNotNull(); }
Example #17
Source File: App.java From drools-workshop with Apache License 2.0 | 4 votes |
public static void printTopology(Topology lookup){ Map<String, List<Topology.Entry>> asMap = lookup.asMap(); for(String key : asMap.keySet()){ System.out.println("Key: "+ key + " - Value: "+asMap.get(key)); } }
Example #18
Source File: TopologySSEServlet.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 4 votes |
protected String topologyToJson(int externalPort) { StringBuilder json = new StringBuilder(); json.append("{"); Map<String, List<Topology.Entry>> map = this.topology.asMap(); Set<String> keys = map.keySet(); Iterator<String> keyIter = keys.iterator(); while (keyIter.hasNext()) { String key = keyIter.next(); json.append(" ").append('"').append(key).append('"').append(": ["); List<Topology.Entry> list = map.get(key); Iterator<Topology.Entry> listIter = list.iterator(); while (listIter.hasNext()) { Topology.Entry server = listIter.next(); server = this.externalAddressMapper.toExternal(server, externalPort); json.append("{"); json.append("\"endpoint\": \"").append(server.getAddress() + ":" + server.getPort()).append("\","); json.append("\"tags\":["); List<String> tags = server.getTags(); Iterator<String> tagIter = tags.iterator(); while ( tagIter.hasNext() ) { String tag = tagIter.next(); json.append("\"").append(tag).append("\""); if ( tagIter.hasNext() ) { json.append(","); } } json.append("]"); json.append("}"); if (listIter.hasNext()) { json.append(","); } } json.append("]"); if (keyIter.hasNext()) { json.append(","); } } json.append("}\n\n"); return json.toString(); }
Example #19
Source File: IdentityExternalAddressMapper.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 4 votes |
@Override public Topology.Entry toExternal(Topology.Entry internalServer, int defaultPort) { return internalServer; }
Example #20
Source File: ArqTopologyJGroupsTest.java From thorntail with Apache License 2.0 | 4 votes |
@Test public void testIt() throws Exception { Topology topology = Topology.lookup(); assertThat(topology).isNotNull(); }