Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/SessionReplicationAop #633

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions etc/tomcat/conf/logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# 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.

handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, 5aop-serializer.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler

.handlers = 1catalina.org.apache.juli.AsyncFileHandler, 5aop-serializer.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler
Comment on lines +16 to +18
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the difference between a handler and a .handler?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging.properties comes directly from apache tomcat (https://tomcat.apache.org/tomcat-8.0-doc/logging.html). I don't understand what each of the configurations are for; I just tried to follow the existing pattern. I saw that the other handlers had entries in both lists, so I added the new one to both lists.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This configuration file isn't related to this feature and in my mind shouldn't be on this commit.
Tomcat logging shouldn't be provided in all case because it's a user customisation. In my case I prefer to keep default tomcat logging file.

Your purpose is to provide a rotation on tomcat catalina.out file, this rotation should be done by logrotate (or any other tool) and is an "OS dependancy". Or if you want a such change do a request on tomcat source, you will get their feed back about a such feature/need.


############################################################
# Handler specific properties.
# Describes specific configuration info for Handlers.
############################################################

1catalina.org.apache.juli.AsyncFileHandler.level = FINE
1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina.
1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8

2localhost.org.apache.juli.AsyncFileHandler.level = FINE
2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost.
2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8

3manager.org.apache.juli.AsyncFileHandler.level = FINE
3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
3manager.org.apache.juli.AsyncFileHandler.prefix = manager.
3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

4host-manager.org.apache.juli.AsyncFileHandler.level = FINE
4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager.
4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter
java.util.logging.ConsoleHandler.encoding = UTF-8

5aop-serializer.org.apache.juli.AsyncFileHandler.level = INFO
5aop-serializer.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs
5aop-serializer.org.apache.juli.AsyncFileHandler.prefix = aop-serializer.
5aop-serializer.org.apache.juli.AsyncFileHandler.encoding = UTF-8
############################################################
# Facility specific properties.
# Provides extra control for each logger.
############################################################

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler

org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO
org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler

org.apereo.portal.[Catalina].[localhost].[/aop-serializer].level = INFO
org.apereo.portal.[Catalina].[localhost].[/aop-serializer].handlers = 5aop-serializer.org.apache.juli.AsyncFileHandler

# For example, set the org.apache.catalina.util.LifecycleBase logger to log
# each component that extends LifecycleBase changing state:
#org.apache.catalina.util.LifecycleBase.level = FINE

# To see debug messages in TldLocationsCache, uncomment the following line:
#org.apache.jasper.compiler.TldLocationsCache.level = FINE

# To see debug messages for HTTP/2 handling, uncomment the following line:
#org.apache.coyote.http2.level = FINE

# To see debug messages for WebSocket handling, uncomment the following line:
#org.apache.tomcat.websocket.level = FINE
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ tomcatVersion=8.5.85
servletApiDependency=javax.servlet:javax.servlet-api:3.0.1
ccppVersion=1.0
personDirectoryVersion=1.8.14
aspectjVersion=1.9.9.1

# Dependencies driven by Pluto Portlet Engine version
plutoVersion=2.1.0-M3
Expand Down
78 changes: 78 additions & 0 deletions gradle/tasks/custom.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
repositories {
jgribonvald marked this conversation as resolved.
Show resolved Hide resolved
mavenLocal()
mavenCentral()
}

configurations {
tomcat
shared
}

dependencies {
tomcat "org.apache.tomcat:tomcat:${tomcatVersion}@tar.gz"
shared "javax.ccpp:ccpp:${ccppVersion}"
shared "org.apache.portals.pluto:pluto-container-api:${plutoVersion}"
shared "org.apache.portals.pluto:pluto-container-driver-api:${plutoVersion}"
shared "org.apache.portals.pluto:pluto-taglib:${plutoVersion}"
shared "org.apereo.service.persondir:person-directory-api:${personDirectoryVersion}"
shared "${portletApiDependency}"
}

/*
* deployAopArchives is a custom task that moves HttpSession instrumented classes and needed
* dependencies to the correct place within ./gradle/tomcat. There are three primary parts:
* 1. Build a jar that contains two cusomt classes, HttpSessionAspect and StandardSessionFacade
* and puts them into the .gradle/tomcat/lib folder in their own jar. HttpSession's implementing class
* must be located in tomcat's lib folder or it won't be found, and the aspect must be with it.
* 2. Put the aspectjweaver.1.9.9.1 jar in the same lib folder
* 3. Update the catalina.jar that also lives in this lib folder by deleting the now duplicated
* StandardSessionFacade. The current implementation creates a duplicate jar with the missing file
* and deletes the original file to prevent conflict. Once this is done, it's hard to recover without
* doing a tomcatInstall, so this may need additinoal work, if this function is run.
* If this function is not run, uPortal on tomcat will run as normal.
*/
task deployAopArchives() {
dependsOn ':portalProperties'
dependsOn ':buildAopJar'
dependsOn ':buildCatalinaAopJar'
doLast {
String serverHome = rootProject.ext['buildProperties'].getProperty('server.home')
copy {
from "${serverHome}/webapps/uPortal/WEB-INF/lib/aspectjweaver-1.9.9.1.jar"
into "${serverHome}/lib"
}
delete "${serverHome}/lib/catalina.jar"
}
}

task buildAopJar(type: Zip) {
group 'Tomcat'
description 'Build AOP Archive for HttpSession testing'

// I'm not sure why, but :portalProperties does not expose server.home
// like it does in other functions. This is directly related to type: Zip
// in the function designation. If the tomcat server is located in another location,
// this property will need to be updated
String serverHome = ".gradle/tomcat"
from("${serverHome}/webapps/uPortal/WEB-INF/classes") {
include("org/apereo/portal/context/HttpSessionAspect.class")
include("org/apache/catalina/session/StandardSessionFacade.class")
}
archiveName 'uPortalAopArchive.jar'
destinationDir(file("${serverHome}/lib"))
}

task buildCatalinaAopJar(type: Zip) {
group 'Tomcat'
// I'm not sure why, but :portalProperties does not expose server.home
// like it does in other functions. This is directly related to type: Zip
// in the function designation. If the tomcat server is located in another location,
// this property will need to be updated
String serverHome = ".gradle/tomcat"
from zipTree("${serverHome}/lib/catalina.jar").matching {
exclude 'org/apache/catalina/session/StandardSessionFacade.class'
}
archiveName 'catalina-aop.jar'
destinationDir(file("${serverHome}/lib"))
}

7 changes: 7 additions & 0 deletions overlays/uPortal/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ ext {
shellDir = rootProject.file("${buildDir}/shell")
}

// This is only needed because during uPortal's build and AOP weaving,
// it modifies the class org.apache.catalina.session.StandardSessionFacade and
// embeds AOP functionality.
dependencies {
implementation "org.aspectj:aspectjweaver:1.9.9.1"
}

dataInit {
description 'Drop and recreate uPortal tables and reimport data'

Expand Down