From 51709cd9fddb952df338119e25f74f25d1ff99fc Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 16 Aug 2008 07:23:27 +0000 Subject: TUSCANY-2391: Apply 'managing_nodes' patch from Thilina Buddhika for Tuscany SCA support in the Geronimo Admin Console git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@686458 13f79535-47bb-0310-9956-ffa450edef68 --- sandbox/thilina/geronimo_ACE/pom.xml | 10 ++++ .../apache/tuscany/geronimoace/GeronimoACE.java | 23 ++++---- .../org/apache/tuscany/geronimoace/LocalNode.java | 49 ++++++++++++++++ .../apache/tuscany/geronimoace/ManageNodes.java | 68 ++++++++++++++++++++++ .../src/main/webapp/WEB-INF/geronimo-web.xml | 2 + 5 files changed, 142 insertions(+), 10 deletions(-) create mode 100644 sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java create mode 100644 sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java (limited to 'sandbox/thilina') diff --git a/sandbox/thilina/geronimo_ACE/pom.xml b/sandbox/thilina/geronimo_ACE/pom.xml index 2ee343dffd..51c99a93b0 100644 --- a/sandbox/thilina/geronimo_ACE/pom.xml +++ b/sandbox/thilina/geronimo_ACE/pom.xml @@ -102,6 +102,16 @@ install + + + maven-compiler-plugin + true + + 1.5 + 1.5 + + + ${basedir}/target ${artifactId}-${version} 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 4808434c2d..f7cb2d72cc 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 @@ -19,11 +19,6 @@ package org.apache.tuscany.geronimoace; -import org.apache.tuscany.sca.host.embedded.SCADomain; -import org.apache.tuscany.sca.node.SCAContribution; -import org.apache.tuscany.sca.node.SCANode2; -import org.apache.tuscany.sca.node.SCANode2Factory; - import javax.portlet.*; import java.io.IOException; @@ -34,15 +29,20 @@ public class GeronimoACE extends GenericPortlet { public void init(PortletConfig config) throws PortletException { super.init(config); + config.getPortletContext().setAttribute("managenodes", new ManageNodes()); + } - public void manageStandaloneNode(String loc, String nodeName, String composite){ + public void manageStandaloneNode(String loc, String nodeName, String composite) { - SCANode2Factory factory = org.apache.tuscany.sca.node.SCANode2Factory.newInstance(); - + /*SCANode2Factory factory = org.apache.tuscany.sca.node.SCANode2Factory.newInstance(); SCAContribution contribution = new SCAContribution(nodeName, "file:"+loc); SCANode2 node = factory.createSCANode(composite, new SCAContribution[] {contribution}); - node.start(); + + node.start(); */ + ManageNodes manager = (ManageNodes) this.getPortletContext().getAttribute("managenodes"); + manager.serviceRequest(loc, nodeName, composite); + this.getPortletContext().setAttribute("managenodes", manager); } @@ -57,6 +57,7 @@ public class GeronimoACE extends GenericPortlet { if (task != null) { if (task.equals("composites")) { // if the request is for Composites,forwarding to Composites.html viewUrl = "/pages/Composite.jsp"; + System.out.println("sys:" + this.getPortletContext().getAttribute("test")); } if (task.equals("StandaloneNode")) { // if the request is for Composites,forwarding to Composites.html viewUrl = "/pages/Standalone.jsp"; @@ -66,12 +67,14 @@ public class GeronimoACE extends GenericPortlet { } if (task.equals("cloud")) { // if the request is for Clouds,forwarding to Cloud.html viewUrl = "/pages/Cloud.jsp"; + this.getPortletContext().setAttribute("test", "hello"); + } if (task.equals("files")) { // iif the request is for Files,forwarding to Files.html viewUrl = "/pages/Files.jsp"; } } - if (location != null){ + if (location != null) { manageStandaloneNode(location, nodeName, composite); } 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 new file mode 100644 index 0000000000..85d54dd03e --- /dev/null +++ b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java @@ -0,0 +1,49 @@ +/* + * 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; + } +} 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 new file mode 100644 index 0000000000..c6a726ddd2 --- /dev/null +++ b/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java @@ -0,0 +1,68 @@ +/* + * 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(); + } + } + + +} 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 bfb6edd2c6..f8767a7327 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,3 +1,4 @@ +