forked from SilverThings/SilverWare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SilverThings#4 getting ready for cluster queries
- Loading branch information
Showing
3 changed files
with
39 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,27 @@ | |
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.silverware.microservices.Context; | ||
import org.silverware.microservices.MicroserviceMetaData; | ||
import org.silverware.microservices.providers.MicroserviceProvider; | ||
import org.silverware.microservices.silver.CdiSilverService; | ||
import org.silverware.microservices.silver.HttpInvokerSilverService; | ||
import org.silverware.microservices.silver.HttpServerSilverService; | ||
import org.silverware.microservices.silver.ProvidingSilverService; | ||
import org.silverware.microservices.silver.SilverService; | ||
import org.silverware.microservices.silver.cluster.ServiceHandle; | ||
import org.silverware.microservices.silver.http.ServletDescriptor; | ||
import org.silverware.microservices.util.Utils; | ||
|
||
import java.io.IOException; | ||
import java.util.Collections; | ||
import java.util.HashSet; | ||
import java.util.Properties; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* @author Martin Večeřa <[email protected]> | ||
|
@@ -40,6 +53,7 @@ public class HttpInvokerMicroserviceProvider implements MicroserviceProvider, Ht | |
|
||
private Context context; | ||
private HttpServerSilverService http; | ||
private Set<ProvidingSilverService> microserviceProviders = new HashSet<>(); | ||
|
||
@Override | ||
public void initialize(final Context context) { | ||
|
@@ -57,6 +71,7 @@ public Context getContext() { | |
public void run() { | ||
try { | ||
log.info("Hello from Http Invoker microservice provider!"); | ||
context.getAllProviders(ProvidingSilverService.class).stream().forEach(silverService -> microserviceProviders.add((ProvidingSilverService) silverService)); | ||
|
||
try { | ||
if (log.isDebugEnabled()) { | ||
|
@@ -118,4 +133,24 @@ private ServletDescriptor getServletDescriptor() { | |
|
||
return null; //new ServletDescriptor("jolokia-agent", org.jolokia.http.AgentServlet.class, "/", properties); | ||
} | ||
|
||
protected Set<ServiceHandle> searchQuery(final MicroserviceMetaData metaData) { | ||
Set<Object> microservices = microserviceProviders.stream().map(providingSilverService -> providingSilverService.lookupMicroservice(metaData)).collect(Collectors.toSet()); | ||
//microservices.stream().map(microservice -> new ServiceHandle()) | ||
// TODO Move to Cluster | ||
return null; | ||
} | ||
|
||
/** | ||
* @author Martin Večeřa <[email protected]> | ||
*/ | ||
public static class HttpInvokerServlet extends HttpServlet { | ||
|
||
|
||
@Override | ||
protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException { | ||
req.getContextPath(); | ||
super.doPost(req, resp); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters