BrightCove Video Player not working on Android - brightcove

java.lang.RuntimeException: A Component requires the 'com.brightcove.player.event.Emits' annotation. If you wish to not listen or emit, create the corresponding annotation with an empty events list.
Has any one else face the same issue??
any help will be appreciable.

It sounds like you do not have the annotation
#Emits(events = {})
before your class declaration. If you show us the relevant fragment it might be obvious to someone what the problem is. A component that emits no events and listens for no events would look like,
/**
* Provides a Component object that is not very useful.
*/
#Emits(events = {})
#ListensFor(events = {})
public class NotVeryUsefulComponent extends AbstractComponent {
}

Please update the proguard with the following lines
-keep public class com.brightcove.player.** { public *;}
-keepclassmembers public class com.brightcove.player.** { public *;}
-keepclasseswithmembers public class com.brightcove.player.** { public *;}
-keep class com.google.android.exoplayer.** { *;}
If you are not using the exoplayer, omit the last line

Your proguard configuration is stripping out the annotations. As an example, please see the proguard-project.txt in our samples repo:
https://github.com/BrightcoveOS/android-player-samples/blob/master/proguard-project.txt

Related

Spring data cassandra (v3.3.1): how to add codec?

I use spring-data-cassandra:3.3.1 and try to apply TimestampCodec. Documentation says that all codecs should be added through CodecRegistry, but says nothing about a way to access it.
I use config like this:
#Configuration
#EnableReactiveCassandraRepositories("com.example.repo")
public class CassandraConfig extends AbstractReactiveCassandraConfiguration
...but I don't understand how could I provide codecs.
Any ideas / examples?
You can override getSessionBuilderConfigurer inside your CassandraConfig class:
#Override
protected SessionBuilderConfigurer getSessionBuilderConfigurer() {
return (sessionBuilder) -> sessionBuilder.addTypeCodecs(ExtraTypeCodecs.LOCAL_TIMESTAMP_UTC);
}

How to annotate JMX beans with OSGi native annotations?

I have a JMX bean which is running on felix scr annotations (AEM 6.4.8, Java 8) and would like to refactor it so it uses OSGi annotations instead. Basically, it's pretty clear what to do, there is only one tiny little "=" that I guess needs to be escaped?
The old code looks like this:
#Component(immediate=true)
#Property(name="jmx.objectname", value={"com.mypackage.monitoring:type=HierarchyModificationListenerMbean"})
#Service
public class HierarchyModificationListenerMbeanImpl
extends AnnotatedStandardMBean
implements ListenerStats {
The refactored code would then be:
#Component(immediate=true, service = ListenerStats.class, property = {"jmx.objectname=com.mypackage.monitoring:type=HierarchyModificationListenerMbean"})
public class HierarchyModificationListenerMbeanImpl
extends AnnotatedStandardMBean
implements ListenerStats {
I am not sure how to deal with the ":type=" in this case.
Any ideas?
take a look at this page https://aem.redquark.org/2018/10/day-16-creating-jmx-mbeans-in-aem.html it looks like the property definition you have should do the trick
your code looks good to me. only thing is, do you have an interface HierarchyModificationListenerMbean? your implementation class should declare that it implements such interface
Example:
public interface MyMBean {
}
#Component(service = DynamicMBean.class, property = {
"jmx.objectname=com.yourproject.osgi:type=MyMBean"
})
public class MyMBeanImpl extends AnnotatedStandardMBean implements MyMBean {
public MyMBeanImpl() {
super(MyMBean.class)
}
}

Using Lombok's #SuperBuilder concept on a class extended from a 3rd party library

