Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
34 changes: 34 additions & 0 deletions pkg/apis/enricher/framework/java/weblogic_detector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2021 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc.
******************************************************************************/

package enricher

import (
"context"

"github.com/devfile/alizer/pkg/apis/model"
)

type WebLogicDetector struct{}

func (o WebLogicDetector) GetSupportedFrameworks() []string {
return []string{"WebLogic"}
}

// DoFrameworkDetection uses the groupId and artifactId to check for the framework name
func (o WebLogicDetector) DoFrameworkDetection(language *model.Language, config string) {
if hasFwk, _ := hasFramework(config, "com.oracle.weblogic", ""); hasFwk {
language.Frameworks = append(language.Frameworks, "WebLogic")
}
}

func (o WebLogicDetector) DoPortsDetection(component *model.Component, ctx *context.Context) {
}
36 changes: 36 additions & 0 deletions pkg/apis/enricher/framework/java/websphere_detector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*******************************************************************************
* Copyright (c) 2021 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v2.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Red Hat, Inc.
******************************************************************************/

package enricher

import (
"context"

"github.com/devfile/alizer/pkg/apis/model"
)

type WebSphereDetector struct{}

func (o WebSphereDetector) GetSupportedFrameworks() []string {
return []string{"WebSphere"}
}

// DoFrameworkDetection uses the groupId and artifactId to check for the framework name
func (o WebSphereDetector) DoFrameworkDetection(language *model.Language, config string) {
hasWebSphereFwk, _ := hasFramework(config, "com.ibm.websphere.appserver", "")
hasOpenLibertyFwk, _ := hasFramework(config, "io.openliberty", "")
if hasWebSphereFwk && !hasOpenLibertyFwk {
language.Frameworks = append(language.Frameworks, "WebSphere")
}
}

func (o WebSphereDetector) DoPortsDetection(component *model.Component, ctx *context.Context) {
}
2 changes: 2 additions & 0 deletions pkg/apis/enricher/java_enricher.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ func getJavaFrameworkDetectors() []FrameworkDetectorWithConfigFile {
&framework.VertxDetector{},
&framework.WildFlyDetector{},
&framework.JBossEAPDetector{},
&framework.WebSphereDetector{},
&framework.WebLogicDetector{},
}
}

Expand Down
52 changes: 52 additions & 0 deletions resources/projects/weblogic-app/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>weblogic-app</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<weblogic.plugin.version>10.3.6.0</weblogic.plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>com.oracle.weblogic</groupId>
<artifactId>weblogic-maven-plugin</artifactId>
<version>${weblogic.plugin.version}</version>
<configuration>
<adminurl>t3://localhost:7001</adminurl>
<user>weblogic</user>
<password>Welcome1</password>
<source>${project.build.directory}/${project.build.finalName}.war</source>
<targets>AdminServer</targets>
<name>${project.artifactId}</name>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.weblogicdemo;

import java.io.IOException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns = "/hello")
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain; charset=UTF-8");
resp.getWriter().println("Hello from WebLogic WAR!");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app
xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
http://xmlns.oracle.com/weblogic/weblogic-web-app/1.9/weblogic-web-app.xsd">

<context-root>/weblogic-app</context-root>
</weblogic-web-app>
9 changes: 9 additions & 0 deletions resources/projects/weblogic-app/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%@ page contentType="text/html; charset=UTF-8" %>
<!doctype html>
<html>
<head><title>WebLogic Demo</title></head>
<body>
<h1>WebLogic Demo</h1>
<p>Try: <a href="hello">/hello</a></p>
</body>
</html>
44 changes: 44 additions & 0 deletions resources/projects/websphere-app/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>websphere-app</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<websphere.api.version>1.1.108</websphere.api.version>
</properties>

<dependencies>
<dependency>
<groupId>com.ibm.websphere.appserver.api</groupId>
<artifactId>com.ibm.websphere.appserver.api.servlet</artifactId>
<version>${websphere.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.example.websphereapp;

import java.io.IOException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet(urlPatterns = "/hello")
public class HelloServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
resp.setContentType("text/plain; charset=UTF-8");
resp.getWriter().println("Hello from websphere-app!");
}
}
9 changes: 9 additions & 0 deletions resources/projects/websphere-app/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%@ page contentType="text/html; charset=UTF-8" %>
<!doctype html>
<html>
<head><title>websphere-app</title></head>
<body>
<h1>websphere-app</h1>
<p>Try: <a href="hello">/hello</a></p>
</body>
</html>
10 changes: 9 additions & 1 deletion test/apis/component_recognizer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ func TestComponentDetectionOnOpenLiberty(t *testing.T) {
isComponentsInProject(t, "open-liberty", 1, "java", "openliberty")
}

func TestComponentDetectionOnWebSphere(t *testing.T) {
isComponentsInProject(t, "websphere-app", 1, "java", "websphere-app")
}

func TestComponentDetectionOnWebLogic(t *testing.T) {
isComponentsInProject(t, "weblogic-app", 1, "java", "weblogic-app")
}

func TestComponentDetectionOnQuarkus(t *testing.T) {
isComponentsInProject(t, "quarkus", 1, "java", "code-with-quarkus-maven")
}
Expand Down Expand Up @@ -423,7 +431,7 @@ func TestComponentDetectionWithGitIgnoreRule(t *testing.T) {

func TestComponentDetectionMultiProjects(t *testing.T) {
components := getComponentsFromTestProject(t, "")
nComps := 71
nComps := 73
if len(components) != nComps {
t.Errorf("Expected %v components but found %v", strconv.Itoa(nComps), strconv.Itoa(len(components)))
}
Expand Down
Loading