How to build service and how to active that in CQ5 - java

I am learning OSGI, CQ5 these days. I am trying to build a bundle that have service (My first code).
I successfully build a bundle and upload that bundle on CQ5, and install that also.
But component shows registered only, not active. Why ?
I also want to activate this service. How can I do this ? Someone on net said to make jsp. I also do that, but didn't get any response. Help me from this problem. I spent lot of time on this, lot of searching, but I didn't get any solution.
How can I use my service in CQ5, CRXDE(Adobe).
JSP code are :-
<% var service = sling.getService(Packages.mh.osgitest.SayHello); %>
<%= service.sayHelloTest() %>
Above code is not working.
The snapshots of these are
Bundle
component
service
My codes are as :-
SayHello
package service.expose;
import org.apache.felix.scr.annotations.Service;
public interface SayHello {
public void sayHelloTest();
}
SayHelloTestServlet // Servlet have no sense here.
package service.expose;
import java.io.IOException;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
#Component
#Service(value = SayHello.class)
public class SayHelloTestServlet implements SayHello {
public void sayHelloTest() {
System.out.println("Testing Say Hello");
}
#Activate
protected void activate() {
System.out.println("service started");
}
#Deactivate
protected void deactivate() {
System.out.println("service stopped");
}
}

Use #Component(immediate=true) to instantiate your service as soon as the bundle is activated as opposed to on-demand.

Related

does vaadin video component support preload attribute

I have more than 10 mp4 videos which I am tying to embed in my web application using vaadin video component. When I run my application on Edge/IE the vidoes work fine, but on chrome they dont. Its known issue with chrome where if the page has more than 6-8 mp4 videos, it hangs as it tried to preload all of them together.
I was wondering if the video component provide me option to set the preload to none. I can see the mediabase has this option
https://vaadin.com/api/7.6.7/index.html?com/google/gwt/media/client/MediaBase.html
But I dont see it for video.
Also I found another link where they seems to do the fix https://github.com/vaadin/framework/issues/5178 , but couldnt make it work.
Any help?
Until the commit/PR in your linkgets merged, it does not in 7 or 8.
However, you can use an AbstractExtension and AbstractExtensionConnector to accomplish this.
The AbstractExtension
package com.my.package;
import com.vaadin.server.AbstractClientConnector;
import com.vaadin.server.AbstractExtension;
import com.vaadin.ui.AbstractComponent;
public class VideoPreloadExtension extends AbstractExtension {
public VideoPreloadExtension() {
}
public VideoPreloadExtension(AbstractClientConnector target) {
super(target);
}
public void extend(AbstractComponent component) {
super.extend(component);
}
}
The AbstractExtensionConnector
package com.my.package.client;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ComponentConnector;
import com.vaadin.client.ServerConnector;
import com.vaadin.client.extensions.AbstractExtensionConnector;
import com.my.package.VideoPreloadExtension;
import com.vaadin.shared.ui.Connect;
#Connect(VideoPreloadExtension.class)
public class VideoPreloadConnector extends AbstractExtensionConnector {
#Override
protected void init() {
super.init();
}
#Override
protected void extend(ServerConnector target) {
// Get the extended widget
final Widget widget = ((ComponentConnector) target).getWidget();
widget.getElement().setAttribute("preload","auto");
}
}
Usage is as follows:
Video image = new Video();
VideoPreloadExtension ext = new VideoPreloadExtension();
ext.extend(image);
Some Notes (because vaadin can be a pain at times)
If you have a library module already, its best to add the above classes to it.
Confirm that the module you add these classes to has the following dependency add so the widgetset will get compiled:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
</dependency>
Remember that the VideoPreloadConnector needs to be in a package name that ends with ".client".
Here is a screenshot of an inspect element from chrome of it working:
HTHs!

Xposed Framework hooking Samsung s7 edge system processes?

Im just getting into developing modules for Xposed Framework.
I get a basic module working, just a module that does nothing but saying that its loaded and prints to log.
Next step was to try hooking the Clock in SystemUI, following rovo89's instructions on GitHub (dont know if I can link?)
The code is as follows:
package com.example.xxx.xposedtest;
import android.graphics.Color;
import android.widget.TextView;
import static de.robv.android.xposed.XposedHelpers.findAndHookMethod;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedBridge;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;
import de.robv.android.xposed.XposedHelpers;
public class xposedTest implements IXposedHookLoadPackage {
public void handleLoadPackage(final LoadPackageParam lpparam) throws Throwable {
if(!lpparam.packageName.equals("com.android.systemui")) {
XposedBridge.log("Did not find package")
return;
}
findAndHookMethod("com.android.systemui.statusbar.policy.Clock", lpparam.classLoader, "updateClock", new XC_MethodHook() {
#Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
TextView tv = (TextView) param.thisObject;
String text = tv.getText().toString();
tv.setText(text + " :)");
XposedBridge.log("Package loaded: Function ran");
}
});
}
}
The log says "Did not find package". And the hook method ofcourse did not run.
My guess is that Samsung s7 edge has some kind of other implementation, other class/method name.
How do I find out what method to actually hook since Samsung decided to not go AOSP? All information on the subject is appriciated.
The answer was other xposed modules were interfering.
Answering if anyone encounters the same problem

