Skip to content

Commit

Permalink
remove the requirement for Extractor to return its own aspect
Browse files Browse the repository at this point in the history
In the past the Extractor interface was extending the
ChannelAspectFunction interface in order to return its own aspect.
This was done for the sole purpose of getting the aspect factory id
of an extractor. However the aspect processing now has a different way
to do this. So this requirement is now removed completely.
  • Loading branch information
ctron committed May 21, 2015
1 parent de0b443 commit 506317e
Show file tree
Hide file tree
Showing 16 changed files with 15 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,6 @@ public void extractMetaData ( final Extractor.Context context, final Map<String,
{
makeMetadata ( context, metadata );
}

@Override
public ChannelAspect getAspect ()
{
return ChannelAspectImpl.this;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ public void extractMetaData ( final Extractor.Context context, final Map<String,
{
makeChecksumMetadata ( context.getPath (), metadata );
}

@Override
public ChannelAspect getAspect ()
{
return ChannelAspectImpl.this;
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ public Extractor getExtractor ()
{
return new Extractor () {

@Override
public ChannelAspect getAspect ()
{
return ChannelAspectImpl.this;
}

@Override
public void extractMetaData ( final Extractor.Context context, final Map<String, String> metadata ) throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ private static class ChannelAspectImpl implements ChannelAspect
@Override
public Extractor getExtractor ()
{
return new OsgiExtractor ( ChannelAspectImpl.this );
return new OsgiExtractor ();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import com.google.common.io.ByteStreams;

import de.dentrassi.pm.aspect.ChannelAspect;
import de.dentrassi.pm.aspect.extract.Extractor;
import de.dentrassi.pm.osgi.bundle.BundleInformation;
import de.dentrassi.pm.osgi.bundle.BundleInformationParser;
Expand All @@ -51,19 +50,6 @@ public class OsgiExtractor implements Extractor

public static final String NAMESPACE = OsgiAspectFactory.ID;

private final ChannelAspect aspect;

public OsgiExtractor ( final ChannelAspect aspect )
{
this.aspect = aspect;
}

@Override
public ChannelAspect getAspect ()
{
return this.aspect;
}

@Override
public void extractMetaData ( final Extractor.Context context, final Map<String, String> metadata ) throws Exception
{
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import de.dentrassi.pm.aspect.ValidationContext;

public interface Extractor extends ChannelAspectFunction
public interface Extractor
{
public interface Context extends ValidationContext
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public String getId ()
@Override
public Extractor getExtractor ()
{
return new DebianExtractor ( this );
return new DebianExtractor ();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,19 @@
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;

import de.dentrassi.pm.aspect.ChannelAspect;
import de.dentrassi.pm.aspect.Constants;
import de.dentrassi.pm.aspect.extract.Extractor;
import de.dentrassi.pm.utils.deb.Packages;

public class DebianExtractor implements Extractor
{
private final ChannelAspect channelAspect;

private final GsonBuilder builder;

public DebianExtractor ( final ChannelAspect channelAspect )
public DebianExtractor ()
{
this.channelAspect = channelAspect;
this.builder = new GsonBuilder ();
}

@Override
public ChannelAspect getAspect ()
{
return this.channelAspect;
}

@Override
public void extractMetaData ( final Extractor.Context context, final Map<String, String> metadata ) throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,15 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import de.dentrassi.pm.aspect.ChannelAspect;
import de.dentrassi.pm.aspect.extract.Extractor;
import de.dentrassi.pm.common.XmlHelper;

public class MavenInformationExtractor implements Extractor
{
private static final String NS = "http://maven.apache.org/POM/4.0.0";

private final ChannelAspect aspect;

private final XmlHelper xml = new XmlHelper ();

public MavenInformationExtractor ( final ChannelAspect aspect )
{
this.aspect = aspect;
}

@Override
public ChannelAspect getAspect ()
{
return this.aspect;
}

@Override
public void extractMetaData ( final Extractor.Context context, final Map<String, String> metadata ) throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public class MavenInformationExtractorFactory implements ChannelAspectFactory
@Override
public ChannelAspect createAspect ()
{
class MavenPomExtractorAspect implements ChannelAspect
{
return new ChannelAspect () {
@Override
public String getId ()
{
Expand All @@ -32,11 +31,9 @@ public String getId ()
@Override
public Extractor getExtractor ()
{
return new MavenInformationExtractor ( MavenPomExtractorAspect.this );
return new MavenInformationExtractor ();
}
};

return new MavenPomExtractorAspect ();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public String getId ()
@Override
public Extractor getExtractor ()
{
return new NpmExtractor ( this );
return new NpmExtractor ();
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,10 @@
import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;

import de.dentrassi.pm.aspect.ChannelAspect;
import de.dentrassi.pm.aspect.extract.Extractor;

public class NpmExtractor implements Extractor
{

private final ChannelAspect channelAspect;

public NpmExtractor ( final ChannelAspect channelAspect )
{
this.channelAspect = channelAspect;
}

@Override
public ChannelAspect getAspect ()
{
return this.channelAspect;
}

@Override
public void extractMetaData ( final Extractor.Context context, final Map<String, String> metadata ) throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public String getId ()
@Override
public Extractor getExtractor ()
{
return new ExtractorImpl ( this );
return new ExtractorImpl ();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,14 @@
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import de.dentrassi.pm.aspect.ChannelAspect;
import de.dentrassi.pm.aspect.Constants;
import de.dentrassi.pm.aspect.extract.Extractor;
import de.dentrassi.pm.common.XmlHelper;

public class ExtractorImpl implements Extractor
{

private final XmlHelper xml = new XmlHelper ();

private final ChannelAspect channelAspect;

public ExtractorImpl ( final ChannelAspect channelAspect )
{
this.channelAspect = channelAspect;
}

@Override
public ChannelAspect getAspect ()
{
return this.channelAspect;
}

@Override
public void extractMetaData ( final Extractor.Context context, final Map<String, String> metadata ) throws Exception
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -598,15 +598,15 @@ protected static SortedMap<MetaKey, String> extractMetaData ( final EntityManage
{
final SortedMap<MetaKey, String> metadata = new TreeMap<> ();

Activator.getChannelAspects ().process ( channel.getAspects ().keySet (), ChannelAspect::getExtractor, extractor -> {
Activator.getChannelAspects ().processWithAspect ( channel.getAspects ().keySet (), ChannelAspect::getExtractor, ( aspect, extractor ) -> {
try
{
final Context context = createExtractorContext ( extractor.getAspect ().getId (), name, creationTimestamp, file, vms );
final Context context = createExtractorContext ( aspect.getId (), name, creationTimestamp, file, vms );

final Map<String, String> md = new HashMap<> ();
extractor.extractMetaData ( context, md );

convertMetaDataFromExtractor ( metadata, extractor.getAspect ().getId (), md );
convertMetaDataFromExtractor ( metadata, aspect.getId (), md );
}
catch ( final Exception e )
{
Expand Down Expand Up @@ -899,14 +899,14 @@ protected void reprocessAspects ( final ChannelEntity channel, final Set<String>
final Map<MetaKey, String> metadata = new HashMap<> ();
final ValidationMessageSink vms = new ValidationMessageSink ( channel, this.validationHandler );

this.channelAspectProcessor.process ( aspectFactoryIds, ChannelAspect::getExtractor, extractor -> {
this.channelAspectProcessor.processWithAspect ( aspectFactoryIds, ChannelAspect::getExtractor, ( aspect, extractor ) -> {
try
{
final Map<String, String> md = new HashMap<> ();

extractor.extractMetaData ( createExtractorContext ( extractor.getAspect ().getId (), ae.getName (), ae.getCreationTimestamp ().toInstant (), file, vms ), md );
extractor.extractMetaData ( createExtractorContext ( aspect.getId (), ae.getName (), ae.getCreationTimestamp ().toInstant (), file, vms ), md );

convertMetaDataFromExtractor ( metadata, extractor.getAspect ().getId (), md );
convertMetaDataFromExtractor ( metadata, aspect.getId (), md );
}
catch ( final Exception e )
{
Expand Down Expand Up @@ -997,7 +997,7 @@ protected void scanArtifacts ( final ChannelEntity ce, final ThrowingConsumer<Ar
query.setHint ( "eclipselink.join-fetch", "ArtifactEntity.providedProperties" );
query.setHint ( "eclipselink.join-fetch", "ArtifactEntity.extractedProperties" );
query.setHint ( "eclipselink.join-fetch", "ArtifactEntity.childIds" );
query.setHint ( "eclipselink.batch", "ArtifactEntity.extractedProperties" );
query.setHint ( "eclipselink.batch", "ArtifactEntity.providedProperties" );
*/
Expand Down

0 comments on commit 506317e

Please sign in to comment.