forked from apache/ofbiz-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove cobertura and sonar completely. Ref OFBIZ-6783
After getting consensus from the community in the email thread below we agreed to remove these two items because they make the startup logic more complex and also because many things are broken and unmaintained for years. It is a good idea to reintroduce cobertura in the future on a cleaner implementation, hopefully completely away from the start component and perhaps as a container implementation. The email thread: http://ofbiz.markmail.org/message/b4jovfhurczunbam?q=remove+cobertura The related JIRA: https://issues.apache.org/jira/browse/OFBIZ-6783 git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1746236 13f79535-47bb-0310-9956-ffa450edef68
- Loading branch information
Showing
16 changed files
with
3 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 0 additions & 94 deletions
94
framework/base/src/org/ofbiz/base/config/CoberturaInstrumenter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +0,0 @@ | ||
/******************************************************************************* | ||
* 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. | ||
*******************************************************************************/ | ||
package org.ofbiz.base.config; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.lang.reflect.Constructor; | ||
import java.lang.reflect.Method; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
||
import net.sourceforge.cobertura.coveragedata.CoverageDataFileHandler; | ||
import net.sourceforge.cobertura.coveragedata.ProjectData; | ||
|
||
import org.objectweb.asm.ClassReader; | ||
import org.objectweb.asm.ClassVisitor; | ||
import org.objectweb.asm.ClassWriter; | ||
import org.ofbiz.base.start.Instrumenter; | ||
|
||
public final class CoberturaInstrumenter implements Instrumenter { | ||
private static final Constructor<?> INSTRUMENTER_CONSTRUCTOR; | ||
private static final Method IS_INSTRUMENTED_METHOD; | ||
static { | ||
try { | ||
Class<?> clz = CoberturaInstrumenter.class.getClassLoader().loadClass("net.sourceforge.cobertura.instrument.ClassInstrumenter"); | ||
INSTRUMENTER_CONSTRUCTOR = clz.getConstructor(ProjectData.class, ClassVisitor.class, Collection.class, Collection.class); | ||
INSTRUMENTER_CONSTRUCTOR.setAccessible(true); | ||
IS_INSTRUMENTED_METHOD = clz.getDeclaredMethod("isInstrumented"); | ||
IS_INSTRUMENTED_METHOD.setAccessible(true); | ||
} catch (Throwable t) { | ||
throw (InternalError) new InternalError(t.getMessage()).initCause(t); | ||
} | ||
} | ||
|
||
protected File dataFile; | ||
protected ProjectData projectData; | ||
protected boolean forInstrumenting; | ||
|
||
public File getDefaultFile() throws IOException { | ||
return CoverageDataFileHandler.getDefaultDataFile(); | ||
} | ||
|
||
public void open(File dataFile, boolean forInstrumenting) throws IOException { | ||
System.setProperty("net.sourceforge.cobertura.datafile", dataFile.toString()); | ||
this.forInstrumenting = forInstrumenting; | ||
this.dataFile = dataFile; | ||
if (forInstrumenting) { | ||
if (dataFile.exists()) { | ||
projectData = CoverageDataFileHandler.loadCoverageData(dataFile); | ||
} else { | ||
projectData = new ProjectData(); | ||
} | ||
} | ||
} | ||
|
||
public void close() throws IOException { | ||
if (forInstrumenting) { | ||
CoverageDataFileHandler.saveCoverageData(projectData, dataFile); | ||
} | ||
} | ||
|
||
public byte[] instrumentClass(byte[] bytes) throws IOException { | ||
if (forInstrumenting) { | ||
ClassReader cr = new ClassReader(bytes); | ||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS/* | ClassWriter.COMPUTE_FRAMES*/); | ||
try { | ||
ClassVisitor ci = (ClassVisitor) INSTRUMENTER_CONSTRUCTOR.newInstance(projectData, cw, Collections.EMPTY_LIST, Collections.EMPTY_LIST); | ||
cr.accept(ci, 0); | ||
if (((Boolean) IS_INSTRUMENTED_METHOD.invoke(ci)).booleanValue()) { | ||
return cw.toByteArray(); | ||
} | ||
} catch (Throwable t) { | ||
throw (IOException) new IOException(t.getMessage()).initCause(t); | ||
} | ||
} | ||
return bytes; | ||
} | ||
} | ||
Oops, something went wrong.