Endpoint publisher in java does not work

I have the following webservice :
package testSmart;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
#WebService(name="AddHM", portName="prtNameHM", serviceName="srvNameHM", targetNamespace="hm.com")
#SOAPBinding(style=Style.RPC)
public class add {
AddBusinessLogic add=new AddBusinessLogic();
#WebMethod(action="GoAdd", operationName="Go_AddNumber")
public int addNum(int i, int j) {
return add.addNum(i, j);
}
}
which works perfectly fine with glassfish.
then I stopped glassfish and use the following code to make my server :
import javax.xml.ws.Endpoint;
public class publisher {
public static void main(String[] args) {
// TODO Auto-generated method stub
Endpoint.publish("http://localhost:1234/add", new add());
}
}
Now when I try this link:
http://localhost:1234/add
Nothing happens and the browser says no data received.
Even after trying different port the same problem exist.
Can anyone help me how to fix it?
Call to http://localhost:1234/add will not get you anything because there is no specific document with that URI that browser can get. But if you type
http://localhost:1234/add?wsdl
you should get the generated wsdl document.

Overriding service-definition.xml of one of Webcenter libraries in ADF application

Here in webcenter-driven ADF application we have a standard library called generic-site-resources-model.jar which contains file META-INF/service-definition.xml, which i wish to alter at one line, to add view resource' security permission, as in:
## -1189,7 +1189,7 ##
<resource-permission>
<resource-permission-impl>oracle.webcenter.security.auth.WebCenterResourcePermission</resource-permission-impl>
<resource-permission-target-id>resource_oracle_webcenter_siteresource_#scope#_navigation_#resource#</resource-permission-target-id>
- <resource-permission-action-list>manage,update</resource-permission-action-list>
+ <resource-permission-action-list>view,manage,update</resource-permission-action-list>
</resource-permission>
</permission-metadata>
</security-definition>
How this is can be possibly done without alterning weblogic domain containing this library itself, somehow configuring our application? Maybe some way to override the whole generic-site-resources-model.jar with application-shipped clone? Or (ideally) some way to replace the targeted resource permission? Or some custom way of taking control over resource loading in application?
It is possible to implement appending custom actions to specific resource type using initialization phase listener and a little bit code, without any overriding at all.
Here is how:
ViewControllerProject/src/META-INF/adf-settings.xml
<?xml version="1.0" encoding="UTF-8" ?>
<adf-settings xmlns="http://xmlns.oracle.com/adf/settings">
<adfc-controller-config xmlns="http://xmlns.oracle.com/adf/controller/config">
<lifecycle>
<phase-listener>
<listener-id>PortalInitializer</listener-id>
<class>com.otr.portal.initializer.PortalInitializer</class>
</phase-listener>
</lifecycle>
</adfc-controller-config>
</adf-settings>
com.otr.portal.initializer.PortalInitializer
package com.otr.portal.initializer;
import oracle.adf.controller.v2.lifecycle.Lifecycle;
import oracle.adf.controller.v2.lifecycle.PagePhaseEvent;
import oracle.adf.controller.v2.lifecycle.PagePhaseListener;
import oracle.webcenter.security.internal.common.SecurityUtil;
import oracle.webcenter.security.model.exception.SecExtensionNotFoundException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class PortalInitializer implements PagePhaseListener {
private static final Log log = LogFactory.getLog(PortalInitializer.class);
private boolean firstCall = true;
#Override
public void afterPhase(PagePhaseEvent pagePhaseEvent) {
if (pagePhaseEvent.getPhaseId() == Lifecycle.INIT_CONTEXT_ID) {
if (firstCall) {
setupViewNavigationResourcePermssion();
firstCall = false;
}
}
}
private void setupViewNavigationResourcePermssion() {
try {
SecurityUtil.getSecurityExtension("oracle.webcenter.siteresources.navigation").getExtensionPermMetadata().getResourcePermMetadata().getResourcePermActionsList().add("view");
} catch (SecExtensionNotFoundException e) {
log.error("Error adding view resource permission to navigation resource type", e);
}
}
#Override
public void beforePhase(PagePhaseEvent pagePhaseEvent) {
}
}

Web Services using jdk 1.6

Hi All
I am new to web services. I have written a java class.
But I am not getting how to deploy it. I mean do i need web server or app server . As this is simple java class i can not make WAR file to deploy it . So what is the method to deploy it and which server should i use. I am using JDK 1.6
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;
import javax.xml.ws.Endpoint;
#WebService
public class WiseQuoteServer {
#SOAPBinding(style = Style.RPC)
public String getQuote(String category) {
if (category.equals("fun")) {
return "5 is a sufficient approximation of infinity.";
}
if (category.equals("work")) {
return "Remember to enjoy life, even during difficult situatons.";
} else {
return "Becoming a master is relatively easily. Do something well and then continue to do it for the next 20 years";
}
}
public static void main(String[] args) {
WiseQuoteServer server = new WiseQuoteServer();
Endpoint endpoint = Endpoint.publish(
"http://localhost:9191/wisequotes", server);
The best answer to your question would be the tutorial of JAX-WS

Categories

Resources