Package org.apache.ws.muws.v1_0.impl.advertiser

Source Code of org.apache.ws.muws.v1_0.impl.advertiser.ResourceAdvertiserResource

package org.apache.ws.muws.v1_0.impl.advertiser;

import org.apache.ws.muws.v1_0.MuwsConstants;
import org.apache.ws.muws.v1_0.capability.AdvertisementCapability;
import org.apache.ws.muws.v1_0.topics.impl.XmlBeansAdvertisementTopicImpl;
import org.apache.ws.notification.topics.Topic;
import org.apache.ws.notification.topics.TopicSpace;
import org.apache.ws.notification.topics.impl.TopicSpaceImpl;
import org.apache.ws.resource.impl.AbstractResourceHome;

import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import java.util.ArrayList;
import java.util.List;

/**
* A ResourceAdvertiser WS-Resource.
* <p/>
* NOTE: This class is generated but IS meant to be modified.
*/
public class ResourceAdvertiserResource extends AbstractResourceAdvertiserResource

{

        /**
     * A NamespaceVerionHolder which maintains the QNames of Spec Wsdls
     */
    public static final org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl SPEC_NAMESPACE_SET = new org.apache.ws.muws.v1_0.impl.WsdmNamespaceVersionHolderImpl();

    public ResourceAdvertiserResource()
    {
        //init();
    }

    /**
     * Initializes this resource's state (properties, etc.).
     */
    public void init()
    {
        super.init();

        /**
     * The ResourcePropertySet which contains all the defined ResourceProperties
     */
    org.apache.ws.resource.properties.ResourcePropertySet resourcePropertySet = getResourcePropertySet();
    org.apache.ws.resource.properties.ResourceProperty resourceProperty = null;


  try{
    // init the {http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part1.xsd}ManageabilityCapability Resource Property
    resourceProperty = resourcePropertySet.get(ResourceAdvertiserPropertyQNames.MANAGEABILITYCAPABILITY);
    org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManageabilityCapabilityDocument prop_manageabilitycapability = org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ManageabilityCapabilityDocument.Factory.newInstance();
    prop_manageabilitycapability.setManageabilityCapability(AdvertisementCapability.URI);
    resourceProperty.add(prop_manageabilitycapability);

    // init the {http://docs.oasis-open.org/wsdm/2004/12/muws/wsdm-muws-part1.xsd}ResourceId Resource Property
    resourceProperty = resourcePropertySet.get(ResourceAdvertiserPropertyQNames.RESOURCEID);
    org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ResourceIdDocument prop_resourceid = org.oasisOpen.docs.wsdm.x2004.x12.muws.wsdmMuwsPart1.ResourceIdDocument.Factory.newInstance();
    prop_resourceid.setResourceId(" ")//singleton
    resourceProperty.add(prop_resourceid);

        org.apache.ws.notification.topics.TopicSpaceSet topicSpaceSet = getTopicSpaceSet();
        TopicSpace topicSpace = new TopicSpaceImpl(MuwsConstants.NSURI_MUWS_PART2_TOPICS);

        Topic manageabilityEndpointCreation = new XmlBeansAdvertisementTopicImpl(AdvertisementCapability.TOPIC_MANAGEABILITY_ENPOINT_CREATION_NAME, false);
        Topic manageabilityEndpointDestruction = new XmlBeansAdvertisementTopicImpl(AdvertisementCapability.TOPIC_MANAGEABILITY_ENPOINT_DESTRUCTION_NAME, false);

        XmlBeansAdvertisementTopicImpl manageableResourceCreation = new XmlBeansAdvertisementTopicImpl(AdvertisementCapability.TOPIC_MANAGEABLE_RESOURCE_CREATION_NAME);
        XmlBeansAdvertisementTopicImpl manageableResourceDestruction = new XmlBeansAdvertisementTopicImpl(AdvertisementCapability.TOPIC_MANAGEABLE_RESOURCE_DESTRUCTION_NAME);

        //todo associate these with all the homes....
        InitialContext ctx = new InitialContext();
        List homes = findHomes(ctx, new ArrayList(),"");
        for (int i = 0; i < homes.size(); i++)
        {
            String home = (String) homes.get(i);
            //do not register its own home
            if( ! home.equals(ResourceAdvertiserHome.HOME_LOCATION))
            {
                AbstractResourceHome absHome = (AbstractResourceHome) ctx.lookup(home);
                absHome.addResourceCreationListener(manageableResourceCreation);
                absHome.addResourceDestructionListener(manageableResourceDestruction);
            }
        }

        manageabilityEndpointCreation.addTopic(manageableResourceCreation);
        manageabilityEndpointDestruction.addTopic(manageableResourceDestruction);
        topicSpace.addTopic(manageabilityEndpointCreation);
        topicSpace.addTopic(manageabilityEndpointDestruction);
        topicSpaceSet.addTopicSpace(topicSpace);

    }
  catch (Exception e)
  {
     throw new javax.xml.rpc.JAXRPCException("There was a problem in initializing your resource properties.  Please check your init() method. Cause: " + e.getLocalizedMessage());
  }
    // Resource Property {http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd}FixedTopicSet is implemented by the framework.
    // Resource Property {http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd}Topic is implemented by the framework.
    // Resource Property {http://docs.oasis-open.org/wsn/2004/06/wsn-WS-BaseNotification-1.2-draft-01.xsd}TopicExpressionDialects is implemented by the framework.


        /**
         * Initializes the Topic, TopicExpressionDialects and FixedTopicSet resource properties
   * </br>
   * FixedTopicSet will be set based on the value returned from the {@see TopicSpaceSet#isFixed()} method.
   * </br>
   * Topic will have all root topics in the TopicSpaceSet, set to Simple dialect AND all child topics set to
   * Concrete dialect.
   * </br>
   *
        * TopicExpressionDialects will be set to the engine's known Topic Dialects acquired from the TopicExpressionEngine
        *
        * If this is not the behavior you would like, you will need to remove the following line of code and initialize the properties
        * individually.
         */
        org.apache.ws.notification.topics.util.TopicUtils.initNotificationProducerProperties(getTopicSpaceSet() , getResourcePropertySet());
        }


    /**
     * Locates the JNDI-deployed homes and returns a list containing their lookup strings
     *
     * @param ctx
     * @param list
     * @param fullname
     * @return A list of homes.
     * @throws NamingException
     */
    public List findHomes(Context ctx, List list, String fullname) throws NamingException
    {
        NamingEnumeration namingEnumeration = ctx.listBindings("");
        while(namingEnumeration.hasMore())
        {
            Binding o = (Binding) namingEnumeration.next();
            String name = o.getName();
            Object value = o.getObject();

            if(name.equals("home"))
            {
               list.add( fullname + "/home" );
            }
            else if (value instanceof Context)
            {
                findHomes((Context)value,list, fullname + "/" + name);
            }
            else
            {
                fullname = "";
            }
        }

        return list;
    }
}
TOP

Related Classes of org.apache.ws.muws.v1_0.impl.advertiser.ResourceAdvertiserResource

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.