ace-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ange...@apache.org
Subject svn commit: r1084844 - in /incubator/ace/trunk: ace-target-devserver/src/main/resources/conf/ ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/
Date Thu, 24 Mar 2011 04:38:00 GMT
Author: angelos
Date: Thu Mar 24 04:38:00 2011
New Revision: 1084844

URL: http://svn.apache.org/viewvc?rev=1084844&view=rev
Log:
The Vaadin UI can now be configured to point to other ACE servers or other ports.

Added:
    incubator/ace/trunk/ace-target-devserver/src/main/resources/conf/org.apache.ace.webui.vaadin.cfg
Modified:
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
    incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinServlet.java

Added: incubator/ace/trunk/ace-target-devserver/src/main/resources/conf/org.apache.ace.webui.vaadin.cfg
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-target-devserver/src/main/resources/conf/org.apache.ace.webui.vaadin.cfg?rev=1084844&view=auto
==============================================================================
--- incubator/ace/trunk/ace-target-devserver/src/main/resources/conf/org.apache.ace.webui.vaadin.cfg
(added)
+++ incubator/ace/trunk/ace-target-devserver/src/main/resources/conf/org.apache.ace.webui.vaadin.cfg
Thu Mar 24 04:38:00 2011
@@ -0,0 +1,2 @@
+aceHost = http://localhost:8080/
+obrUrl = http://localhost:8080/obr/
\ No newline at end of file

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java?rev=1084844&r1=1084843&r2=1084844&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/Activator.java
Thu Mar 24 04:38:00 2011
@@ -55,6 +55,7 @@ public class Activator extends Dependenc
         manager.add(createComponent()
             .setInterface(HttpServlet.class.getName(), props)
             .setImplementation(VaadinServlet.class)
+            .add(createConfigurationDependency().setPid(VaadinServlet.PID))
         );
         
         // shows off components that are contributed by extensions

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java?rev=1084844&r1=1084843&r2=1084844&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinClient.java
Thu Mar 24 04:38:00 2011
@@ -33,6 +33,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.xml.xpath.XPath;
 import javax.xml.xpath.XPathConstants;
@@ -134,9 +135,10 @@ public class VaadinClient extends com.va
     private static String shopRepo = "shop";
     private static String deployRepo = "deployment";
     private static String customerName = "apache";
-    private static String hostName = "http://localhost:8080";
     private static String endpoint = "/repository";
-    private static String obr = "http://localhost:8080/obr/";
+
+    private URL m_aceHost;
+    private URL m_obrUrl;
 
     private volatile DependencyManager m_manager;
     private volatile BundleContext m_context;
@@ -167,12 +169,17 @@ public class VaadinClient extends com.va
     
     private boolean m_dynamicRelations = true;
 	private File m_sessionDir; // private folder for session info
-	private boolean m_dependenciesResolved = false;
+	private final AtomicBoolean m_dependenciesResolved = new AtomicBoolean(false);
 
     // basic session ID generator
     private static long generateSessionID() {
         return SESSION_ID++;
     }
+
+    public VaadinClient(URL aceHost, URL obrUrl) {
+        m_aceHost = aceHost;
+        m_obrUrl = obrUrl;
+    }
     
     public void setupDependencies(Component component) {
         m_sessionID = "" + generateSessionID();
@@ -199,21 +206,12 @@ public class VaadinClient extends com.va
     }
     
     public void start() {
-        synchronized (this) {
-        	m_dependenciesResolved = true;
-        }
-    }
-    
-    public boolean areDependenciesResolved() {
-        synchronized (this) {
-        	return m_dependenciesResolved;
-        }
+        System.out.println("Starting " + m_sessionID);
+        m_dependenciesResolved.set(true);
     }
     
     public void stop() {
-        synchronized (this) {
-        	m_dependenciesResolved = false;
-        }
+        m_dependenciesResolved.set(false);
     }
     
     public void destroyDependencies() {
@@ -224,7 +222,7 @@ public class VaadinClient extends com.va
     
     public void init() {
         setTheme("ace");
-        if (!areDependenciesResolved()) {
+        if (!m_dependenciesResolved.get()) {
         	final Window message = new Window("Apache ACE");
         	setMainWindow(message);
             message.getContent().setSizeFull();
@@ -402,7 +400,7 @@ public class VaadinClient extends com.va
         });
         return addArtifactButton;
     }
-    
+
     public class LoginWindow extends Window {
         private TextField m_name;
         private PasswordField m_password;
@@ -465,10 +463,10 @@ public class VaadinClient extends com.va
             }
             RepositoryAdminLoginContext context = m_admin.createLoginContext(user);
             
-            context.addShopRepository(new URL(hostName + endpoint), customerName, shopRepo,
true)
-                .setObrBase(new URL(obr))
-                .addGatewayRepository(new URL(hostName + endpoint), customerName, gatewayRepo,
true)
-                .addDeploymentRepository(new URL(hostName + endpoint), customerName, deployRepo,
true);
+            context.addShopRepository(new URL(m_aceHost, endpoint), customerName, shopRepo,
true)
+                .setObrBase(m_obrUrl)
+                .addGatewayRepository(new URL(m_aceHost, endpoint), customerName, gatewayRepo,
true)
+                .addDeploymentRepository(new URL(m_aceHost, endpoint), customerName, deployRepo,
true);
             m_admin.login(context);
             m_admin.checkout();
             return true;
@@ -1285,19 +1283,17 @@ public class VaadinClient extends com.va
     }
     
     public void getBundles(Table table) throws Exception {
-        getBundles(table, "http://localhost:8080/obr/");
+        getBundles(table, m_obrUrl);
     }
     
