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
This commit is contained in:
antelder 2008-08-18 12:01:31 +00:00
parent 70aa266cc4
commit ef7c242492
8 changed files with 363 additions and 205 deletions

View file

@ -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.

View file

@ -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<SCAContribution> contributionList = new ArrayList<SCAContribution>();
public LocalNode(SCANode2 node) {
this.node = node;
}
public void addContribution(SCAContribution contr) {
contributionList.add(contr);
}
public ArrayList<SCAContribution> 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<SCAContribution> contributionList = new ArrayList<SCAContribution>();
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<SCAContribution> list) {
this.contributionList = list;
}
public ArrayList<SCAContribution> getContributionList() {
return contributionList;
}
public SCANode2 getNode() {
return node;
}
}

View file

@ -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<String, LocalNode> nodeList = new Hashtable<String, LocalNode>();
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<SCAContribution> 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<String, LocalNode> nodeList = new Hashtable<String, LocalNode>();
List<LocalNode> nodeSet = new ArrayList<LocalNode>();
private SCANode2Factory factory;
public ManageNodes() {
factory = SCANode2Factory.newInstance();
}
public Map<String, LocalNode> getNodeList() {
return nodeList;
}
public List<LocalNode> 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<SCAContribution> 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);
}
}
}

View file

@ -1,53 +1,53 @@
<!--
~ 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.
-->
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2">
<environment>
<moduleId>
<groupId>org.apache.tuscany.geronimoace</groupId>
<artifactId>geronimo-ace</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</moduleId>
<dependencies>
<dependency> <!-- Put a dependancy on the hosting portal (pluto) -->
<groupId>org.apache.geronimo.plugins</groupId>
<artifactId>pluto-support</artifactId>
</dependency>
</dependencies>
</environment>
<!-- This is where the files are accessed from. (aka - portletContext) -->
<context-root>/GeronimoACE</context-root>
<!-- Start off a ACEGBean, this is the lifecycle for the portlet -->
<gbean name="PlutoTest" class="org.apache.geronimo.pluto.AdminConsoleExtensionGBean">
<attribute name="pageTitle">Tuscany ACE</attribute>
<attribute name="portletContext">/GeronimoACE</attribute>
<attribute name="portletList">[GeronimoACE]</attribute>
<reference name="PortalContainerServices">
<name>PlutoPortalServices</name>
</reference>
</gbean>
</web-app>
<!--
~ 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.
-->
<web-app xmlns="http://geronimo.apache.org/xml/ns/j2ee/web-1.2">
<environment>
<moduleId>
<groupId>org.apache.tuscany.geronimoace</groupId>
<artifactId>geronimo-ace</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</moduleId>
<dependencies>
<dependency> <!-- Put a dependancy on the hosting portal (pluto) -->
<groupId>org.apache.geronimo.plugins</groupId>
<artifactId>pluto-support</artifactId>
</dependency>
</dependencies>
</environment>
<!-- This is where the files are accessed from. (aka - portletContext) -->
<context-root>/GeronimoACE</context-root>
<!-- Start off a ACEGBean, this is the lifecycle for the portlet -->
<gbean name="PlutoTest" class="org.apache.geronimo.pluto.AdminConsoleExtensionGBean">
<attribute name="pageTitle">Tuscany ACE</attribute>
<attribute name="portletContext">/GeronimoACE</attribute>
<attribute name="portletList">[GeronimoACE]</attribute>
<reference name="PortalContainerServices">
<name>PlutoPortalServices</name>
</reference>
</gbean>
</web-app>

View file

