Beehive Integration in BEA WebLogic Server

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Code Samples for Annotation Overrides

WARNING: This document is deprecated as of version 10.0 of WebLogic Server. This deprecation warning applies only to this documentation, and not to the underlying functionality it describes nor to the open-source Beehive project. Users who wish to develop and deploy Beehive applications should do so using Workshop for WebLogic, which offers support for all aspects of Beehive technology. Current documentation for integrating Beehive and WebLogic Server can be found at Workshop for WebLogic Platform User's Guide.

This appendix contains the complete code for the files used or referred to in Annotation Overrides.

 


MyControl.java

package controls; 

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.apache.beehive.controls.api.bean.AnnotationMemberTypes;
import org.apache.beehive.controls.api.bean.ControlInterface;

import org.apache.beehive.controls.api.bean.AnnotationMemberTypes.Date;
import org.apache.beehive.controls.api.bean.AnnotationMemberTypes.Decimal;
import org.apache.beehive.controls.api.bean.AnnotationMemberTypes.Optional;

import org.apache.beehive.controls.api.properties.PropertySet;
import weblogic.controls.annotations.RequiresEncryption;

@ControlInterface
public interface MyControl
{
public String getAnnotationValue();
}

 


MyControlImp.java

package controls; 

import java.lang.reflect.Method;
import java.io.Serializable;
import org.apache.beehive.controls.api.bean.ControlImplementation;

import org.apache.beehive.controls.api.bean.Extensible;
import org.apache.beehive.controls.api.bean.ControlBean;
import org.apache.beehive.controls.api.context.Context;
import org.apache.beehive.controls.api.context.ControlBeanContext;

@ControlImplementation
public class MyControlImpl implements MyControl, Extensible, Serializable
{
@Context
ControlBeanContext ctx;

public String getAnnotationValue() {

// This is a key part. The control framework will make sure
// that the precendence is followed when look up annotation
// values for MyAnnotation
MyAnnotation myAnnotation =
ctx.getControlPropertySet(MyAnnotation.class);

return myAnnotation.value();
}

public Object invoke(Method method, Object[] args) throws Throwable
{
// Control Extension not defined for simplicity
return null;
}
}

 


MyAnnotation.java

package controls; 

import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import org.apache.beehive.controls.api.properties.PropertySet;

@PropertySet(externalConfig=true)
@Retention(RetentionPolicy.RUNTIME)
public @interface MyAnnotation
{
String value() default "DEFAULT";
}

 


MyJcx.java

package controls; 

import org.apache.beehive.controls.api.bean.ControlExtension;

@ControlExtension
@MyAnnotation("OnClassDecl")
public interface MyJcx extends MyControl
{
}

 


HelloService.java

/**
* This class demonstrates the use of an override-able annotation
* on a control instance. The field "_jcxBean" was declared with
* MyAnnotation, which has an initial value of "Overriden@Field".
* During runtime, the sayHello() method will actually return a
* value that has been externally overriden via a deployment plan.
*
* There is no code change required for this class in order to
* obtain a new externally-configured value.
*/
package service;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.soap.SOAPBinding;

import weblogic.jws.WLHttpTransport;
import org.apache.beehive.controls.api.bean.Control;
import controls.*;

@WebService(name="Hello")
@SOAPBinding(style=SOAPBinding.Style.RPC, use=SOAPBinding.Use.ENCODED)
@WLHttpTransport(contextPath="helloJWS", serviceUri="HelloService")
public class HelloService
{
@Control()
@MyAnnotation("Overriden@Field")
protected MyJcxBean _jcxBean;

@WebMethod
public String sayHello()
{
return _jcxBean.getAnnotationValue();
}
}

  Back to Top       Previous  Next