You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Lukasz Lenart <lu...@apache.org> on 2020/07/06 14:02:12 UTC

StrutsBoot

Hi,

What do you think about implementing such a simple boot project? I was
able create an embedded Jetty server with these lines:

public static void main(String[] args) throws Exception {
    int port = 8080;
    if (args.length == 2 && "--port".equals(args[0])) {
        port = Integer.parseInt(args[1]);
    }

    LOG.info("Running Http server on port " + port);

    Server server = new Server();

    ServerConnector connector = new ServerConnector(server);
    connector.setPort(port);

    HttpConfiguration https = new HttpConfiguration();
    https.addCustomizer(new SecureRequestCustomizer());

    WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath("/");

    ProtectionDomain protectionDomain = App.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();
    context.setWar(location.toExternalForm());

    server.setHandler(context);
    while (true) {
        try {
            server.start();
            break;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    try {
        System.in.read();
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}

Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: StrutsBoot

Posted by James Chaplin <jc...@apache.org>.
Hi.  My "vote" would also be to preserve XML configuration support for Struts in the future.

Keeping XML configuration as an option, even if a future annotations-based configuration mechanism is introduced, would keep things flexible (and probably make upgrades from older versions less painful).

If an annotations-based configuration mechanism is introduced in the future, hopefully it would be possible to "mix-and-match" with XML configuration, based on developer preference.  Having a way to map/represent any annotations-based configuration as an XML equivalent (e.g. for debugging) might be useful as well.

Regards,
James. 

On 2020/07/08 08:20:05, "info@flyingfischer.ch" <in...@flyingfischer.ch> wrote: 
> I second NOT dropping XML configuration support.
> 
> Best
> Markus
> 
> Am 08.07.20 um 09:19 schrieb Lukasz Lenart:
> > wt., 7 lip 2020 o 16:37 Yasser Zamani <ya...@apache.org> napisał(a):
> >> Yes it's awesome and I've also been thought for long time to add boot
> >> and auto-config (because I've seen people have concerns about Struts
> >> flexibility) but can't find enough time :( wdyt? Looks a huge workload
> >> for me. Basically we should get rid off XMLs to annotations, add
> >> auto-configs, make plugins better and easier to match each other, and as
> >> you mentioned, improve score in benchmarks; to being adapted to modern
> >> cloud-native environments I think.
> > For now I would like to focus on starting an embedded Jetty. And XML
> > is far better than clumsy annotations in your code tbh. At least you
> > have all your configuration in one place and not scattered over the
> > whole code base. I think we should rather use Java based configuration
> > which is already available. Also it would be good to move JSP & tags
> > support into a plugin or a dedicated subproject. Having this done,
> > Struts2 Core can be a pure Http framework :)
> >
> >
> > Kind regards
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: StrutsBoot

Posted by "info@flyingfischer.ch" <in...@flyingfischer.ch>.
I second NOT dropping XML configuration support.

Best
Markus

Am 08.07.20 um 09:19 schrieb Lukasz Lenart:
> wt., 7 lip 2020 o 16:37 Yasser Zamani <ya...@apache.org> napisał(a):
>> Yes it's awesome and I've also been thought for long time to add boot
>> and auto-config (because I've seen people have concerns about Struts
>> flexibility) but can't find enough time :( wdyt? Looks a huge workload
>> for me. Basically we should get rid off XMLs to annotations, add
>> auto-configs, make plugins better and easier to match each other, and as
>> you mentioned, improve score in benchmarks; to being adapted to modern
>> cloud-native environments I think.
> For now I would like to focus on starting an embedded Jetty. And XML
> is far better than clumsy annotations in your code tbh. At least you
> have all your configuration in one place and not scattered over the
> whole code base. I think we should rather use Java based configuration
> which is already available. Also it would be good to move JSP & tags
> support into a plugin or a dedicated subproject. Having this done,
> Struts2 Core can be a pure Http framework :)
>
>
> Kind regards


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: StrutsBoot

Posted by Dave Newton <da...@gmail.com>.
On Wed, Jul 8, 2020 at 3:19 AM Lukasz Lenart <lu...@apache.org>
wrote:

> XML is far better than clumsy annotations in your code tbh.


Seconded. Personally I don't care for annotation-based configuration.
They're great
for language-intrinsic stuff, but I've never liked them for config-related
artifacts.

Re: StrutsBoot

Posted by Lukasz Lenart <lu...@apache.org>.
wt., 7 lip 2020 o 16:37 Yasser Zamani <ya...@apache.org> napisał(a):
>
> Yes it's awesome and I've also been thought for long time to add boot
> and auto-config (because I've seen people have concerns about Struts
> flexibility) but can't find enough time :( wdyt? Looks a huge workload
> for me. Basically we should get rid off XMLs to annotations, add
> auto-configs, make plugins better and easier to match each other, and as
> you mentioned, improve score in benchmarks; to being adapted to modern
> cloud-native environments I think.

For now I would like to focus on starting an embedded Jetty. And XML
is far better than clumsy annotations in your code tbh. At least you
have all your configuration in one place and not scattered over the
whole code base. I think we should rather use Java based configuration
which is already available. Also it would be good to move JSP & tags
support into a plugin or a dedicated subproject. Having this done,
Struts2 Core can be a pure Http framework :)


