From ef7c2424929d86cd59c0197729901bee89d67221 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 18 Aug 2008 12:01:31 +0000 Subject: TUSCANY-2391: apply latest patch from Thilina for Tuscany SCA support in the Geronimo Admin Console git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@686733 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/geronimoace/GeronimoACE.java | 18 ++ .../org/apache/tuscany/geronimoace/LocalNode.java | 120 ++++++++------ .../apache/tuscany/geronimoace/ManageNodes.java | 183 +++++++++++++-------- .../src/main/webapp/WEB-INF/geronimo-web.xml | 106 ++++++------ .../geronimo_ACE/src/main/webapp/pages/Cloud.jsp | 2 +- .../src/main/webapp/pages/Composite.html | 29 ++-- .../src/main/webapp/pages/Standalone.jsp | 107 +++++++++--- .../geronimo_ACE/src/main/webapp/pages/header.jsp | 5 + 8 files changed, 364 insertions(+), 206 deletions(-) (limited to 'sandbox/thilina') diff --git a/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java index f7cb2d72cc..b8a27cc719 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java +++ b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java @@ -44,6 +44,17 @@ public class GeronimoACE extends GenericPortlet { manager.serviceRequest(loc, nodeName, composite); this.getPortletContext().setAttribute("managenodes", manager); + + } + + public void startStopNode(String start, String stop, String nodeName) { + String tempNodeName = nodeName.substring(0, nodeName.length() - 1); + ManageNodes manager = (ManageNodes) this.getPortletContext().getAttribute("managenodes"); + if (start != null) { + manager.startNode(tempNodeName); + } else if (stop != null) { + manager.stopNode(tempNodeName); + } } public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException { @@ -52,6 +63,9 @@ public class GeronimoACE extends GenericPortlet { String location = request.getParameter("contributionLocation"); String nodeName = request.getParameter("nodeName"); String composite = request.getParameter("composite"); + String start = request.getParameter("StartStandaloneNode"); + String stop = request.getParameter("StopStandaloneNode"); + String tempNodeName = request.getParameter("nodeName"); if (task != null) { @@ -78,6 +92,10 @@ public class GeronimoACE extends GenericPortlet { manageStandaloneNode(location, nodeName, composite); } + if (start != null || stop != null) { + startStopNode(start, stop, tempNodeName); + } + response.setPortletMode(PortletMode.VIEW); // by changing portlet mode, doview methos is called again. diff --git a/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java index 85d54dd03e..cdb708c19e 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java +++ b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java @@ -1,49 +1,71 @@ -/* - * 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.geronimoace; - -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode2; - -import java.util.ArrayList; - - -public class LocalNode { - - private SCANode2 node; - private ArrayList contributionList = new ArrayList(); - - public LocalNode(SCANode2 node) { - this.node = node; - } - - public void addContribution(SCAContribution contr) { - contributionList.add(contr); - } - - public ArrayList getContributionList() { - return contributionList; - } - - - public SCANode2 getNode() { - return node; - } -} +/* + * 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.geronimoace; + +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode2; + +import java.util.ArrayList; + + +public class LocalNode { + + private SCANode2 node; + private String nodeName; + private boolean isStarted; + private ArrayList contributionList = new ArrayList(); + + public LocalNode(SCANode2 node) { + this.node = node; + } + + public void setName(String nm) { + this.nodeName = nm; + } + + public void setIsStarted(boolean value) { + isStarted = value; + } + + public boolean getIsStarted() { + return isStarted; + } + + public String getName() { + return this.nodeName; + } + + public void addContribution(SCAContribution contr) { + contributionList.add(contr); + } + + public void setContributionList(ArrayList list) { + this.contributionList = list; + } + + public ArrayList getContributionList() { + return contributionList; + } + + + public SCANode2 getNode() { + return node; + } +} diff --git a/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java index c6a726ddd2..6250378157 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java +++ b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java @@ -1,68 +1,115 @@ -/* - * 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.geronimoace; - -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode2; -import org.apache.tuscany.sca.node.SCANode2Factory; - -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Map; - - -public class ManageNodes { - - Map nodeList = new Hashtable(); - - private SCANode2Factory factory; - - public ManageNodes() { - factory = SCANode2Factory.newInstance(); - } - - public void serviceRequest(String loc, String nodeName, String composite) { - if (nodeList.containsKey(nodeName)) { - LocalNode topNode = nodeList.get(nodeName); - SCANode2 tempNode = topNode.getNode(); - tempNode.stop(); - - SCAContribution contribution = new SCAContribution(nodeName, "file:" + loc); - ArrayList contributionList = topNode.getContributionList(); - contributionList.add(contribution); - SCAContribution[] tempArray = new SCAContribution[contributionList.size()]; - for (int i = 0; i < contributionList.size(); i++) { - tempArray[i] = contributionList.get(i); - } - SCANode2 node = factory.createSCANode(composite, tempArray); - nodeList.remove(nodeName); - nodeList.put(nodeName, new LocalNode(node)); - node.start(); - - } else { - SCAContribution contribution = new SCAContribution(nodeName, "file:" + loc); - SCANode2 node = factory.createSCANode(composite, new SCAContribution[]{contribution}); - nodeList.put(nodeName, new LocalNode(node)); - node.start(); - } - } - - -} +/* + * 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.geronimoace; + +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode2; +import org.apache.tuscany.sca.node.SCANode2Factory; + +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.List; +import java.util.Map; + + +public class ManageNodes { + + Map nodeList = new Hashtable(); + List nodeSet = new ArrayList(); + + private SCANode2Factory factory; + + public ManageNodes() { + factory = SCANode2Factory.newInstance(); + } + + public Map getNodeList() { + return nodeList; + } + + public List getNodeSet() { + return nodeSet; + } + + public void startNode(String nodeName) { + LocalNode lnode = nodeList.get(nodeName); + if (!lnode.getIsStarted()) { + nodeList.get(nodeName).getNode().start(); + lnode.setIsStarted(true); + System.out.println("Node " + nodeName + " is now started"); + } else { + System.out.println("Node " + nodeName + " is already started"); + } + } + + public void stopNode(String nodeName) { + LocalNode lnode = nodeList.get(nodeName); + if (lnode.getIsStarted()) { + nodeList.get(nodeName).getNode().stop(); + lnode.setIsStarted(false); + System.out.println("Node " + nodeName + " is now stopped"); + } else { + System.out.println("Node " + nodeName + " is already stopped"); + } + } + + public void serviceRequest(String loc, String nodeName, String composite) { + if (nodeList.containsKey(nodeName)) { + LocalNode topNode = nodeList.get(nodeName); + SCANode2 tempNode = topNode.getNode(); + tempNode.stop(); + topNode.setIsStarted(false); + + SCAContribution contribution = new SCAContribution(nodeName, "file:" + loc); + ArrayList contributionList = topNode.getContributionList(); + contributionList.add(contribution); + SCAContribution[] tempArray = new SCAContribution[contributionList.size()]; + + for (int i = 0; i < contributionList.size(); i++) { + tempArray[i] = contributionList.get(i); + } + + SCANode2 node = factory.createSCANode(composite, tempArray); + LocalNode tempLocalNode = new LocalNode(node); + tempLocalNode.setName(nodeName); + tempLocalNode.setContributionList(contributionList); + nodeList.remove(nodeName); + nodeSet.remove(topNode); + nodeList.put(nodeName, tempLocalNode); + nodeSet.add(tempLocalNode); + node.start(); + tempLocalNode.setIsStarted(true); + + } else { + SCAContribution contribution = new SCAContribution(nodeName, "file:" + loc); + SCANode2 node = factory.createSCANode(composite, new SCAContribution[]{contribution}); + LocalNode tempLocalNode = new LocalNode(node); + tempLocalNode.setName(nodeName); + tempLocalNode.addContribution(contribution); + + nodeList.put(nodeName, tempLocalNode); + nodeSet.add(tempLocalNode); + node.start(); + tempLocalNode.setIsStarted(true); + } + } + + +} diff --git a/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml b/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml index f8767a7327..e5752f7155 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml +++ b/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml @@ -1,53 +1,53 @@ - - - - - - - - org.apache.tuscany.geronimoace - geronimo-ace - 1.0-SNAPSHOT - war - - - - - org.apache.geronimo.plugins - pluto-support - - - - - - - /GeronimoACE - - - - Tuscany ACE - /GeronimoACE - [GeronimoACE] - - PlutoPortalServices - - - - + + + + + + + + org.apache.tuscany.geronimoace + geronimo-ace + 1.0-SNAPSHOT + war + + + + + org.apache.geronimo.plugins + pluto-support + + + + + + + /GeronimoACE + + + + Tuscany ACE + /GeronimoACE + [GeronimoACE] + + PlutoPortalServices + + + + diff --git a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Cloud.jsp b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Cloud.jsp index c264528092..92e347d013 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Cloud.jsp +++ b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Cloud.jsp @@ -363,7 +363,7 @@ function init() { Composite namespace: - e.g. http://your/namespace + e.g. http://your/namespace Composite name: diff --git a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Composite.html b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Composite.html index 164ea2e6b4..512a952fd2 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Composite.html +++ b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Composite.html @@ -67,17 +67,18 @@ function getCompositesResponse(feed) { content = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue; } var components = ''; - var bs = content.indexOf(''); http://localhost:8080/console/portal//Tuscany ACE/__pm0x3GeronimoACE0x2GeronimoACE!353877598|0_view - if (bs != -1) { - var es = content.indexOf('', bs); - components = content.substring(bs, es + 7); - } else { - bs = content.indexOf('', bs); - components = content.substring(bs, es + 7); - } - } + var bs = content.indexOf(''); + http://localhost:8080/console/portal//Tuscany ACE/__pm0x3GeronimoACE0x2GeronimoACE!353877598|0_view + if (bs != -1) { + var es = content.indexOf('', bs); + components = content.substring(bs, es + 7); + } else { + bs = content.indexOf('', bs); + components = content.substring(bs, es + 7); + } + } composites += '' composites += ''; @@ -104,7 +105,7 @@ function deleteComposite() { } function deleteCompositeResponse() { - + getComposites(); } @@ -204,9 +205,9 @@ function suggestContributionURIs() { } return array(uris); } - function echo(){ +function echo() { - } +} function init() { toolbar(); diff --git a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Standalone.jsp b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Standalone.jsp index 120d7583eb..feaf41d156 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Standalone.jsp +++ b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/Standalone.jsp @@ -1,25 +1,90 @@ <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ include file="header.jsp" %> - Simple jsp page - -
- - - - - - - - - - - - - -
Contribution Location :
Name of the node :
Composite :
- -
- - +Simple jsp page + + + +
+ + + + + + + + + + + + + + + + +

+
Contribution Location :
Name of the node :
Composite :
+ + + +
+ +
+ + Manage Nodes + + + + + + + + + <% ManageNodes mNodes = (ManageNodes) application.getAttribute("managenodes"); + List nodeSet = mNodes.getNodeSet(); + Iterator iterator = nodeSet.iterator(); + if (iterator.hasNext() == false) { %> + + + + + + <% + } + while (iterator.hasNext()) { + LocalNode temp = iterator.next(); + + %> + + + + + + + + + <% + } + %> + +
NodeContributionsStart Nodestop Node
+ +
+ <%= + temp.getName() + %> + + + <% Iterator contributionList = temp.getContributionList().iterator(); + while (contributionList.hasNext()) { %> + + + <%=contributionList.next().getLocation()%> + +
+ <% + } %>
+
/>
+
+ \ No newline at end of file diff --git a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/header.jsp b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/header.jsp index b202ba1d57..b9fbcce8e9 100644 --- a/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/header.jsp +++ b/sandbox/thilina/geronimo_ACE/src/main/webapp/pages/header.jsp @@ -1,3 +1,8 @@ +<%@ page import="org.apache.tuscany.geronimoace.LocalNode" %> +<%@ page import="org.apache.tuscany.geronimoace.ManageNodes" %> +<%@ page import="org.apache.tuscany.sca.node.SCAContribution" %> +<%@ page import="java.util.Iterator" %> +<%@ page import="java.util.List" %>