-    public void getBundles(Table table, String obrBaseUrl) throws Exception {
-        URL obrBase = new URL(obrBaseUrl);
-        
+    public void getBundles(Table table, URL obrBaseUrl) throws Exception {
         // retrieve the repository.xml as a stream
         URL url = null;
         try {
-            url = new URL(obrBase, "repository.xml");
+            url = new URL(obrBaseUrl, "repository.xml");
         }
         catch (MalformedURLException e) {
-            m_log.log(LogService.LOG_ERROR, "Error retrieving repository.xml from " + obrBase);
+            m_log.log(LogService.LOG_ERROR, "Error retrieving repository.xml from " + obrBaseUrl);
             throw e;
         }
 
@@ -1349,7 +1345,7 @@ public class VaadinClient extends com.va
         artifactObjects.addAll(m_artifactRepository.getResourceProcessors());
         for (ArtifactObject ao : artifactObjects) {
             String artifactURL = ao.getURL();
-            if (artifactURL.startsWith(obrBase.toExternalForm())) {
+            if (artifactURL.startsWith(obrBaseUrl.toExternalForm())) {
                 // we now know this artifact comes from the OBR we are querying, so we are
interested.
                 fromRepository.add(new OBREntry(ao.getName(), ao.getAttribute(BundleHelper.KEY_VERSION),
new File(artifactURL).getName()));
             }
@@ -1389,7 +1385,7 @@ public class VaadinClient extends com.va
     }
 
     public ArtifactObject importBundle(OBREntry bundle) throws IOException {
-        return m_artifactRepository.importArtifact(new URL(new URL(obr), bundle.getUri()),
false);
+        return m_artifactRepository.importArtifact(new URL(m_obrUrl, bundle.getUri()), false);
     }
     
     public ArtifactObject importBundle(URL artifact) throws IOException {

Modified: incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinServlet.java
URL: http://svn.apache.org/viewvc/incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinServlet.java?rev=1084844&r1=1084843&r2=1084844&view=diff
==============================================================================
--- incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinServlet.java
(original)
+++ incubator/ace/trunk/ace-webui-vaadin/src/main/java/org/apache/ace/webui/vaadin/VaadinServlet.java
Thu Mar 24 04:38:00 2011
@@ -23,15 +23,28 @@ import javax.servlet.http.HttpServletReq
 
 import org.apache.ace.client.repository.SessionFactory;
 import org.apache.felix.dm.DependencyManager;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ManagedService;
 import org.osgi.service.log.LogService;
 import org.osgi.service.useradmin.UserAdmin;
 
 import com.vaadin.Application;
 import com.vaadin.terminal.gwt.server.AbstractApplicationServlet;
 
-public class VaadinServlet extends AbstractApplicationServlet {
-	private static final long serialVersionUID = 1L;
-	private volatile DependencyManager m_manager;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Dictionary;
+
+public class VaadinServlet extends AbstractApplicationServlet implements ManagedService {
+    private static final long serialVersionUID = 1L;
+    public static final String PID = "org.apache.ace.webui.vaadin";
+    public static final String ACE_HOST = "aceHost";
+    public static final String OBR_URL = "obrUrl";
+
+    private volatile DependencyManager m_manager;
+
+    private volatile URL m_aceHost;
+    private volatile URL m_obrUrl;
     
     @Override
     protected Class<? extends Application> getApplicationClass() {
@@ -40,7 +53,7 @@ public class VaadinServlet extends Abstr
 
     @Override
     protected Application getNewApplication(HttpServletRequest request)	throws ServletException
{
-        Application application = new VaadinClient();
+        Application application = new VaadinClient(m_aceHost, m_obrUrl);
         m_manager.add(m_manager.createComponent()
             .setImplementation(application)
             .setCallbacks("setupDependencies", "start", "stop", "destroyDependencies")
@@ -59,4 +72,37 @@ public class VaadinServlet extends Abstr
         );
         return application;
     }
+
+    public void updated(Dictionary dictionary) throws ConfigurationException {
+        System.out.println("There's a config! "+ dictionary);
+        if (dictionary != null) {
+            URL aceHost;
+            try {
+                String aceHostString = (String) dictionary.get(ACE_HOST);
+                if (aceHostString == null) {
+                    throw new ConfigurationException(ACE_HOST, "Missing property");
+                }
+                aceHost = new URL(aceHostString);
+            }
+            catch (MalformedURLException e) {
+                throw new ConfigurationException(ACE_HOST, "Is not a valid URL", e);
+            }
+
+            URL obrUrl;
+            try {
+                String obrUrlString = (String) dictionary.get(OBR_URL);
+                if (obrUrlString == null) {
+                    throw new ConfigurationException(OBR_URL, "Missing property");
+                }
+                obrUrl = new URL(obrUrlString);
+            }
+            catch (MalformedURLException e) {
+                throw new ConfigurationException(OBR_URL, "Is not a valid URL", e);
+            }
+
+            m_aceHost = aceHost;
+            m_obrUrl = obrUrl;
+        }
+    }
+
 }



Mime
View raw message