Kind regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: StrutsBoot

Posted by Lukasz Lenart <lu...@apache.org>.
The final code to run an embedded Jetty:

pom.xml

<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-server</artifactId>
    <version>${jetty.version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-servlet</artifactId>
    <version>${jetty.version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-webapp</artifactId>
    <version>${jetty.version}</version>
</dependency>
<dependency>
    <groupId>org.eclipse.jetty</groupId>
    <artifactId>jetty-jsp</artifactId>
    <version>${jetty.version}</version>
</dependency>

Java code:

public static void main(String[] args) {
    int port = 8080;
    if (args.length > 0 && "--port".equals(args[0])) {
        port = Integer.parseInt(args[1]);
    }

    Server server = new Server(port);

    WebAppContext context = new WebAppContext();
    context.setServer(server);
    context.setContextPath("/");

    ProtectionDomain protectionDomain = App.class.getProtectionDomain();
    URL location = protectionDomain.getCodeSource().getLocation();
    context.setWar(location.toExternalForm());

    server.setHandler(context);
    while (true) {
        try {
            server.start();
            server.join();
            break;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    try {
        System.in.read();
        server.stop();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(100);
    }
}


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: StrutsBoot

Posted by Yasser Zamani <ya...@apache.org>.
Yes it's awesome and I've also been thought for long time to add boot
and auto-config (because I've seen people have concerns about Struts
flexibility) but can't find enough time :( wdyt? Looks a huge workload
for me. Basically we should get rid off XMLs to annotations, add
auto-configs, make plugins better and easier to match each other, and as
you mentioned, improve score in benchmarks; to being adapted to modern
cloud-native environments I think.

Regards

On 7/6/2020 6:32 PM, Lukasz Lenart wrote:
> Hi,
> 
> What do you think about implementing such a simple boot project? I was
> able create an embedded Jetty server with these lines:
> 
> public static void main(String[] args) throws Exception {
>     int port = 8080;
>     if (args.length == 2 && "--port".equals(args[0])) {
>         port = Integer.parseInt(args[1]);
>     }
> 
>     LOG.info("Running Http server on port " + port);
> 
>     Server server = new Server();
> 
>     ServerConnector connector = new ServerConnector(server);
>     connector.setPort(port);
> 
>     HttpConfiguration https = new HttpConfiguration();
>     https.addCustomizer(new SecureRequestCustomizer());
> 
>     WebAppContext context = new WebAppContext();
>     context.setServer(server);
>     context.setContextPath("/");
> 
>     ProtectionDomain protectionDomain = App.class.getProtectionDomain();
>     URL location = protectionDomain.getCodeSource().getLocation();
>     context.setWar(location.toExternalForm());
> 
>     server.setHandler(context);
>     while (true) {
>         try {
>             server.start();
>             break;
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
>     try {
>         System.in.read();
>         server.stop();
>         server.join();
>     } catch (Exception e) {
>         e.printStackTrace();
>         System.exit(100);
>     }
> }
> 
> Regards
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org