On Tue, Apr 7, 2020 at 8:42 PM Mark Thomas <ma...@apache.org> wrote:

> On 07/04/2020 19:03, Filip Hanik wrote:
> >
> >
> > On Tue, Apr 7, 2020 at 9:35 AM Rémy Maucherat <r...@apache.org
> > <mailto:r...@apache.org>> wrote:
> >
> >
> >         Does the connector need to know about the actual implementations?
> >
> >
> >     Ideally no, but it removes the reflection you say is bad for Graal.
> >
> >
> > Correct. Turns out that the connectors use setProperty/getProperty via
> > reflection (IntrospectionUtils.setProperty/getProperty), so changing
> > only this constructor would achieve a mini step.
> > Before we commit any changes, I'd like to evaluate the scope of
> > reflection we're dealing with.
> >
> > Then I can come back. I'll close the PR for now, as it only touches the
> > surface.
> >
> > sound fair?
>
> Sounds reasonable. I'm happy for any obvious clean-up to stay though.
>
> On a similar note, the ProtocolHandler calls setProperty() on the
> Endpoint which then also uses reflection.
>
> I think I have a way around this but it is not great for maintenance.
>

If we want to improve on the Connector situation regarding duplication and
reflection abuse, the only solution is to expose the different objects
involved.

Since an example is usually better, I'll give one using server.xml.

A typical Connector with TLS is at the moment:
    <Connector port="8443"
protocol="org.apache.coyote.http11.Http11NioProtocol"
               SSLEnabled="true" scheme="https" secure="true"
               socket.directBuffer="true" socket.directSslBuffer="true"
maxHeaderCount="10"

 
sslImplementationName="org.apache.tomcat.util.net.openssl.OpenSSLImplementation">
        <SSLHostConfig honorCipherOrder="false">
            <Certificate certificateKeyFile="${catalina.home}/conf/key.pem"
                         certificateFile="${catalina.home}/conf/cert.pem"
                         type="RSA" />
        </SSLHostConfig>
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol"
/>
    </Connector>

And it would become:
    <Connector scheme="https" secure="true">
        <Endpoint className="org.apache.tomcat.util.net.NioEndpoint"
port="8443" SSLEnabled="true"

 
sslImplementationName="org.apache.tomcat.util.net.openssl.OpenSSLImplementation">
          <SocketProperties directBuffer="true" directSslBuffer="true" />
          <SSLHostConfig honorCipherOrder="false">
            <Certificate certificateKeyFile="${catalina.home}/conf/key.pem"
                         certificateFile="${catalina.home}/conf/cert.pem"
                         type="RSA" />
          </SSLHostConfig>
        </Endpoint>
        <Protocol className="org.apache.coyote.http11.Http11Protocol"
maxHeaderCount="10" />
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol"
/>
    </Connector>

Each individual object is now created by the digester using normal bean
rules, and I suppose it will become wired up by the Connector during init.
Embedded can then do the same as the digester instead of having to go
through the Connector object.

Rémy


>
> Mark
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>

Reply via email to