summaryrefslogtreecommitdiffstats
path: root/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java')
-rw-r--r--sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java161
1 files changed, 0 insertions, 161 deletions
diff --git a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java b/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
deleted file mode 100644
index 754966b9a3..0000000000
--- a/sandbox/slaws/domain-view/src/main/java/org/apache/tuscany/sca/domain/interop/Domain.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you 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.apache.tuscany.sca.domain.interop;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.List;
-
-import javax.servlet.Servlet;
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletOutputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-
-import org.apache.tuscany.sca.impl.NodeImpl;
-import org.oasisopen.sca.annotation.Service;
-
-/**
- * Some hand crafted HTTP code to help me think about what info is missing
- * from the domain ragistry
- *
- */
-@Service(Domain.class)
-public class Domain implements Servlet {
-
- public String getDomainComposite(){
- NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
- return node.getDomainLevelCompositeAsString();
- }
-
- public String getContributions(){
- NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
- List<String> contributions = node.getInstalledContributionURIs();
- return contributions.toString();
- }
-
- public String getEndpoints(){
- NodeImpl node = (NodeImpl)DomainView.domainAccessPointNode;
- return node.getEndpointRegistry().getEndpoints().toString();
- }
-
- public String getNodes(String domainName){
- // use the domain on the file system in lieu of info in the registry
- File domainDir = new File("target/test-classes/" + domainName);
- String nodes = "";
-
- for (File subDir : domainDir.listFiles()){
- if (subDir.isDirectory()){
- nodes += subDir.getName() + "\n";
- }
- }
- return nodes;
- }
-
- public String getComponent(){
- return null;
- }
-
- public void init(ServletConfig config) throws ServletException {
- }
-
- public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
- HttpServletRequest httpRequest = (HttpServletRequest)request;
- ServletOutputStream os = response.getOutputStream();
-
- String pathInfo = httpRequest.getPathInfo();
-
- if (pathInfo == null || pathInfo.length() < 1){
- os.print("<html><body><p>URL should include at least a domain name, e.g. http://localhost/sca/mydomain</body></html>");
- return;
- }
-
- pathInfo = pathInfo.substring(1);
- String[] pathElements = pathInfo.split("/");
-
- String domainName = pathElements[0];
-
-
- // Just some hand crafted code to help me visualize resources
- os.print("<html><body>");
-
- if (pathElements.length > 1){
- String action = "none";
- action = pathElements[1];
-
- if ( action.equals("composite")){
- os.print(prettyPrintXMLString(getDomainComposite()));
- } else if ( action.equals("contribution")){
- os.print(prettyPrintXMLString(getContributions()));
- } else if ( action.equals("endpoint")){
- os.print(prettyPrintXMLString(getEndpoints()));
- } else if ( action.equals("node")){
- os.print(prettyPrintXMLString(getNodes(domainName)));
- } else {
- os.print("URL path component " + action + "is invalid");
- }
-
- } else {
- os.print("<p/><a href=\"" + domainName + "/contribution\">contributions</a>");
- os.print("<p/><a href=\"" + domainName + "/composite\">domainComposite</a>");
- os.print("<p/><a href=\"" + domainName + "/endpoint\">endpoints</a>");
- os.print("<p/><a href=\"" + domainName + "/node\">nodes</a>");
- }
-
- os.print("</body></html>");
-
- }
-
- public void destroy() {
- }
-
- public ServletConfig getServletConfig() {
- return null;
- }
-
- public String getServletInfo() {
- return null;
- }
-
- public void writeResource(ServletOutputStream os, URL url) throws Exception {
- URLConnection connection = url.openConnection();
- connection.setUseCaches(false);
-
- InputStream is = connection.getInputStream();
- int aChar;
- while(( aChar = is.read()) != -1){
- os.write(aChar);
- }
- }
-
- public String prettyPrintXMLString(String inXML){
- return inXML.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
-
- // etc. need to read and write a structured version
- }
-
-} \ No newline at end of file