Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] The Development LifeCycle

Ah, ok (premature send?).

org.mortbay.component.LifeCycle was part of the component lifecycle.
NOT the deployment lifecycle.

To add your own component to the lifecycle of the server, just use addBean(mycomponent) against the level you want in the component tree.

Example:

https://github.com/eclipse/jetty.project/blob/master/jetty-server/src/main/java/org/eclipse/jetty/server/LowResourceMonitor.java#L65

import org.eclipse.jetty.util.component.AbstractLifeCycle;
@ManagedObject ("Monitor for low resource conditions and activate a low resource mode if detected")
public class LowResourceMonitor extends AbstractLifeCycle
{


and the associated XML


<Configure id="Server" class="org.eclipse.jetty.server.Server">
  <Call name="addBean">
    <Arg>
      <New class="org.eclipse.jetty.server.LowResourceMonitor">


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Thu, Jul 2, 2015 at 5:40 AM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
Ah, ok.

org.mortbay.component.LifeCycle was part of the component lifecycle.
NOT the deployment lifecycle.

To add your own component to the lifecycle of the server, just use addBean(mycomponent) against the level you want in the component tree.

Example:



--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts

On Wed, Jul 1, 2015 at 7:40 PM, Сидоров Михаил <mihamix@xxxxxxxxx> wrote:
Yes, in Jetty 6 was not AppLifeCycle (deploy based). This is my custom class with name 'AppLifeCycle' (some code from eclipse):

package app.jls;

import java.util.ArrayList;
import java.util.HashMap;

import org.mortbay.component.LifeCycle;

import app.jls.producers.ActionsProducer;
import app.jls.producers.DataProducer;
import app.jls.producers.IncommingsProducer;
import app.jls.producers.LifeCycleLogMessage;
import app.jls.producers.OutgoingProducer;

public class AppLifeCycle implements LifeCycle,NotifiedByMessage {
   // some fields
   // some methods
}

In jetty.xml file:

     <Call name="addLifeCycle">
      <Arg>
        <New class="app.jls.AppLifeCycle">
        </New>
      </Arg>
    </Call>
    <Call name="addLifeCycle">
      <Arg>
        <New class="org.mortbay.jetty.deployer.ContextDeployer">
          <Set name="contexts"><Ref id="Contexts"/></Set>
          <Set name="configurationDir"><SystemProperty name="jetty.home" default="."/>/contexts</Set>
          <Set name="scanInterval">5</Set>
        </New>
      </Arg>
    </Call>

Now, in Jetty 9, can some Isses appear because I use this name (AppLifeCycle) for my custom class ?

Many thanks for answers!


01.07.2015, 17:38, "Joakim Erdfelt" <joakim@xxxxxxxxxxx>:
>  Wait.  There's no (deploy based) AppLifeCycle in Jetty 6.
>  What is the fully qualified classname that your old Jetty 6 code relied on?
>  That will help immensely.
>
>  --
>  Joakim Erdfelt <joakim@xxxxxxxxxxx>
>  webtide.com - eclipse.org/jetty - cometd.org
>  Expert advice, services and support from from the Jetty & CometD experts
>
>  On Wed, Jul 1, 2015 at 5:35 AM, Сидоров Михаил <mihamix@xxxxxxxxx> wrote:
>>  Thanks, Jan!
>>
>>  I understood how to use external modules.
>>  But my AppLifeCycle do not start. I guess what is the problem...
>>  I migrate from Jetty 6 to Jetty 9.
>>  My AppLifeCycle class (for Jetty 6) implements the LifeCycle and the NotifiedByMessage interfaces.
>>  For Jetty 9 my AppLifeCycle class must implement the org.eclipse.jetty.deploy.AppLifeCycle.Binding interface but i do not know how to implement a method - void processBinding(Node node, App app). And how important do this or can I leave an empty body of method?
>>
>>  My AppLifeCycle class have a method - void start() - that run my tasks (threads) (implement LifeCycle interface) but if the org.eclipse.jetty.deploy.AppLifeCycle.Binding interface have not a signature of this method how me start my tasks in Jetty 9 ?
>>
>>  Can You advise me some books about Jetty 9 that has samples of use Jetty 9 in Java Programs?
>>
>>  Many thanks for the previous answer!
>>
>>  01.07.2015, 09:51, "Jan Bartel" <janb@xxxxxxxxxxx>:
>>
>>>  Hi,
>>>
>>>  Jars that are in ${jetty.base}/lib are not automatically on the
>>>  classpath. This is controlled by the module system. If you enable
>>>  ext.mod and move your jar into ${jetty.base}/lib/ext, then that module
>>>  will put all jars in ${jetty.base}/lib/ext onto the server's
>>>  classpath.
>>>
>>>  Jan
>>>
>>>  On 1 July 2015 at 14:21, Сидоров Михаил <mihamix@xxxxxxxxx> wrote:
>>>>   Hello!
>>>>
>>>>   I am trying deploy a lifecycle on jetty 9 (jetty-9.2.10.v20150310) and want to use my extended AppLifeCycle class - app.jls.AppLifeCycle. My class belongs to AppLib.jar (in directory $(jetty.base)/lib).
>>>>
>>>>   In $(jetty.base)/etc/jetty-deploy.xml i have copied file from $(jetty.home)/etc/jetty-deploy.xml. Then i added records:
>>>>
>>>>   <!-- Add a customize step to the deployment lifecycle -->
>>>>   <!-- uncomment and replace DebugBinding with your extended AppLifeCycle.Binding class -->
>>>>   <Call name="insertLifeCycleNode">
>>>>   <Arg>deployed</Arg>
>>>>   <Arg>starting</Arg>
>>>>   <Arg>customise</Arg>
>>>>   </Call>
>>>>   <Call name="addLifeCycleBinding">
>>>>   <Arg>
>>>>   <New class="app.jls.AppLifeCycle">
>>>>   </New>
>>>>   </Arg>
>>>>   </Call>
>>>>
>>>>   By starting jetty throws an exception, that caused by java.lang.ClassNotFoundException: app.jls.AppLifeCycle and then jetty stop.
>>>>
>>>>   I am new in Jetty. Help me start my Lifecycle.
>>>>   Many thanks in advance.
>>>>
>>>>   P.S. My application contains two parts: app.jls.AppLifeCycle (in directory $(jetty.base)/lib/AppLib.jar) and WebServerApp.war that is in directory $(jetty.base)/webapps.
>>>>   The second part (WebServerApp.war) deploys fine.
>>>>   _______________________________________________
>>>>   jetty-users mailing list
>>>>   jetty-users@xxxxxxxxxxx
>>>>   To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>>>>   https://dev.eclipse.org/mailman/listinfo/jetty-users
>>>
>>>  --
>>>  Jan Bartel <janb@xxxxxxxxxxx>
>>>  www.webtide.com
>>>  'Expert assistance from the creators of Jetty and CometD'
>>>  _______________________________________________
>>>  jetty-users mailing list
>>>  jetty-users@xxxxxxxxxxx
>>>  To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>>>  https://dev.eclipse.org/mailman/listinfo/jetty-users
>>  _______________________________________________
>>  jetty-users mailing list
>>  jetty-users@xxxxxxxxxxx
>>  To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>>  https://dev.eclipse.org/mailman/listinfo/jetty-users
>
>  ,
>
>  _______________________________________________
>  jetty-users mailing list
>  jetty-users@xxxxxxxxxxx
>  To change your delivery options, retrieve your password, or unsubscribe from this list, visit
>  https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top