Permalink
Browse files

audiolicious-web now calls the parser. Also, fixed factories - they a…

…re EJBs now.
  • Loading branch information...
m1key committed Sep 28, 2012
1 parent 98b62d3 commit aed708f650c409c099a43c40d75bbfdeb3eb65e9
@@ -0,0 +1,34 @@
/*
* Audiolicious - Your Music Library Statistics
* Copyright (C) 2011, Michal Huniewicz
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.m1key.me
*/
package me.m1key.audiolicious.commons.qualifiers;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import javax.inject.Qualifier;
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER,
ElementType.TYPE })
public @interface AggregateHandler {
}
@@ -18,13 +18,14 @@
package me.m1key.audiolicious.domain.entities;
import javax.ejb.Singleton;
import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.inject.Produces;
import me.m1key.audiolicious.commons.qualifiers.NullArtist;
import me.m1key.audiolicious.commons.qualifiers.NullLibrary;
@ApplicationScoped
@Singleton
public class NullEntitiesFactory {
@Produces
@@ -24,6 +24,7 @@
import javax.ejb.Stateful;
import javax.inject.Inject;
import me.m1key.audiolicious.commons.qualifiers.AggregateHandler;
import me.m1key.audiolicious.domain.entities.Library;
import me.m1key.audiolicious.domain.to.TrackTo;
@@ -32,6 +33,7 @@
public class DefaultObjectTrackDataHandler implements ObjectTrackDataHandler {
@Inject
@AggregateHandler
private Map<Class<? extends TrackTo>, TrackHandler<? extends TrackTo>> handlersForAllKnownTos;
@Override
@@ -22,9 +22,10 @@
import java.util.Map;
import javax.ejb.EJB;
import javax.enterprise.context.ApplicationScoped;
import javax.ejb.Singleton;
import javax.enterprise.inject.Produces;
import me.m1key.audiolicious.commons.qualifiers.AggregateHandler;
import me.m1key.audiolicious.domain.to.AudiobookTo;
import me.m1key.audiolicious.domain.to.PodcastTo;
import me.m1key.audiolicious.domain.to.SongTo;
@@ -36,7 +37,7 @@
import me.m1key.audiolicious.objecthandler.handlers.SongHandler;
import me.m1key.audiolicious.objecthandler.handlers.VideoHandler;
@ApplicationScoped
@Singleton
public class TrackHandlersFactory {
@EJB
@@ -49,7 +50,8 @@
private VideoHandler videoHandler;
@Produces
public Map<Class<? extends TrackTo>, TrackHandler<? extends TrackTo>> getTrackHandlers() {
@AggregateHandler
public Map<Class<? extends TrackTo>, TrackHandler<? extends TrackTo>> getAggregateTrackHandler() {
Map<Class<? extends TrackTo>, TrackHandler<? extends TrackTo>> handlers = new HashMap<Class<? extends TrackTo>, TrackHandler<? extends TrackTo>>();
handlers.put(AudiobookTo.class, audiobookHandler);
handlers.put(PodcastTo.class, podcastHandler);
@@ -22,7 +22,7 @@
import java.util.Map;
import javax.ejb.EJB;
import javax.enterprise.context.ApplicationScoped;
import javax.ejb.Singleton;
import javax.enterprise.inject.Produces;
import me.m1key.audiolicious.commons.qualifiers.AggregateMapper;
@@ -37,7 +37,7 @@
import me.m1key.audiolicious.objectmapper.trackmappers.SongMapper;
import me.m1key.audiolicious.objectmapper.trackmappers.VideoMapper;
@ApplicationScoped
@Singleton
public class TrackMappersFactory {
@EJB
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="pu" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:jboss/datasources/AudioliciousDS</jta-data-source>
<class>me.m1key.audiolicious.domain.entities.Artist</class>
<class>me.m1key.audiolicious.domain.entities.Album</class>
<class>me.m1key.audiolicious.domain.entities.Song</class>
<class>me.m1key.audiolicious.domain.entities.Rating</class>
<class>me.m1key.audiolicious.domain.entities.Stat</class>
<class>me.m1key.audiolicious.domain.entities.Library</class>
<properties>
<property name="hibernate.show_sql" value="false" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5InnoDBDialect" />
<property name="hibernate.hbm2ddl.auto" value="none" />
</properties>
</persistence-unit>
</persistence>
View
@@ -49,6 +49,30 @@
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>me.m1key.audiolicious</groupId>
<artifactId>audiolicious-library-parsers</artifactId>
</dependency>
<dependency>
<groupId>me.m1key.audiolicious</groupId>
<artifactId>audiolicious-object-handler</artifactId>
</dependency>
<dependency>
<groupId>me.m1key.audiolicious</groupId>
<artifactId>audiolicious-services</artifactId>
</dependency>
<dependency>
<groupId>me.m1key.audiolicious</groupId>
<artifactId>audiolicious-repositories</artifactId>
</dependency>
<dependency>
<groupId>me.m1key.audiolicious</groupId>
<artifactId>audiolicious-domain-objects</artifactId>
</dependency>
<dependency>
<groupId>me.m1key.audiolicious</groupId>
<artifactId>audiolicious-commons</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.faces</groupId>
<artifactId>jboss-jsf-api_2.1_spec</artifactId>
@@ -19,32 +19,31 @@
package me.m1key.audiolicious.web.beans;
import java.io.File;
import java.util.Date;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.inject.Inject;
import me.m1key.audiolicious.domain.entities.Library;
import me.m1key.audiolicious.libraryparser.LibraryParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ManagedBean
@ApplicationScoped
public class ConsumptionBean /* Implements LibraryConsumer */{
public class ConsumptionBean {
private static Logger log = LoggerFactory.getLogger(ConsumptionBean.class);
@Inject
private LibraryParser libraryParser;
public void consume(File savedLibraryFile, String libraryUuid) {
log.info("Consuming library file [{}].", savedLibraryFile);
// TODO make an asynchronous call.
// librariesBeingConsumed.add(libraryUuid);
// libraryManager.parse(savedLibraryFile, libraryUuid, this)
}
/*
@Override
public void libraryConsumed(String libraryUuid) {
librariesBeingConsumed.remove(libraryUuid);
librariesConsumed.add(libraryUuid); // But don't keep more than 5.
libraryParser.process(savedLibraryFile, new Library(new Date()));
}
*/
}
@@ -29,6 +29,9 @@
import javax.faces.component.UIPanel;
import javax.inject.Inject;
import me.m1key.audiolicious.domain.entities.Library;
import me.m1key.audiolicious.libraryparser.LibraryParser;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ArchivePaths;
@@ -65,9 +68,10 @@ public static WebArchive createTestArchive()
ArchivePaths.create("beans.xml"))
.addClasses(AudioliciousConfigurationException.class,
ConsumptionBean.class, FileUploadBean.class,
FileUploadEvent.class, LibrarySaveBean.class,
StubConsumptionBean.class, StubLibrarySaveBean.class,
UploadedFile.class)
FileUploadEvent.class, Library.class,
LibraryParser.class, LibrarySaveBean.class,
StubConsumptionBean.class, StubLibraryParser.class,
StubLibrarySaveBean.class, UploadedFile.class)
.addAsLibraries(
DependencyResolvers.use(MavenDependencyResolver.class)
.artifacts("org.slf4j:slf4j-api:1.6.1")
@@ -0,0 +1,19 @@
package me.m1key.audiolicious.web.beans;
import java.io.File;
import javax.ejb.Local;
import javax.ejb.Stateful;
import me.m1key.audiolicious.domain.entities.Library;
import me.m1key.audiolicious.libraryparser.LibraryParser;
@Stateful
@Local(LibraryParser.class)
public class StubLibraryParser implements LibraryParser {
@Override
public void process(File libraryFile, Library library) {
}
}

0 comments on commit aed708f

Please sign in to comment.