You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by gt...@apache.org on 2014/02/18 15:20:36 UTC
[3/8] git commit: Admin client requires extended permissions (i.e.
java.security.AllPermission) so it's now in a separate profile that includes
AllPermission in the client-deploy.config.
Admin client requires extended permissions (i.e. java.security.AllPermission) so it's now in a separate profile that includes AllPermission in the client-deploy.config.
Client app deployer now has the ability to use a preset app name rather than reading the app name from the command line parameters. Set 'clientAppName' property to invoke this behavior.
Admin-client profile uses the above functionality to automatically startup the admin module.
Project: http://git-wip-us.apache.org/repos/asf/river-container/repo
Commit: http://git-wip-us.apache.org/repos/asf/river-container/commit/f3245a2d
Tree: http://git-wip-us.apache.org/repos/asf/river-container/tree/f3245a2d
Diff: http://git-wip-us.apache.org/repos/asf/river-container/diff/f3245a2d
Branch: refs/heads/master
Commit: f3245a2dd9f26571c360e91dfdaea7ba900cb70b
Parents: 82f44f6
Author: Greg Trasuk <tr...@trasuk.com>
Authored: Mon Jan 20 13:22:29 2014 -0500
Committer: Greg Trasuk <tr...@trasuk.com>
Committed: Mon Jan 20 13:22:29 2014 -0500
----------------------------------------------------------------------
product/src/assemble/product-container.xml | 10 +++
product/src/main/root/bin/logging.properties | 2 +-
.../admin-client/class-server.properties | 17 ++++
.../root/profile/admin-client/client-app.cfg | 53 +++++++++++
.../main/root/profile/admin-client/config.xml | 57 ++++++++++++
.../admin-client/deploy-privileged/readme.txt | 2 +
.../root/profile/admin-client/deploy/readme.txt | 2 +
.../container/deployer/ClientAppDeployer.java | 95 ++++++++++++--------
8 files changed, 201 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/product/src/assemble/product-container.xml
----------------------------------------------------------------------
diff --git a/product/src/assemble/product-container.xml b/product/src/assemble/product-container.xml
index c1c1c56..763d831 100644
--- a/product/src/assemble/product-container.xml
+++ b/product/src/assemble/product-container.xml
@@ -99,6 +99,16 @@
<scope>runtime</scope>
<includes>
<include>*:browser-module</include>
+ </includes>
+ </dependencySet>
+
+ <!-- Admin-client Profile
+ -->
+ <dependencySet>
+ <useProjectArtifact>false</useProjectArtifact>
+ <outputDirectory>/profile/admin-client/deploy</outputDirectory>
+ <scope>runtime</scope>
+ <includes>
<include>*:admin-module</include>
</includes>
</dependencySet>
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/product/src/main/root/bin/logging.properties
----------------------------------------------------------------------
diff --git a/product/src/main/root/bin/logging.properties b/product/src/main/root/bin/logging.properties
index 75d0a47..fdbd071 100644
--- a/product/src/main/root/bin/logging.properties
+++ b/product/src/main/root/bin/logging.properties
@@ -68,7 +68,7 @@ java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
# Provides extra control for each logger.
############################################################
-org.apache.river.container.level = FINE
+org.apache.river.container.level = INFO
org.apache.river.container.ShowContextToConsole.level=INFO
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/product/src/main/root/profile/admin-client/class-server.properties
----------------------------------------------------------------------
diff --git a/product/src/main/root/profile/admin-client/class-server.properties b/product/src/main/root/profile/admin-client/class-server.properties
new file mode 100644
index 0000000..6957c40
--- /dev/null
+++ b/product/src/main/root/profile/admin-client/class-server.properties
@@ -0,0 +1,17 @@
+# 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.
+ #
+initialPort=8080
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/product/src/main/root/profile/admin-client/client-app.cfg
----------------------------------------------------------------------
diff --git a/product/src/main/root/profile/admin-client/client-app.cfg b/product/src/main/root/profile/admin-client/client-app.cfg
new file mode 100644
index 0000000..faa9d09
--- /dev/null
+++ b/product/src/main/root/profile/admin-client/client-app.cfg
@@ -0,0 +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.
+ */
+
+// Sample file that our policy file parser should be able to process.
+
+// Grants given to all applications.
+grant {
+ java.security.AllPermission;
+}
+
+classloader {
+ // Variables required to set up the application classloader.
+ //For a privileged application deployer, parent=containerClassLoader;
+ parent systemClassLoader;
+
+ jars {
+ commons-vfs2-2.0.jar,
+ commons-logging-1.1.1.jar,
+ jsk-platform-${jsk-version}.jar,
+ jsk-lib-${jsk-version}.jar,
+ jsk-resources-${jsk-version}.jar,
+ river-container-core-1.0-SNAPSHOT.jar(org.apache.river.container.liaison.Strings,
+ org.apache.river.container.liaison.VirtualFileSystemConfiguration,
+ org.apache.river.container.liaison.VirtualFileSystemConfiguration$MyConfigurationFile,
+ "META-INF/services/*")
+ }
+
+ codebase {jsk-dl-${jsk-version}.jar}
+}
+
+configuration {
+ // Anything on the left-hand side of '=' is set into the application config
+ // as a "special variable, accessible through '$name'.
+ discoveryGroup=defaultDiscoveryGroup;
+
+ // For privileged deployer, include
+ // context=context;
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/product/src/main/root/profile/admin-client/config.xml
----------------------------------------------------------------------
diff --git a/product/src/main/root/profile/admin-client/config.xml b/product/src/main/root/profile/admin-client/config.xml
new file mode 100644
index 0000000..dc607fe
--- /dev/null
+++ b/product/src/main/root/profile/admin-client/config.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Document : config.xml
+ Created on : December 10, 2010, 6:39 PM
+ Author : trasukg
+ Description:
+ Configuration file in the 'profile' directory selected by the
+ command line.
+-->
+<!--
+ 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.
+
+ -->
+
+<cfg:container-config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
+ xmlns:cfg='http://river.apache.org/xml/ns/container/config/1.0'
+ xsi:schemaLocation='http://river.apache.org/xml/ns/container/config/1.0 file:/home/trasukg/development/surrogate/src/schemas/config.xsd'>
+ <cfg:property name="deploymentDirectory" value="deploy"/>
+
+ <cfg:property name="defaultDiscoveryGroup" value="RiverContainerDefault"/>
+ <cfg:component class="org.apache.river.container.work.ContextualWorkManager"/>
+ <cfg:component class="org.apache.river.container.work.BasicWorkManager"/>
+ <cfg:component class="org.apache.river.container.codebase.ClassServer"/>
+
+ <!-- Deployer for 'service-starter'-style applications. -->
+ <cfg:component class="org.apache.river.container.deployer.StarterServiceDeployer">
+ <cfg:property name="config" value="client-app.cfg"/>
+ </cfg:component>
+
+ <!-- Deployer for 'service-starter'-style applications.
+ This is the 'admin-app' profile, so set the clientAppName to 'admin'
+ -->
+ <cfg:component class="org.apache.river.container.deployer.ClientAppDeployer">
+ <cfg:property name="deployDirectory" value="deploy"/>
+ <cfg:property name="clientAppName" value="admin"/>
+ </cfg:component>
+
+
+ <!--
+ <cfg:component class="org.apache.river.container.ShowContextToConsole"/>
+ -->
+</cfg:container-config>
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/product/src/main/root/profile/admin-client/deploy-privileged/readme.txt
----------------------------------------------------------------------
diff --git a/product/src/main/root/profile/admin-client/deploy-privileged/readme.txt b/product/src/main/root/profile/admin-client/deploy-privileged/readme.txt
new file mode 100644
index 0000000..eb900da
--- /dev/null
+++ b/product/src/main/root/profile/admin-client/deploy-privileged/readme.txt
@@ -0,0 +1,2 @@
+This file is only here to ensure that the parent directory is
+preserved in version control.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/product/src/main/root/profile/admin-client/deploy/readme.txt
----------------------------------------------------------------------
diff --git a/product/src/main/root/profile/admin-client/deploy/readme.txt b/product/src/main/root/profile/admin-client/deploy/readme.txt
new file mode 100644
index 0000000..eb900da
--- /dev/null
+++ b/product/src/main/root/profile/admin-client/deploy/readme.txt
@@ -0,0 +1,2 @@
+This file is only here to ensure that the parent directory is
+preserved in version control.
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/river-container/blob/f3245a2d/river-container-core/src/main/java/org/apache/river/container/deployer/ClientAppDeployer.java
----------------------------------------------------------------------
diff --git a/river-container-core/src/main/java/org/apache/river/container/deployer/ClientAppDeployer.java b/river-container-core/src/main/java/org/apache/river/container/deployer/ClientAppDeployer.java
index 31e4c64..f3c3638 100644
--- a/river-container-core/src/main/java/org/apache/river/container/deployer/ClientAppDeployer.java
+++ b/river-container-core/src/main/java/org/apache/river/container/deployer/ClientAppDeployer.java
@@ -50,34 +50,34 @@ import org.apache.river.container.Utils;
*/
public class ClientAppDeployer {
- private static final Logger log =
- Logger.getLogger(ClientAppDeployer.class.getName(), MessageNames.BUNDLE_NAME);
-
- @Injected
+ private static final Logger log
+ = Logger.getLogger(ClientAppDeployer.class.getName(), MessageNames.BUNDLE_NAME);
+
+ @Injected
ResourceBundle messages;
-
+
@Injected
- public String[] commandLineArguments=null;
+ public String[] commandLineArguments = null;
- @Injected(style= InjectionStyle.BY_TYPE)
- Context context=null;
+ @Injected(style = InjectionStyle.BY_TYPE)
+ Context context = null;
private String deployDirectory = org.apache.river.container.Strings.DEFAULT_DEPLOY_DIRECTORY;
-
+
@Injected(style = InjectionStyle.BY_TYPE)
private FileUtility fileUtility = null;
-
+
@Injected(style = InjectionStyle.BY_TYPE)
private StarterServiceDeployer deployer;
-
+
@Injected(style = InjectionStyle.BY_TYPE)
private MBeanRegistrar mbeanRegistrar;
-
+
@Name
private String myName = null;
- private List<ApplicationEnvironment> applicationEnvironments =
- new ArrayList<ApplicationEnvironment>();
+ private List<ApplicationEnvironment> applicationEnvironments
+ = new ArrayList<ApplicationEnvironment>();
public String getDeployDirectory() {
return deployDirectory;
@@ -87,8 +87,24 @@ public class ClientAppDeployer {
this.deployDirectory = deployDirectory;
}
- FileObject deploymentDirectoryFile=null;
-
+ FileObject deploymentDirectoryFile = null;
+
+ private String clientAppName = null;
+
+ public String getClientAppName() {
+ return clientAppName;
+ }
+
+ /**
+ * Set the client app that should be loaded. If not provided, client app
+ * name is taken from the first parameter.
+ *
+ * @param clientApp
+ */
+ public void setClientAppName(String clientApp) {
+ this.clientAppName = clientApp;
+ }
+
@Init
public void init() {
try {
@@ -103,7 +119,7 @@ public class ClientAppDeployer {
private void tryInitialize() throws IOException, ParseException {
log.log(Level.FINE, MessageNames.STARTER_SERVICE_DEPLOYER_STARTING, myName);
-
+
/*
Establish the deployment directory.
*/
@@ -117,33 +133,40 @@ public class ClientAppDeployer {
* Find the name of the client we need to deploy.
*/
/* First argument was the profile name. Second argument is the name of
- * the client app to run. All the rest are paramters to the client
+ * the client app to run. All the rest are parameters to the client
* app.
*/
- if (commandLineArguments.length < 2) {
+ if (clientAppName == null && commandLineArguments.length < 2) {
System.out.println(messages.getString(MessageNames.CLIENT_APP_USAGE));
System.exit(1);
}
- String clientAppName=commandLineArguments[1];
- String[] clientAppArgs=new String[commandLineArguments.length-2];
- System.arraycopy(commandLineArguments,2, clientAppArgs, 0,
- clientAppArgs.length);
+ String[] clientAppArgs;
+ if (clientAppName == null) {
+ clientAppName = commandLineArguments[1];
+ clientAppArgs = new String[commandLineArguments.length - 2];
+ System.arraycopy(commandLineArguments, 2, clientAppArgs, 0,
+ clientAppArgs.length);
+ } else {
+ clientAppArgs = new String[commandLineArguments.length - 1];
+ System.arraycopy(commandLineArguments, 1, clientAppArgs, 0,
+ clientAppArgs.length);
+ }
// Locate the service archive that has the client's name.
// First get all the jar files.
- List<FileObject> serviceArchives =
- Utils.findChildrenWithSuffix(deploymentDirectoryFile,
- org.apache.river.container.Strings.JAR);
+ List<FileObject> serviceArchives
+ = Utils.findChildrenWithSuffix(deploymentDirectoryFile,
+ org.apache.river.container.Strings.JAR);
//Then find the one that starts with the client name
- FileObject serviceArchive=null;
- for (FileObject fo:serviceArchives) {
- if (fo.getName().getBaseName().startsWith(clientAppName+ org.apache.river.container.Strings.DASH)) {
- serviceArchive=fo;
+ FileObject serviceArchive = null;
+ for (FileObject fo : serviceArchives) {
+ if (fo.getName().getBaseName().startsWith(clientAppName + org.apache.river.container.Strings.DASH)) {
+ serviceArchive = fo;
break;
}
-
+
}
-
- if (serviceArchive==null) {
+
+ if (serviceArchive == null) {
System.err.println(MessageFormat.format(messages.getString(MessageNames.NO_SUCH_CLIENT_APP), clientAppName));
System.exit(1);
}
@@ -157,12 +180,12 @@ public class ClientAppDeployer {
/* Try the archive in all the deployers to see if someone can
* handle it. For now there's only one.
*/
-
+
/*
* Create the ApplicationEnvironment for the archive.
*/
- ServiceLifeCycle deployedApp=deployer.deployServiceArchive(archiveFile);
-
+ ServiceLifeCycle deployedApp = deployer.deployServiceArchive(archiveFile);
+
deployedApp.startWithArgs(commandLineArgs);
} catch (Throwable t) {
log.log(Level.WARNING, MessageNames.FAILED_DEPLOY_SERVICE, archiveFile.toString());