I have a class hierarchy as below.
Child --> Parent --> SuperParent
Since the Child class has extended the Parent class I have to use Lombok's #SuperBuilder annotation instead of the #Builder. Also, as far as I know, all the superclasses need to have the #SuperBuilder annotation. But in my case, the SuperParent class comes from an external library, where I cannot add the #SuperBuilder annotation. I am getting the below compilation error.
The constructor SuperParent(DocumentUploadedResponseDto.DocumentUploadedResponseDtoBuilder<capture#1-of ?,capture#2-of ?>) is undefined.
Any solution or an alternative for this? Thank you.
It's a bit ugly, but it's possible. You have to insert a helper class into your inheritance chain between Parent and SuperParent; let's call it SuperParentBuilderEnabler. In this class, you have to manually implement all neccessary builder elements. Especially, you have to write all setter methods for the fields from SuperParent.
This will allow the Parent and Child classes to simply use a #SuperBuilder annotation without any further modifications.
I assume that SuperParent has an int superParentField field, just to demonstrate how you can write such a setter method in the builder class. Furthermore, I assume that this field can be set via constructor argument. Here is what you have to do:
public abstract class SuperParentBuilderEnabler extends SuperParent {
public static abstract class SuperParentBuilderEnablerBuilder<C extends SuperParentBuilderEnabler, B extends SuperParentBuilderEnablerBuilder<C, B>> {
private int superParentField;
public B superParentField(int superParentField) {
this.superParentField = superParentField;
return self();
}
protected abstract B self();
public abstract C build();
}
protected SuperParentBuilderEnabler(SuperParentBuilderEnablerBuilder<?, ?> b) {
super(b.superParentField);
}
}
Now let Parent extend SuperParentBuilderEnabler and you're done.
I'm sharing how I applied the accepted answer for RepresentationModel.
abstract class BaseTypeParent<T extends BaseTypeParent<T>>
extends RepresentationModel<T> {
protected abstract static class BaseTypeParentBuilder<
T extends BaseTypeParent<T>,
C extends BaseTypeParent<T>,
B extends BaseTypeParentBuilder<T, C, B>
> {
protected abstract B self();
public abstract C build();
}
protected BaseTypeParent(final BaseTypeParentBuilder<T, ?, ?> b) {
super();
}
}

CDI events and generics

I'm trying to send events and do this generically. I mean - create one abstract base DAO class with generic type and fire the event from its method. This should work for all descendants. This works if I define the exact type, but doesn't - if I use generics. What I mean:
AbstractDAO (with generics - doesn't fire the event):
public abstract class AbstractDAO<T extends Persistable> implements Serializable {
#Inject #PostSaveEvent Event<T> postSaveEvent;
public T saveOrUpdate(T object) throws DatabaseException {
T obj = em.merge(object);
postSaveEvent.fire(obj);
}
}
AbstractDAO (no generics, just simple class cast - fires the event):
public abstract class AbstractDAO<T extends Persistable> implements Serializable {
#Inject #PostSaveEvent Event<Polis> postSaveEvent;
public T saveOrUpdate(T object) throws DatabaseException {
T obj = em.merge(object);
postSaveEvent.fire((Polis)obj);
}
}
PolisDAO class, which extends AbstractDAO and defines the generic type:
#Stateless
#Named
#PolisType
public class PolisDAO extends AbstractDAO<Polis> {
// some methods (saveOrUpdate is not overriden!)
}
My observer class:
#Stateless
#Named
public class ProlongationService {
public void attachProlongationToPolisOnSave(#Observes #PostSaveEvent Polis polis) throws DatabaseException {
// ... DO smth with polis object. This is NOT called in the first case and called in the second
}
THis is very strange for me, as "fire()" method for CDI event should define the event type on runtime, not during compilation or deployment... When I debug, I see, that
postSaveEvent.fire(obj);
from the first sample operates exactly with Polis entity. But no event is fired nevertheless...
Upd. I tried the base generic class, but no luck:
#Inject #PostSaveEvent Event<Persistable> postSaveEvent;
Thanks.
This should, in theory, work, however in practice inspecting the type of generic objects at runtime with Java Reflection is, at times, impossible. This is due to type erasure. IIRC the type of the concrete sub class isn't erased, so it should be possible to reconnect this, but I guess the implementation isn't doing this right now.
File this as a bug in the http://issues.jboss.org/browse/WELD issue tracker (if you are using Weld), with the classes you provide as an example and we can try to fix it.
To work around, try injecting the event into the concrete subclass, and passing it as an argument, or using an accessor method, to get it into the abstract super class.

android using proguard, stack trace?

I tested my app, and in the emulator and on my device it is working without errors.
I export my eclipse-project with proguard option enabled.
The resulting apk is crashing when I open a custom dialog http://code.google.com/p/dateslider/.
I tried the -keep options for all the classes I used, but no result.
From what I have read, is that I need the trace of the crash., to debug.
Where is it?, only a dialog is shown telling me that the app has crashed.
Jos
EDIT
Thanks to Sean's suggestions I narrow it down to a call of the method "SetContentView". It tried to load data from a layout.
<?xml version="1.0" encoding="utf-8"?>
<nl.zonneveld.pldkal_free.SliderContainer
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/nl.zonneveld.pldkal_free"
android:id="#+id/dateSliderContainer"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<nl.zonneveld.pldkal_free.ScrollLayout
style="#style/Scroller"
app:labelerClass="nl.zonneveld.pldkal_free.YearLabeler"
app:labelerFormat="%tY"
app:childWidth="150dp"/>
<nl.zonneveld.pldkal_free.ScrollLayout
style="#style/Scroller"
app:labelerClass="nl.zonneveld.pldkal_free.MonthLabeler"
app:labelerFormat="%tB"
app:childWidth="200dp"/>
<include layout="#layout/dialogbuttons"/>
</nl.zonneveld.pldkal_free.SliderContainer>
EDIT
The uknown exception is triggered at
Class<?> klazz = Class.forName(className);
Constructor<?> ctor = klazz.getConstructor(String.class);
className="nl.zonneveld.pldkal_free.YearLabeler".
constructor of YearLabeler:
public YearLabeler(String formatString)
I tried the folowing proguard options, no succes.
-keep public class * extends nl.zonneveld.pldkal_free.YearLabeler{
public <init>(java.lang.String);
}
-keep public class * extends nl.zonneveld.pldkal_free.MonthLabeler{
public <init>(java.lang.String);
}
-keep public class * extends nl.zonneveld.pldkal_free.Labeler{
public <init>(int, int);
}
What is the error -- ClassNotFoundError? Meaning, you think Proguard optimized away that class? You can test that easily by setting -dontshrink, to start. If that doesn't fix it, Proguard isn't the problem.
You can obtain all log output with adb logcat on the command line. There's probably an equivalent for the Eclipse-integrated tools, but I don't know what it is. You can also use the aLogcat app on Android to see the logs.
After a lot of digging, this was the solution. Thanks Sean for the suggestions.
-keep public class * extends nl.zonneveld.pldkal_free.YearLabeler
-keepclassmembers class nl.zonneveld.pldkal_free.YearLabeler{
public <init>(java.lang.String);
}
-keep public class * extends nl.zonneveld.pldkal_free.MonthLabeler
-keepclassmembers class nl.zonneveld.pldkal_free.MonthLabeler{
public <init>(java.lang.String);
}
-keep public class * extends nl.zonneveld.pldkal_free.Labeler
-keepclassmembers class nl.zonneveld.pldkal_free.Labeler{
public <init>(int, int);
}

Resources