Author: antelder
Date: Sat Aug 16 00:23:27 2008
New Revision: 686458

URL: http://svn.apache.org/viewvc?rev=686458&view=rev
Log:
TUSCANY-2391: Apply 'managing_nodes' patch from Thilina Buddhika for Tuscany 
SCA support in the Geronimo Admin Console

Added:
    
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java
    
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java
Modified:
    tuscany/sandbox/thilina/geronimo_ACE/pom.xml
    
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java
    
tuscany/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml

Modified: tuscany/sandbox/thilina/geronimo_ACE/pom.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/thilina/geronimo_ACE/pom.xml?rev=686458&r1=686457&r2=686458&view=diff
==============================================================================
--- tuscany/sandbox/thilina/geronimo_ACE/pom.xml (original)
+++ tuscany/sandbox/thilina/geronimo_ACE/pom.xml Sat Aug 16 00:23:27 2008
@@ -102,6 +102,16 @@
     </dependencies>
     <build>
         <defaultGoal>install</defaultGoal>
+        <plugins>
+                    <plugin>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <inherited>true</inherited>
+                        <configuration>
+                            <source>1.5</source>
+                            <target>1.5</target>
+                        </configuration>
+                    </plugin>
+        </plugins>
         <directory>${basedir}/target</directory>
         <finalName>${artifactId}-${version}</finalName>
         <resources>

Modified: 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java?rev=686458&r1=686457&r2=686458&view=diff
==============================================================================
--- 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java
 (original)
+++ 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/GeronimoACE.java
 Sat Aug 16 00:23:27 2008
@@ -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 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 @@
         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 @@
             }
             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);
         }
 

Added: 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java?rev=686458&view=auto
==============================================================================
--- 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java
 (added)
+++ 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/LocalNode.java
 Sat Aug 16 00:23:27 2008
@@ -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<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;
+    }
+}

Added: 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java?rev=686458&view=auto
==============================================================================
--- 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java
 (added)
+++ 
tuscany/sandbox/thilina/geronimo_ACE/src/main/java/org/apache/tuscany/geronimoace/ManageNodes.java
 Sat Aug 16 00:23:27 2008
@@ -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<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();
+        }
+    }
+
+
+}

Modified: 
tuscany/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml
URL: 
http://svn.apache.org/viewvc/tuscany/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml?rev=686458&r1=686457&r2=686458&view=diff
==============================================================================
--- 
tuscany/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml 
(original)
+++ 
tuscany/sandbox/thilina/geronimo_ACE/src/main/webapp/WEB-INF/geronimo-web.xml 
Sat Aug 16 00:23:27 2008
@@ -1,3 +1,4 @@
+
 <!--
   ~ Licensed to the Apache Software Foundation (ASF) under one
   ~ or more contributor license agreements.  See the NOTICE file
@@ -49,3 +50,4 @@
         </reference>
     </gbean>
 </web-app>
+


Reply via email to