[jboss-cvs] JBossAS SVN: r88148 - in projects/fresh/trunk: fresh-shell/src/main/java/org/jboss/fresh/deployer and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon May 4 09:25:44 EDT 2009
Author: alesj
Date: 2009-05-04 09:25:44 -0400 (Mon, 04 May 2009)
New Revision: 88148
Added:
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazyExecutableRegistry.java
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazySystemShellImpl.java
Modified:
projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java
projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java
Log:
[Fresh-4]; OnDemand initialization.
Modified: projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml
===================================================================
--- projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml 2009-05-04 13:17:32 UTC (rev 88147)
+++ projects/fresh/trunk/fresh-jar/src/main/resources/META-INF/fresh-jboss-beans.xml 2009-05-04 13:25:44 UTC (rev 88148)
@@ -1,7 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="urn:jboss:bean-deployer:2.0">
- <bean name="FreshPoolService" class="org.jboss.fresh.deployer.PoolService">
+ <bean name="FreshSSHServer" class="org.jboss.fresh.deployer.SSHService">
+ <depends>FreshSystemShell</depends>
+ </bean>
+
+ <bean name="FreshSystemShell" class="org.jboss.fresh.deployer.LazySystemShellService" >
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=SystemShell",exposedInterface=org.jboss.fresh.deployer.LazySystemShellServiceMBean.class)</annotation>
+ <constructor>
+ <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+ <parameter>
+ <!--
+ Pretty bad solution as we have to liste them all,
+ but we need to get off JNDI first in order to make it proper.
+ -->
+ <list elementClass="java.lang.String">
+ <value>FreshPoolService</value>
+ <value>FreshVFSService</value>
+ <value>FreshRootVFSService</value>
+ <value>FreshVFSInit</value>
+ <value>FreshScripting</value>
+ <value>FreshShellInit</value>
+ <value>FreshContextBinder</value>
+ </list>
+ </parameter>
+ </constructor>
+ <property name="JNDIName">java:/FRESH/SystemShell</property>
+ <property name="threadPoolJNDIName">java:/FRESH/ThreadPool</property>
+ <property name="VFSJNDIName">java:/FRESH/VFS</property>
+ <property name="GCInterval">10000</property>
+ <property name="executableRegistry"><inject bean="LazyExecutableRegistry"/></property>
+ </bean>
+
+ <bean name="LazyExecutableRegistry" class="org.jboss.fresh.shell.impl.LazyExecutableRegistry">
+ <constructor>
+ <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+ </constructor>
+ </bean>
+
+ <!-- On Demand -->
+
+ <bean name="FreshPoolService" class="org.jboss.fresh.deployer.PoolService" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=ThreadPool",exposedInterface=org.jboss.fresh.deployer.PoolServiceMBean.class)</annotation>
<property name="JNDIName">java:/FRESH/ThreadPool</property>
<property name="factoryName">org.jboss.fresh.cpii.services.PoolRunnerFactory</property>
@@ -12,12 +51,7 @@
<property name="blockingTimeout">10000</property>
</bean>
- <bean name="FreshContextBinder" class="org.jboss.fresh.deployer.ContextBinder">
- <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=GlobalContext",exposedInterface=org.jboss.fresh.deployer.ContextBinderMBean.class)</annotation>
- <property name="JNDIName">java:/FRESH/GlobalContext</property>
- </bean>
-
- <bean name="FreshVFSService" class="org.jboss.fresh.deployer.VFSService">
+ <bean name="FreshVFSService" class="org.jboss.fresh.deployer.VFSService" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=VFS.Mem",exposedInterface=org.jboss.fresh.deployer.VFSServiceMBean.class)</annotation>
<property name="JNDIName">java:/FRESH/VFSMem</property>
<property name="VFSImpl">org.jboss.fresh.vfs.impl.DefaultVFS</property>
@@ -28,54 +62,13 @@
<property name="tagFactory">org.jboss.fresh.vfs.impl.TimeTagFactory</property>
</bean>
+ <bean name="FreshRootVFSService" class="org.jboss.fresh.deployer.RootVFSService" mode="On Demand">
+ <property name="JNDIName">java:/FRESH/VFS</property>
+ <property name="automount">/=java:/FRESH/VFSMem</property>
+ <depends>FreshVFSService</depends>
+ </bean>
- <bean name="FreshRootVFSService" class="org.jboss.fresh.deployer.RootVFSService">
- <property name="JNDIName">java:/FRESH/VFS</property>
- <property name="automount">/=java:/FRESH/VFSMem</property>
- <depends>FreshVFSService</depends>
- </bean>
-
- <bean name="BeanFactoryExecutableRegistry" class="org.jboss.fresh.shell.impl.BeanFactoryExecutableRegistry">
- <constructor>
- <parameter>
- <map keyClass="java.lang.String" valueClass="org.jboss.beans.metadata.spi.factory.BeanFactory">
- <entry>
- <key>mcinvoke</key>
- <value>
- <inject bean="MCBeanInvokeExe"/>
- </value>
- </entry>
- <entry>
- <key>org.jboss.fresh.shell.commands.MCBeanInvokeExe</key>
- <value>
- <inject bean="MCBeanInvokeExe"/>
- </value>
- </entry>
- </map>
- </parameter>
- </constructor>
- </bean>
-
- <beanfactory name="MCBeanInvokeExe" class="org.jboss.fresh.shell.commands.MCBeanInvokeExe">
- <constructor>
- <parameter>
- <inject bean="jboss.kernel:service=KernelBus"/>
- </parameter>
- </constructor>
- </beanfactory>
-
- <bean name="FreshSystemShell" class="org.jboss.fresh.deployer.SystemShellService" >
- <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=SystemShell",exposedInterface=org.jboss.fresh.deployer.SystemShellServiceMBean.class)</annotation>
- <property name="JNDIName">java:/FRESH/SystemShell</property>
- <property name="threadPoolJNDIName">java:/FRESH/ThreadPool</property>
- <property name="VFSJNDIName">java:/FRESH/VFS</property>
- <property name="GCInterval">10000</property>
- <property name="executableRegistry"><inject bean="BeanFactoryExecutableRegistry"/></property>
- <depends>FreshPoolService</depends>
- <depends>FreshRootVFSService</depends>
- </bean>
-
- <bean name="FreshVFSInit" class="org.jboss.fresh.deployer.ShellExecutorService" >
+ <bean name="FreshVFSInit" class="org.jboss.fresh.deployer.ShellExecutorService" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=VFS.Mem.Init",exposedInterface=org.jboss.fresh.deployer.ShellExecutorServiceMBean.class)</annotation>
<property name="batchCode">
mkdir /home
@@ -192,42 +185,66 @@
setattr /usr/local/diag Class org.jboss.fresh.shell.commands.util.DiagExe
mkdir /tmp
mkdir /projects
-
-
</property>
<property name="executeOnStart">true</property>
<property name="stopOnError">false</property>
<property name="useLocal">true</property>
<property name="svcName">java:/FRESH/SystemShell</property>
<depends>FreshSystemShell</depends>
-
-
</bean>
-
- <bean name="FreshScripting" class="org.jboss.fresh.deployer.ScriptingService" >
+ <bean name="FreshScripting" class="org.jboss.fresh.deployer.ScriptingService" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=Scripting",exposedInterface=org.jboss.fresh.deployer.ScriptingServiceMBean.class)</annotation>
<property name="JNDIName">java:/FRESH/Scripting</property>
<depends>FreshSystemShell</depends>
<depends>FreshVFSInit</depends>
</bean>
- <bean name="FreshShellInit" class="org.jboss.fresh.deployer.VFSFileService" >
+ <bean name="FreshShellInit" class="org.jboss.fresh.deployer.VFSFileService" mode="On Demand">
<annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=init-rc",exposedInterface=org.jboss.fresh.deployer.VFSFileServiceMBean.class)</annotation>
- <property name="file">/etc/shell/init.rc</property>
- <property name="content">set PATH = .:/bin
-set SERIALIZE_MODE = true
-set SESSION_TIMEOUT = 1800000
-set PROCESS_TIMEOUT = 60000
+ <property name="file">/etc/shell/init.rc</property>
+ <property name="content">
+ set PATH = .:/bin
+ set SERIALIZE_MODE = true
+ set SESSION_TIMEOUT = 1800000
+ set PROCESS_TIMEOUT = 60000
</property>
- <depends>FreshSystemShell</depends>
+ <depends>FreshSystemShell</depends>
<depends>FreshVFSInit</depends>
- </bean>
+ </bean>
+ <bean name="FreshContextBinder" class="org.jboss.fresh.deployer.ContextBinder" mode="On Demand">
+ <annotation>@org.jboss.aop.microcontainer.aspects.jmx.JMX(name="FRESH:service=GlobalContext",exposedInterface=org.jboss.fresh.deployer.ContextBinderMBean.class)</annotation>
+ <property name="JNDIName">java:/FRESH/GlobalContext</property>
+ </bean>
- <bean name="FreshSSHServer" class="org.jboss.fresh.deployer.SSHService" >
- <depends>FRESH:service=SystemShell</depends>
- <depends>FRESH:service=VFS.Mem.Init</depends>
- </bean>
+ <bean name="ExecutableRegistry" class="org.jboss.fresh.shell.impl.BeanFactoryExecutableRegistry" mode="On Demand">
+ <constructor>
+ <parameter>
+ <map keyClass="java.lang.String" valueClass="org.jboss.beans.metadata.spi.factory.BeanFactory">
+ <entry>
+ <key>mcinvoke</key>
+ <value>
+ <inject bean="MCBeanInvokeExe"/>
+ </value>
+ </entry>
+ <entry>
+ <key>org.jboss.fresh.shell.commands.MCBeanInvokeExe</key>
+ <value>
+ <inject bean="MCBeanInvokeExe"/>
+ </value>
+ </entry>
+ </map>
+ </parameter>
+ </constructor>
+ </bean>
+ <beanfactory name="MCBeanInvokeExe" class="org.jboss.fresh.shell.commands.MCBeanInvokeExe">
+ <constructor>
+ <parameter>
+ <inject bean="jboss.kernel:service=KernelBus"/>
+ </parameter>
+ </constructor>
+ </beanfactory>
+
</deployment>
Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java (from rev 88135, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java)
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java (rev 0)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellService.java 2009-05-04 13:25:44 UTC (rev 88148)
@@ -0,0 +1,27 @@
+package org.jboss.fresh.deployer;
+
+import java.util.List;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.fresh.shell.impl.LazySystemShellImpl;
+import org.jboss.fresh.shell.impl.SystemShellImpl;
+
+public class LazySystemShellService extends SystemShellService implements LazySystemShellServiceMBean
+{
+ private Controller controller;
+ private List<String> onDemandBeans;
+
+ public LazySystemShellService(Controller controller, List<String> onDemandBeans)
+ {
+ if (controller == null && (onDemandBeans != null && onDemandBeans.isEmpty() == false))
+ throw new IllegalArgumentException("Null controller");
+
+ this.controller = controller;
+ this.onDemandBeans = onDemandBeans;
+ }
+
+ protected SystemShellImpl createSystemShell()
+ {
+ return new LazySystemShellImpl(getThreadPoolJNDIName(), getVFSJNDIName(), controller, onDemandBeans);
+ }
+}
\ No newline at end of file
Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java (from rev 88135, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java)
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java (rev 0)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/LazySystemShellServiceMBean.java 2009-05-04 13:25:44 UTC (rev 88148)
@@ -0,0 +1,4 @@
+package org.jboss.fresh.deployer;
+
+public interface LazySystemShellServiceMBean extends SystemShellServiceMBean {
+}
\ No newline at end of file
Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java 2009-05-04 13:17:32 UTC (rev 88147)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/deployer/SystemShellService.java 2009-05-04 13:25:44 UTC (rev 88148)
@@ -64,7 +64,7 @@
protected Object classToInstance(Class c) {
try {
- ss = new SystemShellImpl(tpName, vfsName);
+ ss = createSystemShell();
ss.setGCInterval(gcInterval);
ss.setExecutableRegistry(registry);
@@ -82,8 +82,12 @@
}
}
+ protected SystemShellImpl createSystemShell()
+ {
+ return new SystemShellImpl(tpName, vfsName);
+ }
+
protected boolean bindByReference() {
return true;
}
-
}
Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazyExecutableRegistry.java (from rev 88135, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/BeanFactoryExecutableRegistry.java)
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazyExecutableRegistry.java (rev 0)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazyExecutableRegistry.java 2009-05-04 13:25:44 UTC (rev 88148)
@@ -0,0 +1,77 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.fresh.shell.impl;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.fresh.shell.Executable;
+import org.jboss.fresh.shell.ExecutableRegistry;
+
+/**
+ * @author <a href="mailto:ales.justin at jboss.org">Ales Justin</a>
+ */
+public class LazyExecutableRegistry implements ExecutableRegistry
+{
+ private final Controller controller;
+
+ private String executableRegistryName = ExecutableRegistry.class.getSimpleName();
+ private ExecutableRegistry delegate;
+
+ public LazyExecutableRegistry(Controller controller)
+ {
+ if (controller == null)
+ throw new IllegalArgumentException("Null controller");
+
+ this.controller = controller;
+ }
+
+ public Executable getExecutable(String command)
+ {
+ if (delegate == null)
+ {
+ ControllerContext context;
+ try
+ {
+ context = controller.getContext(executableRegistryName, null);
+ controller.enableOnDemand(context);
+ controller.change(context, ControllerState.INSTALLED);
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalArgumentException(t);
+ }
+
+ if (ControllerState.INSTALLED.equals(context.getState()) == false)
+ throw new IllegalArgumentException("Couldn't fully install executable registry: " + context);
+
+ delegate = (ExecutableRegistry)context.getTarget();
+ }
+
+ return delegate.getExecutable(command);
+ }
+
+ public void setExecutableRegistryName(String executableRegistryName)
+ {
+ this.executableRegistryName = executableRegistryName;
+ }
+}
\ No newline at end of file
Copied: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazySystemShellImpl.java (from rev 88135, projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java)
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazySystemShellImpl.java (rev 0)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/LazySystemShellImpl.java 2009-05-04 13:25:44 UTC (rev 88148)
@@ -0,0 +1,49 @@
+package org.jboss.fresh.shell.impl;
+
+import java.util.List;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.fresh.shell.Shell;
+import org.jboss.fresh.vfs.UserCtx;
+
+public class LazySystemShellImpl extends SystemShellImpl
+{
+ private Controller controller;
+ private List<String> onDemandBeans;
+ private AtomicBoolean initialized = new AtomicBoolean(false);
+
+ public LazySystemShellImpl(String tpname, String vfsname, Controller controller, List<String> onDemandBeans)
+ {
+ super(tpname, vfsname);
+ this.controller = controller;
+ this.onDemandBeans = onDemandBeans;
+ }
+
+ @Override
+ public Shell startSession(UserCtx uctx, boolean interactive)
+ {
+ if (initialized.getAndSet(true) == false && onDemandBeans != null)
+ {
+ for (String name : onDemandBeans)
+ {
+ ControllerContext context = controller.getContext(name, null);
+ if (context == null)
+ throw new IllegalArgumentException("No such context: " + name);
+
+ try
+ {
+ controller.enableOnDemand(context);
+ controller.change(context, ControllerState.INSTALLED);
+ }
+ catch (Throwable t)
+ {
+ throw new IllegalArgumentException("Exception enabling on demand beans: " + t);
+ }
+ }
+ }
+ return super.startSession(uctx, interactive);
+ }
+}
\ No newline at end of file
Modified: projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java
===================================================================
--- projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java 2009-05-04 13:17:32 UTC (rev 88147)
+++ projects/fresh/trunk/fresh-shell/src/main/java/org/jboss/fresh/shell/impl/SystemShellImpl.java 2009-05-04 13:25:44 UTC (rev 88148)
@@ -20,7 +20,6 @@
import org.jboss.fresh.shell.SystemShell;
import org.jboss.fresh.vfs.UserCtx;
import org.jboss.fresh.vfs.VFS;
-import org.jboss.beans.metadata.api.annotations.Inject;
/**
// This class is a server. It has a set of Shell instances.
@@ -33,7 +32,7 @@
*/
public class SystemShellImpl implements SystemShell {
- private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SystemShellImpl.class);
+ protected static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger(SystemShellImpl.class);
HashMap shellmap = new HashMap();
HashMap procmap = new HashMap();
@@ -113,7 +112,6 @@
public VFS getVFS() {
-
VFS vfs = null;
try {
RegistryContext ctx = new RegistryContext();
More information about the jboss-cvs-commits
mailing list