@ -363,7 +363,7 @@ function init() {
<tr>
<td>Composite namespace:</td>
<td><input type="text" name="compositeNamespace" size="50"/></td>
<td>e.g. http://your/namespace</td>
<td>e.g. http://your/namespace</td>
</tr>
<tr>
<td>Composite name:</td>

View file

@ -67,17 +67,18 @@ function getCompositesResponse(feed) {
content = entries[i].getElementsByTagName("content")[0].firstChild.nodeValue;
}
var components = '';
var bs = content.indexOf('<span id="components">'); http://localhost:8080/console/portal//Tuscany ACE/__pm0x3GeronimoACE0x2GeronimoACE!353877598|0_view
if (bs != -1) {
var es = content.indexOf('</span>', bs);
components = content.substring(bs, es + 7);
} else {
bs = content.indexOf('<span id="problem"');
if (bs != -1) {
var es = content.indexOf('</span>', bs);
components = content.substring(bs, es + 7);
}
}
var bs = content.indexOf('<span id="components">');
http://localhost:8080/console/portal//Tuscany ACE/__pm0x3GeronimoACE0x2GeronimoACE!353877598|0_view
if (bs != -1) {
var es = content.indexOf('</span>', bs);
components = content.substring(bs, es + 7);
} else {
bs = content.indexOf('<span id="problem"');
if (bs != -1) {
var es = content.indexOf('</span>', bs);
components = content.substring(bs, es + 7);
}
}
composites += '<tr>'
composites += '<td><input name="composites" type="checkbox" value="' + id + '">';
@ -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();

View file

@ -1,25 +1,90 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="header.jsp" %>
<html>
<head><title>Simple jsp page</title></head>
<body>
<form id="form1" name="form1" method="post" action="<portlet:actionURL/>">
<table>
<tr>
<td>Contribution Location :</td>
<td><input type="text" name="contributionLocation" size="100"/></td>
</tr>
<tr>
<td>Name of the node :</td>
<td><input type="text" name="nodeName" size="100"/></td>
</tr>
<tr>
<td>Composite :</td>
<td><input type="text" name="composite" size="100"/></td>
</tr>
</table>
<input type="submit" name="addStandaloneNode" value="start"/>
</form>
<head><title>Simple jsp page</title></head>
<body>
</body>
<form id="form1" name="form1" method="post" action="<portlet:actionURL/>">
<table>
<tr>
<td>Contribution Location :</td>
<td><input type="text" name="contributionLocation" size="100"/></td>
</tr>
<tr>
<td>Name of the node :</td>
<td><input type="text" name="nodeName" size="100"/></td>
</tr>
<tr>
<td>Composite :</td>
<td><input type="text" name="composite" size="100"/></td>
</tr>
<br><br>
</table>
<input type="submit" name="addStandaloneNode" value="start"/>
</form>
<form id="form2" name="form2" method="post" action="<portlet:actionURL/>">
<table width="100%">
<thead><b> Manage Nodes</b></thead>
<tbody>
<tr>
<th>Node</th>
<th>Contributions</th>
<th>Start Node</th>
<th>stop Node</th>
</tr>
<% ManageNodes mNodes = (ManageNodes) application.getAttribute("managenodes");
List<LocalNode> nodeSet = mNodes.getNodeSet();
Iterator<LocalNode> iterator = nodeSet.iterator();
if (iterator.hasNext() == false) { %>
<tr>
<td>
</td>
</tr>
<%
}
while (iterator.hasNext()) {
LocalNode temp = iterator.next();
%>
<tr>
<td>
<%=
temp.getName()
%>
</td>
<td>
<table>
<% Iterator<SCAContribution> contributionList = temp.getContributionList().iterator();
while (contributionList.hasNext()) { %>
<tr>
<%=contributionList.next().getLocation()%>
</tr>
<br>
<%
} %></table>
</td>
<td><input type="hidden" name="nodeName" value=<%=temp.getName()%>/></td>
<td><input type="submit" name="StartStandaloneNode" value="start"/></td>
<td><input type="submit" name="StopStandaloneNode" value="stop"/></td>
</tr>
<%
}
%>
</tbody>
</table>
</form>
</body>
</html>

View file

@ -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" %>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file