Removal of launcher, and web sockets modules. They aren't supposed at this point in time. Also removed netty and hazelcast dependencies
Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/6df86b4a Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/6df86b4a Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/6df86b4a Branch: refs/heads/USERGRID-1246-MASTER Commit: 6df86b4aeae58a3362260d1f6cd3945396ae15d2 Parents: 13117ca Author: George Reyes <g...@apache.org> Authored: Thu Apr 28 14:32:23 2016 -0700 Committer: George Reyes <g...@apache.org> Committed: Mon May 2 10:49:34 2016 -0700 ---------------------------------------------------------------------- stack/core/pom.xml | 5 - stack/launcher/README.txt | 23 - stack/launcher/launch | 29 - stack/launcher/pom.xml | 273 ------- .../java/org/apache/usergrid/launcher/App.java | 290 -------- .../apache/usergrid/launcher/AppleUtils.java | 42 -- .../launcher/CustomJSPTemplateProcessor.java | 137 ---- .../usergrid/launcher/EmbeddedServerHelper.java | 193 ----- .../org/apache/usergrid/launcher/JarMain.java | 39 - .../apache/usergrid/launcher/LauncherFrame.java | 462 ------------ .../usergrid/launcher/LogViewerFrame.java | 105 --- .../org/apache/usergrid/launcher/Server.java | 620 ---------------- ...thod.dispatch.ResourceMethodDispatchProvider | 0 .../com.sun.jersey.spi.HeaderDelegateProvider | 9 - .../com.sun.jersey.spi.StringReaderProvider | 6 - ...m.sun.jersey.spi.container.ContainerProvider | 2 - ....jersey.spi.container.ContainerRequestFilter | 1 - ...jersey.spi.container.ContainerResponseFilter | 0 ....ResourceMethodCustomInvokerDispatchProvider | 7 - ...spi.container.ResourceMethodDispatchProvider | 6 - ....jersey.spi.container.WebApplicationProvider | 1 - ...com.sun.jersey.spi.inject.InjectableProvider | 6 - .../javax.enterprise.inject.spi.Extension | 1 - .../javax.servlet.ServletContainerInitializer | 1 - .../services/javax.ws.rs.ext.MessageBodyReader | 47 -- .../services/javax.ws.rs.ext.MessageBodyWriter | 41 -- .../services/javax.ws.rs.ext.RuntimeDelegate | 1 - .../services/org.jclouds.apis.ApiMetadata | 2 - .../src/main/resources/META-INF/spring.handlers | 8 - .../src/main/resources/META-INF/spring.schemas | 29 - .../launcher/src/main/resources/cassandra.yaml | 715 ------------------- .../src/main/resources/log4j-server.properties | 35 - .../src/main/resources/log4j.properties | 43 -- .../org/apache/usergrid/launcher/dock_icon.png | Bin 11592 -> 0 bytes .../org/apache/usergrid/launcher/icon_16.png | Bin 3273 -> 0 bytes .../org/apache/usergrid/launcher/icon_256.png | Bin 12578 -> 0 bytes .../org/apache/usergrid/launcher/icon_32.png | Bin 3862 -> 0 bytes .../org/apache/usergrid/launcher/icon_64.png | Bin 5079 -> 0 bytes .../org/apache/usergrid/launcher/log_viewer.png | Bin 6610 -> 0 bytes .../org/apache/usergrid/launcher/start.png | Bin 9253 -> 0 bytes .../apache/usergrid/launcher/start_active.png | Bin 9334 -> 0 bytes .../apache/usergrid/launcher/status_green.png | Bin 2048 -> 0 bytes .../org/apache/usergrid/launcher/status_off.png | Bin 1847 -> 0 bytes .../org/apache/usergrid/launcher/status_red.png | Bin 2047 -> 0 bytes .../apache/usergrid/launcher/status_yellow.png | Bin 2092 -> 0 bytes .../org/apache/usergrid/launcher/stop.png | Bin 8858 -> 0 bytes .../apache/usergrid/launcher/stop_active.png | Bin 8844 -> 0 bytes .../apache/usergrid/launcher/web_browser.png | Bin 4531 -> 0 bytes .../resources/usergrid-standalone-context.xml | 49 -- .../resources/usergrid-standalone.properties | 263 ------- stack/pom.xml | 6 - stack/websocket/README.txt | 49 -- stack/websocket/pom.xml | 208 ------ .../websocket/WebSocketChannelHandler.java | 358 ---------- .../usergrid/websocket/WebSocketKeyStore.java | 50 -- .../usergrid/websocket/WebSocketServer.java | 181 ----- .../websocket/WebSocketServerIndexPage.java | 57 -- .../WebSocketServerPipelineFactory.java | 76 -- .../websocket/WebSocketSslContextFactory.java | 63 -- .../usergrid/websocket/ExampleListener.java | 42 -- .../websocket/SimpleMessageProducer.java | 62 -- .../usergrid/websocket/WebSocketServerTest.java | 44 -- .../src/test/resources/test-activemq.xml | 80 --- .../test/resources/testApplicationContext.xml | 137 ---- 64 files changed, 4904 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/core/pom.xml ---------------------------------------------------------------------- diff --git a/stack/core/pom.xml b/stack/core/pom.xml index ce5b67d..4b8ef55 100644 --- a/stack/core/pom.xml +++ b/stack/core/pom.xml @@ -306,11 +306,6 @@ <artifactId>jline</artifactId> </dependency> - <dependency> - <groupId>org.jboss.netty</groupId> - <artifactId>netty</artifactId> - </dependency> - <!-- Test and Logging Dependencies --> <dependency> http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/README.txt ---------------------------------------------------------------------- diff --git a/stack/launcher/README.txt b/stack/launcher/README.txt deleted file mode 100644 index d301856..0000000 --- a/stack/launcher/README.txt +++ /dev/null @@ -1,23 +0,0 @@ -Usergrid Graphical Server Launcher - -A simple Java app that provides a GUI for running the server as a -desktop app. - -Creates a double-clickable jar. - -Invoked from the command-line like this: - -java -jar usergrid-launcher-${version}.jar -nogui - -To initialize the database: - -java -jar usergrid-launcher-${version}.jar -nogui -init - -To launch an embedded Cassandra server and initialize the database: - -java -jar usergrid-launcher-${version}.jar -nogui -db -init - -The standalone server will load a usergrid-deployment.properties file from the -same location as the jar file. You can override things like the location of -the Cassandra cluster in that file. - http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/launch ---------------------------------------------------------------------- diff --git a/stack/launcher/launch b/stack/launcher/launch deleted file mode 100755 index 1f67c2f..0000000 --- a/stack/launcher/launch +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -# 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. - -# TODO make this a real script that can be executed from any directory - -VERSION=`grep '<parent>' -A 4 pom.xml | grep version | sed -e 's/ *<[\/]*version>//g'` -JVM_OPTS='-Djava.library.path=/tmp -Dorg.xerial.snappy.tempdir=/tmp' - -if [ "$1" == "debug" ]; then - JVM_OPTS="$JVM_OPTS -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005" -fi - -java -jar $JVM_OPTS target/usergrid-launcher-$VERSION.jar - http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/pom.xml ---------------------------------------------------------------------- diff --git a/stack/launcher/pom.xml b/stack/launcher/pom.xml deleted file mode 100644 index d34ced2..0000000 --- a/stack/launcher/pom.xml +++ /dev/null @@ -1,273 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.apache.usergrid</groupId> - <artifactId>usergrid</artifactId> - <version>2.0.0-SNAPSHOT</version> - <relativePath>../</relativePath> - </parent> - - <artifactId>usergrid-launcher</artifactId> - <name>Usergrid Launcher</name> - <description>Usergrid Launcher</description> - <packaging>jar</packaging> - - <properties> - <jar.skipIfEmpty>true</jar.skipIfEmpty> - </properties> - - <build> - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - <includes> - <include>**/*.xml</include> - <include>**/*.png</include> - <include>**/*.yaml</include> - <include>**/*.properties</include> - <include>**/spring.handlers</include> - <include>**/spring.schemas</include> - <include>**/services/**</include> - </includes> - </resource> - </resources> - - <testResources> - <testResource> - <directory>src/test/resources</directory> - <filtering>true</filtering> - <includes> - <include>**/*.xml</include> - </includes> - </testResource> - - <testResource> - <directory>src/test/resources</directory> - <filtering>false</filtering> - <excludes> - <exclude>**/*.xml</exclude> - </excludes> - </testResource> - </testResources> - - <plugins> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - <executions> - <execution> - <id>copy</id> - <phase>prepare-package</phase> - <goals> - <goal>unpack-dependencies</goal> - </goals> - <configuration> - <excludeArtifactIds>junit,AppleJavaExtensions</excludeArtifactIds> - <outputDirectory>${project.build.directory}/classes</outputDirectory> - <excludes>**/spring.handlers, **/spring.schemas, **/META-INF/services/**</excludes> - </configuration> - </execution> - </executions> - </plugin> - - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <phase>package</phase> - <goals> - <goal>jar</goal> - </goals> - </execution> - </executions> - <configuration> - <archive> - <manifest> - <mainClass>org.apache.usergrid.launcher.JarMain</mainClass> - <addDefaultImplementationEntries>true</addDefaultImplementationEntries> - </manifest> - </archive> - <excludes> - <exclude>*.jar</exclude> - </excludes> - </configuration> - </plugin> - - </plugins> - </build> - - <dependencies> - <!-- Usergrid Dependencies --> - - <dependency> - <groupId>org.apache.usergrid</groupId> - <artifactId>usergrid-config</artifactId> - <version>${project.version}</version> - </dependency> - - <dependency> - <groupId>org.apache.usergrid</groupId> - <artifactId>usergrid-rest</artifactId> - <version>${project.version}</version> - <classifier>classes</classifier> - <exclusions> - <exclusion> - <artifactId>servlet-api</artifactId> - <groupId>javax.servlet</groupId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>org.apache.usergrid</groupId> - <artifactId>usergrid-rest</artifactId> - <version>${project.version}</version> - <classifier>compiled-jsp</classifier> - </dependency> - - <!-- Apache Dependencies --> - - <dependency> - <groupId>org.apache.tomcat.embed</groupId> - <artifactId>tomcat-embed-jasper</artifactId> - <exclusions> - <exclusion> - <artifactId>servlet-api</artifactId> - <groupId>org.apache.tomcat</groupId> - </exclusion> - <exclusion> - <groupId>org.apache.tomcat</groupId> - <artifactId>juli</artifactId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - </dependency> - - <!-- SUN, Javax Package, and Other Com/Net Dependencies --> - - <dependency> - <groupId>com.sun.jersey</groupId> - <artifactId>jersey-grizzly2</artifactId> - <exclusions> - <exclusion> - <artifactId>grizzly-http-server</artifactId> - <groupId>org.glassfish.grizzly</groupId> - </exclusion> - - <exclusion> - <artifactId>grizzly-http</artifactId> - <groupId>org.glassfish.grizzly</groupId> - </exclusion> - - <exclusion> - <artifactId>grizzly-http-servlet</artifactId> - <groupId>org.glassfish.grizzly</groupId> - </exclusion> - - <exclusion> - <artifactId>javax.servlet</artifactId> - <groupId>org.glassfish</groupId> - </exclusion> - </exclusions> - </dependency> - - <dependency> - <groupId>javax.annotation</groupId> - <artifactId>jsr250-api</artifactId> - </dependency> - - <dependency> - <groupId>javax.ws.rs</groupId> - <artifactId>jsr311-api</artifactId> - </dependency> - - <dependency> - <groupId>javax.servlet</groupId> - <artifactId>javax.servlet-api</artifactId> - </dependency> - - <!-- Codehaus, Spring, and Other Org Dependencies --> - - <dependency> - <groupId>org.hectorclient</groupId> - <artifactId>hector-test</artifactId> - </dependency> - - <dependency> - <groupId>org.glassfish.grizzly</groupId> - <artifactId>grizzly-http-servlet-server</artifactId> - </dependency> - - <!-- Testing and Logging Dependencies --> - - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-test</artifactId> - <scope>test</scope> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jcl-over-slf4j</artifactId> - </dependency> - - <dependency> - <groupId>org.slf4j</groupId> - <artifactId>jul-to-slf4j</artifactId> - </dependency> - - <dependency> - <artifactId>log4j</artifactId> - <groupId>log4j</groupId> - </dependency> - - <dependency> - <groupId>com.apple</groupId> - <artifactId>AppleJavaExtensions</artifactId> - </dependency> - - <dependency> - <groupId>com.fasterxml.jackson.core</groupId> - <artifactId>jackson-databind</artifactId> - <version>2.3.1</version> - <type>jar</type> - </dependency> - - <dependency> - <groupId>org.mindrot</groupId> - <artifactId>jbcrypt</artifactId> - </dependency> - - </dependencies> -</project> http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/src/main/java/org/apache/usergrid/launcher/App.java ---------------------------------------------------------------------- diff --git a/stack/launcher/src/main/java/org/apache/usergrid/launcher/App.java b/stack/launcher/src/main/java/org/apache/usergrid/launcher/App.java deleted file mode 100644 index 2e436ad..0000000 --- a/stack/launcher/src/main/java/org/apache/usergrid/launcher/App.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * 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.usergrid.launcher; - - -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import java.io.IOException; -import java.util.Arrays; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.prefs.Preferences; -import javax.swing.UIManager; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class App { - - private static final Logger logger = LoggerFactory.getLogger( App.class ); - - // TODO: host portal on Apache infrastructure, or build portal into launcher - private static final String GH_PORTAL_URL = - "http://usergrid.apache.org/v101-portal-demo"; - - public static boolean MAC_OS_X = - ( System.getProperty( "os.name" ).toLowerCase().startsWith( "mac os x" ) ); - - LogViewerFrame logViewer = null; - LauncherFrame launcher = null; - ExecutorService executor = Executors.newSingleThreadExecutor(); - boolean initializeDatabaseOnStart = true; - boolean startDatabaseWithServer = true; - Preferences prefs; - String adminUserEmail = null; - boolean autoLogin = true; - - - public App() { - /* - * super("Launcher"); addComponentsToPane(); pack(); setVisible(true); - */ - } - - - public static void main( String[] args ) { - System.setProperty( "apple.laf.useScreenMenuBar", "true" ); - System.setProperty( "com.apple.mrj.application.apple.menu.about.name", "Usergrid Launcher" ); - System.setProperty( "apple.awt.antialiasing", "true" ); - System.setProperty( "apple.awt.textantialiasing", "true" ); - System.setProperty( "apple.awt.graphics.UseQuartz", "true" ); - try { - UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() ); - } - catch ( Exception e ) { - e.printStackTrace(); - } - - if ( MAC_OS_X ) { - AppleUtils.initMacApp(); - } - - App app = new App(); - app.launch(); - } - - - public void launch() { - loadPrefs(); - - try { - logViewer = new LogViewerFrame( this ); - } - catch ( IOException e ) { - e.printStackTrace(); - } - - launcher = new LauncherFrame( this ); - - logger.info( "App started" ); - // org.apache.usergrid.standalone.Server.main(new String[0]); - } - - - public static ArrayNode getJsonArray( Set<String> strings ) { - ArrayNode node = JsonNodeFactory.instance.arrayNode(); - for ( String string : strings ) { - node.add( string ); - } - return node; - } - - - public void storeUrlsInPreferences( Set<String> urls ) { - ObjectMapper mapper = new ObjectMapper(); - try { - prefs.put( "urlList", mapper.writeValueAsString( getJsonArray( urls ) ) ); - } - catch ( Exception e ) { - } - } - - - public void storeUrlsInPreferences( String[] urls ) { - storeUrlsInPreferences( new LinkedHashSet<String>( Arrays.asList( urls ) ) ); - } - - - public Set<String> getUrlSetFromPreferences() { - Set<String> urls = new TreeSet<String>( String.CASE_INSENSITIVE_ORDER ); - urls.add( GH_PORTAL_URL ); - ObjectMapper mapper = new ObjectMapper(); - String json = null; - try { - json = prefs.get( "urlList", null ); - } - catch ( Exception e ) { - } - if ( json == null ) { - return urls; - } - List<String> strings = null; - try { - strings = mapper.readValue( json, new TypeReference<List<String>>() {} ); - } - catch ( Exception e ) { - } - if ( strings == null ) { - return urls; - } - urls = new LinkedHashSet<String>( strings ); - urls.addAll( strings ); - return urls; - } - - - public String[] getUrlsFromPreferences() { - Set<String> urls = getUrlSetFromPreferences(); - return urls.toArray( new String[urls.size()] ); - } - - - Server server = null; - - - public Server getServer() { - if ( server == null ) { - synchronized ( this ) { - if ( server == null ) { - server = new Server(); - server.setDaemon( false ); - } - } - } - return server; - } - - - public void startServer() { - executor.execute( new Runnable() { - @Override - public void run() { - if ( !getServer().isRunning() ) { - launcher.setStatusYellow(); - getServer().setInitializeDatabaseOnStart( initializeDatabaseOnStart ); - getServer().setStartDatabaseWithServer( startDatabaseWithServer ); - getServer().startServer(); - launcher.setStatusGreen(); - } - } - } ); - } - - - public synchronized void stopServer() { - executor.execute( new Runnable() { - @Override - public void run() { - if ( getServer().isRunning() ) { - getServer().stopServer(); - launcher.setStatusRed(); - } - } - } ); - } - - - public LogViewerFrame getLogViewer() { - return logViewer; - } - - - public LauncherFrame getLauncher() { - return launcher; - } - - - public void showLogView() { - logViewer.setVisible( true ); - } - - - public boolean isInitializeDatabaseOnStart() { - return initializeDatabaseOnStart; - } - - - public void setInitializeDatabaseOnStart( boolean initializeDatabaseOnStart ) { - this.initializeDatabaseOnStart = initializeDatabaseOnStart; - prefs.putBoolean( "initializeDatabaseOnStart", initializeDatabaseOnStart ); - } - - - public boolean isStartDatabaseWithServer() { - return startDatabaseWithServer; - } - - - public void setStartDatabaseWithServer( boolean startDatabaseWithServer ) { - this.startDatabaseWithServer = startDatabaseWithServer; - prefs.putBoolean( "startDatabaseWithServer", startDatabaseWithServer ); - } - - - public String getAdminUserEmail() { - return adminUserEmail; - } - - - public void setAdminUserEmail( String adminUserEmail ) { - this.adminUserEmail = adminUserEmail; - prefs.put( "adminUserEmail", adminUserEmail ); - } - - - public boolean isAutoLogin() { - return autoLogin; - } - - - public void setAutoLogin( boolean autoLogin ) { - this.autoLogin = autoLogin; - prefs.putBoolean( "autoLogin", autoLogin ); - } - - - public String getAccessToken() { - return server.getAccessTokenForAdminUser( adminUserEmail ); - } - - - public UUID getAdminUUID() { - return server.getAdminUUID( adminUserEmail ); - } - - - public boolean serverIsStarted() { - return ( server != null ) && server.isRunning(); - } - - - public void loadPrefs() { - prefs = Preferences.userNodeForPackage( org.apache.usergrid.launcher.App.class ); - initializeDatabaseOnStart = prefs.getBoolean( "initializeDatabaseOnStart", true ); - startDatabaseWithServer = prefs.getBoolean( "startDatabaseWithServer", true ); - adminUserEmail = prefs.get( "adminUserEmail", "t...@usergrid.com" ); - autoLogin = prefs.getBoolean( "autoLogin", true ); - } -} http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/src/main/java/org/apache/usergrid/launcher/AppleUtils.java ---------------------------------------------------------------------- diff --git a/stack/launcher/src/main/java/org/apache/usergrid/launcher/AppleUtils.java b/stack/launcher/src/main/java/org/apache/usergrid/launcher/AppleUtils.java deleted file mode 100644 index a09b720..0000000 --- a/stack/launcher/src/main/java/org/apache/usergrid/launcher/AppleUtils.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.usergrid.launcher; - - -import javax.swing.ImageIcon; -//import javax.swing.JOptionPane; - - -public class AppleUtils { - - public static void initMacApp() { - com.apple.eawt.Application macApp = com.apple.eawt.Application.getApplication(); - macApp.setDockIconImage( new ImageIcon( App.class.getResource( "dock_icon.png" ) ).getImage() ); - - // commented out to allow launcher to compile with the old AppleJavaExcentions 1.4 - // (because that is the newest version available via Maven) - -// macApp.setAboutHandler( new com.apple.eawt.AboutHandler() { -// @Override -// public void handleAbout( com.apple.eawt.AppEvent.AboutEvent evt ) { -// JOptionPane.showMessageDialog( null, -// "Apache Usergrid Standalone Server Launcher\nApache Software Foundation", -// "About Apache Usergrid Launcher", JOptionPane.INFORMATION_MESSAGE ); -// } -// } ); - } -} http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/src/main/java/org/apache/usergrid/launcher/CustomJSPTemplateProcessor.java ---------------------------------------------------------------------- diff --git a/stack/launcher/src/main/java/org/apache/usergrid/launcher/CustomJSPTemplateProcessor.java b/stack/launcher/src/main/java/org/apache/usergrid/launcher/CustomJSPTemplateProcessor.java deleted file mode 100644 index 33ab873..0000000 --- a/stack/launcher/src/main/java/org/apache/usergrid/launcher/CustomJSPTemplateProcessor.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * 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.usergrid.launcher; - - -@javax.ws.rs.ext.Provider -public class CustomJSPTemplateProcessor implements com.sun.jersey.spi.template.ViewProcessor<String> { - - private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger( CustomJSPTemplateProcessor.class ); - - private - @javax.ws.rs.core.Context - com.sun.jersey.api.core.HttpContext hc; - - private - @javax.ws.rs.core.Context - javax.servlet.ServletContext servletContext; - - private - @javax.ws.rs.core.Context - ThreadLocal<javax.servlet.http.HttpServletRequest> requestInvoker; - - private - @javax.ws.rs.core.Context - ThreadLocal<javax.servlet.http.HttpServletResponse> responseInvoker; - - private final String basePath; - - - public CustomJSPTemplateProcessor( @javax.ws.rs.core.Context com.sun.jersey.api.core.ResourceConfig resourceConfig ) { - logger.info( "CustomJSPTemplateProcessor installed" ); - - String path = ( String ) resourceConfig.getProperties().get( com.sun.jersey.spi.container.servlet.ServletContainer.JSP_TEMPLATES_BASE_PATH ); - if ( path == null ) { - basePath = ""; - } - else if ( path.charAt( 0 ) == '/' ) { - basePath = path; - } - else { - basePath = "/" + path; - } - } - - - public String findJsp( String path ) throws java.net.MalformedURLException { - if ( servletContext.getResource( path ) != null ) { - return path; - } - else { - // check if the entry exists in web.xml through the - // RequestDispatcher - javax.servlet.ServletContext jspContext = servletContext.getContext( path ); - if ( jspContext != null ) { - javax.servlet.RequestDispatcher jspReqDispatcher = servletContext.getRequestDispatcher( path ); - if ( jspReqDispatcher != null ) { - return path; - } - } - javax.servlet.RequestDispatcher reqDispatcher = servletContext.getRequestDispatcher( path ); - if ( reqDispatcher != null ) { - return path; - } - } - return null; - } - - - @Override - public String resolve( String path ) { - if ( servletContext == null ) { - return null; - } - - if (!basePath.equals("")) { - path = basePath + path; - } - - try { - if ( findJsp( path ) != null ) { - return path; - } - - if ( !path.endsWith( ".jsp" ) ) { - path = path + ".jsp"; - if ( findJsp( path ) != null ) { - return path; - } - } - } - catch ( java.net.MalformedURLException ex ) { - // TODO log - } - - return null; - } - - - @Override - public void writeTo( String resolvedPath, com.sun.jersey.api.view.Viewable viewable, java.io.OutputStream out ) throws java.io.IOException { - if ( hc.isTracingEnabled() ) { - hc.trace( String.format( "forwarding view to JSP page: \"%s\", it = %s", resolvedPath, - com.sun.jersey.core.reflection.ReflectionHelper.objectToString( viewable.getModel() ) ) ); - } - - // Commit the status and headers to the HttpServletResponse - out.flush(); - - javax.servlet.RequestDispatcher d = servletContext.getRequestDispatcher( resolvedPath ); - if ( d == null ) { - throw new com.sun.jersey.api.container.ContainerException( "No request dispatcher for: " + resolvedPath ); - } - - d = new com.sun.jersey.server.impl.container.servlet.RequestDispatcherWrapper( d, basePath, hc, viewable ); - - try { - d.forward( requestInvoker.get(), responseInvoker.get() ); - } - catch ( Exception e ) { - throw new com.sun.jersey.api.container.ContainerException( e ); - } - } -} http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/src/main/java/org/apache/usergrid/launcher/EmbeddedServerHelper.java ---------------------------------------------------------------------- diff --git a/stack/launcher/src/main/java/org/apache/usergrid/launcher/EmbeddedServerHelper.java b/stack/launcher/src/main/java/org/apache/usergrid/launcher/EmbeddedServerHelper.java deleted file mode 100644 index 441fe21..0000000 --- a/stack/launcher/src/main/java/org/apache/usergrid/launcher/EmbeddedServerHelper.java +++ /dev/null @@ -1,193 +0,0 @@ -/* - * 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.usergrid.launcher; - - -/** @author Ran Tavory (ran...@gmail.com) */ -public class EmbeddedServerHelper { - private static org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger( EmbeddedServerHelper.class ); - - private static final String TMP = "tmp"; - - private final String yamlFile; - static org.apache.cassandra.service.CassandraDaemon cassandraDaemon; - - - public EmbeddedServerHelper() { - this( "/cassandra.yaml" ); - } - - - public EmbeddedServerHelper( String yamlFile ) { - this.yamlFile = yamlFile; - } - - - static java.util.concurrent.ExecutorService executor; - - - /** Set embedded cassandra up and spawn it in a new thread. */ - public void setup() throws org.apache.thrift.transport.TTransportException, java.io.IOException, InterruptedException { - - // delete tmp dir first - rmdir( TMP ); - // make a tmp dir and copy cassandra.yaml and log4j.properties to it - copy( "/log4j-server.properties", TMP ); - copy( yamlFile, TMP ); - - System.setProperty( "cassandra.config", "file:" + TMP + yamlFile ); - System.setProperty( "log4j.configuration", "file:" + TMP + "/log4j-server.properties" ); - System.setProperty( "cassandra-foreground", "true" ); - - cleanupAndLeaveDirs(); - loadSchemaFromYaml(); - // loadYamlTables(); - } - - - public void start() throws org.apache.thrift.transport.TTransportException, java.io.IOException, InterruptedException { - if ( executor == null ) { - executor = java.util.concurrent.Executors.newSingleThreadExecutor(); - System.setProperty( "cassandra.config", "file:" + TMP + yamlFile ); - System.setProperty( "log4j.configuration", "file:" + TMP + "/log4j.properties" ); - System.setProperty( "cassandra-foreground", "true" ); - - logger.info( "Starting executor" ); - - executor.execute( new ITRunner() ); - logger.info( "Started executor" ); - } - else { - cassandraDaemon.start(); - } - - - try { - java.util.concurrent.TimeUnit.SECONDS.sleep( 3 ); - logger.info( "Done sleeping" ); - } - catch ( InterruptedException e ) { - throw new AssertionError( e ); - } - } - - - public static void teardown() { - if ( cassandraDaemon != null ) { - cassandraDaemon.deactivate(); - org.apache.cassandra.service.StorageService.instance.stopClient(); - } - executor.shutdown(); - executor.shutdownNow(); - logger.info( "Teardown complete" ); - } - - - public void stop() { - cassandraDaemon.stop(); - } - - - private static void rmdir( String dir ) throws java.io.IOException { - java.io.File dirFile = new java.io.File( dir ); - if ( dirFile.exists() ) { - org.apache.cassandra.io.util.FileUtils.deleteRecursive( new java.io.File( dir ) ); - } - } - - - /** Copies a resource from within the jar to a directory. */ - private static void copy( String resource, String directory ) throws java.io.IOException { - mkdir( directory ); - java.io.InputStream is = EmbeddedServerHelper.class.getResourceAsStream( resource ); - String fileName = resource.substring( resource.lastIndexOf( "/" ) + 1 ); - java.io.File file = new java.io.File( directory + System.getProperty( "file.separator" ) + fileName ); - java.io.OutputStream out = new java.io.FileOutputStream( file ); - byte buf[] = new byte[1024]; - int len; - while ( ( len = is.read( buf ) ) > 0 ) { - out.write( buf, 0, len ); - } - out.close(); - is.close(); - } - - - /** Creates a directory */ - private static void mkdir( String dir ) throws java.io.IOException { - org.apache.cassandra.io.util.FileUtils.createDirectory( dir ); - } - - - public static void cleanupAndLeaveDirs() throws java.io.IOException { - mkdirs(); - cleanup(); - mkdirs(); - org.apache.cassandra.db.commitlog.CommitLog.instance.resetUnsafe(); // cleanup screws w/ CommitLog, this - // brings it back to safe state - } - - - public static void cleanup() throws java.io.IOException { - // clean up commitlog - String[] directoryNames = { org.apache.cassandra.config.DatabaseDescriptor.getCommitLogLocation(), }; - for ( String dirName : directoryNames ) { - java.io.File dir = new java.io.File( dirName ); - if ( !dir.exists() ) { - throw new RuntimeException( "No such directory: " + dir.getAbsolutePath() ); - } - org.apache.cassandra.io.util.FileUtils.deleteRecursive( dir ); - } - - // clean up data directory which are stored as data directory/table/data - // files - for ( String dirName : org.apache.cassandra.config.DatabaseDescriptor.getAllDataFileLocations() ) { - java.io.File dir = new java.io.File( dirName ); - if ( !dir.exists() ) { - throw new RuntimeException( "No such directory: " + dir.getAbsolutePath() ); - } - org.apache.cassandra.io.util.FileUtils.deleteRecursive( dir ); - } - } - - - public static void mkdirs() { - org.apache.cassandra.config.DatabaseDescriptor.createAllDirectories(); - } - - - public static void loadSchemaFromYaml() { - try { - me.prettyprint.hector.testutils.EmbeddedSchemaLoader.loadSchema(); - } - catch ( RuntimeException e ) { - - } - } - - - class ITRunner implements Runnable { - - @Override - public void run() { - - cassandraDaemon = new org.apache.cassandra.service.CassandraDaemon(); - - cassandraDaemon.activate(); - } - } -} http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/src/main/java/org/apache/usergrid/launcher/JarMain.java ---------------------------------------------------------------------- diff --git a/stack/launcher/src/main/java/org/apache/usergrid/launcher/JarMain.java b/stack/launcher/src/main/java/org/apache/usergrid/launcher/JarMain.java deleted file mode 100644 index 7f82930..0000000 --- a/stack/launcher/src/main/java/org/apache/usergrid/launcher/JarMain.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.usergrid.launcher; - - -/** - * The jar file executable main method in this class uses the graphical App - * when no arguments are provided, but switches to using the standalone cli - * Server class when arguments are provided. To launch the standalone cli - * version the -nogui parameter must be provided first. This way -db and - * -init need not be provided to launch in cli mode. - */ -public class JarMain { - - public static void main( String [] args ) { - - // With no arguments we just start up the graphical launcher - if ( args.length == 0 ) { - App.main( args ); - } - else { - Server.main( args ); - } - } -} http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/src/main/java/org/apache/usergrid/launcher/LauncherFrame.java ---------------------------------------------------------------------- diff --git a/stack/launcher/src/main/java/org/apache/usergrid/launcher/LauncherFrame.java b/stack/launcher/src/main/java/org/apache/usergrid/launcher/LauncherFrame.java deleted file mode 100644 index 2595c28..0000000 --- a/stack/launcher/src/main/java/org/apache/usergrid/launcher/LauncherFrame.java +++ /dev/null @@ -1,462 +0,0 @@ -/* - * 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.usergrid.launcher; - - -import java.awt.Color; -import java.awt.Container; -import java.awt.Desktop; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.GradientPaint; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Image; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.UUID; - -import javax.swing.BorderFactory; -import javax.swing.ComboBoxEditor; -import javax.swing.ImageIcon; -import javax.swing.JButton; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; -import javax.swing.JComponent; -import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JTextArea; -import javax.swing.JTextField; -import javax.swing.JToolBar; -import javax.swing.Timer; -import javax.swing.WindowConstants; -import javax.swing.border.EmptyBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - - -public class LauncherFrame extends JFrame { - - private static final long serialVersionUID = 1L; - - - enum Status { - GREEN, RED, YELLOW - } - - - Status status = Status.RED; - - App app; - - ImageIcon start_icon = createImageIcon( "start.png", "Start" ); - ImageIcon start_active_icon = createImageIcon( "start_active.png", "Start" ); - JButton start_button; - - ImageIcon stop_icon = createImageIcon( "stop.png", "Stop" ); - ImageIcon stop_active_icon = createImageIcon( "stop_active.png", "Start" ); - JButton stop_button; - - ImageIcon log_viewer_icon = createImageIcon( "log_viewer.png", "Log" ); - JButton log_viewer_button; - - ImageIcon usergrid_admin_icon = createImageIcon( "web_browser.png", "Admin" ); - JButton usergrid_admin_button; - - JCheckBox start_database_checkbox; - JCheckBox init_database_checkbox; - JComboBox urlList; - - ImageIcon status_green = createImageIcon( "status_green.png", "Green" ); - ImageIcon status_yellow = createImageIcon( "status_yellow.png", "Green" ); - ImageIcon status_red = createImageIcon( "status_red.png", "Green" ); - ImageIcon status_off = createImageIcon( "status_off.png", "Green" ); - JLabel status_label; - Timer status_timer; - - JCheckBox auto_login_checkbox; - JTextField auto_login_email; - - - public LauncherFrame( App app ) { - super( "Usergrid Launcher" ); - - this.app = app; - - // getRootPane().putClientProperty("apple.awt.brushMetalLook", - // Boolean.TRUE); - // getRootPane().putClientProperty("apple.awt.antialiasing", - // Boolean.TRUE); - addComponentsToPane(); - pack(); - setBackground( new Color( 196, 196, 196 ) ); - setLocationRelativeTo( null ); - setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE ); - setVisible( true ); - setResizable( false ); - } - - - public void addComponentsToPane() { - Container pane = getContentPane(); - pane.setLayout( new GridBagLayout() ); - - GridBagConstraints c; - - JToolBar toolBar = new JToolBar( "Toolbar" ); - toolBar.setBackground( new Color( 128, 128, 128 ) ); - toolBar.setFloatable( false ); - toolBar.setRollover( true ); - toolBar.setMargin( new Insets( 8, 16, 8, 8 ) ); - toolBar.setBorder( new EmptyBorder( new Insets( 8, 16, 8, 8 ) ) ); - - status_label = new JLabel( status_red ); - status_label.setPreferredSize( new Dimension( 24, 64 ) ); - toolBar.add( status_label ); - status_timer = new Timer( 750, new ActionListener() { - @Override - public void actionPerformed( ActionEvent e ) { - if ( status == Status.YELLOW ) { - if ( status_label.getIcon() == status_yellow ) { - status_label.setIcon( status_off ); - } - else { - status_label.setIcon( status_yellow ); - } - } - } - } ); - status_timer.start(); - - toolBar.addSeparator( new Dimension( 16, 0 ) ); - - start_button = new JButton( start_active_icon ); - initButton( start_button ); - toolBar.add( start_button ); - start_button.addActionListener( new ActionListener() { - @Override - public void actionPerformed( ActionEvent event ) { - start_button.setIcon( start_icon ); - stop_button.setIcon( stop_active_icon ); - app.startServer(); - } - } ); - - toolBar.addSeparator( new Dimension( 8, 0 ) ); - - stop_button = new JButton( stop_icon ); - initButton( stop_button ); - toolBar.add( stop_button ); - stop_button.addActionListener( new ActionListener() { - @Override - public void actionPerformed( ActionEvent event ) { - start_button.setIcon( start_active_icon ); - stop_button.setIcon( stop_icon ); - app.stopServer(); - } - } ); - - toolBar.addSeparator( new Dimension( 8, 0 ) ); - - log_viewer_button = new JButton( log_viewer_icon ); - initButton( log_viewer_button ); - toolBar.add( log_viewer_button ); - log_viewer_button.addActionListener( new ActionListener() { - @Override - public void actionPerformed( ActionEvent event ) { - app.showLogView(); - } - } ); - - toolBar.addSeparator( new Dimension( 8, 0 ) ); - - usergrid_admin_button = new JButton( usergrid_admin_icon ); - initButton( usergrid_admin_button ); - toolBar.add( usergrid_admin_button ); - usergrid_admin_button.addActionListener( new ActionListener() { - @Override - public void actionPerformed( ActionEvent event ) { - if ( app.serverIsStarted() && ( status == Status.GREEN ) ) { - storeAdminUrls(); - storeAdminEmail(); - String adminUri = null; - try { - adminUri = getAdminURI().toString(); - Desktop.getDesktop().browse( getAdminURI() ); - } - catch ( IOException e ) { - JOptionPane.showMessageDialog( null, new JTextArea( "Error opening URL in browser." - + " Please open the following URL in a browser manually:\n" + adminUri ), "Warning", - JOptionPane.WARNING_MESSAGE ); - } - catch ( Exception ex ) { - JOptionPane.showMessageDialog( null, new JTextArea( - "Error opening URL in browser." + "Please open the following URL in a browser manually:" - + adminUri ), "Warning", JOptionPane.WARNING_MESSAGE ); - } - } - else { - JOptionPane.showMessageDialog( null, "Server must be started before opening Admin Console.\n" - + "Please start server and wait for the status to turn green.", "Warning", - JOptionPane.WARNING_MESSAGE ); - } - } - } ); - - c = new GridBagConstraints(); - c.anchor = GridBagConstraints.CENTER; - c.weightx = 0.0; - c.fill = GridBagConstraints.HORIZONTAL; - c.gridwidth = 2; - add( toolBar, c ); - - start_database_checkbox = new JCheckBox( "Start Database With Server*" ); - c = new GridBagConstraints( 0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets( 16, 16, 8, 16 ), 0, 0 ); - start_database_checkbox.setSelected( app.isStartDatabaseWithServer() ); - start_database_checkbox.setFont( new Font( "Arial", Font.BOLD, 18 ) ); - pane.add( start_database_checkbox, c ); - start_database_checkbox.addChangeListener( new ChangeListener() { - @Override - public void stateChanged( ChangeEvent change ) { - app.setStartDatabaseWithServer( start_database_checkbox.isSelected() ); - } - } ); - - init_database_checkbox = new JCheckBox( "Initialize Database on Start*" ); - c = new GridBagConstraints( 0, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets( 16, 16, 8, 16 ), 0, 0 ); - init_database_checkbox.setSelected( app.isInitializeDatabaseOnStart() ); - init_database_checkbox.setFont( new Font( "Arial", Font.BOLD, 18 ) ); - pane.add( init_database_checkbox, c ); - init_database_checkbox.addChangeListener( new ChangeListener() { - @Override - public void stateChanged( ChangeEvent change ) { - app.setInitializeDatabaseOnStart( init_database_checkbox.isSelected() ); - } - } ); - - JLabel label = new JLabel( "Console URL:" ); - c = new GridBagConstraints( 0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets( 16, 24, 8, 0 ), 0, 0 ); - label.setFont( new Font( "Arial", Font.BOLD, 18 ) ); - pane.add( label, c ); - - String[] urls = app.getUrlsFromPreferences(); - urlList = new JComboBox( urls ); - urlList.setEditable( true ); - c = new GridBagConstraints( 1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, - new Insets( 16, 0, 8, 16 ), 0, 0 ); - urlList.setFont( new Font( "Arial", Font.BOLD, 18 ) ); - - urlList.setPrototypeDisplayValue( "XXXXXXXXXXXXXXXXXXXX" ); - - ComboBoxEditor editor = urlList.getEditor(); - JTextField textField = ( JTextField ) editor.getEditorComponent(); - textField.setColumns( 20 ); - - setPreferredWidth( textField, 350 ); - setMaxWidth( textField, 350 ); - - setPreferredWidth( urlList, 350 ); - setMaxWidth( urlList, 350 ); - - pane.add( urlList, c ); - - auto_login_checkbox = new JCheckBox( "Auto-login as:" ); - c = new GridBagConstraints( 0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets( 16, 16, 8, 0 ), 0, 0 ); - auto_login_checkbox.setSelected( app.isAutoLogin() ); - auto_login_checkbox.setFont( new Font( "Arial", Font.BOLD, 18 ) ); - pane.add( auto_login_checkbox, c ); - auto_login_checkbox.addChangeListener( new ChangeListener() { - @Override - public void stateChanged( ChangeEvent change ) { - app.setAutoLogin( auto_login_checkbox.isSelected() ); - } - } ); - - auto_login_email = new JTextField( app.getAdminUserEmail() ); - c = new GridBagConstraints( 1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets( 16, 0, 8, 16 ), 0, 0 ); - auto_login_email.setFont( new Font( "Arial", Font.BOLD, 18 ) ); - pane.add( auto_login_email, c ); - - label = new JLabel( "* Database can only be started or initialized once per app launch" ); - c = new GridBagConstraints( 0, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets( 16, 16, 16, 0 ), 0, 0 ); - label.setForeground( Color.RED ); - label.setFont( new Font( "Arial", Font.BOLD, 12 ) ); - pane.add( label, c ); - - List<Image> icons = new ArrayList<Image>( 4 ); - icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_16.png" ) ) - .getImage() ); - icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_32.png" ) ) - .getImage() ); - icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_64.png" ) ) - .getImage() ); - icons.add( new ImageIcon( getClass().getClassLoader().getResource( "org/apache/usergrid/launcher/icon_256.png" ) ) - .getImage() ); - setIconImages( icons ); - } - - - public void setPreferredWidth( JComponent jc, int width ) { - Dimension max = jc.getPreferredSize(); - max.width = width; - jc.setPreferredSize( max ); - } - - - public void setMaxWidth( JComponent jc, int width ) { - Dimension max = jc.getMaximumSize(); - max.width = width; - jc.setMaximumSize( max ); - } - - - public void initButton( JButton button ) { - button.setPreferredSize( new Dimension( 64, 64 ) ); - button.setMargin( new Insets( 8, 8, 8, 8 ) ); - button.setOpaque( false ); - button.setFocusPainted( false ); - button.setBorderPainted( false ); - button.setContentAreaFilled( false ); - button.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) ); - } - - - public void setStatusRed() { - status = Status.RED; - status_label.setIcon( status_red ); - } - - - public void setStatusGreen() { - status = Status.GREEN; - status_label.setIcon( status_green ); - } - - - public void setStatusYellow() { - status = Status.YELLOW; - status_label.setIcon( status_yellow ); - } - - - public URI getAdminURI() throws URISyntaxException, UnsupportedEncodingException { - String url = urlList.getSelectedItem().toString(); - if ( url.contains( "?" ) ) { - url += "&"; - } - else { - url += "?"; - } - url += "api_url=" + URLEncoder.encode( "http://localhost:8080", "UTF-8" ); - if ( app.isAutoLogin() ) { - String access_token = app.getAccessToken(); - UUID adminId = app.getAdminUUID(); - - if ( access_token != null ) { - url += "&admin_email=" + URLEncoder.encode( app.getAdminUserEmail(), "UTF-8" ); - url += "&access_token=" + access_token; - } - - if ( adminId != null ) { - url += "&uuid=" + adminId; - } - } - return new URI( url ); - } - - - public void storeAdminUrls() { - Set<String> urls = app.getUrlSetFromPreferences(); - urls.add( urlList.getSelectedItem().toString() ); - app.storeUrlsInPreferences( urls ); - } - - - protected ImageIcon createImageIcon( String path, String description ) { - java.net.URL imgURL = getClass().getResource( path ); - if ( imgURL != null ) { - return new ImageIcon( imgURL, description ); - } - else { - System.err.println( "Couldn't find file: " + path ); - return null; - } - } - - - public void storeAdminEmail() { - app.setAdminUserEmail( auto_login_email.getText() ); - } - - - public static class LauncherToolBar extends JToolBar { - - public LauncherToolBar() { - super(); - } - - - public LauncherToolBar( int orientation ) { - super( orientation ); - } - - - public LauncherToolBar( String name, int orientation ) { - super( name, orientation ); - } - - - public LauncherToolBar( String name ) { - super( name ); - } - - - private static final long serialVersionUID = 1L; - - - @Override - protected void paintComponent( Graphics g ) { - // Create the 2D copy - Graphics2D g2 = ( Graphics2D ) g.create(); - - // Apply vertical gradient - g2.setPaint( new GradientPaint( 0, 0, Color.WHITE, 0, getHeight(), Color.BLUE ) ); - g2.fillRect( 0, 0, getWidth(), getHeight() ); - - // Dipose of copy - g2.dispose(); - } - } -} http://git-wip-us.apache.org/repos/asf/usergrid/blob/6df86b4a/stack/launcher/src/main/java/org/apache/usergrid/launcher/LogViewerFrame.java ---------------------------------------------------------------------- diff --git a/stack/launcher/src/main/java/org/apache/usergrid/launcher/LogViewerFrame.java b/stack/launcher/src/main/java/org/apache/usergrid/launcher/LogViewerFrame.java deleted file mode 100644 index b70f698..0000000 --- a/stack/launcher/src/main/java/org/apache/usergrid/launcher/LogViewerFrame.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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.usergrid.launcher; - - -import java.awt.BorderLayout; -import java.io.IOException; - -import javax.swing.JFrame; -import javax.swing.JScrollPane; -import javax.swing.JTextArea; -import javax.swing.SwingUtilities; -import javax.swing.WindowConstants; - -import org.apache.log4j.AppenderSkeleton; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.spi.LoggingEvent; - - -public class LogViewerFrame extends JFrame { - - private static final long serialVersionUID = 1L; - - JTextArea textArea = new JTextArea(); - - App app; - - - public LogViewerFrame( App app ) throws IOException { - super( "Log" ); - this.app = app; - - // Add a scrolling text area - textArea.setEditable( false ); - textArea.setRows( 20 ); - textArea.setColumns( 50 ); - getContentPane().add( new JScrollPane( textArea ), BorderLayout.CENTER ); - pack(); - // setLocationRelativeTo(app.getLauncher()); - setLocation( 100, 100 ); - setDefaultCloseOperation( WindowConstants.HIDE_ON_CLOSE ); - setVisible( false ); - - Log4jAppender appender = new Log4jAppender(); - Logger.getRootLogger().addAppender( appender ); - } - - - public void appendMessage( final String message ) { - SwingUtilities.invokeLater( new Runnable() { - @Override - public void run() { - textArea.append( message ); - try { - textArea.setCaretPosition( textArea.getDocument().getLength() ); - } - catch ( Exception e ) { - } - } - } ); - } - - - public class Log4jAppender extends AppenderSkeleton { - - PatternLayout layout; - - - public Log4jAppender() { - layout = new PatternLayout( "[%d{dd-MMM-yyyy HH:mm:ss,SSS}][%p][%t] %l %m%n" ); - } - - - @Override - public void close() { - } - - - @Override - public boolean requiresLayout() { - return false; - } - - - @Override - protected void append( LoggingEvent loggingEvent ) { - appendMessage( layout.format( loggingEvent ) ); - } - } -}